1
|
import os
|
2
|
import quixote
|
3
|
from quixote import get_response
|
4
|
#from wcs import storage
|
5
|
#from wcs import misc
|
6
|
#from wcs.users import User
|
7
|
|
8
|
items = [
|
9
|
('apache', 'Apache')]
|
10
|
|
11
|
# ('forms', N_('Forms')),
|
12
|
#('consultations', N_('Consultations')),
|
13
|
# ('workflows', N_('Workflows')),
|
14
|
# ('users', N_('Users')),
|
15
|
# ('roles', N_('Roles')),
|
16
|
# ('categories', N_('Categories')),
|
17
|
# ('logger', N_('Logs')),
|
18
|
# ('settings', N_('Settings')),
|
19
|
# ('/', N_('WCS Form Server'))]
|
20
|
|
21
|
def generate_header_menu [html] (selected = None):
|
22
|
s = ["""<ul id="menu">\n"""]
|
23
|
base_url = quixote.get_request().environ['SCRIPT_NAME'] + '/admin'
|
24
|
# features = misc.cfg.get('misc', {}).get('features', 'both')
|
25
|
# show_logger = misc.cfg.get('debug', {}).get('logger', False)
|
26
|
for k, v in items:
|
27
|
if k == '/':
|
28
|
continue # skip root
|
29
|
# if k == 'logger' and not show_logger:
|
30
|
# continue
|
31
|
# if features == 'forms' and k == 'consultations':
|
32
|
# continue
|
33
|
# if features == 'consultations' and k == 'forms':
|
34
|
# continue
|
35
|
if k == selected:
|
36
|
s.append('<li class="active">')
|
37
|
else:
|
38
|
s.append('<li>')
|
39
|
s.append('<a href="%s/%s/">%s</a></li>\n' % (base_url, k, v))
|
40
|
s.append('</ul>\n')
|
41
|
return ''.join(s)
|
42
|
|
43
|
#def generate_user_info [html] ():
|
44
|
# session = quixote.get_session()
|
45
|
# if not session or not session.user:
|
46
|
# return ''
|
47
|
# try:
|
48
|
# user = User.get(session.user)
|
49
|
# username = user.name
|
50
|
# except KeyError:
|
51
|
# username = _('Unknown')
|
52
|
# logout_url = quixote.get_request().environ['SCRIPT_NAME'] + '/logout'
|
53
|
# """<ul class="user-info">
|
54
|
# <li class="ui-name">%s</li>
|
55
|
# <li class="ui-logout"><a href="%s">%s</a></li>
|
56
|
#</ul>""" % (username, logout_url, _('logout'))
|
57
|
|
58
|
|
59
|
def html_top [html] (section, title = None, scripts = None):
|
60
|
header_menu = generate_header_menu(section)
|
61
|
# user_info = generate_user_info()
|
62
|
subtitle = ''
|
63
|
for s in items:
|
64
|
if s[0] == section:
|
65
|
subtitle = _(s[1])
|
66
|
if not title:
|
67
|
title = ''
|
68
|
else:
|
69
|
title = ' - ' + title
|
70
|
if not scripts:
|
71
|
scripts = ''
|
72
|
else:
|
73
|
scripts = '\n'.join(['<script src="%s" type="text/javascript"></script>' % x for x in scripts])
|
74
|
|
75
|
sitetitle = 'Larpe Administration'
|
76
|
if title:
|
77
|
sitetitle += ' - '
|
78
|
|
79
|
admin_ezt = True
|
80
|
|
81
|
|
82
|
|
83
|
"""
|
84
|
<?xml version="1.0" encoding="utf-8"?>
|
85
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
86
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
87
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
88
|
<head>
|
89
|
<title>Administration de Larpe</title>
|
90
|
<link rel="stylesheet" type="text/css" href="/css/larpe-admin.css"/>
|
91
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
92
|
</head>
|
93
|
<body>
|
94
|
<div id="header">%s
|
95
|
</div>
|
96
|
<div id="main-content">
|
97
|
<p id="breadcrumb"><a href="/">Administration</a></p>
|
98
|
|
99
|
<h1>Relai inverse Liberty Alliance</h1>
|
100
|
|
101
|
</div>
|
102
|
<div id="footer">
|
103
|
<p id="lasso">Powered by Lasso</p>
|
104
|
</div>
|
105
|
</body>
|
106
|
</html>
|
107
|
""" % header_menu
|
108
|
|
109
|
#<ul id="menu">
|
110
|
#<li><a href="/admin/apache/">Apache</a></li>
|
111
|
#</ul>
|
112
|
#</div>
|
113
|
#<div id="main-content">
|
114
|
|
115
|
|
116
|
# get_response().
|
117
|
# get_response().filter.update(locals())
|
118
|
|
119
|
def error_page [html] (section, error):
|
120
|
html_top(section, title = _('Error'))
|
121
|
'<div id="error-page">'
|
122
|
'<h2>%s</h2>' % _('Error')
|
123
|
'<p>%s</p>' % error
|
124
|
'</div>'
|
125
|
|
126
|
#def command_icon [html] (url, type, label = None, icon = None):
|
127
|
# icons = {
|
128
|
# 'edit': 'stock_edit_16.png',
|
129
|
# 'add': 'stock_add_16.png',
|
130
|
# 'remove': 'stock_remove_16.png',
|
131
|
# 'duplicate': 'stock_copy_16.png',
|
132
|
# 'view': 'view_16.png',
|
133
|
# }
|
134
|
# labels = {
|
135
|
# 'add': N_('Add'),
|
136
|
# 'edit': N_('Edit'),
|
137
|
# 'remove': N_('Remove'),
|
138
|
# 'duplicate': N_('Duplicate'),
|
139
|
# 'view': N_('View'),
|
140
|
# }
|
141
|
# if not label:
|
142
|
# label = _(labels[str(type)])
|
143
|
# if not icon:
|
144
|
# icon = icons[str(type)]
|
145
|
# if url:
|
146
|
# '''<span class="%(type)s">
|
147
|
# <a href="%(url)s"><img src="/images/%(icon)s" alt="%(label)s" title="%(label)s" /></a>
|
148
|
#</span>''' % locals()
|
149
|
# else:
|
150
|
# # no url -> image button
|
151
|
# '''<span class="%(type)s">
|
152
|
# <input type="image" src="/images/%(icon)s" alt="%(label)s" title="%(label)s" />
|
153
|
#</span>''' % locals()
|