From ff0de896c498a427100bbebdb353f98f5adefa00 Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 4 Apr 2014 15:50:20 +0200 Subject: [PATCH] Cleanup and default charts --- .../core/media/movie/charts/__init__.py | 33 +++++++++++ couchpotato/core/media/movie/charts/main.py | 35 +---------- .../core/media/movie/charts/static/charts.css | 12 ++-- .../core/media/movie/charts/static/charts.js | 58 ++++++++++++------- .../movie/providers/automation/bluray.py | 2 +- .../media/movie/providers/automation/imdb.py | 2 +- 6 files changed, 80 insertions(+), 62 deletions(-) diff --git a/couchpotato/core/media/movie/charts/__init__.py b/couchpotato/core/media/movie/charts/__init__.py index 8b137891..9c673751 100644 --- a/couchpotato/core/media/movie/charts/__init__.py +++ b/couchpotato/core/media/movie/charts/__init__.py @@ -1 +1,34 @@ +from .main import Charts + +def autoload(): + return Charts() + + +config = [{ + 'name': 'charts', + 'groups': [ + { + 'label': 'Charts', + 'description': 'Displays selected charts on the home page', + 'type': 'list', + 'name': 'charts_providers', + 'tab': 'display', + 'options': [ + { + 'name': 'max_items', + 'default': 5, + 'type': 'int', + 'description': 'Maximum number of items displayed from each chart.', + }, + { + 'name': 'update_interval', + 'default': 12, + 'type': 'int', + 'advanced': True, + 'description': '(hours)', + }, + ], + }, + ], +}] diff --git a/couchpotato/core/media/movie/charts/main.py b/couchpotato/core/media/movie/charts/main.py index 467eecc3..e6c4b043 100644 --- a/couchpotato/core/media/movie/charts/main.py +++ b/couchpotato/core/media/movie/charts/main.py @@ -1,13 +1,13 @@ import time +from couchpotato import tryInt from couchpotato.core.logger import CPLog from couchpotato.api import addApiView from couchpotato.core.event import addEvent,fireEvent from couchpotato.core.plugins.base import Plugin -log = CPLog(__name__) -autoload = 'Charts' +log = CPLog(__name__) class Charts(Plugin): @@ -51,39 +51,10 @@ class Charts(Plugin): try: self.update_in_progress = True charts = fireEvent('automation.get_chart_list', merge = True) - self.setCache('charts_cached', charts, timeout = 2*3600*self.conf('update_interval', default = 12)) + self.setCache('charts_cached', charts, timeout = 7200 * tryInt(self.conf('update_interval', default = 12))) except: log.error('Failed refreshing charts') self.update_in_progress = False return charts - - -config = [{ - 'name': 'charts', - 'groups': [ - { - 'label': 'Charts', - 'description': 'Displays selected charts on the home page', - 'type': 'list', - 'name': 'charts_providers', - 'tab': 'display', - 'options': [ - { - 'name': 'max_items', - 'default': 10, - 'type': 'int', - 'description': 'Maximum number of items displayed from each chart.', - }, - { - 'name': 'update_interval', - 'default': 12, - 'type': 'int', - 'advanced': True, - 'description': '(hours)', - }, - ], - }, - ], -}] diff --git a/couchpotato/core/media/movie/charts/static/charts.css b/couchpotato/core/media/movie/charts/static/charts.css index 0527bda3..da962a45 100644 --- a/couchpotato/core/media/movie/charts/static/charts.css +++ b/couchpotato/core/media/movie/charts/static/charts.css @@ -15,7 +15,6 @@ .charts div.refresh { margin-top: 10px; clear:both; - background-color: rgba(255,255,255,0.1); text-align:center; } @@ -169,14 +168,10 @@ color: white; position: absolute; top: 0; - background: rgb(0, 0, 0); /* fallback color */ - background: rgba(0, 0, 0, 0.3); padding: 10px; - border-bottom-left-radius: 6px; - border-top-left-radius: 6px; font: bold 2em/1em Helvetica, Sans-Serif; width: 50px; - height: 60px; + height: 100%; } .charts .chart .media_result div.chart_number.chart_in_wanted { @@ -220,18 +215,19 @@ display: block; width: 50%; float: left; - color: #fff; + color: rgba(255,255,255,.6); border-bottom: 1px solid rgba(255, 255, 255, 0.0666667); - text-align: center; } .toggle_menu a:hover { border-color: #047792; border-width: 4px; + color: #fff; } .toggle_menu a.active { border-bottom: 4px solid #04bce6; + color: #fff; } .toggle_menu a:last-child { diff --git a/couchpotato/core/media/movie/charts/static/charts.js b/couchpotato/core/media/movie/charts/static/charts.js index 06cf9c88..5b453691 100644 --- a/couchpotato/core/media/movie/charts/static/charts.js +++ b/couchpotato/core/media/movie/charts/static/charts.js @@ -12,25 +12,43 @@ var Charts = new Class({ create: function(){ var self = this; - self.el_refreshing_text = new Element('span.refreshing', {'text': 'Refreshing charts...'}); - self.el_refresh_link = new Element('a.refresh', { 'href': '#', 'text': 'Refresh charts', 'events': { 'click': function(e) { - e.preventDefault(); - self.el.getChildren('div.chart').destroy(); - self.el_refreshing_text.show(); - self.el_refresh_link.hide(); - self.api_request = Api.request('charts.view', { - 'data': { 'force_update': 1 }, - 'onComplete': self.fill.bind(self) - }); - }}}).hide(); - self.el_refresh_container = new Element('div.refresh').grab( self.el_refreshing_text ).grab( self.el_refresh_link ); - self.el_no_charts_enabled = new Element('p.no_charts_enabled', { - 'html':'Hey, it looks like you have no charts enabled at the moment. If you\'d like some great movie suggestions you can go to settings and turn on some charts of your choice.' + self.el_refreshing_text = new Element('span.refreshing', { + 'text': 'Refreshing charts...' + }); + + self.el_refresh_link = new Element('a.refresh', { + 'href': '#', + 'text': 'Refresh charts', + 'events': { + 'click': function(e) { + e.preventDefault(); + self.el.getChildren('div.chart').destroy(); + self.el_refreshing_text.show(); + self.el_refresh_link.hide(); + self.api_request = Api.request('charts.view', { + 'data': { 'force_update': 1 }, + 'onComplete': self.fill.bind(self) + }); + } + } }).hide(); - self.el = new Element('div.charts').grab(self.el_no_charts_enabled).grab( self.el_refresh_container ); + self.el_refresh_container = new Element('div.refresh').grab( + self.el_refreshing_text + ).grab(self.el_refresh_link); - if( Cookie.read('suggestions_charts_menu_selected') === 'charts') self.el.show(); else self.el.hide(); + self.el_no_charts_enabled = new Element('p.no_charts_enabled', { + 'html': 'Hey, it looks like you have no charts enabled at the moment. If you\'d like some great movie suggestions you can go to settings and turn on some charts of your choice.' + }).hide(); + + self.el = new Element('div.charts').grab( + self.el_no_charts_enabled + ).grab(self.el_refresh_container); + + if( Cookie.read('suggestions_charts_menu_selected') === 'charts') + self.el.show(); + else + self.el.hide(); self.api_request = Api.request('charts.view', { 'onComplete': self.fill.bind(self) @@ -50,8 +68,7 @@ var Charts = new Class({ self.el_refresh_link.show(); self.el_refreshing_text.hide(); } - else - { + else { self.el_no_charts_enabled.hide(); json.charts.sort(function(a, b) { @@ -136,8 +153,9 @@ var Charts = new Class({ afterAdded: function(m, movie){ var self = this; - $(m).getElement('div.chart_number').addClass('chart_in_wanted').setProperty('title','Movie in wanted list'); - + $(m).getElement('div.chart_number') + .addClass('chart_in_wanted') + .set('title', 'Movie in wanted list'); }, diff --git a/couchpotato/core/media/movie/providers/automation/bluray.py b/couchpotato/core/media/movie/providers/automation/bluray.py index 15702b90..55114fd3 100644 --- a/couchpotato/core/media/movie/providers/automation/bluray.py +++ b/couchpotato/core/media/movie/providers/automation/bluray.py @@ -138,7 +138,7 @@ config = [{ 'options': [ { 'name': 'chart_display_enabled', - 'default': False, + 'default': True, 'type': 'enabler', }, ], diff --git a/couchpotato/core/media/movie/providers/automation/imdb.py b/couchpotato/core/media/movie/providers/automation/imdb.py index 2f126bab..0f2e2940 100644 --- a/couchpotato/core/media/movie/providers/automation/imdb.py +++ b/couchpotato/core/media/movie/providers/automation/imdb.py @@ -265,7 +265,7 @@ config = [{ 'options': [ { 'name': 'chart_display_enabled', - 'default': False, + 'default': True, 'type': 'enabler', }, {