Merge: src/doc/commands: use filters
[nit.git] / src / doc / templates / templates_html.nit
index 7a51f06..4faf0a6 100644 (file)
@@ -18,6 +18,7 @@ module templates_html
 import model::model_collect
 import doc::doc_down
 import html::bootstrap
+import catalog
 
 redef class MEntity
 
@@ -104,14 +105,12 @@ redef class MEntity
 end
 
 redef class MPackage
-       redef fun html_url do return "package_{html_id}.html"
        redef fun html_namespace do return html_link
        redef fun html_icon do return new BSIcon("book", ["text-muted"])
        redef var css_classes = ["public"]
 end
 
 redef class MGroup
-       redef fun html_url do return "group_{html_id}.html"
        redef fun html_icon do return new BSIcon("folder-close", ["text-muted"])
 
        redef fun html_namespace do
@@ -127,7 +126,6 @@ redef class MGroup
 end
 
 redef class MModule
-       redef fun html_url do return "module_{html_id}.html"
        redef fun html_icon do return new BSIcon("file", ["text-muted"])
 
        redef fun html_namespace do
@@ -143,7 +141,6 @@ redef class MModule
 end
 
 redef class MClass
-       redef fun html_url do return "class_{html_id}.html"
        redef fun html_icon do return new BSIcon("stop", css_classes)
        redef fun html_signature(short) do return intro.html_signature(short)
        redef fun css_classes do return super + [visibility.to_s]
@@ -163,7 +160,6 @@ redef class MClass
 end
 
 redef class MClassDef
-       redef fun html_url do return "{mclass.html_url}#{html_id}"
        redef fun css_classes do return super + mclass.css_classes
 
        redef fun html_namespace do
@@ -217,7 +213,6 @@ redef class MClassDef
 end
 
 redef class MProperty
-       redef fun html_url do return "property_{html_id}.html"
        redef fun html_declaration do return intro.html_declaration
        redef fun html_signature(short) do return intro.html_signature(short)
        redef fun html_icon do return new BSIcon("tag", css_classes)
@@ -233,7 +228,6 @@ redef class MProperty
 end
 
 redef class MPropDef
-       redef fun html_url do return "{mproperty.html_url}#{html_id}"
        redef fun css_classes do return super + mproperty.css_classes
 
        redef fun html_namespace do
@@ -270,7 +264,9 @@ redef class MMethodDef
                if mproperty.is_root_init and new_msignature != null then
                        return new_msignature.html_signature(short)
                end
-               return msignature.as(not null).html_signature(short)
+               var msignature = self.msignature
+               if msignature == null then return new Template
+               return msignature.html_signature(short)
        end
 end
 
@@ -367,3 +363,29 @@ redef class MParameter
                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&amp;default=retro' />"
+               end
+               tpl.addn html_link
+               tpl.addn "</span>"
+               return tpl.write_to_string
+       end
+end