Formatting starred stories in starred stories view.

This commit is contained in:
Samuel Clay 2010-12-04 13:32:13 -05:00
parent f5f82a68f0
commit 06d95d4c76
3 changed files with 48 additions and 15 deletions

View file

@ -379,8 +379,10 @@ def load_starred_stories(request):
for story in stories:
story_date = localtime_for_timezone(story['story_date'], user.profile.timezone)
starred_date = localtime_for_timezone(story['starred_date'], user.profile.timezone)
story['short_parsed_date'] = format_story_link_date__short(story_date)
story['long_parsed_date'] = format_story_link_date__long(story_date)
story['starred_date'] = format_story_link_date__long(starred_date)
story['read_status'] = 1
story['starred'] = True
story['intelligence'] = {
@ -761,6 +763,7 @@ def mark_story_as_starred(request):
now = datetime.datetime.now()
story_values = dict(user_id=request.user.pk, starred_date=now, **story_db)
MStarredStory.objects.create(**story_values)
logging.info(' ---> [%s] Starring: %s' % (request.user, story.story_title[:50]))
else:
code = -1
@ -775,7 +778,9 @@ def mark_story_as_unstarred(request):
starred_story = MStarredStory.objects(user_id=request.user.pk, story_guid=story_id)
if starred_story:
starred_story.delete()
logging.info(' ---> [%s] Unstarring: %s' % (request.user, starred_story.story_title[:50]))
else:
code = -1
return {'code': code}
return {'code': code}

View file

@ -992,6 +992,9 @@ background: transparent;
background: transparent url('../img/icons/silk/bullet_red.png') no-repeat 14px 50%;
}
#story_titles .story.NB-story-starred {
background-position: 24px 50%;
}
#story_titles .story.NB-hover {
background: #f0f0f0;
}
@ -1218,7 +1221,10 @@ background: transparent;
width: 16px;
height: 16px;
}
#story_pane .NB-feed-story.NB-starred-story .NB-feed-story-sentiment {
display: none;
}
#story_pane .NB-feed-story.NB-story-positive .NB-feed-story-sentiment {
background: transparent url('../img/icons/silk/bullet_green.png') no-repeat 0 0;
}
@ -1264,6 +1270,15 @@ background: transparent;
font-size: 11px;
}
#story_pane .NB-feed-story-header .NB-feed-story-starred-date {
position: absolute;
right: 28px;
top: 26px;
font-size: 11px;
background: transparent url('../img/reader/star_blue.png') no-repeat 0 0;
padding-left: 20px;
}
#story_pane .NB-feed-story-content {
margin: 0 140px 32px 28px;
padding: 12px 0px;

View file

@ -1326,13 +1326,18 @@
$story_titles.empty().scrollTop('0px');
this.reset_feed();
this.hide_splash_page();
this.active_feed = 'starred';
$story_titles.data('page', 0);
$story_titles.data('feed_id', null);
this.iframe_scroll = null;
this.mark_feed_as_selected(null, null);
this.$s.$starred_header.addClass('NB-selected');
this.set_correct_story_view_for_feed(null, 'feed');
var explicit_view_setting = NEWSBLUR.Preferences.view_settings[this.active_feed];
if (!explicit_view_setting) {
explicit_view_setting = 'feed';
}
this.set_correct_story_view_for_feed(this.active_feed, explicit_view_setting);
// this.show_feed_title_in_stories(feed_id);
this.show_feedbar_loading();
// this.make_content_pane_feed_counter(feed_id);
@ -1343,13 +1348,13 @@
},
post_open_starred_stories: function(data, first_load) {
if (this.active_feed == null) {
if (this.active_feed == 'starred') {
// NEWSBLUR.log(['post_open_starred_stories', data.stories, first_load]);
this.flags['feed_view_positions_calculated'] = false;
this.story_titles_clear_loading_endbar();
this.create_story_titles(data.stories);
this.hover_over_story_titles();
this.make_story_feed_entries(data.stories, first_load);
this.make_story_feed_entries(data.stories, first_load, {'starred_stories': true});
this.show_correct_stories_in_page_and_feed_view();
// $('.NB-feedbar-last-updated-date').text(data.last_update + ' ago');
this.flags['story_titles_loaded'] = true;
@ -1762,9 +1767,10 @@
mark_story_as_starred: function(story_id, $button) {
// $button.attr({'title': 'Saving...'});
// $button.tipsy({'title': 'Saving...'});
var story = this.model.get_story(story_id);
$button.removeClass('NB-unstarred');
$button.closest('.story').addClass('NB-story-starred');
this.model.mark_story_as_starred(story_id, this.active_feed, function() {
this.model.mark_story_as_starred(story_id, story.story_feed_id, function() {
// $button.attr({'title': 'Saved!'});
// $button.tipsy({'title': 'Saved!'});
});
@ -2082,7 +2088,7 @@
if (!this.flags['opening_feed']) {
this.show_feedbar_loading();
$story_titles.data('page', page+1);
if (this.active_feed == null) {
if (this.active_feed == 'starred') {
this.model.fetch_starred_stories(page+1,
_.bind(this.post_open_starred_stories, this), false);
} else {
@ -2190,12 +2196,14 @@
// = Story Pane - Feed View =
// ==========================
make_story_feed_entries: function(stories, first_load, refresh_load) {
make_story_feed_entries: function(stories, first_load, options) {
var $feed_view = this.$s.$feed_view;
var self = this;
var unread_view = this.model.preference('unread_view');
var $stories;
options = options || {};
if (first_load) {
$stories = $.make('ul', { className: 'NB-feed-stories' });
$feed_view.empty();
@ -2203,7 +2211,7 @@
$feed_view.append($stories);
} else {
$stories = $('.NB-feed-stories', $feed_view);
if (!refresh_load) {
if (!options.refresh_load) {
$('.NB-feed-story-endbar', $feed_view).remove();
}
}
@ -2211,14 +2219,17 @@
for (var s in stories) {
var story = stories[s];
var read = story.read_status
? 'read'
? ' read '
: '';
var score = this.compute_story_score(story);
var score_color = 'neutral';
var starred_stories = options.starred_stories
? ' NB-starred-story '
: '';
if (score > 0) score_color = 'positive';
if (score < 0) score_color = 'negative';
var $story = $.make('li', { className: 'NB-feed-story ' + read + ' NB-story-' + score_color }, [
var $story = $.make('li', { className: 'NB-feed-story ' + read + starred_stories + ' NB-story-' + score_color }, [
$.make('div', { className: 'NB-feed-story-header' }, [
$.make('div', { className: 'NB-feed-story-sentiment' }),
( story.story_authors &&
@ -2228,7 +2239,9 @@
$.make('a', { className: 'NB-feed-story-title', href: story.story_permalink }, story.story_title)
]),
( story.long_parsed_date &&
$.make('span', { className: 'NB-feed-story-date' }, story.long_parsed_date))
$.make('span', { className: 'NB-feed-story-date' }, story.long_parsed_date)),
( story.starred_date &&
$.make('span', { className: 'NB-feed-story-starred-date' }, story.starred_date))
]),
$.make('div', { className: 'NB-feed-story-content' }, story.story_content)
]).data('story', story.id);
@ -2237,7 +2250,7 @@
$('a', $story).attr('target', '_blank');
}
if (refresh_load) {
if (options.refresh_load) {
$stories.prepend($story);
} else {
$stories.append($story);
@ -3129,7 +3142,7 @@
}
}
if (new_stories.length) {
this.make_story_feed_entries(new_stories, false, true);
this.make_story_feed_entries(new_stories, false, {'refresh_load': true});
this.hover_over_story_titles();
this.flags['feed_view_positions_calculated'] = false;
}