Merge: src/platforms: fallback to version field "0" on error when asking for a git_re...
[nit.git] / contrib / benitlux / src / server / benitlux_view.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # View logic of the Web interface Benitlux
18 module benitlux_view
19
20 import benitlux_model
21 import template
22
23 # Template for the whole Benitlux page
24 class BenitluxDocument
25 super Template
26
27 # Page title
28 var page_title = "Benitlux Mailing List" is writable
29
30 # Page header
31 fun header: Template do return new BenitluxHeader
32
33 # Error or success message content, will be shown in a dismissable panel
34 var message_content: nullable String = null is writable
35
36 # Error or success message level (success/danger/warning/info)
37 var message_level: nullable String = null is writable
38
39 # Lines of the last email sent to subscribers
40 var sample_email_lines: nullable Array[String] = null is writable
41
42 redef fun rendering
43 do
44 add """
45 <!DOCTYPE html>
46 <html>
47 <head>
48 <meta charset="utf-8">
49 <meta http-equiv="X-UA-Compatible" content="IE=edge">
50 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
51 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
52 <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
53 <title>"""
54 add page_title
55 add """</title>
56 </head>
57 <body>
58 """
59 add header
60 add """
61 <div class="container">
62
63 <div class="panel panel-default">
64 <div class="panel-body">
65 <p>Service de diffusion des changements au menu de l'excellente
66 <a href="http://www.brasseriebenelux.com/">Brasserie Bénélux</a>
67 sur la rue Sherbrooke. La liste est mise à jours tous les jours à 14h,
68 le courriel est envoyé au même moment.</p>
69 <form class="form-inline text-center" role="form" method="POST">
70 <div class="form-group">
71 <div class="input-group">
72 <div class="input-group-addon">@</div>
73 <input class="form-control" type="email" name="email" placeholder="Enter email">
74 </div>
75 </div>
76 <button type="submit" class="btn btn-default" name="sub">S'inscrire</button>
77 <button type="submit" class="btn btn-default" name="unsub">Se désinscrire</button>
78 </form>
79 </div>
80 </div>
81 """
82
83 var message_level = message_level
84 var message_content = message_content
85 if message_level != null and message_content != null then
86 add """
87 <div class="alert alert-{{{message_level}}} alert-dismissible" role="alert">
88 <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
89 {{{message_content}}}
90 </div>
91 """
92 end
93
94 var sample_email_lines = sample_email_lines
95 if sample_email_lines != null then
96 add """
97 <div class="panel panel-default">
98 <div class="panel-heading">Dernier courriel envoyé</div>
99 <ul class="list-group">
100 <li class="list-group-item">
101 {{{sample_email_lines.join("</li><li class=\"list-group-item\">")}}}
102 </li>
103 </ul>
104 </div>"""
105 end
106
107 add """
108 </div>
109 </body>
110 </html>"""
111 end
112 end
113
114 # Template for the header of Benitlux (right after the opening of `<body>`)
115 class BenitluxHeader
116 super Template
117
118 redef fun rendering
119 do
120 add """
121 <nav class="navbar navbar-default" role="navigation">
122 <div class="container-fluid">
123 <div class="navbar-header">
124 <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
125 <span class="sr-only">Toggle navigation</span>
126 <span class="icon-bar"></span>
127 <span class="icon-bar"></span>
128 <span class="icon-bar"></span>
129 </button>
130 <a class="navbar-brand" href="http://xymus.net/">Xymus.net</a>
131 </div>
132
133 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
134 <ul class="nav navbar-nav">
135 <li><a href="http://pep8.xymus.net/">Pep/8 Analysis</a></li>
136 <li><a href="http://tnitter.xymus.net/">Tnitter</a></li>
137 <li class="active"><a href="http://benitlux.xymus.net/">Benitlux</a></li>
138 </ul>
139 </div>
140 </div>
141 </nav>"""
142 end
143 end