rename the recentclick cookie for the millionth time

This commit is contained in:
spez
2009-06-03 14:12:36 -07:00
parent 56f3a4822e
commit 32639c8ef3
4 changed files with 9 additions and 8 deletions

View File

@@ -1365,7 +1365,7 @@ class ApiController(RedditController):
def GET_gadget(self, form, jquery, type, links):
if not links and type == 'click':
# malformed cookie, clear it out
set_user_cookie('recentclicks', '')
set_user_cookie('recentclicks2', '')
if not links:
return

View File

@@ -139,6 +139,7 @@ def read_user_cookie(name):
def set_user_cookie(name, val):
uname = c.user.name if c.user_is_loggedin else ""
c.cookies[uname + '_' + name] = Cookie(value = val)
valid_click_cookie = fullname_regex(Link, True).match
def set_recent_clicks():
@@ -146,21 +147,21 @@ def set_recent_clicks():
if not c.user_is_loggedin:
return
click_cookie = read_user_cookie('recentclicks')
click_cookie = read_user_cookie('recentclicks2')
if click_cookie:
if valid_click_cookie(click_cookie):
names = [ x for x in UniqueIterator(click_cookie.split(',')) if x ]
if len(click_cookie) > 1000:
names = names[:20]
set_user_cookie('recentclicks', ','.join(names))
set_user_cookie('recentclicks2', ','.join(names))
#eventually this will look at the user preference
names = names[:5]
c.recent_clicks = Link._by_fullname(names, data = True,
return_dict = False)
else:
#if the cookie wasn't valid, clear it
set_user_cookie('recentclicks', '')
set_user_cookie('recentclicks2', '')
def read_mod_cookie():
cook = [s.split('=')[0:2] for s in read_user_cookie('mod').split(':') if s]

View File

@@ -485,7 +485,7 @@ function add_thing_id_to_cookie(id, cookie_name) {
};
function clicked_items() {
var cookie = $.cookie_read('recentclicks');
var cookie = $.cookie_read('recentclicks2');
if(cookie && cookie.data) {
var fullnames = cookie.data.split(",");
/* don't return empty ones */
@@ -501,7 +501,7 @@ function clicked_items() {
}
function clear_clicked_items() {
var cookie = $.cookie_read('recentclicks');
var cookie = $.cookie_read('recentclicks2');
cookie.data = '';
$.cookie_write(cookie);
$('.gadget').remove();
@@ -542,7 +542,7 @@ function updateEventHandlers(thing) {
/* mark as clicked */
$(this).addClass("click");
/* set the click cookie. */
add_thing_to_cookie(this, "recentclicks");
add_thing_to_cookie(this, "recentclicks2");
/* remember this as the last thing clicked */
var wasorganic = $(this).parents('.organic-listing').length > 0;
last_click(thing, wasorganic);

View File

@@ -149,7 +149,7 @@
## add us to the click cookie
<script type="text/javascript">
$(function() {
add_thing_id_to_cookie('${thing.link._fullname}', 'recentclicks');
add_thing_id_to_cookie("${thing.link._fullname}", "recentclicks2");
});
</script>
<span>