Projet

Général

Profil

Télécharger (1,79 ko) Statistiques
| Branche: | Révision:

root / admin / template.ptl @ b77557ca

1
from cStringIO import StringIO
2

    
3
from quixote.html import htmltext
4

    
5
import ezt
6

    
7
#<?xml version="1.0" encoding="utf-8"?>
8
#    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9

    
10

    
11
ADMIN_TEMPLATE_EZT = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
12
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
13
<html xmlns="http://www.w3.org/1999/xhtml">
14
  <head>
15
    <title>Administration de Larpe - [page_title]</title>
16
    <link rel="stylesheet" type="text/css" href="/css/larpe-admin.css"/>
17
  </head>
18
  <body>
19
  <div id="header">[main_menu]</div>
20
  <div id="main-content">
21
    <p id="breadcrumb">[breadcrumb]</p>
22
    <h1>[subtitle]</h1>
23

    
24
    [body]
25

    
26
  </div>
27
  <div id="footer">
28
   <p id="lasso">Powered by Lasso</p>
29
  </div>
30
 </body>
31
</html>"""
32

    
33
admin_template = ezt.Template()
34
admin_template.parse(ADMIN_TEMPLATE_EZT)
35

    
36
menu_items = [
37
    ('apache', 'Apache')]
38

    
39
def generate_main_menu(selected = None):
40
    s = '<ul id="menu">\n'
41
    for k, v in menu_items:
42
        if k == selected:
43
            s += '<li class="active">'
44
        else:
45
            s += '<li>'
46
        s += '<a href="/%s/">%s</a></li>\n' % (k, v)
47
    s + '</ul>\n'
48
    return s
49

    
50
def generate_breadcrumb(section = None):
51
	s = '<a href="/">Administration</a>'
52
	if section is not None:
53
	    for k, v in menu_items:
54
	    	if k == section:
55
				s += ' > <a href="/%s">%s</a>' % (k, v)
56
				break
57
	return s
58

    
59
def generate_html(section, body):
60
	if section is not None:
61
		section = str(section)
62
	body = str(body)
63
	main_menu = generate_main_menu(section)
64
	breadcrumb = generate_breadcrumb(section)
65
	page_title = ''
66
	if section is not None:
67
	    for k, v in menu_items:
68
	    	if k == section:
69
				page_title = v				
70
				break
71
	subtitle = page_title
72
	
73
	fd = StringIO()
74
	admin_template.generate(fd, locals())
75
	return htmltext(fd.getvalue())
(10-10/10)