mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-26 21:33:03 +01:00
26 lines
597 B
Ruby
26 lines
597 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ApplicationHelper::TitleMethods
|
|
include MarkdownHelper
|
|
|
|
def generate_title(name, junction = nil, content = nil, possessive = false)
|
|
if possessive
|
|
name = if name[-1].downcase == "s"
|
|
"#{name}'"
|
|
else
|
|
"#{name}'s"
|
|
end
|
|
end
|
|
|
|
list = [name, junction].compact
|
|
|
|
unless content.nil?
|
|
content = strip_markdown(content)
|
|
content = "#{content[0..42]}…" if content.length > 45
|
|
list.push content
|
|
end
|
|
list.push "|", APP_CONFIG["site_name"]
|
|
|
|
list.join " "
|
|
end
|
|
end
|