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