From 2dd4b4cbff1db4d20ab9572cadd1668b852c095f Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 9 Feb 2016 14:02:47 -0800 Subject: [PATCH] add schema.org metatags --- app/presenters/post_presenter.rb | 4 ++-- app/presenters/tag_set_presenter.rb | 9 +++++++-- app/views/posts/partials/show/_image.html.erb | 2 +- app/views/posts/partials/show/_information.html.erb | 11 +++++++---- app/views/posts/show.html.erb | 2 +- public/robots.txt | 2 -- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/app/presenters/post_presenter.rb b/app/presenters/post_presenter.rb index d15985e4d..1f5093d03 100644 --- a/app/presenters/post_presenter.rb +++ b/app/presenters/post_presenter.rb @@ -21,7 +21,7 @@ class PostPresenter < Presenter path = options[:path_prefix] || "/posts" - html = %{
} + html = %{
} 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 << %{} - html << %{#{h(post.tag_string)}} + html << %{#{h(post.tag_string)}} html << %{} if options[:pool] diff --git a/app/presenters/tag_set_presenter.rb b/app/presenters/tag_set_presenter.rb index 6602e0617..2321bc03f 100644 --- a/app/presenters/tag_set_presenter.rb +++ b/app/presenters/tag_set_presenter.rb @@ -12,7 +12,7 @@ class TagSetPresenter < Presenter def tag_list_html(template, options = {}) html = "" if @tags.present? - html << "
    " + html << '
      ' @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 << %{#{h(humanized_tag)} } + if categories[tag] == Tag.categories.artist + itemprop = 'itemprop="author"' + else + itemprop = nil + end + html << %{#{h(humanized_tag)} } unless options[:name_only] if counts[tag].to_i >= 10_000 diff --git a/app/views/posts/partials/show/_image.html.erb b/app/views/posts/partials/show/_image.html.erb index 5eb4bf630..023aacdde 100644 --- a/app/views/posts/partials/show/_image.html.erb +++ b/app/views/posts/partials/show/_image.html.erb @@ -1,3 +1,3 @@ <% if post.visible? %> - <%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, "data-uploader" => post.uploader_name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-has-active-children" => post.has_active_children?, "data-score" => post.score, "data-fav-count" => post.fav_count) %> + <%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, "data-uploader" => post.uploader_name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-has-active-children" => post.has_active_children?, "data-score" => post.score, "data-fav-count" => post.fav_count, "itemprop" => "contentUrl") %> <% end %> diff --git a/app/views/posts/partials/show/_information.html.erb b/app/views/posts/partials/show/_information.html.erb index 3ab8e3ef3..26a280754 100644 --- a/app/views/posts/partials/show/_information.html.erb +++ b/app/views/posts/partials/show/_information.html.erb @@ -1,14 +1,17 @@ -
        +
        • ID: <%= post.id %>
        • Uploader: <%= link_to_user(post.uploader) + " ".html_safe + link_to("»".html_safe, posts_path(:tags => "user:#{post.uploader.name}"), :rel => "nofollow") %>
        • -
        • Date: <%= link_to time_ago_in_words_tagged(post.created_at), posts_path(:tags => "date:#{post.created_at.to_date}"), :rel => "nofollow" %>
        • +
        • + Date: <%= link_to time_ago_in_words_tagged(post.created_at), posts_path(:tags => "date:#{post.created_at.to_date}"), :rel => "nofollow" %> + +
        • <% if post.approver %>
        • Approver: <%= link_to_user(post.approver) %>
        • <% end %>
        • - Size: <%= link_to_if post.visible?, number_to_human_size(post.file_size), post.file_url %> + Size: <%= link_to_if post.visible?, number_to_human_size(post.file_size), post.file_url, :itemprop => "contentSize" %> <% if post.has_dimensions? %> - (<%= post.image_width %>x<%= post.image_height %>) + (<%= post.image_width %>x<%= post.image_height %>) <% end %>
        • Source: <%= post_source_tag(post) %>
        • diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 9d224943c..7a6f6ce19 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -40,7 +40,7 @@ <%= render "posts/partials/show/notices", :post => @post %> -
          > +
          >
          <%= @post.presenter.image_html(self) %> diff --git a/public/robots.txt b/public/robots.txt index b03cede03..15efe95a4 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -12,7 +12,6 @@ Disallow: /counts Disallow: /delayed_jobs Disallow: /dmails Disallow: /favorite -Disallow: /favorites Disallow: /iqdb_queries Disallow: /ip_bans Disallow: /janitor_trials @@ -33,7 +32,6 @@ Disallow: /post_sets Disallow: /post_versions Disallow: /post_votes Disallow: /posts.atom -Disallow: /posts/show_seq Disallow: /posts/random Disallow: /posts/copy_notes Disallow: /posts/revert