1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'
module ApplicationHelper
class HTML < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet # yep, that's it.
end
def title(text)
content_for :title, text
end
def sortable(col, title = nil)
title ||= col.titleize
css_class = (col == sort_column) ? "current #{sort_direction}" : nil
direction = (col == sort_column and sort_direction == "asc") ? "desc" : "asc"
link_to title, {:sort => col, :dir => direction}, {:class => css_class}
end
def markdown(text, params = {})
options = { fenced_code_blocks: true, highlight: true, footnotes: true }
html_options = {}
if params[:restricted]
html_options[:filter_html] = true
end
Redcarpet::Markdown.new(HTML.new(html_options), options).render(text).html_safe
end
def links_sidebar
[
{ title: "Code repositories", url: "https://code.fourisland.com/" },
{ title: "Quotes database", url: "https://www.fourisland.com/quotes" },
{ title: "Pokémon", url: "https://www.fourisland.com/poke3" },
{ title: "Wittle", url: "https://www.fourisland.com/wittle/" },
]
end
end
|