diff --git a/apps/rss_feeds/models.py b/apps/rss_feeds/models.py index 45043a4e7..2aee9179c 100644 --- a/apps/rss_feeds/models.py +++ b/apps/rss_feeds/models.py @@ -983,6 +983,8 @@ class Feed(models.Model): story['starred_date'] = story_db.starred_date if hasattr(story_db, 'shared_date'): story['shared_date'] = story_db.shared_date + if hasattr(story_db, 'blurblog_permalink'): + story['blurblog_permalink'] = story_db.blurblog_permalink() if text: from BeautifulSoup import BeautifulSoup soup = BeautifulSoup(story['story_content']) @@ -1343,7 +1345,7 @@ class MStory(mongo.Document): @property def guid_hash(self): - return hashlib.sha1(self.story_guid).hexdigest() + return hashlib.sha1(self.story_guid).hexdigest()[:6] def save(self, *args, **kwargs): story_title_max = MStory._fields['story_title'].max_length @@ -1472,7 +1474,7 @@ class MStarredStory(mongo.Document): @property def guid_hash(self): - return hashlib.sha1(self.story_guid).hexdigest() + return hashlib.sha1(self.story_guid).hexdigest()[:6] class MFeedFetchHistory(mongo.Document): diff --git a/apps/social/models.py b/apps/social/models.py index 0aad2df15..49b573f7a 100644 --- a/apps/social/models.py +++ b/apps/social/models.py @@ -1629,8 +1629,9 @@ class MSharedStory(mongo.Document): def blurblog_permalink(self): profile = MSocialProfile.get_user(self.user_id) - return "%s/story/%s" % ( + return "%s/story/%s/%s" % ( profile.blurblog_url, + slugify(self.story_title)[:20], self.guid_hash[:6] ) diff --git a/apps/social/views.py b/apps/social/views.py index a48081233..8209b4ae4 100644 --- a/apps/social/views.py +++ b/apps/social/views.py @@ -2,6 +2,7 @@ import time import datetime import zlib import random +import re from bson.objectid import ObjectId from django.shortcuts import get_object_or_404, render_to_response from django.core.urlresolvers import reverse @@ -403,7 +404,10 @@ def load_social_page(request, user_id, username=None, **kwargs): active_story = None path = request.META['PATH_INFO'] if '/story/' in path and format != 'html': - story_id = path.replace('/story/', '') + story_id = re.sub(r"^/story/.*?/(.*?)/?", "", path) + if not story_id or '/story' in story_id: + story_id = path.replace('/story/', '') + active_story_db = MSharedStory.objects.filter(user_id=social_user.pk, story_guid_hash=story_id).limit(1) if active_story_db: diff --git a/media/css/social/social_page.css b/media/css/social/social_page.css index 18a89356d..9fe4edde1 100644 --- a/media/css/social/social_page.css +++ b/media/css/social/social_page.css @@ -426,7 +426,13 @@ header { .NB-story-date sup { font-size: 7px; } - +.NB-story-permalink { + text-decoration: none; + color: inherit; +} +.NB-story-permalink:hover { + color: #87ACCC; +} .NB-story-header .NB-story-modifications-button { width: 16px; height: 16px; diff --git a/media/js/newsblur/social_page/social_page_router.js b/media/js/newsblur/social_page/social_page_router.js index 824687d05..5ab593500 100644 --- a/media/js/newsblur/social_page/social_page_router.js +++ b/media/js/newsblur/social_page/social_page_router.js @@ -2,6 +2,8 @@ NEWSBLUR.Router = Backbone.Router.extend({ routes : { "": "index", + "story/:slug/:guid": "story_slug", + "story/:slug/:guid/": "story_slug", "story/:guid": "story", "story/:guid/": "story", "site/:feed_id": "site", @@ -16,6 +18,10 @@ NEWSBLUR.Router = Backbone.Router.extend({ this.story_guid = guid.replace(/\?(.*)$/, ''); }, + story_slug: function(slug, guid) { + this.story_guid = guid.replace(/\?(.*)$/, ''); + }, + site: function(feed_id) { this.feed_id = feed_id; } diff --git a/templates/social/social_story.xhtml b/templates/social/social_story.xhtml index 883d024fa..5df917ffe 100644 --- a/templates/social/social_story.xhtml +++ b/templates/social/social_story.xhtml @@ -25,7 +25,7 @@ {% endif %} - {{ story.shared_date|date:"D F j<\s\u\p>S\s\u\p>, Y"|safe }} + {{ story.shared_date|date:"D F j<\s\u\p>S\s\u\p>, Y"|safe }} {% if story.story_authors %}