retrospring/app/helpers/application_helper/title_methods.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
597 B
Ruby
Raw Normal View History

2022-01-16 01:04:47 +01:00
# frozen_string_literal: true
module ApplicationHelper::TitleMethods
include MarkdownHelper
def generate_title(name, junction = nil, content = nil, possessive = false)
if possessive
2022-01-16 01:04:47 +01:00
name = if name[-1].downcase == "s"
"#{name}'"
else
"#{name}'s"
end
end
2022-01-16 01:04:47 +01:00
list = [name, junction].compact
unless content.nil?
content = strip_markdown(content)
2022-01-16 01:04:47 +01:00
content = "#{content[0..42]}" if content.length > 45
list.push content
end
2022-01-16 01:04:47 +01:00
list.push "|", APP_CONFIG["site_name"]
list.join " "
end
2022-01-16 01:04:47 +01:00
end