1
|
from quixote import get_request, get_publisher
|
2
|
|
3
|
from qommon import template
|
4
|
from wcs.categories import Category
|
5
|
|
6
|
wcs_decorate = template.decorate
|
7
|
|
8
|
def decorate(body, response):
|
9
|
body = str(body)
|
10
|
|
11
|
for key in ('bigdiv', 'gauche'):
|
12
|
if not response.filter.has_key(key):
|
13
|
response.filter[key] = None
|
14
|
|
15
|
root_url = get_publisher().get_root_url()
|
16
|
wcs_path = get_request().get_path()[len(root_url):]
|
17
|
section = wcs_path.split('/')[0]
|
18
|
|
19
|
if section in ('backoffice', 'admin'):
|
20
|
return wcs_decorate(body, response)
|
21
|
|
22
|
section_title = ''
|
23
|
page_title = response.filter.get('title')
|
24
|
if section == 'consultations':
|
25
|
section_title = '<h2 id="consultations">%s</h2>\n' % _('Consultations')
|
26
|
response.filter['bigdiv'] = 'rub_consultation'
|
27
|
elif section == 'announces':
|
28
|
response.filter['bigdiv'] = 'rub_annonce'
|
29
|
section_title = '<h2 id="announces">%s</h2>\n' % _('Announces to citizens')
|
30
|
if page_title == _('Announces to citizens'):
|
31
|
page_title = ''
|
32
|
elif section == 'agenda':
|
33
|
response.filter['bigdiv'] = 'rub_agenda'
|
34
|
section_title = '<h2 id="agenda">%s</h2>\n' % _('Agenda')
|
35
|
if page_title == _('Agenda'):
|
36
|
page_title = ''
|
37
|
elif section and len(section) > 1:
|
38
|
# XXX: this works but is not efficient
|
39
|
if Category.has_urlname(section):
|
40
|
section_title = '<h2 id="services">%s</h2>\n' % _('Services')
|
41
|
response.filter['bigdiv'] = 'rub_service'
|
42
|
|
43
|
if not 'auquotiden-no-titles-in-section' in response.filter.get('keywords', []):
|
44
|
if page_title:
|
45
|
if section_title:
|
46
|
page_title = '<h3>%s</h3>' % page_title
|
47
|
else:
|
48
|
page_title = '<h2 id="info">%s</h2>' % page_title
|
49
|
else:
|
50
|
page_title = ''
|
51
|
|
52
|
body = '\n'.join((section_title, page_title, body))
|
53
|
|
54
|
if hasattr(response, 'breadcrumb') and response.breadcrumb:
|
55
|
if len(response.breadcrumb) == 1:
|
56
|
response.breadcrumb = None
|
57
|
|
58
|
return wcs_decorate(body, response)
|
59
|
|
60
|
template.decorate = decorate
|
61
|
|