mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 23:39:11 -05:00
mising new files on caching branch checkin
This commit is contained in:
142
r2/r2/lib/pages/things.py
Normal file
142
r2/r2/lib/pages/things.py
Normal file
@@ -0,0 +1,142 @@
|
||||
## 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-2009
|
||||
## CondeNet, Inc. All Rights Reserved.
|
||||
################################################################################
|
||||
from r2.lib.menus import Styled
|
||||
from r2.lib.wrapped import Wrapped
|
||||
from r2.models import LinkListing, make_wrapper, Link, IDBuilder, PromotedLink, Thing
|
||||
from r2.lib.utils import tup
|
||||
from r2.lib.strings import Score
|
||||
from pylons import c
|
||||
|
||||
class PrintableButtons(Styled):
|
||||
def __init__(self, style, thing, show_ban = True,
|
||||
show_delete = False, show_report = True, **kw):
|
||||
show_report = show_report and c.user_is_loggedin
|
||||
Styled.__init__(self, style = style,
|
||||
fullnaem = thing._fullname,
|
||||
can_ban = thing.can_ban,
|
||||
show_spam = thing.show_spam,
|
||||
show_reports = thing.show_reports,
|
||||
show_ban = show_ban,
|
||||
show_delete = show_delete,
|
||||
show_report = show_report, **kw)
|
||||
|
||||
class BanButtons(PrintableButtons):
|
||||
def __init__(self, thing, show_ban = True,
|
||||
show_delete = False, show_report = True):
|
||||
PrintableButtons.__init__(self, "banbuttons", thing)
|
||||
|
||||
class LinkButtons(PrintableButtons):
|
||||
def __init__(self, thing, comments = True, delete = True, report = True,
|
||||
ban = True):
|
||||
# is the current user the author?
|
||||
is_author = (c.user_is_loggedin and thing.author and
|
||||
c.user.name == thing.author.name)
|
||||
# do we show the report button?
|
||||
show_report = not is_author and report
|
||||
# do we show the delete button?
|
||||
show_delete = is_author and delete and not thing._deleted
|
||||
|
||||
PrintableButtons.__init__(self, 'linkbuttons', thing,
|
||||
# user existence and preferences
|
||||
is_loggedin = c.user_is_loggedin,
|
||||
new_window = c.user.pref_newwindow,
|
||||
# comment link params
|
||||
comment_label = thing.comment_label,
|
||||
commentcls = thing.commentcls,
|
||||
permalink = thing.permalink,
|
||||
# button visibility
|
||||
saved = thing.saved,
|
||||
editable = thing.editable,
|
||||
hidden = thing.hidden,
|
||||
show_delete = show_delete,
|
||||
show_report = show_report,
|
||||
show_ban = ban,
|
||||
show_comments = comments)
|
||||
|
||||
class CommentButtons(PrintableButtons):
|
||||
def __init__(self, thing, delete = True, report = True):
|
||||
# is the current user the author?
|
||||
is_author = (c.user_is_loggedin and thing.author and
|
||||
c.user.name == thing.author.name)
|
||||
# do we show the report button?
|
||||
show_report = not is_author and report
|
||||
# do we show the delete button?
|
||||
show_delete = is_author and delete and not thing._deleted
|
||||
|
||||
PrintableButtons.__init__(self, "commentbuttons", thing,
|
||||
is_author = is_author,
|
||||
profilepage = c.profilepage,
|
||||
permalink = thing.permalink,
|
||||
deleted = thing.deleted,
|
||||
parent_permalink = thing.parent_permalink,
|
||||
can_reply = thing.can_reply,
|
||||
show_report = show_report,
|
||||
show_delete = show_delete,
|
||||
show_ban = True)
|
||||
|
||||
class MessageButtons(PrintableButtons):
|
||||
def __init__(self, thing, delete = False, report = True):
|
||||
was_comment = getattr(thing, 'was_comment', False)
|
||||
permalink = thing.permalink if was_comment else ""
|
||||
|
||||
PrintableButtons.__init__(self, "messagebuttons", thing,
|
||||
profilepage = c.profilepage,
|
||||
permalink = permalink,
|
||||
was_comment = was_comment,
|
||||
can_reply = c.user_is_loggedin,
|
||||
show_report = True,
|
||||
show_delete = False,
|
||||
show_ban = True)
|
||||
|
||||
# formerly ListingController.builder_wrapper
|
||||
def default_thing_wrapper(**params):
|
||||
style = params.get('style', c.render_style)
|
||||
def _default_thing_wrapper(thing):
|
||||
w = Wrapped(thing)
|
||||
if isinstance(thing, Link):
|
||||
if thing.promoted:
|
||||
w.render_class = PromotedLink
|
||||
w.rowstyle = 'promoted link'
|
||||
elif style == 'htmllite':
|
||||
w.score_fmt = Score.points
|
||||
|
||||
return w
|
||||
params['parent_wrapper'] = _default_thing_wrapper
|
||||
return make_wrapper(**params)
|
||||
|
||||
# TODO: move this into lib somewhere?
|
||||
def wrap_links(links, wrapper = default_thing_wrapper(),
|
||||
listing_cls = LinkListing,
|
||||
num = None, show_nums = False, nextprev = False,
|
||||
num_margin = None, mid_margin = None):
|
||||
links = tup(links)
|
||||
if not all(isinstance(x, str) for x in links):
|
||||
links = [x._fullname for x in links]
|
||||
b = IDBuilder(links, num = num, wrap = wrapper)
|
||||
l = listing_cls(b, nextprev = nextprev, show_nums = show_nums)
|
||||
if num_margin is not None:
|
||||
l.num_margin = num_margin
|
||||
if mid_margin is not None:
|
||||
l.mid_margin = mid_margin
|
||||
return l.listing()
|
||||
|
||||
|
||||
135
r2/r2/public/static/css/mobile.css
Normal file
135
r2/r2/public/static/css/mobile.css
Normal file
@@ -0,0 +1,135 @@
|
||||
body {
|
||||
font-family: verdana,arial,helvetica,sans-serif;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: x-small;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #369;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
ul {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.link {
|
||||
margin-left: 2px;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: blue;
|
||||
font-size: small;
|
||||
margin-right: .5em;
|
||||
}
|
||||
|
||||
.byline {
|
||||
margin: 0px 0px .5em 2px;
|
||||
}
|
||||
|
||||
.description {
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
.domain {
|
||||
color: #369;
|
||||
}
|
||||
|
||||
.buttons {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.child {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
||||
.headerbar {
|
||||
background:lightgray none repeat scroll 0%;
|
||||
margin: 5px 0px 5px 2px;
|
||||
}
|
||||
|
||||
.headerbar span {
|
||||
background-color: white;
|
||||
color: gray;
|
||||
font-size: x-small;
|
||||
font-weight: bold;
|
||||
margin-left: 15px;
|
||||
padding: 0px 3px;
|
||||
}
|
||||
|
||||
.score {
|
||||
margin: 0px .5em 0px .5em;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: red;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
.nextprev {
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.tabmenu {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.tabmenu li {
|
||||
display: inline;
|
||||
margin-right: .25em;
|
||||
padding-left: .25em;
|
||||
border-left: thin solid #000;
|
||||
}
|
||||
|
||||
.redditname {
|
||||
font-weight: bold;
|
||||
margin: 0px 3px 0px 3px;
|
||||
}
|
||||
|
||||
.selected {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pagename {
|
||||
font-weight: bold;
|
||||
margin-right: 1ex;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.or {
|
||||
border-left:thin solid #000000;
|
||||
border-right:thin solid #000000;
|
||||
padding: 0px .25em 0px .25em;
|
||||
}
|
||||
|
||||
#header {
|
||||
background-color: #CEE3F8;
|
||||
}
|
||||
|
||||
#header .redditname a{
|
||||
color: black;
|
||||
}
|
||||
|
||||
#header img {
|
||||
margin-right: 3px;
|
||||
}
|
||||
|
||||
/* markdown */
|
||||
.md { max-width: 60em; overflow: auto; }
|
||||
.md p, .md h1 { margin-bottom: .5em;}
|
||||
.md h1 { font-weight: normal; font-size: 100%; }
|
||||
.md > * { margin-bottom: 0px }
|
||||
.md strong { font-weight: bold; }
|
||||
.md em { font-style: italic; }
|
||||
.md img { display: none }
|
||||
.md ol, .md ul { margin: 10px 2em; }
|
||||
.md pre { margin: 10px; }
|
||||
277
r2/r2/templates/printablebuttons.html
Normal file
277
r2/r2/templates/printablebuttons.html
Normal file
@@ -0,0 +1,277 @@
|
||||
## 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-2009
|
||||
## CondeNet, Inc. All Rights Reserved.
|
||||
################################################################################
|
||||
<%namespace file="utils.html" import="plain_link" />
|
||||
<%!
|
||||
from r2.lib.strings import strings
|
||||
%>
|
||||
|
||||
<%def name="banbuttons()">
|
||||
%if thing.show_report:
|
||||
<li>
|
||||
${ynbutton(_("report"), _("reported"), "report", "hide_thing")}
|
||||
</li>
|
||||
%endif
|
||||
%if thing.show_delete:
|
||||
<li>
|
||||
${ynbutton(_("delete"), _("deleted"), "del", "hide_thing")}
|
||||
</li>
|
||||
%endif
|
||||
%if thing.can_ban and thing.show_ban:
|
||||
%if thing.show_spam:
|
||||
<li>
|
||||
${self.state_button("unban", _("unban"),
|
||||
"return change_state(this, 'unban');", _("unbanned"))}
|
||||
</li>
|
||||
%else:
|
||||
<li>
|
||||
${self.state_button("ban", _("ban"),
|
||||
"return change_state(this, 'ban');", _("banned"))}
|
||||
</li>
|
||||
%endif
|
||||
%if thing.show_reports:
|
||||
<li>
|
||||
${self.state_button("ignore", _("ignore"), \
|
||||
"change_state(this, 'ignore');", _("ignored"))}
|
||||
</li>
|
||||
%endif
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="linkbuttons()">
|
||||
%if thing.show_comments:
|
||||
<li class="first">
|
||||
${self.comment_button("comment", thing.comment_label, thing.permalink,
|
||||
a_class = thing.commentcls,
|
||||
newwindow = thing.new_window)}
|
||||
</li>
|
||||
%endif
|
||||
%if thing.editable:
|
||||
<li>
|
||||
${self.simple_button(_("edit"), "edit_usertext")}
|
||||
</li>
|
||||
%endif
|
||||
<li class="share">
|
||||
${self.toggle_button("share-button", _("share"), _("cancel"),
|
||||
"share", "cancelShare", login_required = True)}
|
||||
</li>
|
||||
%if thing.is_loggedin:
|
||||
<li>
|
||||
%if thing.saved:
|
||||
${self.state_button("unsave", _("unsave"), \
|
||||
"return change_state(this, 'unsave', unsave_thing);", _("unsaved"))}
|
||||
%else:
|
||||
${self.state_button("save", _("save"), \
|
||||
"return change_state(this, 'save', save_thing);", _("saved"))}
|
||||
%endif
|
||||
</li><li>
|
||||
%if thing.hidden:
|
||||
${self.state_button("unhide", _("unhide"), \
|
||||
"change_state(this, 'unhide', hide_thing);", _("unhidden"))}
|
||||
%else:
|
||||
${self.state_button("hide", _("hide"), \
|
||||
"change_state(this, 'hide', hide_thing);", _("hidden"))}
|
||||
%endif
|
||||
</li>
|
||||
%endif
|
||||
${self.banbuttons()}
|
||||
</%def>
|
||||
|
||||
<%def name="commentbuttons()">
|
||||
<li class="first">
|
||||
${self.bylink_button(_("permalink"), thing.permalink)}
|
||||
</li>
|
||||
%if thing.deleted:
|
||||
%if thing.parent_permalink and not thing.profilepage:
|
||||
<li>
|
||||
${self.bylink_button(_("parent"), thing.parent_permalink)}
|
||||
</li>
|
||||
%endif
|
||||
%else:
|
||||
%if not thing.profilepage:
|
||||
%if thing.parent_permalink:
|
||||
<li>
|
||||
${self.bylink_button(_("parent"), thing.parent_permalink)}
|
||||
</li>
|
||||
%endif
|
||||
%if thing.is_author:
|
||||
<li>
|
||||
${self.simple_button(_("edit"), "edit_usertext")}
|
||||
</li>
|
||||
%endif
|
||||
%endif
|
||||
${self.banbuttons()}
|
||||
%if not thing.profilepage and thing.can_reply:
|
||||
<li>
|
||||
${self.simple_button(_("reply"), "reply")}
|
||||
</li>
|
||||
%endif
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
|
||||
<%def name="messagebuttons()">
|
||||
%if thing.was_comment:
|
||||
<li>
|
||||
${self.bylink_button(_("context"), thing.permalink + "?context=3")}
|
||||
</li>
|
||||
%endif
|
||||
${self.banbuttons()}
|
||||
%if not thing.was_comment and thing.can_reply:
|
||||
<li>
|
||||
${self.simple_button(_("reply {verb}"), "reply")}
|
||||
</li>
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
##------------
|
||||
<%def name="state_button(name, title, onclick, executed, clicked=False, a_class = '', fmt=None, fmt_param = '', hidden_data = {})">
|
||||
|
||||
<%def name="_link()" buffered="True">
|
||||
<a href="javascript:void()"
|
||||
%if a_class:
|
||||
class="${a_class}"
|
||||
%endif
|
||||
onclick="${onclick}">${title}</a>
|
||||
</%def>
|
||||
<%
|
||||
link = _link()
|
||||
if fmt:
|
||||
link = fmt % {fmt_param: link}
|
||||
## preserve spaces before and after < & > for space compression
|
||||
link = link.replace(" <", " <").replace("> ", "> ")
|
||||
%>
|
||||
|
||||
%if clicked:
|
||||
${executed}
|
||||
%else:
|
||||
<form action="/post/${name}" method="post"
|
||||
class="state-button ${name}-button">
|
||||
<input type="hidden" name="executed" value="${executed}" />
|
||||
%for key, value in hidden_data.iteritems():
|
||||
<input type="hidden" name="${key}" value="${value}" />
|
||||
%endfor
|
||||
<span>
|
||||
${unsafe(link)}
|
||||
</span>
|
||||
</form>
|
||||
%endif
|
||||
</%def>
|
||||
|
||||
|
||||
<%def name="ynbutton(title, executed, op, callback = 'null',
|
||||
question = None,
|
||||
format = '%(link)s',
|
||||
format_arg = 'link',
|
||||
hidden_data = {})">
|
||||
<%
|
||||
if question is None:
|
||||
question = _("are you sure?")
|
||||
link = ('<a href="#" onclick="return toggle(this)">'
|
||||
+ title + '</a>')
|
||||
link = format % {format_arg : link}
|
||||
link = unsafe(link.replace(" <", " <").replace("> ", "> "))
|
||||
%>
|
||||
<form class="toggle ${op}-button" action="#" method="get">
|
||||
<input type="hidden" name="executed" value="${executed}"/>
|
||||
%for k, v in hidden_data.iteritems():
|
||||
<input type="hidden" name="${k}" value="${v}"/>
|
||||
%endfor
|
||||
<span class="option active">
|
||||
${link}
|
||||
</span>
|
||||
<span class="option error">
|
||||
${question}
|
||||
 <a href="javascript:void(0)" class="yes"
|
||||
onclick='change_state(this, "${op}", ${callback})'>
|
||||
${_("yes")}
|
||||
</a> / 
|
||||
<a href="javascript:void(0)" class="no"
|
||||
onclick="return toggle(this)">${_("no")}</a>
|
||||
</span>
|
||||
</form>
|
||||
</%def>
|
||||
|
||||
<%def name="simple_button(title, nameFunc)">
|
||||
<a class="" href="javascript:void(0)"
|
||||
onclick="return ${nameFunc}(this)">${title}</a>
|
||||
</%def>
|
||||
|
||||
<%def name="toggle_button(class_name, title, alt_title,
|
||||
callback, cancelback,
|
||||
css_class = '', alt_css_class = '',
|
||||
reverse = False,
|
||||
login_required = False,
|
||||
style = '', )">
|
||||
<%
|
||||
if reverse:
|
||||
callback, cancelback = cancelback, callback
|
||||
title, alt_title = alt_title, title
|
||||
css_class, alt_css_class = alt_css_class, css_class
|
||||
%>
|
||||
<span class="${class_name} toggle" style="${style}">
|
||||
<a class="option active ${css_class}" href="#"
|
||||
%if login_required and not c.user_is_loggedin:
|
||||
onclick="return showcover('', '${callback}_' + $(this).thing_id());"
|
||||
%else:
|
||||
onclick="return toggle(this, ${callback}, ${cancelback})"
|
||||
%endif
|
||||
>
|
||||
${title}
|
||||
</a>
|
||||
<a class="option ${alt_css_class}" href="#">${alt_title}</a>
|
||||
</span>
|
||||
</%def>
|
||||
|
||||
### originally in commentbutton
|
||||
<%def name="comment_button(name, link_text, link,\
|
||||
a_class='', title='', newwindow = False)">
|
||||
${plain_link(link_text, link,
|
||||
_class=a_class, title=title,
|
||||
target='_blank' if newwindow else '_parent')}
|
||||
</%def>
|
||||
|
||||
<%def name="bylink_button(title, link)">
|
||||
${plain_link(title, link, _class="bylink", rel="nofollow")}
|
||||
</%def>
|
||||
|
||||
<%def name="toggleable_label(class_name,
|
||||
title, alt_title,
|
||||
callback, cancelback,
|
||||
reverse = False)">
|
||||
<%
|
||||
if reverse:
|
||||
callback, cancelback = cancelback, callback
|
||||
title, alt_title = alt_title, title
|
||||
%>
|
||||
<span class="${class_name} toggle">
|
||||
<span class="toggle option active">${title}</span>
|
||||
<span class="toggle option">${alt_title}</span>
|
||||
 (
|
||||
<a href="#"
|
||||
onclick="return toggle_label(this, ${callback}, ${cancelback})"
|
||||
>
|
||||
${_("toggle")}
|
||||
</a>
|
||||
)
|
||||
</span>
|
||||
</%def>
|
||||
|
||||
0
r2/r2/templates/usertext.htmllite
Normal file
0
r2/r2/templates/usertext.htmllite
Normal file
0
r2/r2/templates/usertext.xml
Normal file
0
r2/r2/templates/usertext.xml
Normal file
Reference in New Issue
Block a user