mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Merge branch 'master' into requests
* master: Fixing feed loads only once for those with skipping stories. Adding handler to to_json calls on all serialized models. 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. Adding WP7 as user agent. Adding necessary import when not running from the REPL.
This commit is contained in:
commit
d3d241d77e
7 changed files with 49 additions and 15 deletions
|
@ -346,7 +346,7 @@ def load_single_feed(request, feed_id):
|
|||
start = time.time()
|
||||
user = get_user(request)
|
||||
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))
|
||||
dupe_feed_id = None
|
||||
userstories_db = None
|
||||
|
|
|
@ -814,12 +814,13 @@ class Feed(models.Model):
|
|||
|
||||
@classmethod
|
||||
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_tags'] = story_db.story_tags or []
|
||||
story['story_date'] = story_db.story_date
|
||||
story['story_authors'] = story_db.story_author_name
|
||||
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_feed_id'] = feed_id or story_db.story_feed_id
|
||||
story['id'] = story_db.story_guid or story_db.story_date
|
||||
|
@ -1266,6 +1267,13 @@ class DuplicateFeed(models.Model):
|
|||
|
||||
def __unicode__(self):
|
||||
return "%s: %s" % (self.feed, self.duplicate_address)
|
||||
|
||||
def to_json(self):
|
||||
return {
|
||||
'duplicate_address': self.duplicate_address,
|
||||
'duplicate_feed_id': self.duplicate_feed_id,
|
||||
'feed_id': self.feed.pk
|
||||
}
|
||||
|
||||
def merge_feeds(original_feed_id, duplicate_feed_id, force=False):
|
||||
from apps.reader.models import UserSubscription
|
||||
|
|
|
@ -92,7 +92,7 @@ NEWSBLUR.AssetModel.Reader.prototype = {
|
|||
}
|
||||
},
|
||||
error: function(e, textStatus, errorThrown) {
|
||||
NEWSBLUR.log(['AJAX Error', textStatus, errorThrown]);
|
||||
NEWSBLUR.log(['AJAX Error', e, textStatus, errorThrown]);
|
||||
if (errorThrown == 'abort') {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1822,6 +1822,21 @@
|
|||
this.show_tryfeed_add_button();
|
||||
}
|
||||
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() && this.flags.pre_load_page_scroll_position) {
|
||||
// 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.post_load_page_scroll_position, {
|
||||
duration: 0,
|
||||
axis: 'y',
|
||||
easing: 'easeInOutQuint',
|
||||
offset: 0,
|
||||
queue: false
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
setup_mousemove_on_views: function() {
|
||||
|
@ -1963,6 +1978,7 @@
|
|||
this.flags['story_titles_loaded'] = true;
|
||||
this.prefetch_story_locations_in_feed_view();
|
||||
this.fill_out_story_titles();
|
||||
this.scroll_back_to_original_position_before_fillout();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -2042,6 +2058,7 @@
|
|||
this.fill_out_story_titles();
|
||||
this.prefetch_story_locations_in_feed_view();
|
||||
this.hide_stories_progress_bar();
|
||||
this.scroll_back_to_original_position_before_fillout();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -3133,8 +3150,9 @@
|
|||
var page = $story_titles.data('page');
|
||||
|
||||
if (!this.flags['opening_feed']) {
|
||||
|
||||
this.flags.pre_load_page_scroll_position = $('#story_titles').scrollTop();
|
||||
if (!hide_loading) this.show_feedbar_loading();
|
||||
this.flags.post_load_page_scroll_position = $('#story_titles').scrollTop();
|
||||
$story_titles.data('page', page+1);
|
||||
if (this.active_feed == 'starred') {
|
||||
this.model.fetch_starred_stories(page+1, _.bind(this.post_open_starred_stories, this),
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
# Use this script to copy the contents of MongoDB from one server
|
||||
# to another using only pymongo. This circumvents the mongod --repair
|
||||
# option, which can fucking fail.
|
||||
# option, which can fail.
|
||||
|
||||
import sys
|
||||
import pymongo
|
||||
import datetime
|
||||
from apps.rss_feeds.models import Feed
|
||||
|
||||
collections = [
|
||||
#"classifier_author",
|
||||
#"classifier_feed",
|
||||
#"classifier_tag",
|
||||
#"classifier_title",
|
||||
#"feed_icons",
|
||||
# "feed_pages",
|
||||
"classifier_author",
|
||||
"classifier_feed",
|
||||
"classifier_tag",
|
||||
"classifier_title",
|
||||
"feed_icons",
|
||||
"feed_pages",
|
||||
"feedback",
|
||||
"starred_stories",
|
||||
"statistics",
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.core.serializers.json import DateTimeAwareJSONEncoder
|
|||
from django.db import models
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.encoding import force_unicode
|
||||
# from django.utils import simplejson as json
|
||||
from django.utils import simplejson as json
|
||||
import cjson
|
||||
from decimal import Decimal
|
||||
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.db.models.query import QuerySet
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
def decode(data):
|
||||
if not data:
|
||||
|
@ -42,7 +43,9 @@ def json_encode(data, *args, **kwargs):
|
|||
# Opps, we used to check if it is of type list, but that fails
|
||||
# i.e. in the case of django.newforms.utils.ErrorList, which extends
|
||||
# the type "list". Oh man, that was a dumb mistake!
|
||||
if isinstance(data, list):
|
||||
if hasattr(data, 'to_json'):
|
||||
ret = data.to_json()
|
||||
elif isinstance(data, list):
|
||||
ret = _list(data)
|
||||
# Same as for lists above.
|
||||
elif isinstance(data, dict):
|
||||
|
@ -61,6 +64,8 @@ def json_encode(data, *args, **kwargs):
|
|||
# see http://code.djangoproject.com/ticket/5868
|
||||
elif isinstance(data, Promise):
|
||||
ret = force_unicode(data)
|
||||
elif isinstance(data, datetime.datetime):
|
||||
ret = str(data)
|
||||
else:
|
||||
ret = data
|
||||
return ret
|
||||
|
@ -90,8 +95,8 @@ def json_encode(data, *args, **kwargs):
|
|||
return ret
|
||||
|
||||
ret = _any(data)
|
||||
# return json.dumps(ret)
|
||||
return cjson.encode(ret, encoding='utf-8', extension=lambda x: "\"%s\"" % str(x))
|
||||
return json.dumps(ret)
|
||||
# return cjson.encode(ret, encoding='utf-8', extension=lambda x: "\"%s\"" % str(x))
|
||||
|
||||
def json_view(func):
|
||||
def wrap(request, *a, **kw):
|
||||
|
|
|
@ -34,6 +34,8 @@ def user(u, msg):
|
|||
platform = 'FF'
|
||||
elif 'Opera' in user_agent:
|
||||
platform = 'Opera'
|
||||
elif 'WP7' in user_agent:
|
||||
platform = 'WP7'
|
||||
premium = '*' if u.is_authenticated() and u.profile.is_premium else ''
|
||||
username = cipher(u.__unicode__()) if settings.CIPHER_USERNAMES else u
|
||||
info(' ---> [~FB~SN%-6s~SB] [%s%s] %s' % (platform, username, premium, msg))
|
||||
|
|
Loading…
Add table
Reference in a new issue