mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Showing share and save buttons (that don't do much).
This commit is contained in:
parent
c05f47f838
commit
1e044b07e8
5 changed files with 213 additions and 26 deletions
|
@ -1139,8 +1139,7 @@ class MSharedStory(mongo.Document):
|
|||
return comments
|
||||
|
||||
@classmethod
|
||||
def stories_with_comments_and_profiles(cls, stories, user_id, check_all=False, public=False,
|
||||
attach_users=False):
|
||||
def stories_with_comments_and_profiles(cls, stories, user_id, check_all=False, public=False):
|
||||
r = redis.Redis(connection_pool=settings.REDIS_POOL)
|
||||
friend_key = "F:%s:F" % (user_id)
|
||||
profile_user_ids = set()
|
||||
|
@ -1188,23 +1187,26 @@ class MSharedStory(mongo.Document):
|
|||
|
||||
profiles = MSocialProfile.objects.filter(user_id__in=list(profile_user_ids))
|
||||
profiles = [profile.to_json(compact=True) for profile in profiles]
|
||||
|
||||
if attach_users and story['share_count']:
|
||||
profiles = dict([(p['user_id'], p) for p in profiles])
|
||||
for s, story in enumerate(stories):
|
||||
for u, user_id in enumerate(story['shared_by_friends']):
|
||||
stories[s]['shared_by_friends'][u] = profiles[user_id]
|
||||
for u, user_id in enumerate(story['shared_by_public']):
|
||||
stories[s]['shared_by_public'][u] = profiles[user_id]
|
||||
for c, comment in enumerate(story['comments']):
|
||||
stories[s]['comments'][c]['user'] = profiles[comment['user_id']]
|
||||
if comment['source_user_id']:
|
||||
stories[s]['comments'][c]['source_user'] = profiles[comment['source_user_id']]
|
||||
for r, reply in enumerate(comment['replies']):
|
||||
stories[s]['comments'][c]['replies'][r]['user'] = profiles[reply['user_id']]
|
||||
|
||||
return stories, profiles
|
||||
|
||||
@staticmethod
|
||||
def attach_users_to_stories(stories, profiles):
|
||||
profiles = dict([(p['user_id'], p) for p in profiles])
|
||||
for s, story in enumerate(stories):
|
||||
for u, user_id in enumerate(story['shared_by_friends']):
|
||||
stories[s]['shared_by_friends'][u] = profiles[user_id]
|
||||
for u, user_id in enumerate(story['shared_by_public']):
|
||||
stories[s]['shared_by_public'][u] = profiles[user_id]
|
||||
for c, comment in enumerate(story['comments']):
|
||||
stories[s]['comments'][c]['user'] = profiles[comment['user_id']]
|
||||
if comment['source_user_id']:
|
||||
stories[s]['comments'][c]['source_user'] = profiles[comment['source_user_id']]
|
||||
for r, reply in enumerate(comment['replies']):
|
||||
stories[s]['comments'][c]['replies'][r]['user'] = profiles[reply['user_id']]
|
||||
|
||||
return stories
|
||||
|
||||
def blurblog_permalink(self):
|
||||
profile = MSocialProfile.objects.get(user_id=self.user_id)
|
||||
return "%s/story/%s" % (
|
||||
|
|
|
@ -166,9 +166,9 @@ def load_social_stories(request, user_id, username=None):
|
|||
|
||||
@render_to('social/social_page.xhtml')
|
||||
def load_social_page(request, user_id, username=None):
|
||||
user = get_user(request)
|
||||
social_user_id = int(user_id)
|
||||
social_user = get_object_or_404(User, pk=social_user_id)
|
||||
user = social_user
|
||||
offset = int(request.REQUEST.get('offset', 0))
|
||||
limit = int(request.REQUEST.get('limit', 12))
|
||||
page = request.REQUEST.get('page')
|
||||
|
@ -197,9 +197,15 @@ def load_social_page(request, user_id, username=None):
|
|||
shared_date = localtime_for_timezone(story['shared_date'], social_user.profile.timezone)
|
||||
story['shared_date'] = shared_date
|
||||
|
||||
stories, profiles = MSharedStory.stories_with_comments_and_profiles(stories, user.pk,
|
||||
check_all=True,
|
||||
attach_users=True)
|
||||
stories, profiles = MSharedStory.stories_with_comments_and_profiles(stories, social_user.pk,
|
||||
check_all=True)
|
||||
|
||||
for story in stories:
|
||||
print user.pk, story['shared_by_friends'], story['shared_by_public']
|
||||
if user.pk in story['shared_by_friends'] or user.pk in story['shared_by_public']:
|
||||
story['shared_by_user'] = True
|
||||
|
||||
stories = MSharedStory.attach_users_to_stories(stories, profiles)
|
||||
|
||||
params = {
|
||||
'user': user,
|
||||
|
|
|
@ -184,7 +184,12 @@ header {
|
|||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
overflow: hidden;
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
}
|
||||
|
||||
@media all and (max-width: 500px) {
|
||||
.NB-mark {
|
||||
-webkit-transform: translate3d(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ===================== */
|
||||
|
@ -393,6 +398,7 @@ header {
|
|||
|
||||
.NB-story-content {
|
||||
padding: 12px 200px 24px 0;
|
||||
position: relative;
|
||||
}
|
||||
@media all and (max-width: 800px) {
|
||||
.NB-story-content {
|
||||
|
@ -724,4 +730,163 @@ header {
|
|||
.NB-story-comment .NB-story-comment-content {
|
||||
clear: both;
|
||||
padding: 0 0 6px 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================= */
|
||||
/* = Side Options in Feed view = */
|
||||
/* ============================= */
|
||||
|
||||
.NB-feed-story-sideoptions-container {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
bottom: 32px;
|
||||
text-align: center;
|
||||
width: 172px;
|
||||
}
|
||||
|
||||
.NB-feed-story-sideoptions-container {
|
||||
|
||||
}
|
||||
.NB-sideoption {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
text-transform: uppercase;
|
||||
font-size: 10px;
|
||||
white-space: nowrap;
|
||||
font-weight: bold;
|
||||
text-shadow: 0 1px 0 #000;
|
||||
}
|
||||
.NB-sideoption .NB-sideoption-icon {
|
||||
width: 24px;
|
||||
padding: 4px;
|
||||
height: 100%;
|
||||
float: right;
|
||||
background: #EBF6DA url('/media/embed/reader/star_blue.png') no-repeat 8px 4px;
|
||||
-webkit-transition: all .12s ease-out;
|
||||
-moz-transition: all .12s ease-out;
|
||||
-o-transition: all .12s ease-out;
|
||||
-ms-transition: all .12s ease-out;
|
||||
}
|
||||
.NB-sideoption.NB-feed-story-train .NB-sideoption-icon {
|
||||
background-image: url('/media/embed/icons/silk/bricks.png');
|
||||
}
|
||||
.NB-sideoption.NB-feed-story-share .NB-sideoption-icon {
|
||||
background-image: url('/media/embed/icons/silk/rainbow.png');
|
||||
}
|
||||
|
||||
.NB-sideoption .NB-sideoption-title {
|
||||
padding: 4px 36px 4px 6px;
|
||||
color: white;
|
||||
text-shadow: none;
|
||||
-webkit-transition: all .12s ease-out;
|
||||
-moz-transition: all .12s ease-out;
|
||||
-o-transition: all .12s ease-out;
|
||||
-ms-transition: all .12s ease-out;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
.NB-sideoption:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
.NB-sideoption:hover .NB-sideoption-icon,
|
||||
.NB-sideoption:hover .NB-sideoption-title,
|
||||
.NB-sideoption.NB-active .NB-sideoption-icon,
|
||||
.NB-sideoption.NB-active .NB-sideoption-title,
|
||||
.NB-story-starred .NB-sideoption.NB-feed-story-save .NB-sideoption-icon,
|
||||
.NB-story-starred .NB-sideoption.NB-feed-story-save .NB-sideoption-title,
|
||||
.NB-story-shared .NB-sideoption.NB-feed-story-share .NB-sideoption-icon,
|
||||
.NB-story-shared .NB-sideoption.NB-feed-story-share .NB-sideoption-title {
|
||||
background-color: #2B478C;
|
||||
color: #D7DDF7;
|
||||
opacity: 1;
|
||||
text-shadow: 0 1px 0 #101010;
|
||||
}
|
||||
.NB-sideoption-share-wrapper {
|
||||
background-color: #EBF6DA;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.NB-sideoption-share {
|
||||
padding: 4px 12px 6px;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-title {
|
||||
text-transform: uppercase;
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
text-shadow: 0 1px 0 #F6F6F6;
|
||||
color: #202020;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost {
|
||||
margin-right: -4px;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-twitter,
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-facebook {
|
||||
float: right;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
margin: 0 0 0 6px;
|
||||
opacity: .4;
|
||||
cursor: pointer;
|
||||
-webkit-filter: grayscale(100%);
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-twitter:hover,
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-facebook:hover {
|
||||
opacity: .7;
|
||||
-webkit-filter: none;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-twitter.NB-active,
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-facebook.NB-active {
|
||||
opacity: 1;
|
||||
-webkit-filter: none;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-twitter {
|
||||
background: transparent url('/media/embed/reader/twitter_icon.png') no-repeat 0 0;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-crosspost-facebook {
|
||||
background: transparent url('/media/embed/reader/facebook_icon.png') no-repeat 0 0;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-comments {
|
||||
width: 100%;
|
||||
height: 52px;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-save {
|
||||
font-size: 10px;
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
color: white;
|
||||
padding: 2px 6px;
|
||||
margin: 2px 0;
|
||||
width: 92%;
|
||||
background-color: #639510;
|
||||
cursor: pointer;
|
||||
-moz-box-shadow: 2px 2px 0 #95AB76;
|
||||
-webkit-box-shadow: 2px 2px 0 #95AB76;
|
||||
box-shadow: 2px 2px 0 #95AB76;
|
||||
text-shadow: 0 1px 0 #101010;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-save.NB-saving {
|
||||
background-color: #b5b4bB;
|
||||
text-shadow: none;
|
||||
}
|
||||
.NB-sideoption-share .NB-sideoption-share-unshare {
|
||||
color: #404040;
|
||||
text-shadow: 0 1px 0 #E0E0E0;
|
||||
line-height: 1;
|
||||
font-size: 11px;
|
||||
padding: 2px 6px;
|
||||
margin: 6px 0;
|
||||
width: 92%;
|
||||
font-weight: normal;
|
||||
-moz-box-shadow: 1px 1px 0 #95AB76;
|
||||
-webkit-box-shadow: 1px 1px 0 #95AB76;
|
||||
box-shadow: 1px 1px 0 #95AB76;
|
||||
}
|
||||
.NB-sideoption-share .NB-error {
|
||||
font-size: 10px;
|
||||
color: #6A1000;
|
||||
padding: 4px 0 0;
|
||||
line-height: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -180,6 +180,7 @@ SESSION_ENGINE = "django.contrib.sessions.backends.db"
|
|||
TEST_RUNNER = "utils.testrunner.TestRunner"
|
||||
SESSION_COOKIE_NAME = 'newsblur_sessionid'
|
||||
SESSION_COOKIE_AGE = 60*60*24*365*2 # 2 years
|
||||
SESSION_COOKIE_DOMAIN = '.newsblur.com'
|
||||
|
||||
# ==============
|
||||
# = Subdomains =
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<title>{{ social_profile.feed_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 }}">
|
||||
<meta name="viewport" content="width=440px">
|
||||
<meta name="viewport" content="width=440">
|
||||
|
||||
{% include_stylesheets "blurblog" %}
|
||||
|
||||
|
@ -125,9 +125,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="NB-story" data-feed-id="{{ story.story_feed_id }}" data-story-id="{{ story.id }}">
|
||||
<div class="NB-story-content">{{ story.story_content|safe }}</div>
|
||||
<div class="NB-story {% if story.saved %}NB-story-saved{% endif %} {% if story.shared_by_user %}NB-story-shared{% endif %}" data-feed-id="{{ story.story_feed_id }}" data-story-id="{{ story.id }}">
|
||||
<div class="NB-story-content">
|
||||
{{ story.story_content|safe }}
|
||||
{% if user.is_authenticated %}
|
||||
<div class="NB-feed-story-sideoptions-container">
|
||||
<div class="NB-sideoption NB-feed-story-save">
|
||||
<div class="NB-sideoption-icon"> </div>
|
||||
<div class="NB-sideoption-title">{% if story.saved %}Saved{% else %}Save this story{% endif %}</div>
|
||||
</div>
|
||||
<div class="NB-sideoption NB-feed-story-share">
|
||||
<div class="NB-sideoption-icon"> </div>
|
||||
<div class="NB-sideoption-title">{% if story.shared_by_user %}Shared{% else %}Post to Blurblog{% endif %}</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if story.share_count %}
|
||||
{% render_story_share story %}
|
||||
|
|
Loading…
Add table
Reference in a new issue