From 9d69c78b36288ebd253db4a3d2b66edec8a73688 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Wed, 28 Mar 2012 08:01:16 -0700 Subject: [PATCH] Add data attributes for ups and downs on links and comments. --- r2/r2/templates/comment.html | 4 ++++ r2/r2/templates/link.html | 4 ++++ r2/r2/templates/printable.html | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/r2/r2/templates/comment.html b/r2/r2/templates/comment.html index 7b2da2cc3..7b2b3cdf9 100644 --- a/r2/r2/templates/comment.html +++ b/r2/r2/templates/comment.html @@ -33,6 +33,10 @@ ### specific fill-in functions for comment ################## +<%def name="thing_data_attributes(what)" buffered="True"> +${parent.thing_data_attributes(what)} data-ups="${what.upvotes}" data-downs="${what.downvotes}" + + <%def name="midcol(display=True, cls = '')"> ${parent.midcol(not thing.collapsed, cls = cls)} diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html index dddf10fda..afd185bda 100644 --- a/r2/r2/templates/link.html +++ b/r2/r2/templates/link.html @@ -156,6 +156,10 @@ ${parent.thing_css_class(what)} ${"over18" if thing.over_18 else ""} +<%def name="thing_data_attributes(what)" buffered="True"> +${parent.thing_data_attributes(what)} data-ups="${what.upvotes}" data-downs="${what.downvotes}" + + <%def name="subreddit()" buffered="True"> ${plain_link(thing.subreddit.name, thing.subreddit_path, sr_path = False, cname = False, _class = "subreddit hover", diff --git a/r2/r2/templates/printable.html b/r2/r2/templates/printable.html index 3d9b766e0..3ca66244a 100644 --- a/r2/r2/templates/printable.html +++ b/r2/r2/templates/printable.html @@ -47,6 +47,8 @@ ${self.RenderPrintable()} <%def name="thing_css_class(what)">thing id-${what._fullname} +<%def name="thing_data_attributes(what)">data-fullname="${what._fullname}" + <%def name="RenderPrintable()"> <% cls = thing.lookups[0].__class__.__name__.lower() %> <% @@ -76,7 +78,8 @@ ${self.RenderPrintable()} rowclass += " hidden" %>
+ ${thing.display} onclick="click_thing(this)" + ${unsafe(self.thing_data_attributes(thing))}>

${self.ParentDiv()}