/usr/share/cherokee/admin/wizards/icons.py is in cherokee-admin 1.2.101-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | # -*- coding: utf-8 -*-
#
# Cherokee-admin's Icons' wizard
#
# Authors:
# Taher Shihadeh <taher@octality.com>
# Alvaro Lopez Ortega <alvaro@alobbs.com>
#
# Copyright (C) 2010 Alvaro Lopez Ortega
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#
#
# Tested:
# 2010/04/13: Cherokee 0.99.41
#
import re
import CTK
import Wizard
from util import *
from configured import *
NOTE_WELCOME_H1 = N_("Welcome to the Icons Wizard")
NOTE_WELCOME_P1 = N_("This wizard adds the /icons and /cherokee_themes directories so Cherokee can use icons when listing directories.")
NOTE_WELCOME_ERR= N_("The /icons and /cherokee_themes directories are already configured. There is nothing left to do.")
PREFIX = 'tmp!wizard!icons'
URL_APPLY = r'/wizard/vserver/icons/apply'
CONFIG_ICONS = """
%(rule_pre_2)s!match = directory
%(rule_pre_2)s!match!directory = /icons
%(rule_pre_2)s!handler = file
%(rule_pre_2)s!handler!iocache = 1
%(rule_pre_2)s!document_root = %(droot_icons)s
%(rule_pre_2)s!encoder!gzip = 0
%(rule_pre_2)s!encoder!deflate = 0
%(rule_pre_2)s!expiration = time
%(rule_pre_2)s!expiration!time = 1h
"""
CONFIG_THEMES = """
%(rule_pre_1)s!match = directory
%(rule_pre_1)s!match!directory = /cherokee_themes
%(rule_pre_1)s!handler = file
%(rule_pre_1)s!handler!iocache = 1
%(rule_pre_1)s!document_root = %(droot_themes)s
%(rule_pre_1)s!encoder!gzip = 0
%(rule_pre_1)s!encoder!deflate = 0
%(rule_pre_1)s!expiration = time
%(rule_pre_1)s!expiration!time = 1h
"""
class Commit:
def Commit_Rule (self):
vsrv_num = CTK.cfg.get_val ('%s!vsrv_num'%(PREFIX))
icons = bool(int(CTK.cfg.get_val ('%s!icons'%(PREFIX))))
themes = bool(int(CTK.cfg.get_val ('%s!themes'%(PREFIX))))
vsrv_pre = 'vserver!%s' %(vsrv_num)
rule_n, x = cfg_vsrv_rule_get_next (vsrv_pre)
config_src = ''
if not icons:
config_src += CONFIG_ICONS
if not themes:
config_src += CONFIG_THEMES
rule_pre_1 = '%s!rule!%d'%(vsrv_pre, rule_n)
rule_pre_2 = '%s!rule!%d'%(vsrv_pre, rule_n+1)
droot_icons = CHEROKEE_ICONSDIR
droot_themes = CHEROKEE_THEMEDIR
config = config_src % (locals())
CTK.cfg.apply_chunk (config)
# Clean up
CTK.cfg.normalize ('%s!rule'%(vsrv_pre))
del (CTK.cfg[PREFIX])
return CTK.cfg_reply_ajax_ok()
def __call__ (self):
CTK.cfg_apply_post()
return self.Commit_Rule()
class Welcome:
def _check_config (self):
tmp = re.findall (r'^/wizard/vserver/(\d+)/', CTK.request.url)[0]
vsrv_pre = 'vserver!%s'
rules = CTK.cfg.keys('%s!rule'%(vsrv_pre))
icons, themes = False, False
for r in rules:
if CTK.get_val ('%s!rule!%s!match'%(vsrv_pre, r)) == 'directory' and \
CTK.cfg.get_val ('%s!rule!%s!match!directory'%(vsrv_pre, r)) == '/icons':
icons = True
if CTK.cfg.get_val ('%s!rule!%s!match'%(vsrv_pre, r)) == 'directory' and \
CTK.cfg.get_val ('%s!rule!%s!match!directory'%(vsrv_pre, r)) == '/cherokee_themes':
themes = True
return (icons, themes)
def __call__ (self):
cont = CTK.Container()
cont += CTK.RawHTML ('<h2>%s</h2>' %(_(NOTE_WELCOME_H1)))
cont += Wizard.Icon ('icons', {'class': 'wizard-descr'})
box = CTK.Box ({'class': 'wizard-welcome'})
box += CTK.RawHTML ('<p>%s</p>' %(_(NOTE_WELCOME_P1)))
cont += box
icons, themes = self._check_config()
if False in [icons, themes]:
# Send the VServer num
tmp = re.findall (r'^/wizard/vserver/(\d+)/', CTK.request.url)
submit = CTK.Submitter (URL_APPLY)
submit += CTK.Hidden('%s!vsrv_num'%(PREFIX), tmp[0])
submit += CTK.Hidden('%s!icons'%(PREFIX), ('0','1')[icons])
submit += CTK.Hidden('%s!themes'%(PREFIX), ('0','1')[themes])
submit += CTK.Hidden('final', '1')
cont += submit
cont += CTK.DruidButtonsPanel_Create()
else:
cont += CTK.RawHTML ('<p>%s</p>' %(_(NOTE_WELCOME_ERR)))
cont += CTK.DruidButtonsPanel_Cancel()
return cont.Render().toStr()
# Rule
CTK.publish ('^/wizard/vserver/(\d+)/icons$', Welcome)
CTK.publish (r'^%s'%(URL_APPLY), Commit, method="POST")
|