mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-27 07:48:16 -05:00
toolbar 2.1
This commit is contained in:
@@ -133,6 +133,7 @@ RATELIMIT = 10
|
||||
num_comments = 200
|
||||
max_comments = 500
|
||||
num_default_reddits = 10
|
||||
num_serendipity = 100
|
||||
|
||||
smtp_server = localhost
|
||||
new_link_share_delay = 5 minutes
|
||||
|
||||
@@ -79,15 +79,19 @@ class FrontController(RedditController):
|
||||
sort = 'new' if rand.choice((True,False)) else 'hot'
|
||||
links = c.site.get_links(sort, 'all')
|
||||
if isinstance(links, thing.Query):
|
||||
links._limit = 25
|
||||
links._limit = g.num_serendipity
|
||||
links = [x._fullname for x in links]
|
||||
else:
|
||||
links = list(links)[:25]
|
||||
links = list(links)[:g.num_serendipity]
|
||||
|
||||
builder = IDBuilder(links, skip = True,
|
||||
keep_fn = lambda x: x.fresh,
|
||||
num = g.num_serendipity)
|
||||
links = builder.get_items()[0]
|
||||
|
||||
if links:
|
||||
name = rand.choice(links)
|
||||
link = Link._by_fullname(name, data = True)
|
||||
return self.redirect(add_sr("/tb/" + link._id36))
|
||||
l = rand.choice(links)
|
||||
return self.redirect(add_sr("/tb/" + l._id36))
|
||||
else:
|
||||
return self.redirect(add_sr('/'))
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ from reddit_base import RedditController
|
||||
from r2.lib.pages import *
|
||||
from r2.models import *
|
||||
from r2.lib.menus import CommentSortMenu
|
||||
from r2.lib.filters import spaceCompress
|
||||
from r2.lib.filters import spaceCompress, safemarkdown
|
||||
from r2.lib.memoize import memoize
|
||||
from r2.lib.template_helpers import add_sr
|
||||
from r2.lib import utils
|
||||
@@ -177,15 +177,20 @@ class ToolbarController(RedditController):
|
||||
title = link.title,
|
||||
url = link.url)
|
||||
|
||||
|
||||
b = TopCommentBuilder(link, CommentSortMenu.operator('top'),
|
||||
wrap = builder_wrapper)
|
||||
|
||||
listing = NestedListing(b, num = 10, # TODO: add config var
|
||||
parent_name = link._fullname)
|
||||
|
||||
raw_bar = strings.comments_panel_text % dict(
|
||||
fd_link=link.permalink)
|
||||
|
||||
md_bar = safemarkdown(raw_bar, target="_top")
|
||||
|
||||
res = RedditMin(content=CommentsPanel(link=link, listing=listing.listing(),
|
||||
expanded = auto_expand_panel(link)))
|
||||
expanded=auto_expand_panel(link),
|
||||
infobar=md_bar))
|
||||
|
||||
return res.render()
|
||||
|
||||
@@ -198,9 +203,13 @@ class ToolbarController(RedditController):
|
||||
|
||||
if link:
|
||||
link_builder = IDBuilder((link._fullname,))
|
||||
|
||||
res = FrameToolbar(link = link_builder.get_items()[0][0],
|
||||
title = link.title,
|
||||
url = link.url,
|
||||
domain = None
|
||||
if link.is_self
|
||||
else domain(link.url),
|
||||
expanded = auto_expand_panel(link))
|
||||
else:
|
||||
res = FrameToolbar(link = None,
|
||||
|
||||
@@ -47,6 +47,7 @@ class Globals(object):
|
||||
'num_default_reddits',
|
||||
'num_query_queue_workers',
|
||||
'max_sr_images',
|
||||
'num_serendipity',
|
||||
]
|
||||
|
||||
bool_props = ['debug', 'translator',
|
||||
|
||||
@@ -38,12 +38,7 @@ organic_length = 30
|
||||
promoted_every_n = 5
|
||||
|
||||
def keep_link(link):
|
||||
return not any((link.likes != None,
|
||||
link.saved,
|
||||
link.clicked,
|
||||
link.hidden,
|
||||
link._deleted,
|
||||
link._spam))
|
||||
return link.fresh
|
||||
|
||||
def insert_promoted(link_names, sr_ids, logged_in):
|
||||
"""
|
||||
|
||||
@@ -947,8 +947,11 @@ class FrameToolbar(Wrapped):
|
||||
self.com_label = _("comment {verb}")
|
||||
else:
|
||||
# generates "XX comments" as a noun
|
||||
com_label = ungettext("comment", "comments", link.num_comments)
|
||||
self.com_label = strings.number_label % (link.num_comments, com_label)
|
||||
com_label = ungettext("comment", "comments",
|
||||
link.num_comments)
|
||||
self.com_label = strings.number_label % (
|
||||
link.num_comments, com_label)
|
||||
|
||||
|
||||
# generates "XX points" as a noun
|
||||
self.score_label = Score.safepoints(score)
|
||||
|
||||
@@ -109,6 +109,10 @@ string_dict = dict(
|
||||
permalink_title = _("%(author)s comments on %(title)s"),
|
||||
link_info_title = _("%(title)s : %(site)s"),
|
||||
banned_subreddit = _("""**this reddit has been banned**\n\nmost likely this was done automatically by our spam filtering program. the program is still learning, and may even have some bugs, so if you feel the ban was a mistake, please send a message to [feedback](%(link)s) and be sure to include the exact name of the reddit."""),
|
||||
comments_panel_text = _("""
|
||||
The following is a sample of what Reddit users had to say about this
|
||||
page. The full discussion is available [here](%(fd_link)s).
|
||||
"""),
|
||||
)
|
||||
|
||||
class StringHandler(object):
|
||||
|
||||
@@ -292,4 +292,4 @@ def choose_width(link, width):
|
||||
|
||||
def panel_size(state):
|
||||
"the frame.cols of the reddit-toolbar's inner frame"
|
||||
return '100%, 400px' if state =='expanded' else '100%x, 0px'
|
||||
return '400px, 100%' if state =='expanded' else '0px, 100%x'
|
||||
|
||||
@@ -340,6 +340,13 @@ class Link(Thing, Printable):
|
||||
elif c.user.pref_frame:
|
||||
item.click_url = item.tblink
|
||||
|
||||
item.fresh = not any((item.likes != None,
|
||||
item.saved,
|
||||
item.clicked,
|
||||
item.hidden,
|
||||
item._deleted,
|
||||
item._spam))
|
||||
|
||||
if c.user_is_loggedin:
|
||||
incr_counts(wrapped)
|
||||
|
||||
|
||||
@@ -718,7 +718,7 @@ a.star { text-decoration: none; color: #ff8b60 }
|
||||
|
||||
/* compressed links */
|
||||
.linkcompressed { margin: 4px 0; overflow: hidden; margin-top: 7px; }
|
||||
.linkcompressed .title {margin-bottom: 2px; font-size:medium; font-weight: normal;}
|
||||
.linkcompressed .title {margin-bottom: 3px; font-size:medium; font-weight: normal;}
|
||||
.linkcompressed .child h3 {
|
||||
margin: 15px;
|
||||
text-transform: none;
|
||||
@@ -728,7 +728,7 @@ a.star { text-decoration: none; color: #ff8b60 }
|
||||
.linkcompressed .score.likes { color: #FF8B60; }
|
||||
.linkcompressed .score.dislikes { color: #9494FF; }
|
||||
.linkcompressed .rank {
|
||||
margin-top: 7px;
|
||||
margin-top: 8px;
|
||||
float:left;
|
||||
color: #c6c6c6;
|
||||
font-family: arial;
|
||||
@@ -736,7 +736,7 @@ a.star { text-decoration: none; color: #ff8b60 }
|
||||
text-align: right;
|
||||
}
|
||||
.linkcompressed .arrow.down, .linkcompressed .arrow.downmod {
|
||||
margin-top: 2px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.linkcompressed .tagline { display: inline; margin-top: 0px; margin-bottom: 1px; }
|
||||
@@ -747,7 +747,7 @@ a.star { text-decoration: none; color: #ff8b60 }
|
||||
.linkcompressed .entry .buttons li.first {padding-left: .5em;}
|
||||
.linkcompressed .entry .buttons li a {
|
||||
padding: 0 2px;
|
||||
background-color: #f8f8f8;
|
||||
background-color: #f9f9f9;
|
||||
font-weight: bold
|
||||
}
|
||||
|
||||
@@ -925,20 +925,6 @@ textarea.gray { color: gray; }
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.starkcomment + .clearleft + .starkcomment {
|
||||
margin-top: 10px
|
||||
}
|
||||
.starkcomment .commentbox {
|
||||
color: black;
|
||||
background-color: #f0f0f0;
|
||||
padding: 5px;
|
||||
margin-left: 10px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.starkcomment .tagline {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.fixedwidth { float: left; width: 100px; height: 0px; }
|
||||
.clearleft { clear: left; height: 0px; }
|
||||
.clear { clear: both; }
|
||||
@@ -1481,12 +1467,13 @@ textarea.gray { color: gray; }
|
||||
height: 19px;
|
||||
float: left;
|
||||
border-right: solid #336699 1px;
|
||||
background-image: url(/static/button-normal.png);
|
||||
background-color: #EFF7FF;
|
||||
}
|
||||
|
||||
.toolbar .middle-side {
|
||||
text-align: center;
|
||||
background-image: url(/static/button-normal.png);
|
||||
background-color: #EFF7FF;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.toolbar .middle-side a, .toolbar .middle-side b {
|
||||
@@ -1501,13 +1488,20 @@ textarea.gray { color: gray; }
|
||||
height: 18px;
|
||||
border: none;
|
||||
border-top: solid transparent 1px;
|
||||
margin-left: 2px;
|
||||
}
|
||||
.toolbar .middle-side .url {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.toolbar .middle-side .domain {
|
||||
color: #888;
|
||||
font-size: small;
|
||||
}
|
||||
|
||||
.toolbar .right-side {
|
||||
float: right;
|
||||
background-image: url(/static/button-normal.png);
|
||||
background-color: #EFF7FF;
|
||||
}
|
||||
|
||||
.toolbar a, .toolbar b {
|
||||
@@ -1529,7 +1523,7 @@ textarea.gray { color: gray; }
|
||||
}
|
||||
|
||||
.toolbar .clickable:active, .pushed-button {
|
||||
background-image: url(/static/button-pressed.png) !important;
|
||||
background-color: #cee3f8 !important;
|
||||
color: orangered !important;
|
||||
}
|
||||
|
||||
@@ -1549,13 +1543,14 @@ textarea.gray { color: gray; }
|
||||
vertical-align: top;
|
||||
}
|
||||
.toolbar .title {
|
||||
padding-left: 20px;
|
||||
padding-left: 1em;
|
||||
padding-right: 1em;
|
||||
color: black;
|
||||
font-style: italic;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
}
|
||||
.toolbar .title:hover {
|
||||
text-decoration: underline;
|
||||
.toolbar .title:active {
|
||||
color: orangered;
|
||||
}
|
||||
.toolbar .controls {
|
||||
float: right;
|
||||
@@ -1595,17 +1590,19 @@ textarea.gray { color: gray; }
|
||||
padding-right: 3px;
|
||||
}
|
||||
.tb-comments-panel-toggle {
|
||||
display: block;
|
||||
font-size: larger;
|
||||
margin: 15px 13px;
|
||||
}
|
||||
.comments-panel .infobar {
|
||||
padding: 3px 10px 7px;
|
||||
margin: 5px 10px 10px 3px;
|
||||
}
|
||||
|
||||
.min-body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.min-body .content {
|
||||
margin-top: 0px;
|
||||
border-left: solid #369 1px;
|
||||
border-right: solid #369 1px;
|
||||
min-height: 100%;
|
||||
max-width: 60em;
|
||||
overflow: auto;
|
||||
@@ -1620,6 +1617,20 @@ textarea.gray { color: gray; }
|
||||
margin: 0 0 0 13px;
|
||||
}
|
||||
|
||||
.starkcomment + .clearleft + .starkcomment {
|
||||
margin-top: 10px
|
||||
}
|
||||
.starkcomment .commentbox {
|
||||
color: black;
|
||||
background-color: #f0f0f0;
|
||||
padding: 5px;
|
||||
margin-left: 0px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.starkcomment .tagline {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* default form styles */
|
||||
.pretty-form {
|
||||
font-size: larger;
|
||||
|
||||
@@ -147,6 +147,14 @@ function hide_thing(elem) {
|
||||
thing.addClass("hidden");
|
||||
};
|
||||
|
||||
function toggle_label (elem, callback, cancelback) {
|
||||
$(elem).parent().find(".option").toggle();
|
||||
$(elem).onclick = function() {
|
||||
return(toggle_label(elem, cancelback, callback));
|
||||
}
|
||||
if (callback) callback(elem);
|
||||
}
|
||||
|
||||
function toggle(elem, callback, cancelback) {
|
||||
var self = $(elem).parent().andSelf().filter(".option");
|
||||
var sibling = self.removeClass("active")
|
||||
@@ -659,11 +667,12 @@ var toolbar_p = function(expanded_size, collapsed_size) {
|
||||
/* namespace for functions related to the reddit toolbar frame */
|
||||
|
||||
this.toggle_linktitle = function(s) {
|
||||
$('.title, .submit, .url').toggle();
|
||||
$('.title, .submit, .url, .linkicon').toggle();
|
||||
if($(s).is('.pushed-button')) {
|
||||
$(s).parents('.middle-side').removeClass('clickable');
|
||||
} else {
|
||||
$(s).parents('.middle-side').addClass('clickable');
|
||||
$('.url').children('form').children('input').focus().select();
|
||||
}
|
||||
return this.toggle_pushed(s);
|
||||
};
|
||||
|
||||
BIN
r2/r2/public/static/link-active.png
Normal file
BIN
r2/r2/public/static/link-active.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 245 B |
@@ -20,27 +20,28 @@
|
||||
## CondeNet, Inc. All Rights Reserved.
|
||||
################################################################################
|
||||
|
||||
<%namespace file="printable.html" import="toggle_button"/>
|
||||
<%namespace file="printable.html" import="toggleable_label"/>
|
||||
|
||||
<div class="comments-panel">
|
||||
|
||||
<script type="text/javascript">
|
||||
toolbar = new toolbar_p();
|
||||
</script>
|
||||
|
||||
<h1>
|
||||
${_('top comments')}
|
||||
</h1>
|
||||
<h2>
|
||||
<a target="_top" href="${thing.link.permalink}">
|
||||
${_("full discussion")}
|
||||
</a>
|
||||
</h2>
|
||||
<% from r2.lib.strings import strings %>
|
||||
|
||||
<div class="infobar">
|
||||
${unsafe(thing.infobar)}
|
||||
|
||||
${toggleable_label("tb-comments-panel-toggle",
|
||||
_("This panel will appear when " +
|
||||
"there are comments."),
|
||||
_("This panel will be hidden by default."),
|
||||
"toolbar.pref_commentspanel_hide",
|
||||
"toolbar.pref_commentspanel_show",
|
||||
reverse = not c.user.pref_frame_commentspanel)}
|
||||
</div>
|
||||
|
||||
${thing.listing.render()}
|
||||
|
||||
${toggle_button("tb-comments-panel-toggle",
|
||||
_("hide this panel by default"),
|
||||
_("show this panel " +
|
||||
"when there are comments"),
|
||||
"toolbar.pref_commentspanel_hide",
|
||||
"toolbar.pref_commentspanel_show",
|
||||
reverse = not c.user.pref_frame_commentspanel)}
|
||||
</div>
|
||||
|
||||
@@ -51,9 +51,13 @@
|
||||
</div>
|
||||
|
||||
<div class="right-side">
|
||||
<a href="#" onclick="return toolbar.toggle_linktitle(this);">
|
||||
<img src="${static('link.png')}" height="13" width="16"
|
||||
<a href="${thing.url}" onclick="return toolbar.toggle_linktitle(this);">
|
||||
<img class="linkicon" src="${static('link.png')}"
|
||||
height="13" width="16"
|
||||
title="${_('show url')}" alt="${_('show url')}"/>
|
||||
<img class="linkicon" src="${static('link-active.png')}"
|
||||
style="display: none" height="13" width="16"
|
||||
title="${_('hide url')}" alt="${_('hide url')}"/>
|
||||
</a>
|
||||
|
||||
<a class="serendipity popped-button"
|
||||
@@ -80,15 +84,23 @@
|
||||
</a>
|
||||
%endif
|
||||
|
||||
%if c.have_messages:
|
||||
<a target="_top" href="/message/inbox/">
|
||||
<img src="${static('mail.png')}"
|
||||
width="15" height="10"
|
||||
alt="${_('help')}" title="${_('help')}" />
|
||||
</a>
|
||||
%endif
|
||||
|
||||
<a target="_top" href="/help/toolbar">
|
||||
<img src="${static('help.png')}"
|
||||
height="11" width="11"
|
||||
width="11" height="11"
|
||||
alt="${_('help')}" title="${_('help')}" />
|
||||
</a>
|
||||
|
||||
<a href="${thing.url}" target="_top">
|
||||
<img src="${static('kill.png')}"
|
||||
height="11" width="11"
|
||||
width="11" height="11"
|
||||
alt="${_('visit this link without the toolbar')}"
|
||||
title="${_('visit this link without the toolbar')}" />
|
||||
</a>
|
||||
@@ -100,8 +112,13 @@
|
||||
title="${_('click to visit the main page for this submission')}"
|
||||
class="title clickable"
|
||||
target="_top"
|
||||
href="${thing.link.make_permalink_slow()}">
|
||||
${thing.link.title}
|
||||
href="${thing.link.make_permalink_slow()}"
|
||||
>
|
||||
${thing.link.title}
|
||||
|
||||
%if thing.domain:
|
||||
<span class="domain"> (${thing.domain})</span>
|
||||
%endif
|
||||
</a>
|
||||
%else:
|
||||
${plain_link(_('click to submit this link to reddit'), thing.submit_url,
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
from r2.lib.template_helpers import add_sr, panel_size
|
||||
%>
|
||||
<html>
|
||||
<frameset cols="${panel_size('expanded' if thing.expanded else 'collapsed')}" name="inner_toolbar">
|
||||
<frameset cols="${panel_size('expanded' if thing.expanded else 'collapsed')}"
|
||||
name="inner_toolbar">
|
||||
<frame frameborder="0" src="${add_sr('/toolbar/comments/'+thing.link._id36)}"
|
||||
name="reddit_panel" />
|
||||
<frame frameborder="0" src="${thing.link.url}" name="reddit_link" />
|
||||
<frame frameborder="0" src="${add_sr('/toolbar/comments/'+thing.link._id36)}" name="reddit_panel" />
|
||||
</frameset>
|
||||
</html>
|
||||
|
||||
@@ -326,6 +326,28 @@ thing id-${what._fullname}
|
||||
</span>
|
||||
</%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>
|
||||
|
||||
<%def name="tags(**kw)">
|
||||
%for k, v in kw.iteritems():
|
||||
%if v is not None:
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
</span>
|
||||
<p class="tagline">
|
||||
${self.tagline()}
|
||||
 
|
||||
<a target="_top" href="${thing.permalink}">
|
||||
 
|
||||
${_("context")}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user