diff --git a/ChangeLog b/ChangeLog index 0ba23a608..bf00c80a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,9 @@ Deluge 1.0.4 (31 October 2008) Windows: * Fix starting on non-English versions of Windows +WebUi: + * Javascript auto refresh for both templates. + Deluge 1.0.3 (18 October 2008) Core: * Fix upnp - it should work on more routers now too diff --git a/deluge/ui/webui/config_tabs_webui.py b/deluge/ui/webui/config_tabs_webui.py index e6a99e483..fe25956c6 100644 --- a/deluge/ui/webui/config_tabs_webui.py +++ b/deluge/ui/webui/config_tabs_webui.py @@ -52,6 +52,7 @@ class Template(config_forms.WebCfgForm): template = forms.ChoiceField( label=_("Template"), choices = _templates) button_style = forms.IntChoiceField(_("Button style"),_button_choices) + refresh_secs = forms.IntegerField(label=_("Auto refresh (seconds)"), min_value=2, max_value=60*60) cache_templates = forms.CheckBox(_("Cache templates")) def post_save(self): diff --git a/deluge/ui/webui/page_decorators.py b/deluge/ui/webui/page_decorators.py index a200a02aa..741dec41c 100644 --- a/deluge/ui/webui/page_decorators.py +++ b/deluge/ui/webui/page_decorators.py @@ -20,10 +20,11 @@ def deluge_page_noauth(func): add http headers;print result of func """ def deco(self, name = None): - web.header("Content-Type", "text/html; charset=utf-8") - web.header("Cache-Control", "no-cache, must-revalidate") - res = func(self, name) #deluge_page_noauth - print res + render.set_global("is_auto_refreshed", False); + web.header("Content-Type", "text/html; charset=utf-8") + web.header("Cache-Control", "no-cache, must-revalidate") + res = func(self, name) #deluge_page_noauth + print res deco.__name__ = func.__name__ return deco @@ -112,11 +113,12 @@ def torrent(func): return deco def auto_refreshed(func): - "adds a refresh header" + """" + sets 'is_auto_refreshed' global for templates + note : decorate AFTER deluge_page_* + """ def deco(self, name = None): - if getcookie('auto_refresh') == '1': - web.header("Refresh", "%i ; url=%s" % - (int(getcookie('auto_refresh_secs',10)),self_url())) + render.set_global("is_auto_refreshed", True); return func(self, name) #auto_refreshed deco.__name__ = func.__name__ return deco diff --git a/deluge/ui/webui/render.py b/deluge/ui/webui/render.py index d0ec65a7d..ec2913a09 100644 --- a/deluge/ui/webui/render.py +++ b/deluge/ui/webui/render.py @@ -205,7 +205,8 @@ template.Template.globals.update({ #'env':'0.6', 'forms':web.Storage(), 'enumerate':enumerate, - 'base':'' #updated when running within apache. + 'base':'', #updated when running within apache. + 'is_auto_refreshed':False }) #/template-defs diff --git a/deluge/ui/webui/templates/classic/header.html b/deluge/ui/webui/templates/classic/header.html index eff4c8dd5..78d6e208d 100644 --- a/deluge/ui/webui/templates/classic/header.html +++ b/deluge/ui/webui/templates/classic/header.html @@ -4,8 +4,8 @@ $def with (title, active_tab="NONE")
$:render.part_button('GET', '/torrent/add', _('Add torrent'), 'tango/list-add.png') $:render.part_button('POST', '/pause_all', _('Pause all'), 'tango/pause.png') $:render.part_button('POST', '/resume_all', _('Resume all'), 'tango/start.png') + | ++$if is_auto_refreshed: + | + +