generate the <script> and <link> tags dynamically

This commit is contained in:
Damien Churchill 2009-04-16 19:59:34 +00:00
parent 134bed774c
commit 9be54918fb
3 changed files with 49 additions and 40 deletions

View File

@ -7,37 +7,14 @@
<link rel="icon" href="/icons/deluge.png" type="image/png" /> <link rel="icon" href="/icons/deluge.png" type="image/png" />
<!-- Stylesheets --> <!-- Stylesheets -->
<link rel="stylesheet" type="text/css" href="/css/ext-all.css" /> %for stylesheet in stylesheets:
<link rel="stylesheet" type="text/css" href="/css/xtheme-slate.css" /> <link rel="stylesheet" type="text/css" href="${stylesheet}" />
<link rel="stylesheet" type="text/css" href="/css/Spinner.css" /> %endfor
<link rel="stylesheet" type="text/css" href="/css/Roar.css" />
<link rel="stylesheet" type="text/css" href="/css/deluge.css" />
<!-- Javascript --> <!-- Javascript -->
<script type="text/javascript" src="/js/mootools-1.2.1-core-yc.js"></script> %for script in scripts:
<script type="text/javascript" src="/js/ext-mootools-adapter.js"></script> <script type="text/javascript" src="${script}"></script>
%if debug: %endfor
<script type="text/javascript" src="/js/ext-all-debug.js"></script>
%else:
<script type="text/javascript" src="/js/ext-all.js"></script>
%endif
<script type="text/javascript" src="/js/Spinner.js"></script>
<script type="text/javascript" src="/js/SpinnerStrategy.js"></script>
<script type="text/javascript" src="/js/SpinnerPlugin.js"></script>
<script type="text/javascript" src="/js/Roar.js"></script>
<script type="text/javascript" src="/js/rpc.js"></script>
<script type="text/javascript" src="/gettext.js"></script>
<script type="text/javascript" src="/js/deluge.js"></script>
<script type="text/javascript" src="/js/deluge-ext.js"></script>
<script type="text/javascript" src="/js/deluge-login.js"></script>
<script type="text/javascript" src="/js/deluge-menus.js"></script>
<script type="text/javascript" src="/js/deluge-bars.js"></script>
<script type="text/javascript" src="/js/deluge-connections.js"></script>
<script type="text/javascript" src="/js/deluge-torrents.js"></script>
<script type="text/javascript" src="/js/deluge-details.js"></script>
<script type="text/javascript" src="/js/deluge-add.js"></script>
<script type="text/javascript" src="/js/deluge-preferences.js"></script>
<script type="text/javascript" src="/js/deluge-ui.js"></script>
</head> </head>
<body></body> <body></body>
</html> </html>

View File

@ -25,9 +25,6 @@ Copyright:
Deluge.UI = { Deluge.UI = {
initialize: function() { initialize: function() {
this.errorCount = 0; this.errorCount = 0;
this.roar = new Roar({
position: 'lowerRight'
});
Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
this.MainPanel = new Ext.Panel({ this.MainPanel = new Ext.Panel({
id: 'mainPanel', id: 'mainPanel',
@ -55,10 +52,6 @@ Deluge.UI = {
Deluge.Client = new JSON.RPC('/json'); Deluge.Client = new JSON.RPC('/json');
}, },
notify: function(title, message) {
//this.roar.alert(title, message);
},
update: function() { update: function() {
var filters = Deluge.SideBar.getFilters(); var filters = Deluge.SideBar.getFilters();
Deluge.Client.web.update_ui(Deluge.Keys.Grid, filters, { Deluge.Client.web.update_ui(Deluge.Keys.Grid, filters, {

View File

@ -229,6 +229,41 @@ class TopLevel(resource.Resource):
self.putChild("themes", static.File(rpath("themes"))) self.putChild("themes", static.File(rpath("themes")))
self.putChild("tracker", Tracker()) self.putChild("tracker", Tracker())
self.__stylesheets = [
"/css/ext-all.css",
"/css/xtheme-slate.css",
"/css/Spinner.css",
"/css/deluge.css"
]
self.__scripts = [
"/js/mootools-1.2.1-core-yc.js",
"/js/ext-mootools-adapter.js",
"/js/ext-all.js",
"/js/Spinner.js",
"/js/SpinnerStrategy.js",
"/js/rpc.js",
"/gettext.js",
"/js/deluge.js",
"/js/deluge-ext.js",
"/js/deluge-login.js",
"/js/deluge-menus.js",
"/js/deluge-bars.js",
"/js/deluge-connections.js",
"/js/deluge-torrents.js",
"/js/deluge-details.js",
"/js/deluge-add.js",
"/js/deluge-preferences.js",
"/js/deluge-ui.js"
]
@property
def scripts(self):
return self.__scripts
@property
def stylesheets(self):
return self.__stylesheets
def getChild(self, path, request): def getChild(self, path, request):
if path == "": if path == "":
return self return self
@ -236,15 +271,19 @@ class TopLevel(resource.Resource):
return resource.Resource.getChild(self, path, request) return resource.Resource.getChild(self, path, request)
def render(self, request): def render(self, request):
debug = request.args.get('debug', ['false'])[-1] == 'true' scripts = self.scripts[:]
if request.args.get('debug', ['false'])[-1] == 'true':
i = scripts.index("/js/ext-all.js")
scripts[i] = "/js/ext-all-debug.js"
template = Template(filename=rpath("index.html")) template = Template(filename=rpath("index.html"))
request.setHeader("content-type", "text/html; charset=utf-8") request.setHeader("content-type", "text/html; charset=utf-8")
return template.render(debug=debug) return template.render(scripts=scripts, stylesheets=self.stylesheets)
class DelugeWeb(component.Component): class DelugeWeb(component.Component):
def __init__(self): def __init__(self):
super(DelugeWeb, self).__init__("DelugeWeb") super(DelugeWeb, self).__init__("DelugeWeb")
self.site = server.Site(TopLevel()) self.top_level = TopLevel()
self.site = server.Site(self.top_level)
self.config = ConfigManager("web.conf", CONFIG_DEFAULTS) self.config = ConfigManager("web.conf", CONFIG_DEFAULTS)
self.port = self.config["port"] self.port = self.config["port"]
self.web_api = WebApi() self.web_api = WebApi()