mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 18:39:52 +01:00
66efa5d4f4
- replace `match` with `get`/`post`/`patch`/`delete` - format routes.rb - rename the `show_user_{profile,question,answer}` routes to `profile`, `question`, `answer` so `url_for` (used by Rails Admin) works fine for these things - also add `to_param` to the `User` model so that `url_for(some_user)` uses the user name
28 lines
527 B
Ruby
28 lines
527 B
Ruby
# frozen_string_literal: true
|
|
|
|
class FlavoredMarkdown < Redcarpet::Render::HTML
|
|
include Rails.application.routes.url_helpers
|
|
include SharedMarkers
|
|
|
|
def preprocess(text)
|
|
wrap_mentions(text)
|
|
end
|
|
|
|
def wrap_mentions(text)
|
|
text.gsub(/(^|\s)(@[a-zA-Z0-9_]{1,16})/) do
|
|
"#{$1}[#{$2}](#{user_path $2.tr('@', '')})"
|
|
end
|
|
end
|
|
|
|
def header(text, _header_level)
|
|
paragraph text
|
|
end
|
|
|
|
def paragraph(text)
|
|
"<p>#{text}</p>"
|
|
end
|
|
|
|
def raw_html(raw_html)
|
|
Rack::Utils.escape_html raw_html
|
|
end
|
|
end
|