Merge branch 'master' into social

* master:
  Fixing two major bugs: auto filling stories now works far better nad doesn't lock you in. Also fixing the infernal unicode json parsing bug that's been effecting a bunch of sites.
This commit is contained in:
Samuel Clay 2011-12-24 19:42:04 -08:00
commit 9837c5a9ee
5 changed files with 29 additions and 7 deletions

View file

@ -354,7 +354,7 @@ def load_single_feed(request, feed_id):
start = time.time() start = time.time()
user = get_user(request) user = get_user(request)
offset = int(request.REQUEST.get('offset', 0)) offset = int(request.REQUEST.get('offset', 0))
limit = int(request.REQUEST.get('limit', 12)) limit = int(request.REQUEST.get('limit', 6))
page = int(request.REQUEST.get('page', 1)) page = int(request.REQUEST.get('page', 1))
dupe_feed_id = None dupe_feed_id = None
userstories_db = None userstories_db = None

View file

@ -812,12 +812,13 @@ class Feed(models.Model):
@classmethod @classmethod
def format_story(cls, story_db, feed_id=None, text=False): def format_story(cls, story_db, feed_id=None, text=False):
story_content = story_db.story_content_z and zlib.decompress(story_db.story_content_z) or ''
story = {} story = {}
story['story_tags'] = story_db.story_tags or [] story['story_tags'] = story_db.story_tags or []
story['story_date'] = story_db.story_date story['story_date'] = story_db.story_date
story['story_authors'] = story_db.story_author_name story['story_authors'] = story_db.story_author_name
story['story_title'] = story_db.story_title story['story_title'] = story_db.story_title
story['story_content'] = story_db.story_content_z and zlib.decompress(story_db.story_content_z) or '' story['story_content'] = story_content
story['story_permalink'] = urllib.unquote(urllib.unquote(story_db.story_permalink)) story['story_permalink'] = urllib.unquote(urllib.unquote(story_db.story_permalink))
story['story_feed_id'] = feed_id or story_db.story_feed_id story['story_feed_id'] = feed_id or story_db.story_feed_id
story['id'] = story_db.story_guid or story_db.story_date story['id'] = story_db.story_guid or story_db.story_date

View file

@ -92,7 +92,7 @@ NEWSBLUR.AssetModel.Reader.prototype = {
} }
}, },
error: function(e, textStatus, errorThrown) { error: function(e, textStatus, errorThrown) {
NEWSBLUR.log(['AJAX Error', textStatus, errorThrown]); NEWSBLUR.log(['AJAX Error', e, textStatus, errorThrown]);
if (errorThrown == 'abort') { if (errorThrown == 'abort') {
return; return;
} }

View file

@ -1823,6 +1823,21 @@
this.show_tryfeed_add_button(); this.show_tryfeed_add_button();
} }
this.make_content_pane_feed_counter(feed_id); this.make_content_pane_feed_counter(feed_id);
this.scroll_back_to_original_position_before_fillout();
},
scroll_back_to_original_position_before_fillout: function() {
var $story_titles = this.$s.$story_titles;
if (this.flags.post_load_page_scroll_position == $story_titles.scrollTop()) {
// NEWSBLUR.log(['Snap back pre-autofill', this.flags.post_load_page_scroll_position, this.flags.pre_load_page_scroll_position]);
$story_titles.scrollTo(this.flags.pre_load_page_scroll_position, {
duration: 0,
axis: 'y',
easing: 'easeInOutQuint',
offset: 0,
queue: false
});
}
}, },
setup_mousemove_on_views: function() { setup_mousemove_on_views: function() {
@ -1965,6 +1980,7 @@
this.prefetch_story_locations_in_feed_view(); this.prefetch_story_locations_in_feed_view();
this.scroll_story_titles_to_show_selected_story_title(); this.scroll_story_titles_to_show_selected_story_title();
this.fill_out_story_titles(); this.fill_out_story_titles();
this.scroll_back_to_original_position_before_fillout();
} }
}, },
@ -2045,6 +2061,7 @@
this.fill_out_story_titles(); this.fill_out_story_titles();
this.prefetch_story_locations_in_feed_view(); this.prefetch_story_locations_in_feed_view();
this.hide_stories_progress_bar(); this.hide_stories_progress_bar();
this.scroll_back_to_original_position_before_fillout();
} }
}, },
@ -3263,7 +3280,7 @@
var page = $story_titles.data('page'); var page = $story_titles.data('page');
if (!this.flags['opening_feed']) { if (!this.flags['opening_feed']) {
this.flags.pre_load_page_scroll_position = $('#story_titles').scrollTop();
if (!hide_loading) this.show_feedbar_loading(); if (!hide_loading) this.show_feedbar_loading();
$story_titles.data('page', page+1); $story_titles.data('page', page+1);
if (this.active_feed == 'starred') { if (this.active_feed == 'starred') {
@ -3322,6 +3339,7 @@
offset: 0, offset: 0,
queue: false queue: false
}); });
this.flags.post_load_page_scroll_position = $('#story_titles').scrollTop();
}, },
show_feed_title_in_stories: function(feed_id) { show_feed_title_in_stories: function(feed_id) {

View file

@ -2,7 +2,7 @@ from django.core.serializers.json import DateTimeAwareJSONEncoder
from django.db import models from django.db import models
from django.utils.functional import Promise from django.utils.functional import Promise
from django.utils.encoding import force_unicode from django.utils.encoding import force_unicode
# from django.utils import simplejson as json from django.utils import simplejson as json
import cjson import cjson
from decimal import Decimal from decimal import Decimal
from django.core import serializers from django.core import serializers
@ -11,6 +11,7 @@ from django.http import HttpResponse, HttpResponseForbidden, Http404
from django.core.mail import mail_admins from django.core.mail import mail_admins
from django.db.models.query import QuerySet from django.db.models.query import QuerySet
import sys import sys
import datetime
def decode(data): def decode(data):
if not data: if not data:
@ -61,6 +62,8 @@ def json_encode(data, *args, **kwargs):
# see http://code.djangoproject.com/ticket/5868 # see http://code.djangoproject.com/ticket/5868
elif isinstance(data, Promise): elif isinstance(data, Promise):
ret = force_unicode(data) ret = force_unicode(data)
elif isinstance(data, datetime.datetime):
ret = str(data)
else: else:
ret = data ret = data
return ret return ret
@ -90,8 +93,8 @@ def json_encode(data, *args, **kwargs):
return ret return ret
ret = _any(data) ret = _any(data)
# return json.dumps(ret) return json.dumps(ret)
return cjson.encode(ret, encoding='utf-8', extension=lambda x: "\"%s\"" % str(x)) # return cjson.encode(ret, encoding='utf-8', extension=lambda x: "\"%s\"" % str(x))
def json_view(func): def json_view(func):
def wrap(request, *a, **kw): def wrap(request, *a, **kw):