Tons of small fixes: opml uploads, rss feeds for blurblogs, default images on blurblogs.

This commit is contained in:
Samuel Clay 2012-07-30 21:39:21 -07:00
parent 953050913b
commit 78338bba0d
6 changed files with 81 additions and 65 deletions

View file

@ -34,19 +34,26 @@ def opml_upload(request):
logging.user(request, "~FR~SBOPML upload starting...")
file = request.FILES['file']
xml_opml = file.read()
UploadedOPML.objects.create(user_id=request.user.pk, opml_file=xml_opml)
opml_importer = OPMLImporter(xml_opml, request.user)
try:
folders = opml_importer.try_processing()
except TimeoutError:
uploaded_opml = UploadedOPML.objects.create(user_id=request.user.pk, opml_file=xml_opml)
except UnicodeDecodeError:
uploaded_opml = None
folders = None
ProcessOPML.delay(request.user.pk)
feed_count = opml_importer.count_feeds_in_opml()
logging.user(request, "~FR~SBOPML pload took too long, found %s feeds. Tasking..." % feed_count)
payload = dict(folders=folders, delayed=True, feed_count=feed_count)
code = 2
message = ""
code = -1
message = "There was a Unicode decode error when reading your OPML file."
if uploaded_opml:
opml_importer = OPMLImporter(xml_opml, request.user)
try:
folders = opml_importer.try_processing()
except TimeoutError:
folders = None
ProcessOPML.delay(request.user.pk)
feed_count = opml_importer.count_feeds_in_opml()
logging.user(request, "~FR~SBOPML pload took too long, found %s feeds. Tasking..." % feed_count)
payload = dict(folders=folders, delayed=True, feed_count=feed_count)
code = 2
message = ""
if folders:
feeds = UserSubscription.objects.filter(user=request.user).values()

View file

@ -358,7 +358,8 @@ class MSocialProfile(mongo.Document):
if not force:
from apps.social.tasks import EmailNewFollower
EmailNewFollower.delay(follower_user_id=self.user_id, followee_user_id=user_id)
EmailNewFollower.delay(follower_user_id=self.user_id, followee_user_id=user_id,
countdown=60)
return socialsub
@ -420,11 +421,17 @@ class MSocialProfile(mongo.Document):
def send_email_for_new_follower(self, follower_user_id):
user = User.objects.get(pk=self.user_id)
if not user.email or not user.profile.send_emails or self.user_id == follower_user_id:
if not user.email:
logging.user(user, "~BB~FMNo email to send to, skipping.")
elif not user.profile.send_emails:
logging.user(user, "~BB~FMDisabled emails, skipping.")
if follower_user_id not in self.follower_user_ids:
logging.user(user, "~BB~FMNo longer being followed by %s" % follower_user_id)
return
if not user.email:
logging.user(user, "~BB~FMNo email to send to, skipping.")
return
elif not user.profile.send_emails:
logging.user(user, "~BB~FMDisabled emails, skipping.")
return
if self.user_id == follower_user_id:
logging.user(user, "~BB~FMDisabled emails, skipping.")
return
emails_sent = MSentEmail.objects.filter(receiver_user_id=user.pk,

View file

@ -215,7 +215,7 @@ def load_social_page(request, user_id, username=None, **kwargs):
"stories": [],
"feeds": {},
"social_user": social_user,
"social_profile": social_profile.page(),
"social_profile": social_profile,
'user_social_profile' : json.encode(user_social_profile and user_social_profile.page()),
}
template = 'social/social_page.xhtml'
@ -769,12 +769,14 @@ def unfollow(request):
@json.json_view
def find_friends(request):
query = request.GET.get('query')
profiles = MSocialProfile.objects.filter(username__icontains=query)[:3]
limit = int(request.GET.get('limit', 3))
profiles = MSocialProfile.objects.filter(username__icontains=query)[:limit]
if not profiles:
profiles = MSocialProfile.objects.filter(email__icontains=query)[:3]
profiles = MSocialProfile.objects.filter(email__icontains=query)[:limit]
if not profiles:
profiles = MSocialProfile.objects.filter(blurblog_title__icontains=query)[:3]
profiles = MSocialProfile.objects.filter(blurblog_title__icontains=query)[:limit]
profiles = [p.to_json(include_following_user=True) for p in profiles]
return dict(profiles=profiles)
@ajax_login_required
@ -871,8 +873,7 @@ def shared_stories_rss_feed(request, user_id, username):
data = {}
data['title'] = social_profile.title
link = reverse('shared-stories-public', kwargs={'username': user.username})
data['link'] = "http://www.newsblur.com/%s" % link
data['link'] = social_profile.blurblog_url
data['description'] = "Stories shared by %s on NewsBlur." % user.username
data['lastBuildDate'] = datetime.datetime.utcnow()
data['items'] = []
@ -885,8 +886,10 @@ def shared_stories_rss_feed(request, user_id, username):
'title': shared_story.story_title,
'link': shared_story.story_permalink,
'description': shared_story.story_content_z and zlib.decompress(shared_story.story_content_z),
'author': shared_story.story_author_name,
'categories': shared_story.story_tags,
'guid': shared_story.story_guid,
'pubDate': shared_story.story_date,
'pubDate': shared_story.shared_date,
}
data['items'].append(RSS.RSSItem(**story_data))

View file

@ -46,45 +46,47 @@ _.extend(NEWSBLUR.ReaderIntro.prototype, {
$.make('div', { className: 'NB-page NB-page-1' }, [
$.make('h4', { className: 'NB-page-1-started' }, "So much time and so little to do. Strike that! Reverse it.")
]),
$.make('div', { className: 'NB-page NB-page-2 carousel slide' }, [
$.make('div', { className: 'carousel-inner NB-intro-imports' }, [
$.make('div', { className: 'item NB-intro-imports-start' }, [
$.make('h4', { className: 'NB-page-2-started' }, "Let's get some sites to read."),
$.make('div', { className: 'NB-intro-import NB-intro-import-google' }, [
$.make('h3', [
'Import from',
$.make('br'),
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + 'img/reader/google-reader-logo.gif' })
$.make('div', { className: 'NB-page NB-page-2' }, [
$.make('div', { className: 'carousel slide'}, [
$.make('div', { className: 'carousel-inner NB-intro-imports' }, [
$.make('div', { className: 'item NB-intro-imports-start' }, [
$.make('h4', { className: 'NB-page-2-started' }, "Let's get some sites to read."),
$.make('div', { className: 'NB-intro-import NB-intro-import-google' }, [
$.make('h3', [
'Import from',
$.make('br'),
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + 'img/reader/google-reader-logo.gif' })
]),
$.make('a', { href: NEWSBLUR.URLs['google-reader-authorize'], className: 'NB-google-reader-oauth NB-modal-submit-green NB-modal-submit-button' }, [
'Connect to Google'
]),
$.make('div', { className: 'NB-error' })
]),
$.make('a', { href: NEWSBLUR.URLs['google-reader-authorize'], className: 'NB-google-reader-oauth NB-modal-submit-green NB-modal-submit-button' }, [
'Connect to Google'
]),
$.make('div', { className: 'NB-error' })
$.make('div', { className: 'NB-intro-import NB-intro-import-opml' }, [
$.make('h3', ['Upload an', $.make('br'), 'OPML file']),
$.make('form', { method: 'post', enctype: 'multipart/form-data', encoding: 'multipart/form-data', className: 'NB-opml-upload-form' }, [
$.make('div', { href: '#', className: 'NB-intro-upload-opml NB-modal-submit-green NB-modal-submit-button' }, [
'Upload OPML File',
$.make('input', { type: 'file', name: 'file', id: 'NB-intro-upload-opml-button', className: 'NB-intro-upload-opml-button' })
])
]),
$.make('div', { className: 'NB-error' })
])
]),
$.make('div', { className: 'NB-intro-import NB-intro-import-opml' }, [
$.make('h3', ['Upload an', $.make('br'), 'OPML file']),
$.make('form', { method: 'post', enctype: 'multipart/form-data', encoding: 'multipart/form-data', className: 'NB-opml-upload-form' }, [
$.make('div', { href: '#', className: 'NB-intro-upload-opml NB-modal-submit-green NB-modal-submit-button' }, [
'Upload OPML File',
$.make('input', { type: 'file', name: 'file', id: 'NB-intro-upload-opml-button', className: 'NB-intro-upload-opml-button' })
])
]),
$.make('div', { className: 'NB-error' })
])
]),
$.make('div', { className: 'item NB-intro-imports-progress' }, [
$.make('h4', { className: 'NB-page-2-started' }, "Importing your sites..."),
$.make('div', { className: 'NB-loading' })
]),
$.make('div', { className: 'item NB-intro-imports-sites' }, [
$.make('h4'),
$.make('div', { className: 'NB-intro-import-restart NB-modal-submit-grey NB-modal-submit-button' }, [
'« Restart and re-import your sites'
$.make('div', { className: 'item NB-intro-imports-progress' }, [
$.make('h4', { className: 'NB-page-2-started' }, "Importing your sites..."),
$.make('div', { className: 'NB-loading' })
]),
$.make('div', { className: 'NB-intro-import-delayed' }, [
'There are too many sites to process...',
$.make('br'),
'You will be emailed within a minute or three.'
$.make('div', { className: 'item NB-intro-imports-sites' }, [
$.make('h4'),
$.make('div', { className: 'NB-intro-import-restart NB-modal-submit-grey NB-modal-submit-button' }, [
'« Restart and re-import your sites'
]),
$.make('div', { className: 'NB-intro-import-delayed' }, [
'There are too many sites to process...',
$.make('br'),
'You will be emailed within a minute or three.'
])
])
])
]),

View file

@ -4,7 +4,7 @@
<html>
<head>
<title>{{ social_profile.blurblog_title }}</title>
<title>{{ social_profile.title }}</title>
<link rel="alternate" type="application/rss+xml" href="{% url shared-stories-rss-feed social_profile.user_id social_profile.username|slugify %}" title="{{ social_profile.feed_title }} RSS feed">
<link rel="shortcut icon" href="{{ social_profile.photo_url }}">
<link rel="icon" href="{{ social_profile.photo_url }}">
@ -72,11 +72,7 @@
<tr>
<td class="NB-title-photo">
<a href="/">
{% if social_profile.photo_url %}
<img src="{{ social_profile.large_photo_url }}" />
{% else %}
<img src="{{ MEDIA_URL }}img/reader/default_profile_photo.png" />
{% endif %}
</a>
</td>
<td class="NB-title">

View file

@ -409,6 +409,7 @@ class Dispatcher:
page_data = page_importer.fetch_page()
except TimeoutError, e:
logging.debug(' ---> [%-30s] ~FRPage fetch timed out...' % (feed.title[:30]))
page_data = None
feed.save_page_history(555, 'Timeout', '')
except Exception, e:
logging.debug('[%d] ! -------------------------' % (feed_id,))