import model::model_collect
import doc::doc_down
import html::bootstrap
+import catalog
redef class MEntity
end
var mdoc = self.mdoc_or_fallback
if title == null and mdoc != null then
- title = mdoc.synopsis.html_escape
+ title = mdoc.synopsis
end
return new Link(html_url, text, title)
end
# An icon representative of the mentity
fun html_icon: BSIcon do return new BSIcon("tag", ["text-muted"])
- # A li element that can go in a `HTMLList`
- fun html_list_item: ListItem do
- var tpl = new Template
- tpl.add html_namespace
- var comment = mdoc_or_fallback
- if comment != null then
- tpl.add ": "
- tpl.add comment.html_synopsis
- end
- return new ListItem(tpl)
- end
-
# CSS classes used to decorate `self`
#
# Mainly used for icons.
return tpl
end
end
+
+redef class Person
+
+ # HTML uniq id
+ fun html_id: String do return name.to_cmangle
+
+ # HTML default URL
+ #
+ # Should be redefined in clients.
+ fun html_url: String do return "person_{html_id}.html"
+
+ # Link to this person `html_url`
+ fun html_link: Link do return new Link(html_url, name)
+
+ redef fun to_html do
+ var tpl = new Template
+ tpl.addn "<span>"
+ var gravatar = self.gravatar
+ if gravatar != null then
+ tpl.addn "<img class='avatar' src='https://secure.gravatar.com/avatar/{gravatar}?size=14&default=retro' />"
+ end
+ tpl.addn html_link
+ tpl.addn "</span>"
+ return tpl.write_to_string
+ end
+end