nitdoc: Added function to get the commit form
authorStefan Lage <lagestfan@gmail.com>
Sat, 4 May 2013 00:14:42 +0000 (20:14 -0400)
committerStefan Lage <lagestfan@gmail.com>
Fri, 24 May 2013 01:14:37 +0000 (21:14 -0400)
This function add all necessary tags for the commit form.
Add also all tags for editing a comment, each are placed after a 'pre' tag
which correspond at a comment zone

signed-off by: Stefan Lage <lagestfan@gmail.com>

src/nitdoc.nit

index e366538..fc233bf 100644 (file)
@@ -184,6 +184,7 @@ class DocContext
                self.filename = "index.html"
                clear
                addGithubInformation
+               addCommitForm
                add("<!DOCTYPE html>")
                add("<html><head>{head}<title>Overview | {custom_title}</title></head><body>\n")
                add(action_bar)
@@ -229,6 +230,7 @@ class DocContext
                        action_bar = "<header><nav class='main'><ul>{custom_items}<li><a href='./index.html'>Overview</a></li><li class=\"current\">{mod.name}</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li><li id=\"liGitHub\" class=\"\"><a id=\"logGitHub\" class=\"btn\" ><img id=\"imgGitHub\" src=\"resources/icons/github-icon.png\" /></a><div class=\"popover bottom\"><div class=\"arrow\"></div><div><label id=\"lbloginGit\" for=\"login\">Username</label><input id=\"loginGit\" type=\"text\" name=\"login\"><label id=\"logginMessage\" >Hello <a id=\"githubAccount\" ><strong id=\"nickName\"></strong></a></label></div><div><label id=\"lbpasswordGit\" for=\"password\">Password</label><input id=\"passwordGit\" type=\"password\" name=\"password\"></div><div><label id=\"lbrepositoryGit\" for=\"repository\">Repository</label><input id=\"repositoryGit\" type=\"text\" name=\"repository\"></div><div><label id=\"lbbranchGit\" for=\"branch\">Branch</label><input id=\"branchGit\" type=\"text\" name=\"branch\"></div><div id=\"divlogIn\"><a id=\"signIn\" >Sign In</a></div></div></li></ul></nav></header>\n"
                        clear
                        addGithubInformation
+                       addCommitForm
                        add("<!DOCTYPE html>")
                        add("<html><head>{head}<title>{mod.name} module | {custom_title}</title></head><body>\n")
                        add(action_bar)
@@ -247,6 +249,7 @@ class DocContext
                        action_bar = "<header><nav class='main'><ul>{custom_items}<li><a href='./index.html'>Overview</a></li><li>{c.global.intro.mmmodule.toplevel_owner.html_link(self)}</li><li class=\"current\">{c.name}</li><li><a href='full-index.html'>Full Index</a></li><li><a href=\"help.html\">Help</a></li><li id=\"liGitHub\" class=\"\"><a id=\"logGitHub\" class=\"btn\" ><img id=\"imgGitHub\" src=\"resources/icons/github-icon.png\" /></a><div class=\"popover bottom\"><div class=\"arrow\"></div><div><label id=\"lbloginGit\" for=\"login\">Username</label><input id=\"loginGit\" type=\"text\" name=\"login\"><label id=\"logginMessage\" >Hello <a id=\"githubAccount\" ><strong id=\"nickName\"></strong></a></label></div><div><label id=\"lbpasswordGit\" for=\"password\">Password</label><input id=\"passwordGit\" type=\"password\" name=\"password\"></div><div><label id=\"lbrepositoryGit\" for=\"repository\">Repository</label><input id=\"repositoryGit\" type=\"text\" name=\"repository\"></div><div><label id=\"lbbranchGit\" for=\"branch\">Branch</label><input id=\"branchGit\" type=\"text\" name=\"branch\"></div><div id=\"divlogIn\"><a id=\"signIn\" >Sign In</a></div></div></li></ul></nav></header>\n"
                        clear
                        addGithubInformation
+                       addCommitForm
                        add("<!DOCTYPE html>")
                        add("<html><head>{head}<title>{c.name} class | {custom_title}</title></head><body>\n")
                        add(action_bar)
@@ -262,6 +265,7 @@ class DocContext
                action_bar = "<header><nav class='main'><ul>{custom_items}<li><a href='./index.html'>Overview</a></li><li class=\"current\">Full Index</li><li><a href=\"help.html\">Help</a></li><li id=\"liGitHub\" class=\"\"><a id=\"logGitHub\" class=\"btn\" ><img id=\"imgGitHub\" src=\"resources/icons/github-icon.png\" /></a><div class=\"popover bottom\"><div class=\"arrow\"></div><div><label id=\"lbloginGit\" for=\"login\">Username</label><input id=\"loginGit\" type=\"text\" name=\"login\"><label id=\"logginMessage\" >Hello <a id=\"githubAccount\" ><strong id=\"nickName\"></strong></a></label></div><div><label id=\"lbpasswordGit\" for=\"password\">Password</label><input id=\"passwordGit\" type=\"password\" name=\"password\"></div><div><label id=\"lbrepositoryGit\" for=\"repository\">Repository</label><input id=\"repositoryGit\" type=\"text\" name=\"repository\"></div><div><label id=\"lbbranchGit\" for=\"branch\">Branch</label><input id=\"branchGit\" type=\"text\" name=\"branch\"></div><div id=\"divlogIn\"><a id=\"signIn\" >Sign In</a></div></div></li></ul></nav></header>\n"
                clear
                addGithubInformation
+               addCommitForm
                add("<!DOCTYPE html>")
                add("<html><head>{head}<title>Full Index | {custom_title}</title></head><body>\n")
                add(action_bar)
@@ -285,6 +289,11 @@ class DocContext
                if not github_repo == null then add("<div id=\"repoName\" name=\"{github_repo.to_s}\"></div>")
        end
 
+       # Add all tags for the commit form
+       fun addCommitForm do    
+               add("<div id=\"modal\"><form class=\"clearfix\"><div><label for=\"commitMessage\">Commit message</label><input id=\"commitMessage\" type=\"text\" name=\"commitMessage\"></div><div class=\"social-signup login\"><form ></form></div><form id=\"github-connect-form\" class=\"connect-button\" name=\"login\"><a id=\"loginAction\" title=\"Commit on GitHub\"><img src=\"resources/icons/github-icon.png\"><span id=\"btnGitHub\"><strong>Commit</strong></span></a></form></form></div><div id=\"modalQuestion\"><label id=\"txtQuestion\"></label><br><a id=\"btnCreateBranch\">Yes</a><a id=\"btnCancelBranch\">No</a></div><div id=\"waitCommit\"></div>\n\n")
+       end
+
        # Add a (source) link fo a given location
        fun show_source(l: Location)
        do
@@ -303,6 +312,24 @@ class DocContext
                end
        end
 
+       # Return source link for a given location
+       fun get_source(l: Location): String
+       do
+               var s = opt_source.value
+               if s == null then
+                       return l.file.filename.simplify_path
+               else
+                       # THIS IS JUST UGLY ! (but there is no replace yet)
+                       var x = s.split_with("%f")
+                       s = x.join(l.file.filename.simplify_path)
+                       x = s.split_with("%l")
+                       s = x.join(l.line_start.to_s)
+                       x = s.split_with("%L")
+                       s = x.join(l.line_end.to_s)
+                       return s
+               end
+       end
+
        # Generate a clicable graphiz image using a dot content.
        # `name' refer to the filename (without extension) and the id name of the map.
        # `name' must also match the name of the graph in the dot content (eg. digraph NAME {...)
@@ -613,7 +640,9 @@ redef class MMModule
                var doc = doc
                if doc != null then
                        dctx.add("<div id=\"description\">\n")
-                       dctx.add("<pre>{doc.to_html}</pre>\n")
+                       dctx.add("<pre class=\"text_label\">{doc.to_html}</pre>\n")
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>\n")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
                        dctx.add("</div>\n")
                end
 
@@ -836,7 +865,7 @@ redef class MMModule
                        var lpi = self[gp.intro.local_class.global][gp]
                        
                        lps.remove(lpi)
-                               dctx.add("<li class='intro'><span title='introduction'>I</span>&nbsp;{lpi.html_open_link(dctx)}{lpi.html_name}&nbsp;({lpi.local_class})</a></li>\n")
+                       dctx.add("<li class='intro'><span title='introduction'>I</span>&nbsp;{lpi.html_open_link(dctx)}{lpi.html_name}&nbsp;({lpi.local_class})</a></li>\n")
                        if lps.length >= 1 then
                                dctx.sort(lps)
                                for lp in lps do
@@ -1041,7 +1070,6 @@ redef class MMLocalProperty
                dctx.add("<article id=\"{html_anchor}\" class=\"{kind} {visibility} {if is_redef then "redef" else ""}\">\n")
                dctx.add("<h3 class=\"signature\">{html_name}{signature.to_html(dctx, true)}</h3>\n")
                dctx.add("<div class=\"info\">\n")
-               #dctx.add("<p>LP: {self.mmmodule.html_link(dctx)}::{self.local_class.html_link(dctx)}::{self.html_link(dctx)}</p>")
 
                if is_redef then
                        dctx.add("redef ")
@@ -1083,7 +1111,9 @@ redef class MMLocalProperty
                        end
                end
                if introdoc then
-                       dctx.add("<pre>{global.intro.doc.to_html}</pre>")
+                       dctx.add("<pre class=\"text_label\" name=\"{html_name}\" >{global.intro.doc.to_html}</pre>")
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
                end
 
                var tlmods = new Array[MMModule]
@@ -1114,12 +1144,21 @@ redef class MMLocalProperty
                                dctx.add("<h4>In module {tm.html_link(dctx)} :</h4>")
                        end
 
-                       #dctx.add("<p>TLP: {tm} x {lc} : {tlp.full_name}</p>")
-
                        var doc = tlp.doc
+                       var n = tlp.node
                        if doc != null and (not introdoc or global.intro.doc != doc) then
-                               dctx.add("<pre>{doc.to_html}</pre>")
+                               if n != null then
+                                       var l = n.location
+                                       dctx.add("<pre type=\"1\" class=\"text_label\" tag=\"{l.file.filename}\" name=\"{dctx.get_source(l)}\" title=\"{l.line_start.to_s}\" >{doc.to_html}</pre>")
+                               end
+                       else if not is_redef then
+                               if n != null then
+                                       var l = n.location
+                                       dctx.add("<a class=\"newComment\" tag=\"{l.file.filename}\" title=\"{l.line_start.to_s}\">New comment</a>\n")
+                               end
                        end
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
                        dctx.add("<p>")
                        if tlp.local_class.global != lc.global then
                                dctx.add("inherited from {tlp.local_class.html_link(dctx)} ")
@@ -1127,7 +1166,6 @@ redef class MMLocalProperty
                        if tm != tlp.mmmodule then
                                dctx.add("defined by the module {tlp.mmmodule.html_link(dctx)} ")
                        end
-                       var n = tlp.node
                        if n != null then
                                var l = n.location
                                dctx.show_source(l)
@@ -1149,11 +1187,6 @@ redef class MMLocalProperty
                                        var l = n.location
                                        dctx.show_source(l)
                                end
-
-                               #var doc = lp.doc
-                               #if doc != null and (not introdoc or global.intro.doc != doc) then
-                               #       dctx.add("<pre>{doc.to_html}</pre>")
-                               #end
                        end
                        dctx.close_stage
                        dctx.add("</p>")
@@ -1408,7 +1441,10 @@ redef class MMLocalClass
                dctx.add("<section class=\"description\">\n")
                var doc = doc
                if doc != null then
-                       dctx.add("<pre>{doc.to_html}</pre>\n")
+                       var l = doc.location
+                       dctx.add("<pre type=\"2\" class=\"text_label\" tag=\"{l.file.filename}\" name=\"{dctx.get_source(l)}\" title=\"{l.line_start.to_s}\">{doc.to_html}</pre>\n")
+                       dctx.add("<textarea rows=\"1\" cols=\"76\" id=\"fileContent\" class=\"edit\"></textarea>")
+                       dctx.add("<a id=\"cancelBtn\">Cancel</a><a id=\"commitBtn\">Commit</a>")
                end
 
                var cla = new HashSet[MMLocalClass]