From 4d5d31a2b0886289fad58a7aafef8ace1d708ff4 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Sun, 28 Mar 2010 03:36:51 +0100 Subject: [PATCH] add support for defining order via a .order file --- deluge/ui/web/js/deluge-all/.order | 1 + .../{00OptionsManager.js => OptionsManager.js} | 0 deluge/ui/web/server.py | 17 +++++++++++++++++ 3 files changed, 18 insertions(+) create mode 100644 deluge/ui/web/js/deluge-all/.order rename deluge/ui/web/js/deluge-all/{00OptionsManager.js => OptionsManager.js} (100%) diff --git a/deluge/ui/web/js/deluge-all/.order b/deluge/ui/web/js/deluge-all/.order new file mode 100644 index 000000000..7c2a1533d --- /dev/null +++ b/deluge/ui/web/js/deluge-all/.order @@ -0,0 +1 @@ ++ OptionsManager.js diff --git a/deluge/ui/web/js/deluge-all/00OptionsManager.js b/deluge/ui/web/js/deluge-all/OptionsManager.js similarity index 100% rename from deluge/ui/web/js/deluge-all/00OptionsManager.js rename to deluge/ui/web/js/deluge-all/OptionsManager.js diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index ed6e4ad7a..eefd06774 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -359,6 +359,23 @@ class ScriptResource(resource.Resource, component.Component): for dirpath, dirnames, filenames in os.walk(filepath, False): files = fnmatch.filter(filenames, "*.js") files.sort() + + order_file = os.path.join(dirpath, '.order') + if os.path.isfile(order_file): + for line in open(order_file, 'rb'): + line = line.strip() + if not line or line[0] == '#': + continue + try: + pos, filename = line.split() + files.pop(files.index(filename)) + if pos == '+': + files.insert(0, filename) + else: + files.append(filename) + except: + pass + dirpath = dirpath[len(filepath)+1:] if dirpath: scripts.extend(['js/' + path + '/' + dirpath + '/' + f for f in files])