nitdoc: auto hide source-link
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 26 Jun 2014 18:30:59 +0000 (14:30 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 1 Jul 2014 15:48:11 +0000 (11:48 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/nitdoc/css/nitdoc.css
src/doc/doc_pages.nit
src/doc/doc_templates.nit

index eabe3e7..3f200bc 100644 (file)
@@ -264,6 +264,20 @@ h3 {
        margin-left: 30px;
 }
 
+.source-link {
+       display: none;
+       float: right;
+       margin-top: 10px;
+}
+
+.source-link a {
+       color: #0d8921;
+}
+
+article:hover .source-link, article:target .source-link {
+       display: block;
+}
+
 /*
  * Code Highlighting
  */
index 828458c..2881557 100644 (file)
@@ -340,7 +340,7 @@ abstract class NitdocPage
        do
                if location == null then return null
                var source = ctx.opt_source.value
-               if source == null then return "({location.file.filename.simplify_path})"
+               if source == null then return "{location.file.filename.simplify_path}"
                # THIS IS JUST UGLY ! (but there is no replace yet)
                var x = source.split_with("%f")
                source = x.join(location.file.filename.simplify_path)
@@ -349,7 +349,7 @@ abstract class NitdocPage
                x = source.split_with("%L")
                source = x.join(location.line_end.to_s)
                source = source.simplify_path
-               return " (<a target='_blank' title='Show source' href=\"{source.to_s}\">source</a>)"
+               return "<a target='_blank' title='Show source' href=\"{source.to_s}\">View Source</a>"
        end
 
        # MProject description template
index a95361d..8962221 100644 (file)
@@ -475,6 +475,11 @@ class TplArticle
        redef fun rendering do
                if is_empty then return
                add "<article id='{id}' class='{css_classes.join(" ")}'>"
+               if source_link != null then
+                       add "<div class='source-link'>"
+                       add source_link.as(not null)
+                       add "</div>"
+               end
                if title != null then
                        var lvl = hlvl
                        if lvl == 2 then title_classes.add "well well-sm"
@@ -490,9 +495,6 @@ class TplArticle
                if content != null then
                        add content.as(not null)
                end
-               if source_link != null then
-                       add source_link.as(not null)
-               end
                for child in children do
                        add child
                end