Make clientside ordered

This commit is contained in:
Ruud
2014-04-09 19:29:30 +02:00
parent 4776cef473
commit 6ea49405f4
13 changed files with 38 additions and 34 deletions

View File

@@ -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']

View File

@@ -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;

View File

@@ -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'
})
)

View File

@@ -1,4 +1,4 @@
Block.Search.MovieItem = new Class({
var BlockSearchMovieItem = new Class({
Implements: [Options, Events],

View File

@@ -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)
}

View File

@@ -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)
}

View File

@@ -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)

View File

@@ -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();
}

View File

@@ -35,5 +35,3 @@ var BlockBase = new Class({
}
});
var Block = BlockBase;

View File

@@ -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');
}
});
});

View File

@@ -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');
}
});
});

View File

@@ -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({
}
});
});

View File

@@ -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 = [