Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove deprecated button code and templates.

Redirect deprecated requests to /button?t=<num>... to the static js.
  • Loading branch information...
commit ae908d39aead5bd0a77888107f3b63807af91b6b 1 parent 87c86c4
Max Goodman authored
View
6 r2/r2/config/routing.py
@@ -74,11 +74,9 @@ def make_map():
requirements=dict(where='subscriber|contributor|moderator'))
mc('/buttons', controller='buttons', action='button_demo_page')
- mc('/upgradebuttons', controller='buttons', action='upgrade_buttons')
- #the frame
- mc('/button_content', controller='buttons', action='button_content')
+
#/button.js and buttonlite.js - the embeds
- mc('/button', controller='buttonjs', action='button_embed')
+ mc('/button', controller='buttons', action='button_embed')
mc('/buttonlite', controller='buttons', action='button_lite')
mc('/widget', controller='buttons', action='widget_demo_page')
View
1  r2/r2/controllers/__init__.py
@@ -57,7 +57,6 @@ def load_controllers():
from front import FrontController
from health import HealthController
from buttons import ButtonsController
- from buttons import ButtonjsController
from captcha import CaptchaController
from embed import EmbedController
from error import ErrorController
View
122 r2/r2/controllers/buttons.py
@@ -20,74 +20,17 @@
# Inc. All Rights Reserved.
###############################################################################
-from reddit_base import RedditController, MinimalController, make_key
-from r2.lib.pages import Button, ButtonNoBody, ButtonEmbed, ButtonLite, \
- ButtonDemoPanel, WidgetDemoPanel, Bookmarklets, BoringPage, UpgradeButtons
+from reddit_base import RedditController
+from r2.lib.pages import (ButtonLite, ButtonDemoPanel, WidgetDemoPanel,
+ Bookmarklets, BoringPage)
from r2.lib.pages.things import wrap_links
from r2.models import *
-from r2.lib.utils import tup, query_string
+from r2.lib.utils import tup
from pylons import c, request
from validator import *
from pylons.i18n import _
-from r2.lib.filters import spaceCompress
-from r2.controllers.listingcontroller import ListingController
-
-class ButtonjsController(MinimalController):
- def pre(self):
- MinimalController.pre(self)
- # override user loggedin behavior to ensure this page always
- # uses the page cache
- user = valid_cookie(c.cookies[g.login_cookie].value
- if g.login_cookie in c.cookies
- else '')
- if user:
- self.user_is_loggedin = True
-
- @validate(buttontype = VInt('t', 1, 5),
- url = VSanitizedUrl("url"),
- _height = VInt('height', 0, 300),
- _width = VInt('width', 0, 800),
- autohide = VBoolean("autohide"))
- def GET_button_embed(self, buttontype, _height, _width, url, autohide):
- # no buttons on domain listings
- if isinstance(c.site, DomainSR):
- return self.abort404()
- c.render_style = 'js'
- c.response_content_type = 'text/javascript; charset=UTF-8'
- if not c.user_is_loggedin and autohide:
- c.response.content = "void(0);"
- return c.response
-
- buttontype = buttontype or 1
- width, height = ((120, 22), (51, 69), (69, 52),
- (51, 52), (600, 52))[min(buttontype - 1, 4)]
- if _width: width = _width
- if _height: height = _height
-
- bjs = ButtonEmbed(button=buttontype,
- width=width,
- height=height,
- url = url,
- referer = request.referer).render()
- return self.sendjs(bjs, callback='', escape=False)
-
- def request_key(self):
- return make_key('button_request_key',
- c.lang,
- c.content_langs,
- request.host,
- c.cname,
- request.referer,
- request.fullpath)
class ButtonsController(RedditController):
- def buttontype(self):
- b = request.get.get('t') or 1
- try:
- return int(b)
- except ValueError:
- return 1
-
def get_wrapped_link(self, url, link = None, wrapper = None):
try:
links = []
@@ -123,47 +66,13 @@ def get_wrapped_link(self, url, link = None, wrapper = None):
if wrapper:
return wrapper(None)
+ @validate(buttontype = VInt('t', 1, 5))
+ def GET_button_embed(self, buttontype):
+ if not buttontype:
+ abort(404)
- def GET_button_content(self, *a, **kw):
- return """
- <html>
- <head>
- </head>
- <body style='border:1px solid #336699;text-align:center;margin:0px'>
- <a href='http://www.reddit.com/upgradebuttons' target='_top' style='color:red'>upgrade</a>
- </body>
- </html>
- """
-
- @validate(buttontype = VInt('t', 1, 5),
- url = VSanitizedUrl("url"),
- _height = VInt('height', 0, 300),
- _width = VInt('width', 0, 800),
- autohide = VBoolean("autohide"))
- def GET_button_embed(self, buttontype, _height, _width, url, autohide):
- # no buttons on domain listings
- if isinstance(c.site, DomainSR):
- return self.abort404()
- c.render_style = 'js'
- c.response_content_type = 'text/javascript; charset=UTF-8'
- if not c.user_is_loggedin and autohide:
- c.response.content = "void(0);"
- return c.response
-
- buttontype = buttontype or 1
- width, height = ((120, 22), (51, 69), (69, 52),
- (51, 52), (600, 52))[min(buttontype - 1, 4)]
- if _width: width = _width
- if _height: height = _height
-
- bjs = ButtonEmbed(button=buttontype,
- width=width,
- height=height,
- url = url,
- referer = request.referer).render()
- # we doing want the JS to be cached (it is referer dependent)
- c.used_cache = True
- return self.sendjs(bjs, callback='', escape=False)
+ return self.redirect('/static/button/button%s.js' % buttontype,
+ code=301)
@validate(buttonimage = VInt('i', 0, 14),
title = nop('title'),
@@ -192,8 +101,6 @@ def builder_wrapper(thing = None):
bjs = self.get_wrapped_link(url, wrapper = builder_wrapper)
return self.sendjs(bjs.render(), callback='', escape=False)
-
-
def GET_button_demo_page(self):
# no buttons for domain listings -> redirect to top level
if isinstance(c.site, DomainSR):
@@ -202,15 +109,6 @@ def GET_button_demo_page(self):
show_sidebar = False,
content=ButtonDemoPanel()).render()
- def GET_upgrade_buttons(self):
- # no buttons for domain listings -> redirect to top level
- if isinstance(c.site, DomainSR):
- return self.redirect('/buttons')
- return BoringPage(_("reddit buttons"),
- show_sidebar = False,
- content=UpgradeButtons()).render()
-
-
def GET_widget_demo_page(self):
return BoringPage(_("reddit widget"),
show_sidebar = False,
View
24 r2/r2/lib/pages/pages.py
@@ -1957,21 +1957,6 @@ class OptIn(Templated):
pass
-class ButtonEmbed(CachedTemplate):
- """Generates the JS wrapper around the buttons for embedding."""
- def __init__(self, button = None, width = 100,
- height=100, referer = "", url = "", **kw):
- arg = "cnameframe=1&" if c.cname else ""
- sr = c.site.name if not isinstance(c.site, FakeSubreddit) else ""
- if sr:
- arg += "sr=%s&" % sr
- Templated.__init__(self, button = button,
- width = width, height = height,
- referer=referer, url = url,
- domain = get_domain(subreddit = False),
- arg = arg,
- **kw)
-
class Button(Wrapped):
cachable = True
extension_handling = False
@@ -2001,19 +1986,10 @@ class ButtonLite(Button):
def render(self, *a, **kw):
return Wrapped.render(self, *a, **kw)
-class ButtonNoBody(Button):
- """A button page that just returns the raw button for direct embeding"""
- pass
-
class ButtonDemoPanel(Templated):
"""The page for showing the different styles of embedable voting buttons"""
pass
-class UpgradeButtons(Templated):
- """The page for showing the different styles of embedable voting buttons"""
- pass
-
-
class SelfServeBlurb(Templated):
pass
View
74 r2/r2/templates/button.html
@@ -1,74 +0,0 @@
-## 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 reddit Inc.
-##
-## All portions of the code written by reddit are Copyright (c) 2006-2012
-## reddit Inc. All Rights Reserved.
-###############################################################################
-
-<%!
- from r2.lib.template_helpers import get_domain
- from r2.lib.utils import query_string
- %>
-<%inherit file="reddit.html"/>
-<%namespace module="r2.lib.template_helpers" import="generateurl"/>
-<%namespace file="buttontypes.html" import="*" />
-<%namespace file="printable.html" import="thing_css_class" />
-
-
-
-<%def name="javascript()">
- <% from r2.lib import js %>
- ${unsafe(js.use('jquery', 'reddit'))}
- <script type="text/javascript">
- function showcover() { $("#cover").show(); }
- </script>
-</%def>
-
-
-<%def name="javascript_run()">
-</%def>
-
-<%def name="bodyHTML()">
- <body style="background-color: ${'#%s' % (c.bgcolor or 'FFFFFF')}"
- class="button-body">
- <div class="button ${thing_css_class(thing) if thing._fullname else ''}">
- %if not c.user_is_loggedin:
- <div id="cover" style="display: none">
- <div class="cover"></div>
- <div id="popup">
- <a href="${submiturl(thing.url, thing.title)}"
- target="_parent">please login</a>
- </div>
- </div>
- %endif
- %if thing.button == 1:
- ${button1(thing)}
- %elif thing.button == 2:
- ${button2(thing)}
- %elif thing.button == 3:
- ${button3(thing)}
- %elif thing.button == 4:
- ${button4(thing)}
- %elif thing.button == 5:
- ${button5(thing)}
- %endif
- </div>
- </body>
-</%def>
-
-
View
41 r2/r2/templates/buttonembed.js
@@ -1,41 +0,0 @@
-## 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 reddit Inc.
-##
-## All portions of the code written by reddit are Copyright (c) 2006-2012
-## reddit Inc. All Rights Reserved.
-###############################################################################
-
-(function() {
-var write_string="<iframe src=\"http://${thing.domain}/static/button/button${thing.button}.html?${unsafe(thing.arg)}width=${thing.width}&url=${(thing.url or "")|u}";
-%if not thing.url:
- if (window.reddit_url) { write_string += encodeURIComponent(reddit_url); }
-else { write_string += encodeURIComponent('${thing.referer}');}
-%endif
-if (window.reddit_title) {
- write_string += '&title=' + encodeURIComponent(window.reddit_title); }
-if (window.reddit_css) {
- write_string += '&css=' + encodeURIComponent(window.reddit_css); }
-if (window.reddit_bgcolor) {
- write_string += '&bgcolor=' + encodeURIComponent(window.reddit_bgcolor); }
-if (window.reddit_bordercolor) {
- write_string += '&bordercolor=' + encodeURIComponent(window.reddit_bordercolor); }
-if (window.reddit_newwindow) {
- write_string += '&newwindow=' + encodeURIComponent(window.reddit_newwindow);}
-write_string += "\" height=\"${thing.height}\" width=\"${thing.width}\" scrolling='no' frameborder='0'></iframe>";
-document.write(write_string);
-})()
View
5 r2/r2/templates/buttonlite.js
@@ -21,11 +21,12 @@
###############################################################################
<%!
- from r2.lib.template_helpers import static
+ from r2.lib.template_helpers import static, get_domain
+ from r2.lib.utils import query_string
from r2.lib.strings import Score
%>
-<%namespace file="buttontypes.html" import="submiturl" />
+<%def name="submiturl(url, title='')">${("http://%s/submit" % get_domain(cname = c.cname, subreddit = not c.cname)) + query_string(dict(url=url, title=title))}</%def>
<%
if thing._fullname:
View
35 r2/r2/templates/buttonnobody.html
@@ -1,35 +0,0 @@
-## 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 reddit Inc.
-##
-## All portions of the code written by reddit are Copyright (c) 2006-2012
-## reddit 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)}
-%elif thing.button == 4:
- ${button4(thing)}
-%elif thing.button == 5:
- ${button5(thing)}
-%endif
View
263 r2/r2/templates/buttontypes.html
@@ -1,263 +0,0 @@
-## 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 reddit Inc.
-##
-## All portions of the code written by reddit are Copyright (c) 2006-2012
-## reddit Inc. All Rights Reserved.
-###############################################################################
-
-<%!
- from r2.lib.template_helpers import get_domain, static, style_line, choose_width
- from r2.lib.utils import query_string
- from r2.lib.strings import Score
- %>
-
-<%namespace file="printable.html" import="arrow, score" />
-<%namespace file="utils.html" import="img_link" />
-
-<%def name="submiturl(url, title='')">${("http://%s/submit" % get_domain(cname = c.cname, subreddit = not c.cname)) + query_string(dict(url=url, title=title))}</%def>
-
-<%def name="submitlink(url, title='', text='submit')">
- <a href='${submiturl(url, title)}' target='${thing.target}'>${text}</a>
-</%def>
-
-<%def name="class_def(class_number, width=None)">
- <%
- like_cls = "unvoted"
- if getattr(thing, "likes", None):
- like_cls = "likes"
- elif getattr(thing, "likes", None) is False:
- like_cls = "dislikes"
- %>
- <div class="blog blog${class_number} entry ${like_cls}"
- %if style_line(width):
- style="${style_line(width)}"
- %endif
- >
- ${caller.body()}
- </div>
-</%def>
-
-<%def name="button1(thing)">
-<%self:class_def class_number="1"
- width="${choose_width(thing, thing.width)}">
- <div class="headimgcell">
- <a href="${submiturl(thing.url, thing.title)}" target="${thing.target}">
- <img src="http://www.reddit.com/static/blog_head.png" alt=""/>
- </a>
- </div>
- %if thing._fullname:
- %if thing.vote:
- ${arrow(thing, 1, thing.likes)}
- ${arrow(thing, 0, thing.likes == False)}
- ${score(thing, thing.likes,
- scores = map(Score.safepoints, thing.voting_score),
- tag='div')}
- %else:
- ${thing.score}
- %endif
- %else:
- ${submitlink(thing.url, thing.title)}
- %endif
- <div class="clear"></div>
-</%self:class_def>
-</%def>
-
-<%def name="button2(thing)">
-<%self:class_def class_number="2">
- %if thing._fullname:
- %if thing.vote:
- ${arrow(thing, 1, thing.likes)}
- ${score(thing, thing.likes, tag='div')}
- ${arrow(thing, 0, thing.likes == False)}
- %else:
- &nbsp;<br />
- ${thing.score}
- &nbsp;<br />
- %endif
- %else:
- <img src="http://www.reddit.com/static/blog_head.png" alt=""/>
- ${submitlink(thing.url, thing.title, 'submit to')}
- %endif
- %if thing.bgcolor:
- <div class="bottomreddit" style="background-color: #${thing.bgcolor}">
- %else:
- <div class="bottomreddit">
- %endif
- <a href="${submiturl(thing.url, thing.title)}" target="${thing.target}">reddit</a>
- </div>
-</%self:class_def>
-</%def>
-
-
-<%def name="button3(thing)">
-<%self:class_def class_number="3">
- <div class="left">
- %if thing._fullname:
- %if thing.vote:
- ${arrow(thing, 1, thing.likes)}
- ${score(thing, thing.likes, tag='div')}
- ${arrow(thing, 0, thing.likes == False)}
- %else:
- &nbsp;<br />
- ${thing.score}
- &nbsp;<br />
- %endif
- %else:
- ${submitlink(thing.url, thing.title, unsafe('<div class="arrow upmod"></div>'))}
- ${submitlink(thing.url, thing.title, '?')}
- ${submitlink(thing.url, thing.title, unsafe('<div class="arrow downmod"></div>'))}
- %endif
- </div>
- <div class="right">
- ${img_link('submit', '/static/blog_snoo.gif', capture(submiturl, thing.url, thing.title), target=thing.target)}
- </div>
- <div class="clear"></div>
-</%self:class_def>
-</%def>
-
-<%def name="button4(thing)">
-<%self:class_def class_number="2">
- %if thing._fullname:
- %if thing.vote:
- ${arrow(thing, 1, thing.likes)}
- ${score(thing, thing.likes, tag='div')}
- ${arrow(thing, 0, thing.likes == False)}
- %else:
- &nbsp;<br />
- ${thing.score}
- &nbsp;<br />
- %endif
- %else:
- <img src="http://www.reddit.com/static/blog_head.png" alt=""/>
- ${submitlink(thing.url, thing.title, 'submit to')}
- %endif
-</%self:class_def>
-</%def>
-
-<%def name="button5(thing)">
-<%self:class_def class_number="5"
- width="${choose_width(thing, thing.width)}">
- ${img_link('submit', '/static/blog_snoo.gif', capture(submiturl, thing.url, thing.title), _class="left")}
-<%
- # this button style submits to the cname as a default
- c.cname = hasattr(c.site, "domain") and bool(c.site.domain)
- submitlink = capture(submiturl, thing.url, thing.title)
- if thing._fullname:
- fullname = thing._fullname
- ups = thing.upvotes
- downs = thing.downvotes
- link = "http://%s%s" % (get_domain(cname = c.cname, subreddit = False),
- thing.make_permalink_slow())
- else:
- fullname = ""
- ups = 0
- downs = 0
- link = submitlink
- if c.user_is_loggedin and thing._fullname:
- dir = 1 if thing.likes else 0 if thing.likes is None else -1
- ups = ups - (1 if dir > 0 else 0)
- downs = downs - (1 if dir < 0 else 0)
- else:
- dir = 0
-
- other_votes = float(ups + downs)
- ups = [ups, ups, ups + 1]
- downs = [downs + 1, downs, downs]
- votes = [other_votes + 1, other_votes, other_votes + 1]
- up_pct = [int( 100 * ups[i] / votes[i]) if votes[i] else "--" for i in range(len(votes))]
- down_pct = [int( 100 * downs[i] / votes[i]) if votes[i] else "--" for i in range(len(votes))]
- def controversy_text(_up_pct):
- if isinstance(_up_pct, str):
- return ""
- p = abs(50 - _up_pct)
- msg = "<b class='controversy%d'>%s</b>"
- if p <= 5:
- return msg % (3, _("quite controversial"))
- elif p <= 15:
- return msg % (2, _("controversial"))
- elif p <= 25:
- return msg % (1, _("uncontroversial"))
- else:
- return msg % (0, _("quite uncontroversial"))
- controversy = map(controversy_text, up_pct)
- %>
- <script type="text/javascript">
- function set_score(id, dir) {
- id = $(id).filter(":first").thing_id();
- for(var i = 0; i < 3; i++) {
- var fn = (i == dir + 1) ? 'show': 'hide';
- $("#down" + i + "_" + id)[fn]();
- $("#up" + i + "_" + id)[fn]();
- $("#controversy" + i + "_" + id)[fn]();
- }
- }
- </script>
- <div class="container">
- <ul>
- <li class="selected">
- ${_("Vote on this article")}
- </li>
- <li>
- <a href="${link}" target="_new">
- %if thing._fullname:
- ${_("Discuss at the %(name)s reddit") % dict(name = c.site.name)}
- %else:
- ${_("Submit to the %(name)s reddit") % dict(name = c.site.name)}
- %endif
- </a>
- </li>
- </ul>
- <div class="votes ${'' if thing._fullname else 'disabled'}">
- %for i in range(3):
- <div class="right" id="controversy${i}_${fullname}"
- ${"" if i == dir + 1 else "style='display:none'"}>
- ${unsafe(controversy[i])}
- </div>
- %endfor
- <a class="arrow up${'mod' if dir==1 else ''}"
- id="up_${fullname}"
- %if c.user_is_loggedin and thing._fullname:
- href="#" onclick="$(this).vote('', set_score, event); return false;"
- %else:
- href="${submitlink}" target="_new"
- %endif
- >
- %for i in range(3):
- <span id="up${i}_${fullname}"
- ${"" if i == dir + 1 else "style='display:none'"}
- ><b>${up_pct[i]}%</b>&#32;liked it (${ups[i]})</span>
- %endfor
- </a>
- <a class="arrow down${'mod' if dir==-1 else ''}" id="down_${fullname}"
- %if c.user_is_loggedin and thing._fullname:
- href="#" onclick="$(this).vote('', set_score, event); return false;"
- %else:
- href="${submitlink}" target="_new"
- %endif
- >
- %for i in range(3):
- <span id="down${i}_${fullname}"
- ${"" if i == dir + 1 else "style='display:none'"}
- ><b>${down_pct[i]}%</b>&#32;disliked it (${downs[i]})</span>
- %endfor
- </a>
- </div>
- <div class="clearleft"><!--IEsux--></div>
- </div>
- </%self:class_def>
-</%def>
View
150 r2/r2/templates/upgradebuttons.html
@@ -1,150 +0,0 @@
-## 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 reddit Inc.
-##
-## All portions of the code written by reddit are Copyright (c) 2006-2012
-## reddit Inc. All Rights Reserved.
-###############################################################################
-
-<%!
- from r2.lib.template_helpers import get_domain
- %>
-
-<% domain = get_domain(False) %>
-
-<div class="instructions">
- <h1>You need to upgrade your buttons</h1>
- <p>
- You were redirected here because the site you came from has out of date buttons and were linking directly to our iframe contents rather than our JS (tsk tsk). If you are the site administrator, use the code snippets below to fix it.
- </p>
-
- <h2>${_('simple interactive button')}</h2>
- <p>${_('put this code on your page:')}</p>
- <code>
- ${capture(draw_interactive,False)}
- </code>
- <p>${_("and you'll get something like this:")}</p>
- <span style="margin-left: 10px;">
- ${draw_interactive(False)}
- </span>
-
- <h2>${_("more interactive buttons")}</h2>
- <ul class="buttons">
- %for x in xrange(1,4):
- ${demo(capture(draw_interactive, x))}
- %endfor
- </ul>
-
- <h2>${_('interactive button advanced settings')}</h2>
- <div class="box buttonsettings">
- <ul>
- <li>
- <p><strong>${_("specify a url")}</strong><br />
- ${_("useful in places like blogs, where you want to link to the post's permalink")}</p>
- <code>${drawoption('url','[URL]')}</code>
- </li>
- <li>
- <p><strong>${_("specify a community to target")}</strong></p>
- <code>${drawoption('target','[COMMUNITY]')}</code>
- </li>
- <li>
- <p><strong>${_("specify a title")}</strong></p>
- <code>${drawoption('title','[TITLE]')}</code>
- </li>
- <li>
- <p><strong>${_("open links in a new window")}</strong></p>
- <code>${drawoption('newwindow','1')}</code>
- </li>
- <li>
- <p><strong>${_("specify the color")}</strong></p>
- <code>${drawoption('bgcolor','[COLOR]')}</code>
- </li>
- <li>
- <p><strong>${_("specify a border color")}</strong></p>
- <code>${drawoption('bordercolor','[COLOR]')}</code>
- </li>
- </ul>
- <p style="font-weight: bold">${_('Example:')}</p>
- <p>${_('to make this button:')}</p>
- <span style="margin-left: 10px;">${draw_interactive_example()}</span>
- <p>${_('use this code:')}</p>
- <code>
- <%
- ex = websafe(capture(draw_interactive_example))
- ex = ex.replace("\n", "<br/>").replace(" ", "&nbsp;")
- %>
- ${unsafe(ex)}
- </code>
- </div>
-
-</div>
-
-<script type="text/javascript">
-$(function() {
- $(".view-code").click(function(evt) {
- $(this).parent().addClass("show-demo");
- });
- $(".hide-code").click(function(evt) {
- $(this).parent().removeClass("show-demo");
- });
-});
-</script>
-
-<%def name="demo(content)">
-<li class="button-demo">
- <a class="view-code" href="javascript:void(0)">${_("view code")}</a>
- <a class="hide-code" href="javascript:void(0)">${_("hide code")}</a>
- ${unsafe(content)}
- <br />
- <code>
- ${content}
- </code>
-</li>
-</%def>
-
-<%def name="draw_point_button(image)">
- <script type="text/javascript"
- src="http://${domain}/buttonlite.js?i=${image}"></script>
-</%def>
-
-<%def name="point_option_example()" buffered="True">
- <script type="text/javascript"
- src="http://${domain}/buttonlite.js?i=1&styled=off&url=foo.com&newwindow=1"></script>
-</%def>
-
-<%def name="draw_interactive(type)">
-%if type:
- <script type="text/javascript"
- src="http://${domain}/static/button/button${type}.js"></script>
-%else:
- <script type="text/javascript" src="http://${domain}/static/button/button1.js"></script>
-%endif
-</%def>
-
-<%def name="drawoption(option, val)" buffered="True">
- <script type="text/javascript">reddit_${option}='${val}'</script>
-</%def>
-
-<%def name="draw_interactive_example()"><script type="text/javascript">
- reddit_url = "http://${domain}/buttons";
- reddit_title = "Buttons!";
- reddit_bgcolor = "FF3";
- reddit_bordercolor = "00F";
-</script>
-<script type="text/javascript" src="http://${domain}/static/button/button3.js"></script>
-</%def>
-
Please sign in to comment.
Something went wrong with that request. Please try again.