webui:apache,allow relative urls
This commit is contained in:
parent
0ee52a17fe
commit
cf8f7f0376
|
@ -36,7 +36,7 @@ from deluge.ui.client import sclient as proxy
|
|||
from deluge.log import LOG as log
|
||||
|
||||
from render import render
|
||||
from web import seeother
|
||||
from utils import seeother
|
||||
import sys
|
||||
import os
|
||||
import utils
|
||||
|
|
|
@ -79,11 +79,9 @@ config_forms.register()
|
|||
#/self registering pages.
|
||||
|
||||
|
||||
utils.set_config_defaults()
|
||||
sclient.set_core_uri(config.get('daemon'))
|
||||
|
||||
|
||||
def WsgiApplication(middleware):
|
||||
def WsgiApplication(middleware = None):
|
||||
if not middleware:
|
||||
middleware = []
|
||||
from web import webpyfunc, wsgifunc
|
||||
from deluge import component
|
||||
|
||||
|
@ -92,17 +90,21 @@ def WsgiApplication(middleware):
|
|||
|
||||
def WebServer(debug = False):
|
||||
"starts builtin webserver"
|
||||
|
||||
utils.set_config_defaults()
|
||||
config.set('base','')
|
||||
config.set('disallow',{})
|
||||
utils.apply_config()
|
||||
|
||||
import web
|
||||
|
||||
from lib.gtk_cherrypy_wsgiserver import CherryPyWSGIServer
|
||||
|
||||
|
||||
if debug:
|
||||
middleware = [web.reloader]
|
||||
else:
|
||||
middleware = []
|
||||
|
||||
|
||||
wsgi_app = WsgiApplication(middleware)
|
||||
|
||||
server_address=("0.0.0.0", int(config.get('port')))
|
||||
|
@ -116,6 +118,9 @@ def WebServer(debug = False):
|
|||
print "http://%s:%d/" % server_address
|
||||
return server
|
||||
|
||||
def mod_wsgi_application(sub_dir, config_dir , template_dir):
|
||||
pass
|
||||
|
||||
def run(debug = False):
|
||||
server = WebServer(debug)
|
||||
try:
|
||||
|
|
|
@ -7,7 +7,7 @@ static fileserving for web.py
|
|||
without the need for wsgi wrapper magic.
|
||||
"""
|
||||
import web
|
||||
from web import seeother, url
|
||||
from web import url
|
||||
|
||||
import posixpath
|
||||
import urlparse
|
||||
|
|
|
@ -10,8 +10,9 @@ from deluge.log import LOG as log
|
|||
#/relative
|
||||
|
||||
from web import cookies, setcookie as w_setcookie
|
||||
from web import seeother, url
|
||||
from web import changequery as self_url
|
||||
from web import url, changequery
|
||||
from utils import self_url
|
||||
from render import error_page
|
||||
|
||||
#deco's:
|
||||
def deluge_page_noauth(func):
|
||||
|
@ -28,20 +29,32 @@ def deluge_page_noauth(func):
|
|||
|
||||
def check_session(func):
|
||||
"""
|
||||
1:check session
|
||||
2:block urls in config.disallow
|
||||
return func if session is valid, else redirect to login page.
|
||||
mostly used for POST-pages.
|
||||
"""
|
||||
def deco(self, name = None):
|
||||
log.debug('%s.%s(name=%s)' % (self.__class__.__name__, func.__name__,
|
||||
name))
|
||||
#check disallow config
|
||||
current_url = changequery()
|
||||
for blocked in utils.config["disallow"]:
|
||||
if current_url.startswith(blocked):
|
||||
return error_page("Not allowed to : '%s' , Reason: '%s'" %
|
||||
(blocked , utils.config["disallow"][blocked]))
|
||||
#/check disallow
|
||||
|
||||
#check session:
|
||||
vars = web.input(redir_after_login = None)
|
||||
ck = cookies()
|
||||
if ck.has_key("session_id") and ck["session_id"] in utils.SESSIONS:
|
||||
return func(self, name) #check_session:ok
|
||||
elif vars.redir_after_login:
|
||||
seeother(url("/login",redir=self_url()))
|
||||
utils.seeother(url("/login",redir=self_url()))
|
||||
else:
|
||||
seeother("/login") #do not continue, and redirect to login page
|
||||
utils.seeother("/login") #do not continue, and redirect to login page
|
||||
#/check session
|
||||
deco.__name__ = func.__name__
|
||||
return deco
|
||||
|
||||
|
@ -56,9 +69,7 @@ def check_connected(func):
|
|||
if connected:
|
||||
return func(self, name) #check_connected:ok
|
||||
else:
|
||||
seeother("/connect")
|
||||
|
||||
|
||||
utils.seeother("/connect")
|
||||
deco.__name__ = func.__name__
|
||||
return deco
|
||||
|
||||
|
@ -122,3 +133,16 @@ def remote(func):
|
|||
print traceback.format_exc()
|
||||
deco.__name__ = func.__name__
|
||||
return deco
|
||||
|
||||
"""
|
||||
obsolete: -> using check-session.
|
||||
def check_allowed(capability):
|
||||
def check_allowed_inner(func):
|
||||
def deco(self, name = None): #check allowed (capablity)
|
||||
if capability in config.get("disallow"):
|
||||
return error_page("Not allowed to: '%s' , because:'%s'"
|
||||
% (capability , config.get("disallow")[capability]))
|
||||
return func(self, name)
|
||||
return deco
|
||||
return check_allowed_inner
|
||||
"""
|
|
@ -43,7 +43,7 @@ from deluge.common import get_pixmap
|
|||
from deluge.log import LOG as log
|
||||
|
||||
import web
|
||||
from web import seeother, url
|
||||
from web import url
|
||||
from lib.static_handler import static_handler
|
||||
|
||||
from operator import attrgetter
|
||||
|
@ -74,9 +74,10 @@ class login:
|
|||
start_session()
|
||||
do_redirect()
|
||||
elif vars.redir:
|
||||
seeother(url('/login', error=1, redir=vars.redir))
|
||||
utils.seeother(url('/login', error=1, redir=vars.redir))
|
||||
else:
|
||||
seeother('/login?error=1')
|
||||
utils.seeother('/login?error=1')
|
||||
|
||||
route('/login',login)
|
||||
|
||||
class index:
|
||||
|
@ -259,7 +260,7 @@ class logout:
|
|||
@deco.check_session
|
||||
def POST(self, name):
|
||||
end_session()
|
||||
seeother('/login')
|
||||
utils.seeother('/login')
|
||||
route('/logout', logout)
|
||||
|
||||
class connect:
|
||||
|
@ -304,7 +305,7 @@ class daemon_control:
|
|||
else:
|
||||
raise Exception('Unknown command:"%s"' % command)
|
||||
|
||||
seeother('/connect')
|
||||
utils.seeother('/connect')
|
||||
|
||||
def start(self):
|
||||
import time
|
||||
|
@ -388,3 +389,13 @@ class pixmaps:
|
|||
web.header("Cache-Control" , "public, must-revalidate, max-age=86400")
|
||||
print content
|
||||
route("/pixmaps/(.*)", pixmaps)
|
||||
|
||||
"""
|
||||
#debug:
|
||||
class catch_all:
|
||||
@deco.deluge_page_noauth
|
||||
def GET(self, name):
|
||||
log.debug("xname=" + name)
|
||||
print "name=" + name
|
||||
route("(.*)", catch_all)
|
||||
"""
|
|
@ -32,9 +32,10 @@
|
|||
#relative:
|
||||
from webserver_common import REVNO, VERSION
|
||||
from utils import *
|
||||
import utils
|
||||
#/relative
|
||||
from deluge import common
|
||||
from web import changequery as self_url, template, Storage
|
||||
from web import template, Storage
|
||||
import os
|
||||
|
||||
from deluge.configmanager import ConfigManager
|
||||
|
@ -56,14 +57,14 @@ class subclassed_render(object):
|
|||
self.webui_path = os.path.dirname(__file__)
|
||||
|
||||
#load template-meta-data
|
||||
cfg_template = config.get('template')
|
||||
template_path = os.path.join(self.webui_path, 'templates/%s/' % cfg_template)
|
||||
self.cfg_template = config.get('template')
|
||||
template_path = os.path.join(self.webui_path, 'templates/%s/' % self.cfg_template)
|
||||
if not os.path.exists(template_path):
|
||||
template_path = os.path.join(self.webui_path, 'templates/deluge/')
|
||||
self.meta = Storage(eval(open(os.path.join(template_path,'meta.cfg')).read()))
|
||||
|
||||
#load renerders
|
||||
for template_name in [cfg_template] + list(reversed(self.meta.inherits)):
|
||||
for template_name in [self.cfg_template] + list(reversed(self.meta.inherits)):
|
||||
self.renderers.append(template.render(
|
||||
os.path.join(self.webui_path, 'templates/%s/' % template_name),cache=False))
|
||||
|
||||
|
@ -86,8 +87,7 @@ class subclassed_render(object):
|
|||
if hasattr(renderer, attr):
|
||||
self.template_cache[attr] = getattr(renderer, attr)
|
||||
return getattr(renderer, attr)
|
||||
|
||||
raise AttributeError, 'no template named "%s" ' % attr
|
||||
raise AttributeError, 'no template named "%s" in base path "%s"' % (attr, self.webui_path)
|
||||
|
||||
def __getitem__(self, item):
|
||||
"for plugins/templates"
|
||||
|
@ -102,6 +102,9 @@ class subclassed_render(object):
|
|||
if os.path.isdir(os.path.join(template_path, dirname))
|
||||
and not dirname.startswith('.')]
|
||||
|
||||
@staticmethod
|
||||
def set_global(key, val):
|
||||
template.Template.globals[key] = val
|
||||
|
||||
render = subclassed_render()
|
||||
|
||||
|
@ -186,7 +189,7 @@ template.Template.globals.update({
|
|||
'sorted': sorted,
|
||||
'altrow':altrow,
|
||||
'get_config': get_config,
|
||||
'self_url': self_url,
|
||||
'self_url': utils.self_url,
|
||||
'fspeed': common.fspeed,
|
||||
'fsize': common.fsize,
|
||||
'ftime':ftime,
|
||||
|
@ -195,10 +198,10 @@ template.Template.globals.update({
|
|||
'version': VERSION,
|
||||
'getcookie':getcookie,
|
||||
'get': lambda (var): getattr(web.input(**{var:None}), var), # unreadable :-(
|
||||
'env':'0.6',
|
||||
#'env':'0.6',
|
||||
'forms':web.Storage(),
|
||||
'enumerate':enumerate
|
||||
|
||||
'enumerate':enumerate,
|
||||
'base':'' #updated when running within apache.
|
||||
})
|
||||
#/template-defs
|
||||
|
||||
|
|
|
@ -7,8 +7,9 @@ so i'd rather start from scratch,
|
|||
Probably broken in an unexpected way , but worksforme.
|
||||
*/
|
||||
state = {
|
||||
'row_js_continue':true
|
||||
,'selected_rows': new Array()
|
||||
'row_js_continue':true,
|
||||
'selected_rows': new Array(),
|
||||
'base_url':''
|
||||
};
|
||||
|
||||
function $(el_id){
|
||||
|
@ -91,7 +92,7 @@ function open_details(e, id){
|
|||
|
||||
function open_inner_details(id){
|
||||
/*probably broken for IE, use FF!*/
|
||||
$('torrent_info').src = '/torrent/info_inner/' + id;
|
||||
$('torrent_info').src = state.base_url + '/torrent/info_inner/' + id;
|
||||
}
|
||||
|
||||
function on_click_do_nothing(e, id){
|
||||
|
|
|
@ -2,10 +2,10 @@ $def with (title, active_tab=None)
|
|||
<html>
|
||||
<head>
|
||||
<title>Deluge:$title</title>
|
||||
<link rel="icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="/template_style.css" />
|
||||
<script language="javascript" src="/static/deluge.js"></script>
|
||||
<link rel="icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="$base/template_style.css" />
|
||||
<script language="javascript" src="$base/static/deluge.js"></script>
|
||||
|
||||
|
||||
</head>
|
||||
|
@ -13,7 +13,7 @@ $def with (title, active_tab=None)
|
|||
<body>
|
||||
<div id="page">
|
||||
|
||||
<a href='/home'>
|
||||
<a href='$base/home'>
|
||||
<div id="simple_logo">
|
||||
<div class="title">Deluge</div>
|
||||
<div class="info">$title</div>
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
$_('Auto refresh:')
|
||||
$if getcookie('auto_refresh') == '1':
|
||||
($getcookie('auto_refresh_secs')) $_('seconds')
|
||||
<a href="/refresh/set">$_('Set')</a>
|
||||
<a href="/refresh/off">$_('Disable')</a><!--WRONG, setting things on a GET-->
|
||||
<a href="$base/refresh/set">$_('Set')</a>
|
||||
<a href="$base/refresh/off">$_('Disable')</a><!--WRONG, setting things on a GET-->
|
||||
$else:
|
||||
$_('Off')
|
||||
<a href="/refresh/on">$_('Enable')</a><!--WRONG, setting things on a GET-->
|
||||
<a href="$base/refresh/on">$_('Enable')</a><!--WRONG, setting things on a GET-->
|
||||
]
|
||||
|
||||
|
||||
<a href="/config/">$_('Admin') </a>
|
||||
<a href="$base/config/">$_('Admin') </a>
|
||||
|
||||
</div>
|
|
@ -2,20 +2,13 @@ $def with (stats)
|
|||
|
||||
|
||||
<div id='stats_panel'>
|
||||
<!--<a href='/config'>-->
|
||||
|
||||
<img src="$base/static/images/tango/connections.png" title="$_('Connections')">$stats.num_connections ($deluge_int(stats.max_num_connections))
|
||||
|
||||
<img src="/static/images/tango/connections.png" title="$_('Connections')">$stats.num_connections ($deluge_int(stats.max_num_connections))
|
||||
<img src="$base/pixmaps/downloading16.png" title="$_('Down Speed')">$stats.download_rate ($deluge_int(stats.max_download))
|
||||
|
||||
<img src="/pixmaps/downloading16.png" title="$_('Down Speed')">$stats.download_rate ($deluge_int(stats.max_download))
|
||||
<img src="$base/pixmaps/seeding16.png" title="$_('Up Speed')">$stats.upload_rate ($deluge_int(stats.max_upload))
|
||||
|
||||
<img src="/pixmaps/seeding16.png" title="$_('Up Speed')">$stats.upload_rate ($deluge_int(stats.max_upload))
|
||||
|
||||
<img src="/pixmaps/dht16.png" title="$_('DHT Nodes')">$stats.dht_nodes
|
||||
|
||||
|
||||
|
||||
|
||||
<!--</a>-->
|
||||
<img src="$base/pixmaps/dht16.png" title="$_('DHT Nodes')">$stats.dht_nodes
|
||||
|
||||
</div>
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
$def with (method, func, title, image='')
|
||||
<div class="deluge_button">
|
||||
<form method="$method" action="$url" class="deluge_button">
|
||||
<form method="$method" action="$base$url" class="deluge_button">
|
||||
<input type="hidden" name="redir" value="$self_url()">
|
||||
$if (get_config('button_style') == 0):
|
||||
<button type="submit" class="deluge_button" alt="$title">
|
||||
$title
|
||||
$if image:
|
||||
<image src="/static/images/$image" class="button" alt="$title"/>
|
||||
<image src="$base/static/images/$image" class="button" alt="$title"/>
|
||||
</button>
|
||||
|
||||
$if (get_config('button_style') == 1):
|
||||
$if image:
|
||||
<input type="image" image src="/static/images/$image" class="img_button" alt="$title"/>
|
||||
<input type="image" image src="$base/static/images/$image" class="img_button" alt="$title"/>
|
||||
$else:
|
||||
<button type="submit" class="deluge_button" alt="$title">
|
||||
$title
|
||||
|
@ -24,12 +24,3 @@ $if (get_config('button_style') == 2):
|
|||
|
||||
</form>
|
||||
</div>
|
||||
<!--
|
||||
|
||||
pause
|
||||
start
|
||||
up
|
||||
down
|
||||
|
||||
|
||||
-->
|
|
@ -1,6 +1,6 @@
|
|||
$for id, title, image, flag, method, url, important in toolbar_items:
|
||||
$if important:
|
||||
<a class='toolbar_btn' href="#"
|
||||
onclick='toolbar_$(method.lower()) ("$url",$flag)'
|
||||
onclick='toolbar_$(method.lower()) ("$base$url",$flag)'
|
||||
title='$title'><img class='toolbar_btn'
|
||||
src='/static/images/tango/$image'></a>
|
||||
src='$base/static/images/tango/$image'></a>
|
||||
|
|
|
@ -6,9 +6,11 @@ var all_torrents = [
|
|||
$for t in torrent_list:
|
||||
"$t.id",
|
||||
]
|
||||
state.base_url = '$base';
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<table class="torrent_list" id="torrent_table" border=0 cellspacing=0 cellpadding=2 id="torrent_list" >
|
||||
<thead class="fixedHeader">
|
||||
<tr>
|
||||
|
@ -39,10 +41,10 @@ $#4-space indentation is mandatory for for-loops in templetor!
|
|||
$for torrent in torrent_list:
|
||||
<tr class="$altrow()" onclick="on_click_row(event, '$torrent.id')" id="torrent_$torrent.id">
|
||||
<td>
|
||||
<form action="/torrent/$torrent.action/$torrent.id" method="POST"
|
||||
<form action="$base/torrent/$torrent.action/$torrent.id" method="POST"
|
||||
class="pause_resume">
|
||||
<input type="image"
|
||||
src="/pixmaps/$torrent.state.lower()"
|
||||
src="$base/pixmaps/$torrent.state.lower()"
|
||||
name="pauseresume" value="submit" />
|
||||
</form>
|
||||
</td>
|
||||
|
|
|
@ -3,7 +3,7 @@ $def with (torrent, active_tab)
|
|||
<html>
|
||||
<head>
|
||||
<title>Deluge:$torrent.name</title>
|
||||
<link rel="stylesheet" type="text/css" href="/template_style.css" />
|
||||
<link rel="stylesheet" type="text/css" href="$base/template_style.css" />
|
||||
</head>
|
||||
<body class="inner">
|
||||
|
||||
|
|
|
@ -6,5 +6,5 @@ $for id, title, url in admin_pages:
|
|||
class="tab_button_active"
|
||||
$else:
|
||||
class="tab_button"
|
||||
href='$url'>$title</a>
|
||||
href='$base$url'>$title</a>
|
||||
</div>
|
||||
|
|
|
@ -11,9 +11,9 @@ $for group in groups:
|
|||
$for page in pages:
|
||||
$if pages[page].group == group:
|
||||
$if page == selected:
|
||||
<li class="selected"><a href="/config/$page" >$pages[page].title</a></li>
|
||||
<li class="selected"><a href="$base/config/$page" >$pages[page].title</a></li>
|
||||
$else:
|
||||
<li><a href="/config/$page">$pages[page].title</a></li>
|
||||
<li><a href="$base/config/$page">$pages[page].title</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--form block-->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$def with (connect_list, connected)
|
||||
|
||||
$:render.header(_("Connect to Daemon"), 'Connect')
|
||||
$:render.header(_("Connect to Daemon"), 'connect')
|
||||
|
||||
$:render.admin_toolbar('connect')
|
||||
|
||||
|
@ -12,12 +12,12 @@ $if connected:
|
|||
$_('Connected to')
|
||||
$connected
|
||||
</td><td>
|
||||
<form method="POST" action="/daemon/control/stop">
|
||||
<form method="POST" action="$base/daemon/control/stop">
|
||||
<input type="submit" name="stop"
|
||||
value="$_('Stop')">
|
||||
</form>
|
||||
</td><td>
|
||||
<form method="POST" action="/daemon/control/restart">
|
||||
<form method="POST" action="$base/daemon/control/restart">
|
||||
<input type="submit" name="restart"
|
||||
value="$_('Restart')">
|
||||
</form>
|
||||
|
@ -25,7 +25,7 @@ $if connected:
|
|||
$else:
|
||||
<div class="error">$_("Not Connected to a daemon")
|
||||
</div>
|
||||
<form method="POST" action="/daemon/control/start">
|
||||
<form method="POST" action="$base/daemon/control/start">
|
||||
<input type="hidden" name="uri" value="$connect_list[0]">
|
||||
<input type="submit" name="stop"
|
||||
value="$_('Start') $connect_list[0]">
|
||||
|
|
|
@ -2,16 +2,16 @@ $def with (title, active_tab="NONE")
|
|||
<html>
|
||||
<head>
|
||||
<title>Deluge:$title</title>
|
||||
<link rel="icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="/static/simple_site_style.css" />
|
||||
<link rel="icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="$base/static/simple_site_style.css" />
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="page">
|
||||
|
||||
<a href='/home'>
|
||||
<a href='$base/home'>
|
||||
<div id="simple_logo">
|
||||
<div class="title">Deluge</div>
|
||||
<div class="info">$title</div>
|
||||
|
|
|
@ -24,13 +24,13 @@ $#4-space indentation is mandatory for for-loops in templetor!
|
|||
$for torrent in torrent_list:
|
||||
<tr class="torrent_table" id="torrent_$torrent.id">
|
||||
<td>
|
||||
<form action="/torrent/$torrent.action/$torrent.id" method="POST" class="pause_resume">
|
||||
<form action="$base/torrent/$torrent.action/$torrent.id" method="POST" class="pause_resume">
|
||||
<input type="image"
|
||||
src="/pixmaps/$torrent.state.lower()"
|
||||
src="$base/pixmaps/$torrent.state.lower()"
|
||||
name="pauseresume" value="submit" /></form></td>
|
||||
<td>$torrent.queue</td>
|
||||
<td style="width:100px; overflow:hidden;white-space: nowrap">
|
||||
<a href="/torrent/info/$torrent.id" >
|
||||
<a href="$base/torrent/info/$torrent.id" >
|
||||
$(crop(torrent.name, 40))</a></td>
|
||||
<td>$fsize(torrent.total_size)</td>
|
||||
<td class="progress_bar">
|
||||
|
|
|
@ -6,7 +6,7 @@ $:render.header(_('Login'))
|
|||
$if error > 0:
|
||||
<div class="error">$_("Password is invalid,try again")</div>
|
||||
|
||||
<form method="POST" id="loginform" action='/login'>
|
||||
<form method="POST" id="loginform" action='$base/login'>
|
||||
<input type="hidden" name="redir" value="$get('redir')">
|
||||
<div id="loginpanel">
|
||||
<div class="form_row">
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
$def with (method, url, title, image='')
|
||||
<div class="deluge_button">
|
||||
<form method="$method" action="$url" class="deluge_button">
|
||||
<form method="$method" action="$base$url" class="deluge_button">
|
||||
<input type="hidden" name="redir" value="$self_url()">
|
||||
$if (int(get_config('button_style')) == 0):
|
||||
<button type="submit" class="deluge_button" alt="$title">
|
||||
$title
|
||||
$if image:
|
||||
<image src="/static/images/$image" class="button" alt="$title"/>
|
||||
<image src="$base/static/images/$image" class="button" alt="$title"/>
|
||||
</button>
|
||||
|
||||
$if (int(get_config('button_style')) == 1):
|
||||
$if image:
|
||||
<input type="image" image src="/static/images/$image" class="img_button" alt="$title"/>
|
||||
<input type="image" image src="$base/static/images/$image" class="img_button" alt="$title"/>
|
||||
$else:
|
||||
<button type="submit" class="deluge_button" alt="$title">
|
||||
$title
|
||||
|
|
|
@ -33,7 +33,7 @@ title="$_('Filter on a keyword')"
|
|||
/>
|
||||
|
||||
<input type="image" id='toolbar_refresh' name="refresh_organize"
|
||||
src='/static/images/tango/view-refresh.png'
|
||||
src='$base/static/images/tango/view-refresh.png'
|
||||
title='$_('Refresh')'
|
||||
>
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ $:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png')
|
|||
</div>
|
||||
|
||||
<div class="panel" id='stats_panel'>
|
||||
<!--<a href='/config'>-->
|
||||
|
||||
$_('Connections') : $stats.num_connections ($stats.max_num_connections)
|
||||
|
||||
|
@ -26,14 +25,8 @@ $:render.part_button('POST', '/logout', _('Logout'), 'tango/system-log-out.png')
|
|||
|
||||
$_('Up Speed') : $stats.upload_rate ($stats.max_upload)
|
||||
|
||||
|
||||
<!--</a>-->
|
||||
|
||||
$if env == '0.6':
|
||||
$:render.part_button('GET', '/config/', _('Settings'), 'tango/preferences-system.png')
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$:render.header(_('Set Timeout'))
|
||||
<div class="panel">
|
||||
<form action="/refresh/set" method="POST">
|
||||
<form action="$base/refresh/set" method="POST">
|
||||
$_('Refresh page every:')
|
||||
<input type="text" name="refresh" value="$getcookie('auto_refresh_secs')"
|
||||
size="3">
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
$def with (column_id, column_name, order, active_up, active_down)
|
||||
<th class="torrent_table">
|
||||
<a href="/index?sort=$column_id&order=$order&state=$get('state')&tracker=$get('tracker')&keyword=$get('keyword')"">
|
||||
<a href="$base/index?sort=$column_id&order=$order&state=$get('state')&tracker=$get('tracker')&keyword=$get('keyword')"">
|
||||
$column_name\
|
||||
$if active_up:
|
||||
<img src="/static/images/tango/up.png" />
|
||||
<img src="$base/static/images/tango/up.png" />
|
||||
$if active_down:
|
||||
<img src="/static/images/tango/down.png" />
|
||||
<img src="$base/static/images/tango/down.png" />
|
||||
</a>
|
||||
</th>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$def with (torrent)
|
||||
|
||||
<form method="POST" action="/torrent/files/$torrent.id">
|
||||
<form method="POST" action="$base/torrent/files/$torrent.id">
|
||||
<input type="hidden" name="redir" value="$self_url()">
|
||||
<table width="95%">
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
$def with (torrent)
|
||||
<form method="post" action="/torrent/options/$torrent.id">
|
||||
<form method="post" action="$base/torrent/options/$torrent.id">
|
||||
<input type="hidden" name="redir" value="$self_url()">
|
||||
<table><tr><td valign="top">
|
||||
<table>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$def with (torrent)
|
||||
|
||||
<form method="POST" action="/torrent/files/$torrent.id">
|
||||
<form method="POST" action="$base/torrent/files/$torrent.id">
|
||||
<input type="hidden" name="redir" value="$self_url()">
|
||||
<table width="95%">
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ $def with (add_form, options_form, error)
|
|||
$:render.header(_("Add Torrent"))
|
||||
<div class="panel">
|
||||
<h2>$_("Add Torrent")</h2>
|
||||
<form method="POST" action="/torrent/add" ENCTYPE="multipart/form-data">
|
||||
<form method="POST" action="$base/torrent/add" ENCTYPE="multipart/form-data">
|
||||
<input type="hidden" name="redir" value="$get('redir')">
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$def with (torrent_ids, torrent_list)
|
||||
$:render.header(_("Remove torrent"))
|
||||
<div class="panel">
|
||||
<form method="POST" action='/torrent/delete/$torrent_ids'>
|
||||
<form method="POST" action='$base/torrent/delete/$torrent_ids'>
|
||||
<div id="del_torrent">
|
||||
|
||||
<h2>$_("Remove torrent")</h2>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
$def with (torrent_ids, torrent_list, form, error)
|
||||
$:render.header(_("Remove torrent"))
|
||||
<div class="panel">
|
||||
<form method="POST" action='/torrent/move/$torrent_ids'>
|
||||
<form method="POST" action='$base/torrent/move/$torrent_ids'>
|
||||
<div id="del_torrent">
|
||||
<h2>$_("Move torrent")</h2>
|
||||
<ul>
|
||||
|
|
|
@ -4,10 +4,10 @@ $def with (title, active_tab="NONE")
|
|||
<html>
|
||||
<head>
|
||||
<title>Deluge:$_('Torrent list')</title>
|
||||
<link rel="icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="/template_style.css" />
|
||||
<script language="javascript" src="/static/deluge.js"></script>
|
||||
<link rel="icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="$base/template_style.css" />
|
||||
<script language="javascript" src="$base/static/deluge.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -22,7 +22,7 @@ $def with (title, active_tab="NONE")
|
|||
class="tab_button_active"
|
||||
$else:
|
||||
class="tab_button"
|
||||
href='/home'>Home</a>
|
||||
href='$base/home'>Home</a>
|
||||
|
||||
<!--ADMIN-TABS-->
|
||||
$for id, title, url in admin_pages:
|
||||
|
@ -31,7 +31,7 @@ $for id, title, url in admin_pages:
|
|||
class="tab_button_active"
|
||||
$else:
|
||||
class="tab_button"
|
||||
href='$url'>$title</a>
|
||||
href='$base$url'>$title</a>
|
||||
</div>
|
||||
|
||||
</td><td align="right">
|
||||
|
|
|
@ -4,10 +4,10 @@ $def with (torrent_list, organize_filters)
|
|||
<html>
|
||||
<head>
|
||||
<title>Deluge:$_('Torrent list')</title>
|
||||
<link rel="icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="/template_style.css" />
|
||||
<script language="javascript" src="/static/deluge.js"></script>
|
||||
<link rel="icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="shortcut icon" href="$base/static/images/deluge_icon.gif" type="image/gif" />
|
||||
<link rel="stylesheet" type="text/css" href="$base/template_style.css" />
|
||||
<script language="javascript" src="$base/static/deluge.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -16,9 +16,9 @@ $def with (torrent_list, organize_filters)
|
|||
<table width="100%"><tr>
|
||||
<td>
|
||||
<div id="home_top">
|
||||
<a class="tab_button_active" href='/home'>Home</a>
|
||||
<a class="tab_button_active" href='$base/home'>Home</a>
|
||||
$for id, title, url in admin_pages:
|
||||
<a class="tab_button" href='$url'>$title</a>
|
||||
<a class="tab_button" href='$base$url'>$title</a>
|
||||
|
||||
|
||||
</td><td>
|
||||
|
@ -30,8 +30,6 @@ $def with (torrent_list, organize_filters)
|
|||
<hr>
|
||||
|
||||
|
||||
|
||||
|
||||
$if organize_filters:
|
||||
$:render.part_organize(organize_filters)
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ $for state, num in filters.state:
|
|||
$if state == get('state'):
|
||||
class="selected"
|
||||
>
|
||||
<img src="/pixmaps/$state.lower() ">
|
||||
<img src="$base/pixmaps/$state.lower() ">
|
||||
<a href="$self_url(state=state)">$_(state) ($num)</a>
|
||||
</li>
|
||||
$else:
|
||||
|
@ -49,9 +49,6 @@ $if get('keyword'):
|
|||
|
||||
</div>
|
||||
</form>
|
||||
<!--
|
||||
<img src="/pixmaps/deluge.png">
|
||||
-->
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -30,16 +30,7 @@
|
|||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
import web
|
||||
import os
|
||||
from web import cookies, setcookie as w_setcookie
|
||||
from web import changequery as self_url, template
|
||||
from web import Storage
|
||||
from web import seeother, url
|
||||
|
||||
from deluge.common import fsize,fspeed,ftime
|
||||
from deluge.log import LOG as log
|
||||
|
||||
import traceback
|
||||
import random
|
||||
from operator import attrgetter
|
||||
|
@ -48,14 +39,19 @@ import pickle
|
|||
from urlparse import urlparse
|
||||
from md5 import md5
|
||||
|
||||
from webserver_common import REVNO, VERSION, TORRENT_KEYS, STATE_MESSAGES, CONFIG_DEFAULTS
|
||||
from deluge.ui.client import sclient as proxy
|
||||
from deluge.ui.client import aclient as async_proxy
|
||||
|
||||
import web
|
||||
from web import changequery , template , url , Storage
|
||||
from web import cookies, setcookie as w_setcookie
|
||||
from web import seeother as w_seeother
|
||||
|
||||
from deluge.common import fsize, fspeed, ftime
|
||||
from deluge import component
|
||||
from deluge.log import LOG as log
|
||||
from deluge.configmanager import ConfigManager
|
||||
|
||||
from webserver_common import REVNO, VERSION, TORRENT_KEYS, CONFIG_DEFAULTS
|
||||
from deluge.ui.client import sclient, aclient
|
||||
|
||||
webui_plugin_manager = component.get("WebPluginManager")
|
||||
config = ConfigManager("webui.conf")
|
||||
|
||||
|
@ -70,7 +66,6 @@ def setcookie(key, val):
|
|||
"""add 30 days expires header for persistent cookies"""
|
||||
return w_setcookie(key, val , expires=2592000)
|
||||
|
||||
|
||||
#really simple sessions, to bad i had to implement them myself.
|
||||
SESSIONS = []
|
||||
def start_session():
|
||||
|
@ -83,6 +78,14 @@ def end_session():
|
|||
setcookie("session_id","")
|
||||
#/sessions
|
||||
|
||||
def seeother(url, *args, **kwargs):
|
||||
url_with_base = config["base"] + url
|
||||
log.debug("seeother:%s" % url_with_base)
|
||||
return w_seeother(url_with_base, *args, **kwargs)
|
||||
|
||||
def self_url(**kwargs):
|
||||
return config["base"] + changequery(**kwargs)
|
||||
|
||||
def do_redirect():
|
||||
"""for redirects after a POST"""
|
||||
vars = web.input(redir = None)
|
||||
|
@ -91,7 +94,7 @@ def do_redirect():
|
|||
|
||||
#redirect to a non-default page.
|
||||
if vars.redir:
|
||||
seeother(vars.redir)
|
||||
w_seeother(vars.redir) #redir variable contains base
|
||||
return
|
||||
|
||||
#for the filters:
|
||||
|
@ -100,7 +103,7 @@ def do_redirect():
|
|||
|
||||
organize = False
|
||||
try:
|
||||
organize = ('Organize' in proxy.get_enabled_plugins())
|
||||
organize = ('Organize' in sclient.get_enabled_plugins())
|
||||
except:
|
||||
pass
|
||||
|
||||
|
@ -114,7 +117,7 @@ def do_redirect():
|
|||
url_vars['keyword'] = ck['keyword']
|
||||
|
||||
#redirect.
|
||||
seeother(url("/index", **url_vars))
|
||||
w_seeother(url("/index", **url_vars))
|
||||
|
||||
def getcookie(key, default = None):
|
||||
"because i'm too lazy to type 3 lines for something this simple"
|
||||
|
@ -125,18 +128,18 @@ def getcookie(key, default = None):
|
|||
def get_stats():
|
||||
stats = Storage()
|
||||
|
||||
async_proxy.get_download_rate(dict_cb('download_rate',stats))
|
||||
async_proxy.get_upload_rate(dict_cb('upload_rate',stats))
|
||||
async_proxy.get_config_value(dict_cb('max_download',stats)
|
||||
aclient.get_download_rate(dict_cb('download_rate',stats))
|
||||
aclient.get_upload_rate(dict_cb('upload_rate',stats))
|
||||
aclient.get_config_value(dict_cb('max_download',stats)
|
||||
,"max_download_speed")
|
||||
async_proxy.get_config_value(dict_cb('max_upload',stats)
|
||||
aclient.get_config_value(dict_cb('max_upload',stats)
|
||||
,"max_upload_speed")
|
||||
async_proxy.get_num_connections(dict_cb("num_connections",stats))
|
||||
async_proxy.get_config_value(dict_cb('max_num_connections',stats)
|
||||
aclient.get_num_connections(dict_cb("num_connections",stats))
|
||||
aclient.get_config_value(dict_cb('max_num_connections',stats)
|
||||
,"max_connections_global")
|
||||
async_proxy.get_dht_nodes(dict_cb('dht_nodes',stats))
|
||||
aclient.get_dht_nodes(dict_cb('dht_nodes',stats))
|
||||
|
||||
async_proxy.force_call(block=True)
|
||||
aclient.force_call(block=True)
|
||||
|
||||
stats.download_rate = fspeed(stats.download_rate)
|
||||
stats.upload_rate = fspeed(stats.upload_rate)
|
||||
|
@ -177,16 +180,16 @@ def enhance_torrent_status(torrent_id,status):
|
|||
def get_torrent_status(torrent_id):
|
||||
"""
|
||||
helper method.
|
||||
enhance proxy.get_torrent_status with some extra data
|
||||
enhance sclient.get_torrent_status with some extra data
|
||||
"""
|
||||
status = proxy.get_torrent_status(torrent_id,TORRENT_KEYS)
|
||||
status = sclient.get_torrent_status(torrent_id,TORRENT_KEYS)
|
||||
return enhance_torrent_status(torrent_id, status)
|
||||
|
||||
def get_enhanced_torrent_list(torrent_ids):
|
||||
"""
|
||||
returns a list of storified-torrent-dicts.
|
||||
"""
|
||||
torrent_dict = proxy.get_torrents_status(torrent_ids, TORRENT_KEYS)
|
||||
torrent_dict = sclient.get_torrents_status(torrent_ids, TORRENT_KEYS)
|
||||
return [enhance_torrent_status(id, status)
|
||||
for id, status in torrent_dict.iteritems()]
|
||||
|
||||
|
@ -239,7 +242,7 @@ def daemon_connect(uri):
|
|||
config.set('daemon', uri)
|
||||
config.save()
|
||||
|
||||
proxy.set_core_uri(uri)
|
||||
sclient.set_core_uri(uri)
|
||||
webui_plugin_manager.start()
|
||||
|
||||
#generic:
|
||||
|
@ -279,8 +282,12 @@ def set_config_defaults():
|
|||
if changed:
|
||||
config.save()
|
||||
|
||||
|
||||
|
||||
def apply_config():
|
||||
#etc, mostly for apache:
|
||||
from render import render
|
||||
sclient.set_core_uri(config.get('daemon'))
|
||||
render.set_global('base', config.get('base'))
|
||||
render.apply_cfg()
|
||||
|
||||
#exceptions:
|
||||
class WebUiError(Exception):
|
||||
|
@ -290,3 +297,4 @@ class WebUiError(Exception):
|
|||
|
||||
class UnknownTorrentError(WebUiError):
|
||||
pass
|
||||
|
||||
|
|
|
@ -32,10 +32,8 @@
|
|||
"""
|
||||
webui constants
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
#constants
|
||||
try:
|
||||
REVNO = open(os.path.join(os.path.dirname(__file__),'revno')).read()
|
||||
except:
|
||||
|
@ -59,16 +57,6 @@ TORRENT_KEYS = ['name', 'total_size', 'num_files', 'num_pieces', 'piece_length',
|
|||
'tracker_name' #organize-plugin
|
||||
]
|
||||
|
||||
STATE_MESSAGES = [
|
||||
"Allocating",
|
||||
"Checking",
|
||||
"Downloading",
|
||||
"Seeding",
|
||||
"Paused",
|
||||
"Error"
|
||||
]
|
||||
|
||||
|
||||
CONFIG_DEFAULTS = {
|
||||
"port":8112,
|
||||
"button_style":2,
|
||||
|
@ -79,9 +67,7 @@ CONFIG_DEFAULTS = {
|
|||
"pwd_md5":".\xe8w\\+\xec\xdb\xf2id4F\xdb\rUc",
|
||||
"cache_templates":True,
|
||||
"use_https":False,
|
||||
"daemon":"http://localhost:58846"
|
||||
"daemon":"http://localhost:58846",
|
||||
"base":"",
|
||||
"disallow":{}
|
||||
}
|
||||
|
||||
#/constants
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue