From ccdf7e260bd155f8b2872321d2a38e18ddae5dd5 Mon Sep 17 00:00:00 2001 From: Samuel Clay Date: Wed, 9 Dec 2020 18:20:55 -0500 Subject: [PATCH] Stubbing in dashboard rivers model and loading. Needs attachment to JS models. --- apps/profile/models.py | 37 ++++++++++++++ apps/reader/views.py | 8 +++- config/nginx.local.conf | 6 +++ media/css/reader.css | 2 +- media/js/newsblur/views/dashboard_river.js | 16 ++++++- templates/reader/dashboard.xhtml | 56 +++------------------- templates/reader/dashboard_river.xhtml | 12 +++++ utils/templatetags/utils_tags.py | 9 ++++ 8 files changed, 92 insertions(+), 54 deletions(-) create mode 100644 templates/reader/dashboard_river.xhtml diff --git a/apps/profile/models.py b/apps/profile/models.py index ef2ffd7ab..bc23fe518 100644 --- a/apps/profile/models.py +++ b/apps/profile/models.py @@ -1517,7 +1517,44 @@ class MCustomStyling(mongo.Document): styling.custom_css = css styling.custom_js = js styling.save() + + +class MDashboardRivers(mongo.Document): + user_id = mongo.IntField(unique=True) + left_rivers = mongo.ListField(mongo.StringField()) + right_rivers = mongo.ListField(mongo.StringField()) + + def canonical(self): + return { + 'left_rivers': self.left_rivers, + 'right_rivers': self.right_rivers, + } + + @classmethod + def get_user(cls, user_id): + try: + rivers = cls.objects.get(user_id=user_id) + except cls.DoesNotExist: + return None + return rivers + + @classmethod + def save_user(cls, user_id, left_rivers, right_rivers): + rivers = cls.get_user(user_id) + if not left_rivers and not right_rivers: + if rivers: + rivers.delete() + return + + if not rivers: + rivers = cls.objects.create(user_id=user_id) + + rivers.left_rivers = left_rivers + rivers.right_rivers = right_rivers + rivers.save() + + class RNewUserQueue: KEY = "new_user_queue" diff --git a/apps/reader/views.py b/apps/reader/views.py index cdbcbdaa9..c06ce2ca2 100644 --- a/apps/reader/views.py +++ b/apps/reader/views.py @@ -32,7 +32,7 @@ from apps.analyzer.models import MClassifierTitle, MClassifierAuthor, MClassifie from apps.analyzer.models import apply_classifier_titles, apply_classifier_feeds from apps.analyzer.models import apply_classifier_authors, apply_classifier_tags from apps.analyzer.models import get_classifiers_for_user, sort_classifiers_by_feed -from apps.profile.models import Profile, MCustomStyling +from apps.profile.models import Profile, MCustomStyling, MDashboardRivers from apps.reader.models import UserSubscription, UserSubscriptionFolders, RUserStory, Feature from apps.reader.forms import SignupForm, LoginForm, FeatureForm from apps.rss_feeds.models import MFeedIcon, MStarredStoryCounts, MSavedSearch @@ -119,6 +119,7 @@ def dashboard(request, **kwargs): statistics = MStatistics.all() social_profile = MSocialProfile.get_user(user.pk) custom_styling = MCustomStyling.get_user(user.pk) + dashboard_rivers = MDashboardRivers.get_user(user.pk) preferences = json.decode(user.profile.preferences) if not user.is_active: @@ -133,6 +134,7 @@ def dashboard(request, **kwargs): 'preferences' : preferences, 'feed_count' : feed_count, 'custom_styling' : custom_styling, + 'dashboard_rivers' : dashboard_rivers, 'account_images' : list(range(1, 4)), 'recommended_feeds' : recommended_feeds, 'unmoderated_feeds' : unmoderated_feeds, @@ -324,7 +326,8 @@ def load_feeds(request): social_feeds = MSocialSubscription.feeds(**social_params) social_profile = MSocialProfile.profile(user.pk) social_services = MSocialServices.profile(user.pk) - + dashboard_rivers = MDashboardRivers.get_user(user.pk) + categories = None if not user_subs: categories = MCategory.serialize() @@ -344,6 +347,7 @@ def load_feeds(request): 'starred_count': starred_count, 'starred_counts': starred_counts, 'saved_searches': saved_searches, + 'dashboard_rivers': dashboard_rivers, 'categories': categories } return data diff --git a/config/nginx.local.conf b/config/nginx.local.conf index 126f59e6c..893536fae 100644 --- a/config/nginx.local.conf +++ b/config/nginx.local.conf @@ -26,6 +26,12 @@ server { server_name *.nb.local.com nb.local.com; add_header X-nginx-server nginx_none; + # kill cache + add_header Last-Modified $date_gmt; + add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; + if_modified_since off; + expires off; + # if ($host = 'newsblur.com') { # rewrite ^/(.*)$ https://www.newsblur.com/$1 permanent; # } diff --git a/media/css/reader.css b/media/css/reader.css index 0468a62c1..599c13d8d 100644 --- a/media/css/reader.css +++ b/media/css/reader.css @@ -6505,7 +6505,7 @@ form.opml_import_form input { /* =========================== */ .NB-module-features { - margin-top: 36px; + margin-top: 0; } .NB-account .NB-module, diff --git a/media/js/newsblur/views/dashboard_river.js b/media/js/newsblur/views/dashboard_river.js index 1d30efc04..b31948cab 100644 --- a/media/js/newsblur/views/dashboard_river.js +++ b/media/js/newsblur/views/dashboard_river.js @@ -33,6 +33,20 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({ this.setup_dashboard_refresh(); }, + + options_template: function () { + var $options = $(_.template('
\ + \ +
\ + <%= NEWSBLUR.assets.view_setting(feed_id, "read_filter") %>\ + ·\ + <%= NEWSBLUR.assets.view_setting(feed_id, "order") %>\ +
\ +
'), { + feed_id: this.options.active_feed + }); + + }, feeds: function() { var feeds; @@ -254,4 +268,4 @@ NEWSBLUR.Views.DashboardRiver = Backbone.View.extend({ } -}); \ No newline at end of file +}); diff --git a/templates/reader/dashboard.xhtml b/templates/reader/dashboard.xhtml index 6c1383dc3..ae8dc5a59 100644 --- a/templates/reader/dashboard.xhtml +++ b/templates/reader/dashboard.xhtml @@ -53,45 +53,10 @@ {% if not user_profile.hide_getting_started %} {% render_getting_started %} {% endif %} - -
-
-
- All Site Stories -
- -
-
-
-
-
-
-
-
-
- Infrequent Site Stories -
- -
-
-
-
-
-
- -
-
-
- Global Shared Stories -
- -
-
-
-
-
-
+ {% for dashboard_river in dashboard_rivers.left_rivers %} + {% render_dashboard_river dashboard_river %} + {% endfor %}