Adding blurblog permalink to story on blurblog. Adding story slug to permalink. Fixing story guid hashes.

This commit is contained in:
Samuel Clay 2012-11-27 11:59:54 -08:00
parent 9deff7a336
commit 931d4bc991
6 changed files with 25 additions and 6 deletions

View file

@ -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):

View file

@ -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]
)

View file

@ -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:

View file

@ -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;

View file

@ -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;
}

View file

@ -25,7 +25,7 @@
{% endif %}
{{ story.shared_date|date:"D F j<\s\u\p>S</\s\u\p>, Y"|safe }}
<a href="{{ story.blurblog_permalink }}" class="NB-story-permalink">{{ story.shared_date|date:"D F j<\s\u\p>S</\s\u\p>, Y"|safe }}</a>
</div>
{% if story.story_authors %}
<div class="NB-story-author">{{ story.story_authors }}</div>