1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2014-2015 Alexandre Terrasa <alexandre@moz-code.org>
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 # Base HTML rendering templates for `nitpg`.
22 redef class GameEntity
24 # Path to this entity from root.
25 fun path
: String do return collection_name
/ key
27 # URL to this game entity page.
28 fun url
: String do return game
.url
/ path
33 # Root URL ise used as a prefix for `url`.
35 # This must be set before any access to `url`.
36 var root_url
: String is noinit
, writable
38 redef fun url
do return "{root_url}/{path}"
40 # Return a HTML link to this Game.
41 fun link
: String do return "<a href=\"{url}\
">{name}</a>"
45 # Return a HTML link to this Player.
46 fun link
: String do return "<a href=\"{url}\
">{name}</a>"
50 # Return a HTML link to this Issue.
51 fun link
: String do return "<a href=\"{html_url or else "#"}\
">#{number}</a>"
54 redef class Achievement
55 # Return a HTML link to this Issue.
56 fun link
: String do return "<a href=\"{url}\
">{name}</a>"
58 # Render self as a media item.
59 fun list_item
: String do
60 return """<div class="media">
61 <div class="media-left" style="width: 50px">
62 <span class="glyphicon glyphicon-check"></span>
63 <span class="badge progress-bar-success"
64 style="position: absolute; margin-top: 10px;
65 margin-left: -5px;">+{{{reward}}}</span>
67 <div class="media-body">
68 <h4 class="media-heading">{{{link}}}</h4>
69 <span class="text-muted">{{{desc}}}</span>