Add og meta tags

This commit is contained in:
Vokhmin Alexey V 2015-02-26 05:01:47 +03:00
parent bf7b130ec1
commit 9cc7191b12
27 changed files with 90 additions and 56 deletions

View File

@ -59,8 +59,14 @@ module ApplicationHelper
name = object.class == Group ? object.uname : object.name
object_name = t "activerecord.models.#{object.class.name.downcase}"
case object.class.name
when 'Project', 'Platform'
when 'Project'
"#{object_name} #{object.owner.uname}/#{object.name}"
when 'Platform'
if object.main?
"#{object_name} #{object.name}"
else
"#{object_name} #{object.owner.uname}/#{object.name}"
end
when 'Repository', 'Product'
"#{object_name} #{object.name} - #{title_object object.platform}"
when 'Group'

View File

@ -1,22 +1,5 @@
module FacebookHelper
# Returns a facebook-specific title for the current page.
def facebook_meta_title
resource = get_resource
@fb_meta_title ||= resource.fb_meta_title if resource.respond_to?(:fb_meta_title)
@fb_meta_title = APP_CONFIG['project_name'] if @fb_meta_title.blank?
@fb_meta_title
end
# Returns a facebook-specific description for the current page.
def facebook_meta_description
resource = get_resource
@fb_meta_description ||= resource.fb_meta_description if resource.respond_to?(:fb_meta_description)
@fb_meta_description ||= resource.description if resource.respond_to?(:description)
@fb_meta_description = I18n.t('helpers.facebook.meta_description') if @fb_meta_description.blank?
truncate(@fb_meta_description, length: 255)
end
# Returns a facebook-specific image for the current page.
def facebook_meta_image
resource = get_resource
@ -76,9 +59,4 @@ module FacebookHelper
end
end
# Hack to check if a translation is defined for a particular key.
def translation_defined?(key)
I18n.backend.exists?(:en, key)
end
end

View File

@ -1,4 +1,6 @@
- set_meta_tags title: t('layout.advisories.list_header')
- set_meta_tags og: { title: t('layout.advisories.list_header') }
- render partial: 'submenu'
.col-xs-12.col-md-10.col-md-offset-1
.row

View File

@ -1,4 +1,8 @@
- set_meta_tags title: [title_object(@advisory), t('activerecord.models.advisory')]
- title = [title_object(@advisory), t('activerecord.models.advisory')]
- set_meta_tags title: title
- set_meta_tags og: { title: title.reverse * ' - ',
description: truncate(@advisory.description, length: 255) }
- render partial: 'submenu'
.container.col-md-offset-2.col-md-8

View File

@ -1,4 +1,5 @@
- set_meta_tags title: t('layout.contact.page_header')
- set_meta_tags og: { title: t('layout.contact.page_header') }
.row
.col-md-10.col-md-offset-1

View File

@ -1,4 +1,7 @@
- set_meta_tags title: title_object(@group)
- set_meta_tags og: { title: title_object(@group),
description: truncate(@group.description, length: 255) }
= render 'groups/base/submenu'

View File

@ -1,4 +1,7 @@
- set_meta_tags title: title_object(@mass_build)
- set_meta_tags og: { title: title_object(@mass_build),
description: truncate(@mass_build.description, length: 255) }
= render 'submenu'
.col-xs-12.col-md-10.col-md-offset-1

View File

@ -1,4 +1,5 @@
- set_meta_tags title: [title_object(@platform), t('layout.advisories.list_header')]
- set_meta_tags og: { title: t('layout.advisories.list_header') + ' - ' + title_object(@platform) }
== render 'submenu'
.col-xs-12.col-md-10.col-md-offset-1

View File

@ -1,4 +1,7 @@
- set_meta_tags title: title_object(@platform)
- set_meta_tags og: { title: title_object(@platform),
description: truncate(@platform.description, length: 255) }
= render 'submenu'
.col-xs-12.col-md-10.col-md-offset-1

View File

@ -1,4 +1,5 @@
- set_meta_tags title: t('.title')
- set_meta_tags og: { title: t('.title') }
= render 'projects/build_lists/submenu'

View File

@ -1,4 +1,8 @@
- set_meta_tags title: [title_object(@product_build_list.product), t('layout.product_build_lists.show')]
- description = @product_build_list.results.map{ |r| r['file_name'] }.select{ |n| n =~ /.iso$/ }
- set_meta_tags og: { title: title_object(@product_build_list.product),
description: description * ', ' }
= render 'submenu'
- pbl = @product_build_list

View File

@ -1,4 +1,7 @@
-set_meta_tags title: title_object(@product)
- set_meta_tags og: { title: title_object(@product),
description: truncate(@product.description, length: 255) }
= render 'submenu'
.container.col-md-offset-2.col-md-8

View File

@ -1,4 +1,6 @@
- set_meta_tags title: [title_object(@platform), t('layout.repositories.list_header')]
- set_meta_tags og: { title: t('layout.repositories.list_header') + ' - ' + title_object(@platform) }
= render 'submenu' if params[:platform_id]
.container.col-md-offset-2.col-md-8

View File

@ -1,4 +1,6 @@
- set_meta_tags title: title_object(@repository)
- set_meta_tags og: { title: title_object(@repository),
description: truncate(@repository.description, length: 255) }
= render 'submenu'
.container.col-md-offset-2.col-md-8

View File

@ -1,4 +1,8 @@
- set_meta_tags title: [title_object(@build_list.project), t('activerecord.models.build_list')]
- description = @build_list.packages.map(&:fullname) * ', '
- set_meta_tags og: { title: t('activerecord.models.build_list') + ' - ' + title_object(@build_list.project),
description: truncate(description, length: 255) }
= render 'submenu'

View File

@ -1,2 +1,6 @@
-set_meta_tags title: "#{title_object @project} #{t('at') if @branch} #{@branch.try :name}"
- title = "#{title_object @project} #{t('at') if @branch} #{@branch.try :name}"
- set_meta_tags title: title
- set_meta_tags og: { title: title,
description: truncate(@project.description, length: 255) }
== render partial: "blame", layout: 'layout'

View File

@ -1,2 +1,6 @@
-set_meta_tags title: [title_object(@project), "#{@project.name}/#{@path} #{t('at') if @branch} #{@branch.try :name}"]
- title = [title_object(@project), "#{@project.name}/#{@path} #{t('at') if @branch} #{@branch.try :name}"]
- set_meta_tags title: title
- set_meta_tags og: { title: title * ' - ',
description: truncate(@project.description, length: 255) }
== render partial: "show", layout: 'layout'

View File

@ -1,5 +1,8 @@
- title = "#{t('diff')} #{shortest_hash_id @commit1.id}...#{shortest_hash_id @commit.id}"
-set_meta_tags title: [title_object(@project), title]
- title = [title_object(@project), title]
- set_meta_tags title: title
- set_meta_tags og: { title: title * ' - ',
description: truncate(@project.description, length: 255) }
== render 'submenu'
.col-xs-12.col-md-10.col-md-offset-1

View File

@ -1,4 +1,8 @@
-set_meta_tags title: [title_object(@project), "#{t '.title'} #{t('at') if @branch} #{@branch.try :name}"]
- title = [title_object(@project), "#{t '.title'} #{t('at') if @branch} #{@branch.try :name}"]
- set_meta_tags title: title
- set_meta_tags og: { title: title * ' - ',
description: truncate(@project.description, length: 255) }
== render 'submenu'
.col-xs-12.col-md-10.col-md-offset-1
.row

View File

@ -1,4 +1,7 @@
-set_meta_tags title: [title_object(@project), shortest_hash_id(@commit.id), @commit.message]
- title = [title_object(@project), shortest_hash_id(@commit.id)]
- set_meta_tags title: [title, @commit.message].flatten
- set_meta_tags og: { title: title * ' - ',
description: truncate(@commit.message, length: 255) }
== render 'submenu'
.col-xs-12.col-md-10.col-md-offset-1

View File

@ -1,2 +1,6 @@
-set_meta_tags title: "#{title_object @project}"
- title = title_object(@project)
- set_meta_tags title: title
- set_meta_tags og: { title: title,
description: truncate(@project.description, length: 255) }
== render partial: "branches", layout: 'layout'

View File

@ -1,4 +1,8 @@
-set_meta_tags title: title_object(@project)
- title = title_object(@project)
- set_meta_tags title: title
- set_meta_tags og: { title: title,
description: truncate(@project.description, length: 255) }
= render 'submenu'
= render 'repo_block', project: @project
= render 'about_block', project: @project

View File

@ -1,2 +1,5 @@
- set_meta_tags title: "#{title_object @project} #{t('at') if @branch} #{@branch.try :name}"
- set_meta_tags og: { title: title_object(@project),
description: truncate(@project.description, length: 255) }
== render partial: "show", layout: 'layout'

View File

@ -1,2 +1,6 @@
-set_meta_tags title: "#{title_object @project}"
- title = title_object(@project)
- set_meta_tags title: title
- set_meta_tags og: { title: title,
description: truncate(@project.description, length: 255) }
== render partial: "tags", layout: 'layout'

View File

@ -1,9 +1,9 @@
link rel='canonical' href=facebook_meta_url
meta property='og:title' content=facebook_meta_title
/ meta property='og:title' content=facebook_meta_title
meta property='og:type' content='website'
meta property='og:url' content=facebook_meta_url
meta property='og:image' content=facebook_meta_image
meta property='og:site_name' content=facebook_site_name
meta property='fb:app_id' content=facebook_meta_app_id
meta property='og:description' content=facebook_meta_description
meta name='Description' content=facebook_meta_description
/ meta property='og:description' content=facebook_meta_description
/ meta name='Description' content=facebook_meta_description

View File

@ -1,12 +0,0 @@
en:
helpers:
facebook:
meta_description: "A distributed environment to build distributions, supporting all steps from managing source code to create ISO images."
fb_meta_titles:
project: "Project %{name} - ABF"
build_list: "Build list - Project %{name} - ABF"
platform: "Platform %{name} - ABF"
user: "User %{name} - ABF"
group: "Group %{name} - ABF"

View File

@ -1,4 +0,0 @@
ru:
helpers:
facebook:
meta_description: "Платформа разработки и управления жизненным циклом дистрибутивов: от исходного кода до ISO-образов."