Add a theme selector

This commit is contained in:
Frédéric Péters 2011-04-16 21:27:12 +02:00
parent 951df2b547
commit f9d60573cd
4 changed files with 68 additions and 1 deletions

View File

@ -60,3 +60,28 @@ body div#popup h2 {
padding-top: 3px;
}
div.themes div.theme {
border: 1px dotted #888;
margin: 1em;
float: left;
text-align: center;
}
div.themes div.theme.active {
border: 1px solid black;
}
div.themes div.theme img.theme-icon {
float: none;
margin: 0;
display: block;
width: 88px;
height: 88px;
padding: 6px;
border: 0;
}
div.themes div.theme a {
display: block;
border: 0;
}

View File

@ -168,6 +168,7 @@ class RootDirectory(AccessControlled, Directory):
'<ul>'
' <li><a href="config/sitetitle" rel="popup">%s</a></li>' % _('Title')
' <li><a href="config/homepage">%s</a></li>' % _('Home Page Text')
' <li><a href="config/appearance">%s</a></li>' % _('Appearance')
' <li><a href="config/texts/">%s</a></li>' % _('Message Texts')
'</ul>'
'</div>'

View File

@ -30,7 +30,8 @@ from qommon.form import *
class ConfigDirectory(Directory):
_q_exports = ['', 'password', 'contact', 'sitetitle', 'homepage', 'texts']
_q_exports = ['', 'password', 'contact', 'sitetitle', 'homepage', 'texts',
'appearance']
def _q_traverse (self, path):
get_response().breadcrumb.append( ('config/', _('Configuration')) )
@ -168,3 +169,43 @@ class ConfigDirectory(Directory):
get_publisher().write_cfg()
redirect('.')
def appearance [html] (self):
request = get_request()
if request.form.has_key('theme'):
themes = qommon.template.get_themes()
if themes.has_key(str(request.form['theme'])):
branding_cfg = get_cfg('branding', {})
branding_cfg[str('theme')] = str(request.form['theme'])
get_publisher().cfg[str('branding')] = branding_cfg
get_publisher().write_cfg()
current_theme = get_cfg('branding', {}).get('theme', 'default')
get_response().breadcrumb.append(('appearance', _('Appearance')))
html_top('config', title = _('Appearance'))
"<h2>%s</h2>" % _('Appearance')
get_session().display_message()
'<div class="themes">'
'<p>'
_('Click on a thumbnail to change the appearance of your site.')
'</p>'
themes = qommon.template.get_themes()
for theme, (label, desc, author, icon) in sorted(themes.items()):
if not theme.startswith(str('asec')):
# ignore themes that were not made for asec
continue
if current_theme == theme:
active = ' active'
else:
active = ''
'<div class="theme%s">' % active
'<a href="appearance?theme=%s">' % theme
'<img src="/themes/%s/icon.png" alt="" class="theme-icon" />' % theme
'</a>'
'</div>'
'</div>'

BIN
themes/asec/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB