a4f40d938039bdf3e0f8afd17eafb5b0dfde0f8b
[nit.git] / contrib / nitrpg / src / templates / templates_base.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2014-2015 Alexandre Terrasa <alexandre@moz-code.org>
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 # Base HTML rendering templates for `nitpg`.
18 module templates_base
19
20 import achievements
21
22 redef class GameEntity
23
24 # URL to this game entity page.
25 fun url: String do return game.url / key
26 end
27
28 redef class Game
29
30 # Root URL ise used as a prefix for `url`.
31 #
32 # This must be set before any access to `url`.
33 var root_url: String is noinit, writable
34
35 redef fun url do return "{root_url}/games" / key
36
37 # Return a HTML link to this Game.
38 fun link: String do return "<a href=\"{url}\">{name}</a>"
39 end
40
41 redef class Player
42 # Return a HTML link to this Player.
43 fun link: String do return "<a href=\"{url}\">{name}</a>"
44 end
45
46 redef class Issue
47 # Return a HTML link to this Issue.
48 fun link: String do return "<a href=\"{html_url}\">#{number}</a>"
49 end
50
51 redef class Achievement
52 # Return a HTML link to this Issue.
53 fun link: String do return "<a href=\"{url}\">{name}</a>"
54
55 fun list_item: String do
56 return """<div class="media">
57 <div class="media-left" style="width: 50px">
58 <span class="glyphicon glyphicon-check"></span>
59 <span class="badge progress-bar-success"
60 style="position: absolute; margin-top: 10px;
61 margin-left: -5px;">+{{{reward}}}</span>
62 </div>
63 <div class="media-body">
64 <h4 class="media-heading">{{{link}}}</h4>
65 <span class="text-muted">{{{desc}}}</span>
66 </div>
67 </div>"""
68
69 end
70 end