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" />
<!-- Stylesheets -->
<link rel="stylesheet" type="text/css" href="/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="/css/xtheme-slate.css" />
<link rel="stylesheet" type="text/css" href="/css/Spinner.css" />
<link rel="stylesheet" type="text/css" href="/css/Roar.css" />
<link rel="stylesheet" type="text/css" href="/css/deluge.css" />
%for stylesheet in stylesheets:
<link rel="stylesheet" type="text/css" href="${stylesheet}" />
%endfor
<!-- Javascript -->
<script type="text/javascript" src="/js/mootools-1.2.1-core-yc.js"></script>
<script type="text/javascript" src="/js/ext-mootools-adapter.js"></script>
%if debug:
<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>
%for script in scripts:
<script type="text/javascript" src="${script}"></script>
%endfor
</head>
<body></body>
</html>

View File

@ -25,9 +25,6 @@ Copyright:
Deluge.UI = {
initialize: function() {
this.errorCount = 0;
this.roar = new Roar({
position: 'lowerRight'
});
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
this.MainPanel = new Ext.Panel({
id: 'mainPanel',
@ -55,10 +52,6 @@ Deluge.UI = {
Deluge.Client = new JSON.RPC('/json');
},
notify: function(title, message) {
//this.roar.alert(title, message);
},
update: function() {
var filters = Deluge.SideBar.getFilters();
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("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):
if path == "":
return self
@ -236,15 +271,19 @@ class TopLevel(resource.Resource):
return resource.Resource.getChild(self, path, 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"))
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):
def __init__(self):
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.port = self.config["port"]
self.web_api = WebApi()