Made titles functional, because functional programming is the future
This commit is contained in:
parent
0fa564a137
commit
2e1cb4d273
|
@ -38,9 +38,9 @@ module ApplicationHelper
|
|||
|
||||
content_tag(:a, body.html_safe, href: path, class: ("list-group-item #{'active ' if current_page? path}#{options[:class]}"))
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
#
|
||||
#
|
||||
def bootstrap_color c
|
||||
case c
|
||||
when "error", "alert"
|
||||
|
@ -93,4 +93,64 @@ module ApplicationHelper
|
|||
return true if user_agent.match /^Mozilla\/\d+\.\d+ \(i(?:Phone|Pad|Pod); CPU(?:.*) like Mac OS X\)(?:.*) Mobile(?:\S*)$/
|
||||
false
|
||||
end
|
||||
|
||||
def generate_title(name, junction = nil, content = nil, s = false)
|
||||
if s
|
||||
if name[-1] != "s"
|
||||
name = name + "'s"
|
||||
else
|
||||
name = name + "'"
|
||||
end
|
||||
end
|
||||
|
||||
list = [name]
|
||||
|
||||
list.push junction unless junction.nil?
|
||||
|
||||
unless content.nil?
|
||||
content = strip_markdown(content)
|
||||
if content.length > 45
|
||||
content = content[0..42] + "..."
|
||||
end
|
||||
list.push content
|
||||
end
|
||||
list.push "|", APP_CONFIG['site_name']
|
||||
|
||||
list.join " "
|
||||
end
|
||||
|
||||
def question_title(question)
|
||||
name = user_screen_name question.user, question.author_is_anonymous, false
|
||||
generate_title name, "asked", question.content
|
||||
end
|
||||
|
||||
def answer_title(answer)
|
||||
name = user_screen_name answer.user, false, false
|
||||
generate_title name, "answered", answer.content
|
||||
end
|
||||
|
||||
def user_title(user, junction = nil)
|
||||
name = user_screen_name user, false, false
|
||||
generate_title name, junction, nil, !junction.nil?
|
||||
end
|
||||
|
||||
def questions_title(user)
|
||||
user_title user, "questions"
|
||||
end
|
||||
|
||||
def answers_title(user)
|
||||
user_title user, "answers"
|
||||
end
|
||||
|
||||
def smiles_title(user)
|
||||
user_title user, "smiles"
|
||||
end
|
||||
|
||||
def comments_title(user)
|
||||
user_title user, "comments"
|
||||
end
|
||||
|
||||
def group_title(group)
|
||||
generate_title group.name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
- provide(:title, "#{@answer.user.display_name.blank? ? "@#{@answer.user.screen_name}'s" : "#{@answer.user.display_name}'s"} answer | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, answer_title(@answer))
|
||||
.container.j2-page
|
||||
= render 'shared/answerbox', a: @answer
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Resend confirmation instructions | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Resend confirmation instructions"))
|
||||
.container
|
||||
%h1 Resend confirmation instructions
|
||||
= bootstrap_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f|
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Change your password | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Reset Password"))
|
||||
.container
|
||||
%h1 Change your password
|
||||
= bootstrap_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Forgot your password? | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Forgot your Password?"))
|
||||
.container
|
||||
%h1 Forgot your password?
|
||||
= bootstrap_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Sign up | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Sign Up"))
|
||||
.container
|
||||
%h1 Sign up
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Sign in | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Sign In"))
|
||||
.container
|
||||
%h1 Sign in
|
||||
= render 'layouts/messages'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Unlock | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Unlock"))
|
||||
.container
|
||||
%h1 Resend unlock instructions
|
||||
= render 'layouts/messages'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "#{@group.display_name} | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, group_title(@group))
|
||||
= render 'static/mobile_nav'
|
||||
.container.j2-page
|
||||
.col-md-3.col-sm-3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Inbox | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Inbox"))
|
||||
.container.j2-page
|
||||
.row
|
||||
.col-md-3.col-xs-12.col-sm-3.hidden-xs
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Moderation | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Inbox"))
|
||||
= render 'moderation/moderation_nav'
|
||||
.container.j2-page
|
||||
.row
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Notifications | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Notifications"))
|
||||
= render 'notifications/notification_nav'
|
||||
.container.j2-page
|
||||
= render 'notification_tabs'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Public Timeline | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Public Timeline"))
|
||||
= render 'static/mobile_nav'
|
||||
.container.j2-page
|
||||
.col-md-3.col-sm-3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "#{@question.user.display_name.blank? ? "@#{@question.user.screen_name}'s" : "#{@question.user.display_name}'s"} question | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, question_title(@question))
|
||||
= render 'shared/question_header', question: @question, hidden: false
|
||||
= render 'shared/question_header', question: @question, hidden: true
|
||||
.container.question-page
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Service Settings | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Service Settings"))
|
||||
.container.j2-page
|
||||
= render 'user/settings_tabs'
|
||||
.col-md-9.col-xs-12.col-sm-9
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "About | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("About"))
|
||||
.jumbotron.j2-jumbo.text-center.particle-jumbotron
|
||||
#particles
|
||||
.particle-content
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Frequently Asked Questions | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Frequently Asked Questions"))
|
||||
.jumbotron.j2-jumbo.text-center.particle-jumbotron
|
||||
#particles
|
||||
.particle-content
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Privacy Policy | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Privacy Policy"))
|
||||
.container
|
||||
.panel.panel-default
|
||||
.panel-body
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Terms of Service | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Terms of Service"))
|
||||
.container
|
||||
.panel.panel-default
|
||||
.panel-body
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Account Settings | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Account Settings"))
|
||||
.container.j2-page
|
||||
= render 'user/settings_tabs'
|
||||
.col-md-9.col-xs-12.col-sm-9
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Profile Settings | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Profile Settings"))
|
||||
.container.j2-page
|
||||
= render 'settings_tabs'
|
||||
.col-md-9.col-xs-12.col-sm-9
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "Privacy Settings | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, generate_title("Privacy Settings"))
|
||||
.container.j2-page
|
||||
= render 'settings_tabs'
|
||||
.col-md-9.col-xs-12.col-sm-9
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "#{@user.display_name.blank? ? "@#{@user.screen_name}'s" : "#{@user.display_name}'s"} questions | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, questions_title(@user))
|
||||
.profile--header
|
||||
.container.j2-page
|
||||
.col-md-3.col-xs-12.col-sm-4.j2-col-reset
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "#{@user.display_name.blank? ? "@#{@user.screen_name}" : "#{@user.display_name} (@#{@user.screen_name})"} | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, user_title(@user))
|
||||
- no_header = unless @user.profile_header.exists? then "profile--no-header" else "" end
|
||||
#profile--header.hidden-xs{class: no_header}
|
||||
%img.profile--header-img{src: @user.profile_header.url(:web)}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
- provide(:title, "#{@user.display_name.blank? ? "@#{@user.screen_name}'s" : "#{@user.display_name}'s"} friends & followers | #{APP_CONFIG['site_name']}")
|
||||
- provide(:title, user_title(@user, "friends and followers"))
|
||||
.profile--header
|
||||
.container.j2-page
|
||||
.col-md-3.col-xs-12.col-sm-4.j2-col-reset
|
||||
|
|
Loading…
Reference in New Issue