Skip to content

Commit a2c96f6

Browse files
committed
Annotate protip with schema.org tech article.
Migrate data-vocabulary.org annotations to schema.org. Minon styles changes: single quotes etc.
1 parent 036d05d commit a2c96f6

File tree

5 files changed

+38
-19
lines changed

5 files changed

+38
-19
lines changed

app/helpers/application_helper.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module ApplicationHelper
22
include TweetButton
3-
3+
include SchemaOrgHelper
4+
45
def link_twitter_path
56
'/auth/twitter'
67
end
@@ -237,14 +238,6 @@ def admin_stat_class(yesterday, today)
237238
today > yesterday ? "goodday" : "badday"
238239
end
239240

240-
def mperson
241-
"http://data-vocabulary.org/Person"
242-
end
243-
244-
def maddress
245-
"http://data-vocabulary.org/Address"
246-
end
247-
248241
def image_url(source)
249242
abs_path = image_path(source)
250243
unless abs_path =~ /^http/

app/helpers/schema_org_helper.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module SchemaOrgHelper
2+
3+
def meta_person_schema_url
4+
'http://schema.org/Person'
5+
end
6+
7+
def meta_address_schema_url
8+
'http://schema.org/Address'
9+
end
10+
11+
def meta_article_schema_url
12+
'http://schema.org/TechArticle'
13+
end
14+
15+
def meta_comment_schema_url
16+
'http://schema.org/UserComments'
17+
end
18+
19+
end

app/views/comments/_comment.html.haml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
%li.cf.comment{:class => top_comment?(comment, comment_counter) ? "top-comment" : "" , :id => "comment_#{comment.id}"}
2-
%header.cf
1+
%li.cf.comment{:class => top_comment?(comment, comment_counter) ? 'top-comment' : '' , :id => "comment_#{comment.id}", :itemscope => true, :itemtype => meta_comment_schema_url, :itemprop => :comment}
2+
%meta{:itemprop => :commentTime, :content => comment.created_at}
3+
%meta{:itemprop => :name, :content => comment.id}
4+
%header.cf{:itemprop => "creator", :itemscope => true ,:itemtype => meta_person_schema_url}
5+
%meta{:itemprop => :name, :content => comment.user.display_name}
6+
%meta{:itemprop => :alternateName, :content => comment.user.username}
37
.comment-avatar
48
=image_tag(users_image_path(comment.user), :class => 'avatar')
59
%a.comment-user{:href => profile_path(comment.user.username), 'data-reply-to' => comment.user.username}
610
= comment.user.username
711
%a.like{:href =>like_protip_comment_path(comment.commentable.try(:public_id), comment.id), 'data-remote' => 'true', 'data-method' => :post, :class => comment_liked_class(comment), :rel => "nofollow"}
812
=comment_likes(comment)
9-
.comment
13+
.comment{:itemprop => :commentText}
1014
=raw sanitize(formatted_comment(comment.body))
1115
- if can_edit_comment?(comment)
1216
.edit-comment.hidden

app/views/protips/_protip.html.haml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
.inside.cf.x-protip-pane
1+
.inside.cf.x-protip-pane{:itemscope => true, :itemtype => meta_article_schema_url}
2+
%meta{:itemprop => :dateCreated, :content => protip.created_at}
23
.tip-container.cf.x-protip-content.protip-single#x-protip{:class => mode}
34
%aside.tip-sidebar
45
.user-box
56
%a.avatar{:href => profile_path(protip.user.username), 'data-action' => 'view user profile', 'data-from' => 'protip author avatar on top', 'data-properties' => {'mode' => mode}.to_json}
67
=image_tag(users_image_path(protip.user), :class => 'avatar')
78

89
%ul.user-team
9-
%li.user
10+
%li.user{:itemprop => :author, :itemscope => true ,:itemtype => meta_person_schema_url}
11+
%meta{:itemprop => :name, :content => protip.user.display_name}
12+
%meta{:itemprop => :alternateName, :content => protip.user.username}
1013
by
1114
%a.track{:href => profile_path(protip.user.username), 'data-action' => 'view user profile', 'data-from' => 'protip author name on top', 'data-properties' => {'mode' => mode}.to_json}
1215
= protip.user.display_name
@@ -69,7 +72,7 @@
6972
= share_on_twitter(protip, 'share-this-tip direction')
7073
= upvote_link(protip, "upvote")
7174
%header.tip-header
72-
%h1.tip-title
75+
%h1.tip-title{:itemprop => :headline}
7376
-if mode == 'popup'
7477
%a.track{:href => protip_path(protip), 'data-action' => 'view protip', 'data-from' => 'popup protip title'}=sanitize(protip.title)
7578
-else
@@ -80,7 +83,7 @@
8083
%span
8184
= protip.total_views
8285
views
83-
%ul#tags.cf
86+
%ul#tags.cf{:itemprop => :keywords}
8487
- protip.topics.each do |tag|
8588
%li
8689
%a{:href => "/p/t/#{tag.parameterize}"}=tag
@@ -99,7 +102,7 @@
99102
%li=link_to('delete', protip_path(protip.public_id), :method => :delete, :class => 'delete-tip del', :rel => 'nofollow', :title => 'remove protip', :confirm => "Are you sure you permanently want to remove this pro tip?")
100103

101104
%hr
102-
%div.tip-content
105+
%div.tip-content{:itemprop => :articleBody}
103106
=raw sanitize(protip.to_html)
104107

105108
-if include_comments

app/views/users/show.html.haml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
=location_image_tag_credits_for(@user)
1616
=link_to(image_tag('cclicense.png'), 'http://creativecommons.org/licenses/by-sa/2.0/', :target => :new)
1717

18-
%section.profile{:itemscope => true, :itemtype => mperson}
18+
%section.profile{:itemscope => true, :itemtype => meta_person_schema_url}
1919
.special-image
2020
=location_image_tag_for(@user)
2121
.business-card
2222
=image_tag(users_image_path(@user), :class => 'profile-avatar', :width => 80, :height => 80, :itemprop => :image)
2323
.bc-right
2424
%h1{:itemprop => :name}=@user.display_name
2525
-if signed_in?
26-
%p.location{:itemscope => true, :itemtype => maddress, :itemprop => :address}=@user.location
26+
%p.location{:itemscope => true, :itemtype => meta_address_schema_url, :itemprop => :address}=@user.location
2727
%p.title{:itemprop => :title}=business_card_for(@user)
2828
-if !@user.protips.empty? || viewing_self?
2929
.user-pro-tip.cf

0 commit comments

Comments
 (0)