diff --git a/r2/r2/lib/pages/things.py b/r2/r2/lib/pages/things.py new file mode 100644 index 000000000..38675e79e --- /dev/null +++ b/r2/r2/lib/pages/things.py @@ -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() + + diff --git a/r2/r2/public/static/css/mobile.css b/r2/r2/public/static/css/mobile.css new file mode 100644 index 000000000..80cabe465 --- /dev/null +++ b/r2/r2/public/static/css/mobile.css @@ -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; } diff --git a/r2/r2/templates/printablebuttons.html b/r2/r2/templates/printablebuttons.html new file mode 100644 index 000000000..5f381ad56 --- /dev/null +++ b/r2/r2/templates/printablebuttons.html @@ -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: +