add schema.org metatags

This commit is contained in:
r888888888
2016-02-09 14:02:47 -08:00
parent 0f0917210e
commit 2dd4b4cbff
6 changed files with 18 additions and 12 deletions

View File

@@ -21,7 +21,7 @@ class PostPresenter < Presenter
path = options[:path_prefix] || "/posts"
html = %{<article id="post_#{post.id}" class="#{preview_class(post, options[:pool])}" #{data_attributes(post)}>}
html = %{<article itemscope itemtype="http://schema.org/ImageObject" id="post_#{post.id}" class="#{preview_class(post, options[:pool])}" #{data_attributes(post)}>}
if options[:tags].present?
tag_param = "?tags=#{CGI::escape(options[:tags])}"
elsif options[:pool_id] || options[:pool]
@@ -32,7 +32,7 @@ class PostPresenter < Presenter
tag_param = nil
end
html << %{<a href="#{path}/#{post.id}#{tag_param}">}
html << %{<img src="#{post.preview_file_url}" alt="#{h(post.tag_string)}">}
html << %{<img itemprop="thumbnailUrl" src="#{post.preview_file_url}" alt="#{h(post.tag_string)}">}
html << %{</a>}
if options[:pool]

View File

@@ -12,7 +12,7 @@ class TagSetPresenter < Presenter
def tag_list_html(template, options = {})
html = ""
if @tags.present?
html << "<ul>"
html << '<ul itemscope itemtype="http://schema.org/ImageObject">'
@tags.each do |tag|
html << build_list_item(tag, template, options)
end
@@ -112,7 +112,12 @@ private
humanized_tag = tag.tr("_", " ")
path = options[:path_prefix] || "/posts"
html << %{<a class="search-tag" href="#{path}?tags=#{u(tag)}">#{h(humanized_tag)}</a> }
if categories[tag] == Tag.categories.artist
itemprop = 'itemprop="author"'
else
itemprop = nil
end
html << %{<a class="search-tag" #{itemprop} href="#{path}?tags=#{u(tag)}">#{h(humanized_tag)}</a> }
unless options[:name_only]
if counts[tag].to_i >= 10_000