diff --git a/r2/r2/config/rewrites.py b/r2/r2/config/rewrites.py index 625fbd17c..f545dca1f 100644 --- a/r2/r2/config/rewrites.py +++ b/r2/r2/config/rewrites.py @@ -26,6 +26,6 @@ rewrites = (#these first two rules prevent the .embed rewrite from ("^/_(.*)", "/_$1"), ("^/static/(.*\.js)", "/static/$1"), #This next rewrite makes it so that all the embed stuff works. - ("^(.*)(? <%! from pylons.i18n import _ - from r2.lib.template_helpers import get_domain + from r2.lib.template_helpers import get_domain, style_line + from r2.models.subreddit import FakeSubreddit, Default %> -

- - - <% - link = 'reddit

' % get_domain() - label = _("link from %(site)s") - label = label.replace(" ", " "); - %> - ${unsafe(label % dict(site = link))} -${next.body()} +
+ +

+ + + + <% + style = capture(optionalstyle, "text-decoration:none;color:#336699") + link = '%s

' % (style, get_domain(), c.site.name) + label = _("links from %(site)s").replace(" ", " "); + %> + ${unsafe(label % dict(site = link))} + + %if not isinstance(c.site, FakeSubreddit) or c.site != Default: +

+ + powered by + + ${Default.name} + + +

+ %endif + + ${next.body()} +
diff --git a/r2/r2/templates/button.html b/r2/r2/templates/button.html index 030414707..a0bdb51cc 100644 --- a/r2/r2/templates/button.html +++ b/r2/r2/templates/button.html @@ -25,7 +25,7 @@ %> <%inherit file="reddit.html"/> <%namespace module="r2.lib.template_helpers" import="generateurl"/> -<%namespace file="printable.html" import="arrow, score" /> +<%namespace file="buttontypes.html" import="button1, button2, button3, submiturl, submitlink" /> @@ -63,70 +63,4 @@ -<%def name="submiturl(url, title='')"> - ${("http://%s/submit" % get_domain(True)) + query_string(dict(url=url, title=title))} - - -<%def name="submitlink(url, title='', text='submit')"> - ${text} - - - -<%def name="button1(thing)"> -
-
- - - -
- %if thing.link: - <% thing.link.score = thing.link._ups - thing.link._downs %> - ${arrow(thing.link, 1, thing.likes)} - ${arrow(thing.link, 0, thing.likes == False)} - ${score(thing.link, thing.likes, inline=False)} - %else: - ${submitlink(thing.url, thing.title)} - %endif -
-
- - -<%def name="button2(thing)"> -
- %if thing.link: - ${arrow(thing.link, 1, thing.likes)} - <% thing.link.score = thing.link._ups - thing.link._downs %> - ${score(thing.link, thing.likes, inline=False, label = False)} - ${arrow(thing.link, 0, thing.likes == False)} - %else: - ${submitlink(thing.url, thing.title, 'submit to')} - %endif -
- reddit -
-
- - - -<%def name="button3(thing)"> -
-
- %if thing.link: - ${arrow(thing.link, 1, thing.likes)} - <% thing.link.score = thing.link._ups - thing.link._downs %> - ${score(thing.link, thing.likes, inline=False, label = False)} - ${arrow(thing.link, 0, thing.likes == False)} - %else: - ${submitlink(thing.url, thing.title, unsafe('
'))} - ${submitlink(thing.url, thing.title, '?')} - ${submitlink(thing.url, thing.title, unsafe('
'))} - %endif -
-
- ${submitlink(thing.url, thing.title, \ - unsafe(''))} -
-
-
- diff --git a/r2/r2/templates/buttondemopanel.html b/r2/r2/templates/buttondemopanel.html index 8e61109a9..b3e001fb4 100644 --- a/r2/r2/templates/buttondemopanel.html +++ b/r2/r2/templates/buttondemopanel.html @@ -25,47 +25,158 @@ <% domain = get_domain(True) %> -<%def name="drawrequired(type)" buffered="True"> - - - -<%def name="drawoptional(url, title)"> -${"" % url}
-${"" % title} - -

${_("put %(site)s buttons on your site") % dict(site=c.site.name)}

-

${_("copy and paste the code for the style of button you would like\ - into your site. The green lines are\ - optional.")}

- -

${_("if the site has not been submitted yet, clicking on the button\ - will take the user to a reddit submit page, otherwise it takes\ - them to the comments page.")}

- -

${_("if you want to specify the URL that should be submitted to\ - reddit, include the reddit_url line. if you don't include that\ - line, then the current page's URL will be used.")}

- -

${_("if you want to specify the title that should be submitted to\ - reddit, include the reddit_title line. if you don't include that\ - line, then the user will have to specify a title when they\ - submit.")}

- - - ${buttondemo(1)} - ${buttondemo(2)} - ${buttondemo(3)} +

${_('the reddit button is the smart way to get your content submitted to\ + and discussed on reddit. pick the button you like from below, and then\ + copy/paste the code into your HTML editor.')}

+ +

${_("commonly used buttons")}

+

${_('use one of these buttons to quickly add reddit links to your site, or \ + see below for more options.')}

+ + + +

${_("buttons with points")}

+ +

${_("customizing the look of your buttons")}

+

${_('the buttons with points have two additional options.')}

+ +

${_('Example:')}

+ + ${capture(point_option_example)} + + + +

${_('simple interactive button')}

+

${_('put this code on your page:')}

+ ${draw_interactive(False)} +

${_("and you'll get something like this:")}

+ ${unsafe(draw_interactive(False))} + +

${_("more interactive buttons")}

+ + +

${_('interactive button advanced settings')}

+
+ +

${_('Example:')}

+

${_('to make this button:')}

+ ${draw_interactive_example()} +

${_('use this code:')}

+ + ${capture(draw_interactive_example)} + +
+ +

${_("more badges and buttons")}

+ + +
- -<%def name="buttondemo(type)"> -

${_("style %(number)s") % dict(number=type)}

- - ${unsafe(drawrequired(type))} -
-  ${drawoptional('[URL]', '[TITLE]')}
- ${drawrequired(type)} -
+ +<%def name="drawbadge(image)"> + +submit to reddit + + + +<%def name="badgedemo(image)"> + view code + ${unsafe(drawbadge(image))}
+ + ${capture(drawbadge, image)} + + + +<%def name="draw_point_button(image)" buffered="True"> + + + +<%def name="point_option_example()"> + + + +<%def name="point_button_demo(image)"> + view code + ${unsafe(draw_point_button(image))}
+ + ${draw_point_button(image)} + + + +<%def name="draw_interactive(type)" buffered="True"> +%if type: + +%else: + +%endif + + +<%def name="interactive_button_demo(number)"> + view code + ${unsafe(draw_interactive(number))}
+ + ${draw_interactive(number)} + + + +<%def name="drawoption(option, val)"> +${"" % (option, val)} + + +<%def name="draw_interactive_example()"> + + diff --git a/r2/r2/templates/buttonembed.js b/r2/r2/templates/buttonembed.js index 1da848330..d2d33ba93 100644 --- a/r2/r2/templates/buttonembed.js +++ b/r2/r2/templates/buttonembed.js @@ -33,6 +33,9 @@ if (window.reddit_url) { write_string += encodeURIComponent(reddit_url); } else { write_string += encodeURIComponent('${thing.referer}');} if (window.reddit_title) { write_string += '&title=' + encodeURIComponent(reddit_title); } if (window.reddit_css) { write_string += '&css=' + encodeURIComponent(reddit_css); } +if (window.reddit_bgcolor) { write_string += '&bgcolor=' + encodeURIComponent(reddit_bgcolor); } +if (window.reddit_bordercolor) { write_string += '&bordercolor=' + encodeURIComponent(reddit_bordercolor); } +write_string += '&width=${thing.width}'; write_string += '" height="${thing.height}" width="${thing.width}" scrolling="no" frameborder="0">'; document.write(write_string); })() diff --git a/r2/r2/templates/buttonlite.js b/r2/r2/templates/buttonlite.js new file mode 100644 index 000000000..e9e4cf66f --- /dev/null +++ b/r2/r2/templates/buttonlite.js @@ -0,0 +1,67 @@ +## The contents of this file are subject to the Common Public Attribution +## License Version 1.0. (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License at +## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public +## License Version 1.1, but Sections 14 and 15 have been added to cover use of +## software over a computer network and provide for limited attribution for the +## Original Developer. In addition, Exhibit A has been modified to be consistent +## with Exhibit B. +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for +## the specific language governing rights and limitations under the License. +## +## The Original Code is Reddit. +## +## The Original Developer is the Initial Developer. The Initial Developer of +## the Original Code is CondeNet, Inc. +## +## All portions of the code written by CondeNet are Copyright (c) 2006-2008 +## CondeNet, Inc. All Rights Reserved. +################################################################################ +<%! + from r2.lib.template_helpers import get_domain + from r2.lib.strings import Score + %> + +<%namespace file="buttontypes.html" import="submiturl" /> + +<% + domain = get_domain() + if thing.link: + thing.link.score = thing.link._ups - thing.link._downs +%> +(function() { + var styled_submit = ''; + var unstyled_submit = ''; + var write_string=''; +%if thing.image > 0: + write_string += ''; +%endif +%if thing.link: + write_string += '${Score.safepoints(thing.link.score)}'; + %if thing.styled: + write_string += ' on ' + styled_submit + 'reddit'; + %else: + write_string += ' on ' + unstyled_submit + 'reddit'; + %endif +%else: + %if thing.styled: + write_string += styled_submit + 'submit'; + %else: + write_string += unstyled_submit + 'submit'; + %endif + %if thing.image > 0: + write_string += ''; + %else: + write_string += ' to reddit'; + %endif +%endif + write_string += ''; + +document.write(write_string); +})() diff --git a/r2/r2/templates/buttonnobody.html b/r2/r2/templates/buttonnobody.html new file mode 100644 index 000000000..4dd9e7538 --- /dev/null +++ b/r2/r2/templates/buttonnobody.html @@ -0,0 +1,31 @@ +## The contents of this file are subject to the Common Public Attribution +## License Version 1.0. (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License at +## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public +## License Version 1.1, but Sections 14 and 15 have been added to cover use of +## software over a computer network and provide for limited attribution for the +## Original Developer. In addition, Exhibit A has been modified to be consistent +## with Exhibit B. +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for +## the specific language governing rights and limitations under the License. +## +## The Original Code is Reddit. +## +## The Original Developer is the Initial Developer. The Initial Developer of +## the Original Code is CondeNet, Inc. +## +## All portions of the code written by CondeNet are Copyright (c) 2006-2008 +## CondeNet, Inc. All Rights Reserved. +################################################################################ + +<%namespace file="buttontypes.html" import="button1, button2, button3, submiturl, submitlink" /> + +%if thing.button == 1: + ${button1(thing)} +%elif thing.button == 2: + ${button2(thing)} +%elif thing.button == 3: + ${button3(thing)} +%endif diff --git a/r2/r2/templates/buttontypes.html b/r2/r2/templates/buttontypes.html new file mode 100644 index 000000000..8b9c07e9f --- /dev/null +++ b/r2/r2/templates/buttontypes.html @@ -0,0 +1,120 @@ +## The contents of this file are subject to the Common Public Attribution +## License Version 1.0. (the "License"); you may not use this file except in +## compliance with the License. You may obtain a copy of the License at +## http://code.reddit.com/LICENSE. The License is based on the Mozilla Public +## License Version 1.1, but Sections 14 and 15 have been added to cover use of +## software over a computer network and provide for limited attribution for the +## Original Developer. In addition, Exhibit A has been modified to be consistent +## with Exhibit B. +## +## Software distributed under the License is distributed on an "AS IS" basis, +## WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for +## the specific language governing rights and limitations under the License. +## +## The Original Code is Reddit. +## +## The Original Developer is the Initial Developer. The Initial Developer of +## the Original Code is CondeNet, Inc. +## +## All portions of the code written by CondeNet are Copyright (c) 2006-2008 +## CondeNet, Inc. All Rights Reserved. +################################################################################ +<%! + from r2.lib.template_helpers import get_domain, static, style_line, choose_width + from r2.lib.utils import query_string + %> + +<%namespace file="printable.html" import="arrow, score" /> +<%namespace file="utils.html" import="img_link" /> + +<%def name="submiturl(url, title='')">${("http://%s/submit" % get_domain(True)) + query_string(dict(url=url, title=title))} + +<%def name="submitlink(url, title='', text='submit')"> + ${text} + + +<%def name="class_def(class_number, width=None)"> + %if style_line(width): +
+ %else: +
+ %endif + + +<%def name="button1(thing)"> +${class_def(1, width=choose_width(thing, thing.width))} +
+ + + +
+ %if thing.link: + <% thing.link.score = thing.link._ups - thing.link._downs %> + %if thing.vote: + ${arrow(thing.link, 1, thing.likes)} + ${arrow(thing.link, 0, thing.likes == False)} + ${score(thing.link, thing.likes, inline=False)} + %else: + ${thing.link.score} + %endif + %else: + ${submitlink(thing.url, thing.title)} + %endif +
+
+ + +<%def name="button2(thing)"> + ${class_def(2)} + %if thing.link: + <% thing.link.score = thing.link._ups - thing.link._downs %> + %if thing.vote: + ${arrow(thing.link, 1, thing.likes)} + ${score(thing.link, thing.likes, inline=False, label = False)} + ${arrow(thing.link, 0, thing.likes == False)} + %else: +  
+ ${thing.link.score} +  
+ %endif + %else: + + ${submitlink(thing.url, thing.title, 'submit to')} + %endif + %if thing.bgcolor: +
+ %else: +
+ %endif + reddit +
+
+ + + +<%def name="button3(thing)"> +${class_def(3)} +
+ %if thing.link: + <% thing.link.score = thing.link._ups - thing.link._downs %> + %if thing.vote: + ${arrow(thing.link, 1, thing.likes)} + ${score(thing.link, thing.likes, inline=False, label = False)} + ${arrow(thing.link, 0, thing.likes == False)} + %else: +  
+ ${thing.link.score} +  
+ %endif + %else: + ${submitlink(thing.url, thing.title, unsafe('
'))} + ${submitlink(thing.url, thing.title, '?')} + ${submitlink(thing.url, thing.title, unsafe('
'))} + %endif +
+
+ ${img_link('submit', '/static/blog_snoo.gif', '/submit' + query_string(dict(url=thing.url, title=thing.title)))} +
+
+
+ diff --git a/r2/r2/templates/link.htmllite b/r2/r2/templates/link.htmllite index ab4413be7..4e759c693 100644 --- a/r2/r2/templates/link.htmllite +++ b/r2/r2/templates/link.htmllite @@ -19,6 +19,7 @@ ## All portions of the code written by CondeNet are Copyright (c) 2006-2008 ## CondeNet, Inc. All Rights Reserved. ################################################################################ +<%namespace file="utils.html" import="optionalstyle"/> <%! from pylons.i18n import _, ungettext @@ -36,12 +37,33 @@ else: # generates "comment" the imperative verb com_label = _("comment") + + domain = get_domain(subreddit=False) + permalink = "http://%s%s" % (domain, thing.permalink) + if thing.likes == False: + arrow = "http://%s/static/widget_arrows_down.png" + elif thing.likes: + arrow = "http://%s/static/widget_arrows_up.png" + else: + arrow = "http://%s/static/widget_arrows.png" + arrow = arrow % domain %> - \ - - ${thing.title}
- - ${thing.score} ${ungettext("point", "points", thing.score)} | -  ${com_label} - + + vote + +
+ + ${thing.title} + +
+ + ${thing.score} ${ungettext("point", "points", thing.score)} + | + ${com_label} + +
diff --git a/r2/r2/templates/listing.htmllite b/r2/r2/templates/listing.htmllite index 77c7f21d0..6764bde3c 100644 --- a/r2/r2/templates/listing.htmllite +++ b/r2/r2/templates/listing.htmllite @@ -19,7 +19,40 @@ ## All portions of the code written by CondeNet are Copyright (c) 2006-2008 ## CondeNet, Inc. All Rights Reserved. ################################################################################ +<%namespace file="utils.html" import="optionalstyle"/> +
+ <% + t = thing.things + l = len(t) + %> + %for i, a in enumerate(t): + <% + cls = "reddit-link " + cls += "odd " if i % 2 else "even " + cls += "first-half" if i < (l+1)/2 else "second-half" -%for a in thing.things: - ${a.render()} -%endfor: + two_col = request.get.has_key("twocolumn") + %> + %if two_col: + %if i == 0: +
+ %elif i - 1 < (l+1)/2 and i >= (l+1)/2: +
+
+ %endif + %endif + +
+ ${a.render()} +
+ %if two_col and i == l - 1: +
+ %endif + %endfor: + %if two_col: +
+ %endif +
diff --git a/r2/r2/templates/printable.htmllite b/r2/r2/templates/printable.htmllite index d5326b0da..a7eecccb8 100644 --- a/r2/r2/templates/printable.htmllite +++ b/r2/r2/templates/printable.htmllite @@ -20,20 +20,16 @@ ## CondeNet, Inc. All Rights Reserved. ################################################################################ -

- ${self.parent()} - ${self.entry()} -

+${self.parent()} +${self.entry()} +${self.Child()} -
- ${self.Child()} -
<%def name="parent()"> <%def name="Child()"> -${hasattr(thing, "child") and thing.child.render() or ''} + ${hasattr(thing, "child") and thing.child.render() or ''} <%def name="entry()"> diff --git a/r2/r2/templates/utils.html b/r2/r2/templates/utils.html index 74d633c71..775e91858 100644 --- a/r2/r2/templates/utils.html +++ b/r2/r2/templates/utils.html @@ -215,3 +215,9 @@ ${unsafe(txt)} <%def name="separator()"> | + +<%def name="optionalstyle(style)"> + %if request.get.get('style') != "off": + style="${style}" + %endif + diff --git a/r2/r2/templates/widgetdemopanel.html b/r2/r2/templates/widgetdemopanel.html index 9f1612c42..e4673dac5 100644 --- a/r2/r2/templates/widgetdemopanel.html +++ b/r2/r2/templates/widgetdemopanel.html @@ -23,7 +23,10 @@ from r2.lib.template_helpers import get_domain %> -<% domain = get_domain(True) %> +<% + domain = get_domain(cname = c.cname, subreddit = False) + sr_domain = get_domain(cname = c.cname, subreddit = True) + %>
@@ -78,63 +103,133 @@ function update() {

${_("get live %(site)s headlines on your site") % dict(site=c.site.name)}

${_("just cut and paste the generated code into your site and your specified %(site)s feed will be displayed and updated as new stories bubble up") % dict(site=c.site.name)}

+

${_("which links do you want to display?")}

-
-

- ${_("number")}: - + + + + + -

-

- - ${unsafe(_("%(site)s %(what)s links from %(when)s") % dict(site = c.site.name, what = capture(what), when = capture(when)))} - <%def name="what()"> - - - <%def name="when()"> - - -

-

- - ${unsafe(_("%(what)s %(where)s %(who)s") % dict(what = capture(what2), where= capture(where2), who = capture(who2)))} - - <%def name="what2()"> - - - - <%def name="where2()"> - - - - <%def name="who2()"> - - -

+ + <%def name="where2()" buffered="True"> + + + <%def name="text_input(name)" buffered="True"> + + + + + + + + + + + + + + + +
+ ${_("listing options")} + +

+ + ${_("links from %(domain)s") % dict(domain = get_domain())} +

+

+ + ${unsafe(_("links %(submitted_by)s the user %(who)s") % dict(submitted_by = where2(), who = text_input("who")))} +

+

+ + ${unsafe(_("links from the domain %(domain)s") % dict(domain = text_input("domain")))} +

+
+ ${_("sorting options")} + +

+ <%def name="what()" buffered="True"> + + + ${unsafe(_("sort links by %(what)s") % dict(what = what()))} +

+

+ ${unsafe(_("date range includes %(when)s") % dict(when = when()))} +

+

+ ${_("number of links to show")}: + +

+
+ ${_("display options")} + +

+ + +

+
+

+ + +

+

+ + +  #${unsafe(text_input("bg_color"))} + + ${_("(e.g., FF0000 = red)")} + +

+

+ + +  #${unsafe(text_input("bord_color"))} +

+
+

${_("the code")}