From 6ea49405f4e76dcb5520b9d8caeda8dbb2dd9dca Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 9 Apr 2014 19:29:30 +0200 Subject: [PATCH] Make clientside ordered --- couchpotato/core/_base/clientscript.py | 26 ++++++++++++------- .../core/media/_base/search/static/search.js | 4 +-- .../core/media/movie/_base/static/list.js | 4 +-- .../core/media/movie/_base/static/search.js | 2 +- .../core/media/movie/charts/static/charts.js | 2 +- .../media/movie/suggestion/static/suggest.js | 2 +- .../notifications/core/static/notification.js | 2 +- .../plugins/userscript/static/userscript.js | 2 +- couchpotato/static/scripts/block.js | 2 -- couchpotato/static/scripts/block/footer.js | 4 +-- couchpotato/static/scripts/block/menu.js | 4 +-- .../static/scripts/block/navigation.js | 8 +++--- couchpotato/static/scripts/couchpotato.js | 10 +++---- 13 files changed, 38 insertions(+), 34 deletions(-) diff --git a/couchpotato/core/_base/clientscript.py b/couchpotato/core/_base/clientscript.py index 58d1ffdd..c71185b2 100644 --- a/couchpotato/core/_base/clientscript.py +++ b/couchpotato/core/_base/clientscript.py @@ -130,7 +130,9 @@ class ClientScript(Plugin): data_combined = '' raw = [] - for file_path in paths: + new_paths = [] + for x in paths: + file_path, urls = x f = open(file_path, 'r').read() @@ -145,13 +147,14 @@ class ClientScript(Plugin): if Env.get('dev'): self.watcher.watch(file_path, self.compile) - url_path = paths[file_path].get('original_url') + url_path = urls.get('original_url') compiled_file_name = position + '_%s.css' % url_path.replace('/', '_').split('.scss')[0] compiled_file_path = os.path.join(minified_dir, compiled_file_name) self.createFile(compiled_file_path, f.strip()) # Remove scss path - paths[file_path]['url'] = 'minified/%s?%s' % (compiled_file_name, tryInt(time.time())) + urls['url'] = 'minified/%s?%s' % (compiled_file_name, tryInt(time.time())) + new_paths.append((file_path, urls)) if not Env.get('dev'): @@ -165,16 +168,19 @@ class ClientScript(Plugin): data_combined += self.comment.get(file_type) % (ss(file_path), int(os.path.getmtime(file_path))) data_combined += data + '\n\n' - - del paths[file_path] + else: + new_paths.append(x) # Combine all files together with some comments if not Env.get('dev'): - self.createFile(os.path.join(minified_dir, out_name), data_combined.strip()) + out_path = os.path.join(minified_dir, out_name) + self.createFile(out_path, data_combined.strip()) minified_url = 'minified/%s?%s' % (out_name, tryInt(os.path.getmtime(out))) - self.minified[file_type][position].append(minified_url) + new_paths.append((out_path, {'url': minified_url})) + + self.paths[file_type][position] = new_paths def getStyles(self, *args, **kwargs): return self.get('style', *args, **kwargs) @@ -184,7 +190,7 @@ class ClientScript(Plugin): def get(self, type, location = 'head'): paths = self.paths[type][location] - return [paths[x].get('url', paths[x].get('original_url')) for x in paths] + return [x[1].get('url', x[1].get('original_url')) for x in paths] def registerStyle(self, api_path, file_path, position = 'head'): self.register(api_path, file_path, 'style', position) @@ -197,8 +203,8 @@ class ClientScript(Plugin): api_path = '%s?%s' % (api_path, tryInt(os.path.getmtime(file_path))) if not self.paths[type].get(location): - self.paths[type][location] = {} - self.paths[type][location][file_path] = {'original_url': api_path} + self.paths[type][location] = [] + self.paths[type][location].append((file_path, {'original_url': api_path})) prefix_properties = ['border-radius', 'transform', 'transition', 'box-shadow'] prefix_tags = ['ms', 'moz', 'webkit'] diff --git a/couchpotato/core/media/_base/search/static/search.js b/couchpotato/core/media/_base/search/static/search.js index 1892ad1e..8b8f2a58 100644 --- a/couchpotato/core/media/_base/search/static/search.js +++ b/couchpotato/core/media/_base/search/static/search.js @@ -1,4 +1,4 @@ -Block.Search = new Class({ +var BlockSearch = new Class({ Extends: BlockBase, @@ -157,7 +157,7 @@ Block.Search = new Class({ if(typeOf(media) == 'array'){ Object.each(media, function(m){ - var m = new Block.Search[m.type.capitalize() + 'Item'](m); + var m = new BlockSearch[m.type.capitalize() + 'Item'](m); $(m).inject(self.results); self.media[m.imdb || 'r-'+Math.floor(Math.random()*10000)] = m; diff --git a/couchpotato/core/media/movie/_base/static/list.js b/couchpotato/core/media/movie/_base/static/list.js index 91207505..9310ce1a 100644 --- a/couchpotato/core/media/movie/_base/static/list.js +++ b/couchpotato/core/media/movie/_base/static/list.js @@ -230,7 +230,7 @@ var MovieList = new Class({ ), new Element('div.menus').adopt( self.navigation_counter = new Element('span.counter[title=Total]'), - self.filter_menu = new Block.Menu(self, { + self.filter_menu = new BlockMenu(self, { 'class': 'filter' }), self.navigation_actions = new Element('ul.actions', { @@ -249,7 +249,7 @@ var MovieList = new Class({ } } }), - self.navigation_menu = new Block.Menu(self, { + self.navigation_menu = new BlockMenu(self, { 'class': 'extra' }) ) diff --git a/couchpotato/core/media/movie/_base/static/search.js b/couchpotato/core/media/movie/_base/static/search.js index 3b426762..0fa17417 100644 --- a/couchpotato/core/media/movie/_base/static/search.js +++ b/couchpotato/core/media/movie/_base/static/search.js @@ -1,4 +1,4 @@ -Block.Search.MovieItem = new Class({ +var BlockSearchMovieItem = new Class({ Implements: [Options, Events], diff --git a/couchpotato/core/media/movie/charts/static/charts.js b/couchpotato/core/media/movie/charts/static/charts.js index 00033f4a..079eabf6 100644 --- a/couchpotato/core/media/movie/charts/static/charts.js +++ b/couchpotato/core/media/movie/charts/static/charts.js @@ -83,7 +83,7 @@ var Charts = new Class({ Object.each(chart.list, function(movie){ - var m = new Block.Search.MovieItem(movie, { + var m = new BlockSearchMovieItem(movie, { 'onAdded': function(){ self.afterAdded(m, movie) } diff --git a/couchpotato/core/media/movie/suggestion/static/suggest.js b/couchpotato/core/media/movie/suggestion/static/suggest.js index 494f0459..5156337d 100644 --- a/couchpotato/core/media/movie/suggestion/static/suggest.js +++ b/couchpotato/core/media/movie/suggestion/static/suggest.js @@ -64,7 +64,7 @@ var SuggestList = new Class({ Object.each(json.suggestions, function(movie){ - var m = new Block.Search.MovieItem(movie, { + var m = new BlockSearchMovieItem(movie, { 'onAdded': function(){ self.afterAdded(m, movie) } diff --git a/couchpotato/core/notifications/core/static/notification.js b/couchpotato/core/notifications/core/static/notification.js index 81bf9500..3b2bc618 100644 --- a/couchpotato/core/notifications/core/static/notification.js +++ b/couchpotato/core/notifications/core/static/notification.js @@ -20,7 +20,7 @@ var NotificationBase = new Class({ self.notifications = []; App.addEvent('load', function(){ - App.block.notification = new Block.Menu(self, { + App.block.notification = new BlockMenu(self, { 'button_class': 'icon2.eye-open', 'class': 'notification_menu', 'onOpen': self.markAsRead.bind(self) diff --git a/couchpotato/core/plugins/userscript/static/userscript.js b/couchpotato/core/plugins/userscript/static/userscript.js index 2ef1ea6a..71543d51 100644 --- a/couchpotato/core/plugins/userscript/static/userscript.js +++ b/couchpotato/core/plugins/userscript/static/userscript.js @@ -34,7 +34,7 @@ Page.Userscript = new Class({ if(json.error) self.frame.set('html', json.error); else { - var item = new Block.Search.MovieItem(json.movie); + var item = new BlockSearchMovieItem(json.movie); self.frame.adopt(item); item.showOptions(); } diff --git a/couchpotato/static/scripts/block.js b/couchpotato/static/scripts/block.js index 7407b7fe..487c384a 100644 --- a/couchpotato/static/scripts/block.js +++ b/couchpotato/static/scripts/block.js @@ -35,5 +35,3 @@ var BlockBase = new Class({ } }); - -var Block = BlockBase; \ No newline at end of file diff --git a/couchpotato/static/scripts/block/footer.js b/couchpotato/static/scripts/block/footer.js index acec1585..619922fd 100644 --- a/couchpotato/static/scripts/block/footer.js +++ b/couchpotato/static/scripts/block/footer.js @@ -1,4 +1,4 @@ -Block.Footer = new Class({ +var BlockFooter = new Class({ Extends: BlockBase, @@ -8,4 +8,4 @@ Block.Footer = new Class({ self.el = new Element('div.footer'); } -}); \ No newline at end of file +}); diff --git a/couchpotato/static/scripts/block/menu.js b/couchpotato/static/scripts/block/menu.js index 91e29a23..b36c4e85 100644 --- a/couchpotato/static/scripts/block/menu.js +++ b/couchpotato/static/scripts/block/menu.js @@ -1,4 +1,4 @@ -Block.Menu = new Class({ +var BlockMenu = new Class({ Extends: BlockBase, @@ -52,4 +52,4 @@ Block.Menu = new Class({ return new Element('li').adopt(tab).inject(self.more_option_ul, position || 'bottom'); } -}); \ No newline at end of file +}); diff --git a/couchpotato/static/scripts/block/navigation.js b/couchpotato/static/scripts/block/navigation.js index f5642df2..a9e9f514 100644 --- a/couchpotato/static/scripts/block/navigation.js +++ b/couchpotato/static/scripts/block/navigation.js @@ -1,4 +1,4 @@ -Block.Navigation = new Class({ +var BlockNavigation = new Class({ Extends: BlockBase, @@ -38,7 +38,7 @@ Block.Navigation = new Class({ self.backtotop.fade('in') } }); - + self.nav.addEvents({ 'click:relay(a)': function(){ if($(document.body).getParent().hasClass('menu_shown')) @@ -70,7 +70,7 @@ Block.Navigation = new Class({ if(nr <= 2) return; if(el.get('tag') == 'a') self.nav.grab(new Element('li').grab(el.clone().cloneEvents(el))); - else + else self.nav.grab(new Element('li.separator')); }); @@ -89,4 +89,4 @@ Block.Navigation = new Class({ } -}); \ No newline at end of file +}); diff --git a/couchpotato/static/scripts/couchpotato.js b/couchpotato/static/scripts/couchpotato.js index ffc0e9aa..f6f7db85 100644 --- a/couchpotato/static/scripts/couchpotato.js +++ b/couchpotato/static/scripts/couchpotato.js @@ -69,18 +69,18 @@ createLayout: function(){ var self = this; - self.block.header = new Block(); + self.block.header = new BlockBase(); self.c.adopt( $(self.block.header).addClass('header').adopt( new Element('div').adopt( - self.block.navigation = new Block.Navigation(self, {}), - self.block.search = new Block.Search(self, {}), - self.block.more = new Block.Menu(self, {'button_class': 'icon2.cog'}) + self.block.navigation = new BlockNavigation(self, {}), + self.block.search = new BlockSearch(self, {}), + self.block.more = new BlockMenu(self, {'button_class': 'icon2.cog'}) ) ), self.content = new Element('div.content'), - self.block.footer = new Block.Footer(self, {}) + self.block.footer = new BlockFooter(self, {}) ); var setting_links = [