Send focus to content frame when using the Reddit toolbar. Also, cut back on title fetching.

This commit is contained in:
Mike
2009-06-18 14:04:50 -07:00
parent 7412ceeccd
commit b755abcbeb
5 changed files with 24 additions and 16 deletions

View File

@@ -260,9 +260,18 @@ class ApiController(RedditController):
form.redirect(path)
@validatedForm(VUser(),
url = VSanitizedUrl(['url']))
@validatedForm(VRatelimit(rate_ip = True,
rate_user = True,
prefix = 'fetchtitle_'),
VUser(),
url = VSanitizedUrl(['url']))
def POST_fetch_title(self, form, jquery, url):
if form.has_errors('ratelimit', errors.RATELIMIT):
form.set_html(".title-status", "");
return
VRatelimit.ratelimit(rate_ip = True, rate_user = True,
prefix = 'fetchtitle_', seconds=1)
if url:
title = get_title(url)
if title:

View File

@@ -73,12 +73,6 @@ def auto_expand_panel(link):
else:
return c.user.pref_frame_commentspanel
@memoize('toolbar.get_title', time = 500)
def get_title(url):
"""Find the <title> in the page contained at 'url'. Copied here
from utils so that we can memoize it"""
return utils.get_title(url)
class ToolbarController(RedditController):
@validate(link1 = VByName('id'),
link2 = VLink('id', redirect = False))
@@ -139,9 +133,7 @@ class ToolbarController(RedditController):
# link-id-based URL so that their URL is reusable
return self.redirect(add_sr("/tb/" + link._id36))
title = get_title(path)
if not title:
title = utils.domain(path)
title = utils.domain(path)
res = Frame(title = title, url = path)
# we don't want clients to think that this URL is actually a
@@ -213,7 +205,7 @@ class ToolbarController(RedditController):
expanded = auto_expand_panel(link))
else:
res = FrameToolbar(link = None,
title = get_title(url),
title = None,
url = url,
expanded = False)

View File

@@ -743,7 +743,7 @@ a.star { text-decoration: none; color: #ff8b60 }
/* compressed links */
.linkcompressed { margin: 4px 0; overflow: hidden; margin-top: 8px; }
.linkcompressed .title {margin-bottom: 4px; font-size:medium; font-weight: normal;}
.linkcompressed .title {margin-bottom: 5px; font-size:medium; font-weight: normal;}
.linkcompressed .child h3 {
margin: 15px;
text-transform: none;
@@ -772,7 +772,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: #fafafa;
background-color: #fbfbfb;
font-weight: bold
}

View File

@@ -30,7 +30,14 @@
<head>
<title>${thing.title}</title>
</head>
<frameset framespacing="0" frameborder="0" border="0" rows="20px, 100%">
<frameset framespacing="0" frameborder="0" border="0" rows="20px, 100%"
%if not thing.fullname:
onload="window.frames[1].focus();"
%endif
## When thing.fullname is present, innertoolbarframe.html will take care of
## the focus.
>
%if thing.fullname:
<frame frameborder="0" border="0" scrolling="no" name="reddit_top"
noresize="1" src="${add_sr('/toolbar/toolbar?id=' + thing.fullname)}"

View File

@@ -24,7 +24,7 @@
%>
<html>
<frameset cols="${panel_size('expanded' if thing.expanded else 'collapsed')}"
name="inner_toolbar">
name="inner_toolbar" onload="window.frames[1].focus()">
<frame frameborder="0" src="${add_sr('/toolbar/comments/'+thing.link._id36)}"
name="reddit_panel" />
<frame frameborder="0" src="${thing.link.url}" name="reddit_link" />