ni_nitdoc: moved JS GitHub to Nitdoc.GitHub module
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 11 Oct 2013 03:08:22 +0000 (23:08 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 11 Oct 2013 03:08:22 +0000 (23:08 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

share/ni_nitdoc/resources/icons/github-icon-green.png [new file with mode: 0644]
share/ni_nitdoc/resources/icons/github-icon-white.png [moved from share/ni_nitdoc/resources/icons/github-icon-w.png with 100% similarity]
share/ni_nitdoc/scripts/Nitdoc.GitHub.js [new file with mode: 0644]
share/ni_nitdoc/scripts/Nitdoc.QuickSearch.js
share/ni_nitdoc/scripts/Nitdoc.UI.js
share/ni_nitdoc/scripts/github.js [deleted file]
share/ni_nitdoc/styles/Nitdoc.GitHub.css [moved from share/ni_nitdoc/styles/github.css with 71% similarity]
share/ni_nitdoc/styles/Nitdoc.QuickSearch.css
share/ni_nitdoc/styles/Nitdoc.UI.css
share/ni_nitdoc/styles/main.css
src/ni_nitdoc.nit

diff --git a/share/ni_nitdoc/resources/icons/github-icon-green.png b/share/ni_nitdoc/resources/icons/github-icon-green.png
new file mode 100644 (file)
index 0000000..bd70ccc
Binary files /dev/null and b/share/ni_nitdoc/resources/icons/github-icon-green.png differ
diff --git a/share/ni_nitdoc/scripts/Nitdoc.GitHub.js b/share/ni_nitdoc/scripts/Nitdoc.GitHub.js
new file mode 100644 (file)
index 0000000..7568e41
--- /dev/null
@@ -0,0 +1,1215 @@
+/* This file is part of NIT ( http://www.nitlanguage.org ).\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+   http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+   Documentation generator for the nit language.\r
+   Generate API documentation in HTML format from nit source code.\r
+*/\r
+\r
+/*\r
+ * Nitdoc.Github comment edition module\r
+ *\r
+ * Allows user to modify source code comments directly from the Nitdoc\r
+ */\r
+\r
+var Nitdoc = Nitdoc || {};\r
+\r
+Nitdoc.GitHub = {}; // Declare Nitdoc.GitHub submodule\r
+\r
+// Load GitHub UI\r
+$(document).ready(function() {\r
+       //FIXME base should be choosen by user\r
+       var base = $("body").attr("data-github-base");\r
+       var head = $("body").attr("data-github-head");\r
+       if(base && head) {\r
+               Nitdoc.GitHub.UI.init(base, head);\r
+       }\r
+});\r
+\r
+/*\r
+ * Nitdoc.Github.UI for comment edition module\r
+ */\r
+Nitdoc.GitHub.UI = function(base, head) {\r
+       var base;\r
+       var head;\r
+\r
+       var openedComments = 0; // currently edited comments count\r
+       var user = false; // logged user\r
+\r
+       var init = function(baseStr, headStr) {\r
+               base = baseStr;\r
+               head = headStr;\r
+               console.log("init GitHub module (base: "+ base +", head: "+ head +")");\r
+\r
+               // check local session\r
+               if(localStorage.user) {\r
+                       var session = JSON.parse(localStorage.user);\r
+                       var user = tryLogin(session.login, Base64.decode(session.password), session.repo);\r
+                       if(!user) {\r
+                               console.log("Session found but authentification failed");\r
+                               localStorage.clear();\r
+                       }\r
+               } else {\r
+                       console.log("No session found");\r
+               }\r
+\r
+               // activate ui\r
+               Nitdoc.GitHub.LoginBox.init("nav.main ul");\r
+               if(user) {\r
+                       Nitdoc.GitHub.LoginBox.displayLogout(base, head, user);\r
+                       activate(user);\r
+               } else {\r
+                       Nitdoc.GitHub.LoginBox.displayLogin();\r
+               }\r
+\r
+               // Prevent page unload if there is comments in editing mode\r
+               $(window).on('beforeunload', function() {\r
+                       if(Nitdoc.GitHub.UI.getOpenedComments() > 0){\r
+                               return "There is uncommited modified comments. Are you sure you want to leave this page?";\r
+                       }\r
+               });\r
+       }\r
+\r
+       // Activate comment UI for a logged user\r
+       var activate = function(loggedUser) {\r
+               // Save session\r
+               user = loggedUser;\r
+               saveSession(user);\r
+               \r
+               // get lastest commit\r
+               var latest = Nitdoc.GitHub.API.getLastCommit(user, head);\r
+               if(!latest || !latest.sha) {\r
+                       Nitdoc.GitHub.ModalBox.open("Head branch not found!", latest.status + ": " + latest.statusText, true);\r
+                       return;\r
+               }\r
+               if(localStorage.latestCommit != latest.sha) {\r
+                       console.log("Latest commit changed: cleaned cache");\r
+                       localStorage.requests = "[]";\r
+                       localStorage.latestCommit = latest.sha;\r
+               }\r
+               console.log("Latest commit sha: " + localStorage.latestCommit);\r
+\r
+               attachCommentEvents();\r
+               reloadComments();\r
+       }\r
+\r
+       // clear storage\r
+       var disactivate = function() {\r
+               if(Nitdoc.GitHub.UI.getOpenedComments() > 0){\r
+                       if(!confirm('There is uncommited modified comments. Are you sure you want to leave this page?')) {\r
+                               return false;\r
+                       }\r
+               }\r
+               // close session and purge cookie\r
+               localStorage.clear();\r
+               $(window).unbind('beforeunload');\r
+               window.location.reload();\r
+       }\r
+\r
+       // Attempt login through GitHub API\r
+       var tryLogin = function(login, password, repo) {\r
+               var user = new Nitdoc.GitHub.User(login, password, repo);\r
+               if(!Nitdoc.GitHub.API.login(user)) {\r
+                       return false;\r
+               }\r
+               return user;\r
+       }\r
+\r
+       // Attach edit button on each comment\r
+       var attachCommentEvents = function() {\r
+               // Blocks without comment\r
+               $("span.noComment").each(function() {\r
+                       //FIXME this should be done by nitdoc\r
+                       var baseComment = $(this).parent().prev();\r
+                       var location = Nitdoc.GitHub.Utils.parseLocation(baseComment.attr("data-comment-location"));\r
+                       var locString = "../" + location.path + ":" + location.lstart + "," + location.tabpos + "--" + location.lstart + ",0";\r
+                       baseComment.attr("data-comment-location", locString);\r
+                       $(this).html("<a class='nitdoc-github-editComment noComment'>add comment</a> for ");\r
+                       $(this).addClass("nitdoc-github-editComment");\r
+               });\r
+               // Blocks with comment\r
+               $('.description div.comment').each(function() {\r
+                       var p = $(this).next();\r
+                       p.prepend("<span class='nitdoc-github-editComment'><a class='nitdoc-github-editComment'>edit comment</a> for </span>")\r
+               });\r
+\r
+               // Attach links events\r
+               $('a.nitdoc-github-editComment').each(function() {\r
+                       $(this).css("cursor", "pointer")\r
+                       $(this).click(function() {\r
+                               // hide link\r
+                               $(this).parent().hide();\r
+                               // add infos\r
+                               var infos = {};\r
+                               var baseTextarea;\r
+                               if(!$(this).hasClass("noComment")) {\r
+                                       $(this).parent().parent().prev().hide();\r
+                                       baseTextarea = $(this).parent().parent().prev().prev();\r
+                               } else {\r
+                                       baseTextarea = $(this).parent().parent().prev();\r
+                                       infos.isNew = true;\r
+                               }\r
+                               infos.user = Nitdoc.GitHub.UI.getUser();\r
+                               infos.location = Nitdoc.GitHub.Utils.parseLocation(baseTextarea.attr("data-comment-location"));\r
+                               infos.namespace = baseTextarea.attr("data-comment-namespace");\r
+                               infos.oldComment = baseTextarea.val();\r
+                               var box = new Nitdoc.GitHub.CommentBox(infos);\r
+                               box.open(baseTextarea);\r
+                       });\r
+               });\r
+       }\r
+\r
+       // reload comments from saved pull request\r
+       var reloadComments = function() {\r
+               if(!localStorage.requests){ return; }\r
+               var requests = JSON.parse(localStorage.requests);\r
+               var converter = new Markdown.Converter();\r
+               // Look for modified comments in page\r
+               for(i in requests) {\r
+                       if(!requests[i]) { continue; }\r
+                       var request = requests[i];\r
+                       $("textarea[data-comment-location=\"" + request.location + "\"]").each(function () {\r
+                               var div = $(this).next();\r
+                               if(request.isClosed) {\r
+                                       if(div.is("div.comment.newComment")) {\r
+                                               // hide empty comment\r
+                                               div.next().remove();\r
+                                               div.next().find("span.noComment").show();\r
+                                               div.remove();\r
+                                       } else if(div.is("div.comment.locked")) {\r
+                                               // unlock comment\r
+                                               div.empty();\r
+                                               div.append(converter.makeHtml($(this).text()));\r
+                                               div.removeClass("locked");\r
+                                               div.css("cursor", "pointer")\r
+                                               div.next().remove();\r
+                                               div.next().find("span.nitdoc-github-editComment").show();\r
+                                       }\r
+                               } else {\r
+                                       // create div for the new coment\r
+                                       if(!div.is("div.comment")) {\r
+                                               $(this).after("<div class='comment newComment'></div>");\r
+                                               div = $(this).next();\r
+                                       }\r
+                                       // lock modified comment\r
+                                       if(!div.hasClass("locked")) {\r
+                                               // convert modified comment to markdown\r
+                                               div.empty()\r
+                                               div.append(converter.makeHtml(Base64.decode(request.comment)));\r
+                                               // lock click\r
+                                               div.css("cursor", "auto");\r
+                                               div.addClass("locked");\r
+                                               div.next().find("span.nitdoc-github-editComment").hide();\r
+                                               div.after(\r
+                                                       $("<p class='locked inheritance'>")\r
+                                                       .text("comment modified in ")\r
+                                                       .append("<a href='"+ request.request.html_url +"' target='_blank' title='Review on GitHub'>pull request #"+ request.request.number +"</a>")\r
+                                                       .append(" ")\r
+                                                       .append(\r
+                                                               $("<a data-pullrequest-number='"+ request.request.number +"' class='nitdoc-github-update'>update</a>")\r
+                                                               .click(function (){\r
+                                                                       $(this).parent().hide();\r
+                                                                       div.hide();\r
+                                                                       var baseTextarea = div.prev();\r
+                                                                       // add infos\r
+                                                                       var infos = {};\r
+                                                                       infos.user = Nitdoc.GitHub.UI.getUser();\r
+                                                                       infos.location = Nitdoc.GitHub.Utils.parseLocation(baseTextarea.attr("data-comment-location"));\r
+                                                                       infos.namespace = baseTextarea.attr("data-comment-namespace");\r
+                                                                       infos.oldComment = baseTextarea.val();\r
+                                                                       infos.requestID = $(this).attr("data-pullrequest-number");\r
+                                                                       var box = new Nitdoc.GitHub.CommentBox(infos);\r
+                                                                       box.open(baseTextarea);                                                         \r
+                                                               })\r
+                                                       )\r
+                                                       .append(" ")\r
+                                                       .append(\r
+                                                               $("<a data-pullrequest-number='"+ request.request.number +"' class='nitdoc-github-cancel'>cancel</a>")\r
+                                                               .click(function (){\r
+                                                                       ui.closePullRequest($(this).attr("data-pullrequest-number"));\r
+                                                                       ui.reloadComments();\r
+                                                               })\r
+                                                       )\r
+                                               );\r
+                                       }\r
+                                       // hide "add comment" link\r
+                                       if(div.hasClass("newComment")) {\r
+                                               div.next().next().find("span.noComment").hide();\r
+                                       }\r
+                               }\r
+\r
+                       });\r
+               }\r
+       }\r
+\r
+       // Commit changes and send pull request\r
+       var saveChanges = function(infos) {\r
+               // if pull request update close existing pull request for the comment\r
+               if(infos.requestID) {\r
+                       closePullRequest(infos.requestID);\r
+               }\r
+\r
+               // forge commit\r
+               var fileContent = getFileContent(infos.location.path);\r
+               infos.newContent = Nitdoc.GitHub.Utils.mergeComment(fileContent, infos.newComment, infos.location);\r
+\r
+               // commit\r
+               infos.request = pushChanges(infos)\r
+               if(!infos.request) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to commit changes!", response, true);\r
+                       return;\r
+               }\r
+               saveRequest(infos);\r
+\r
+               // close boxes and reload comments              \r
+               Nitdoc.GitHub.CommitBox.close();\r
+               infos.commentBox.close();\r
+               reloadComments();\r
+       }\r
+\r
+       /*\r
+          Creating a new pull request with the new comment take 5 steps:\r
+               1. get the base tree from latest commit\r
+\r
+               2. create a new blob with updated file content\r
+               3. post a new tree from base tree and blob\r
+               4. post the new commit with new tree\r
+               5. create the pull request\r
+       */\r
+       var pushChanges = function(infos) {\r
+               var baseTree = Nitdoc.GitHub.API.getTree(user, localStorage.latestCommit);\r
+               if(!baseTree.sha) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to locate base tree!", baseTree.status + ": " + baseTree.statusText, true);\r
+                       return false;\r
+               }\r
+               console.log("Base tree: " + baseTree.url);\r
+               var newBlob = Nitdoc.GitHub.API.createBlob(user, infos.newContent);\r
+               if(!newBlob.sha) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to create new blob!", newBlob.status + ": " + newBlob.statusText, true);\r
+                       return false;\r
+               }\r
+               console.log("New blob: " + newBlob.url);\r
+               var newTree = Nitdoc.GitHub.API.createTree(user, baseTree, infos.location.path, newBlob);\r
+               if(!newTree.sha) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to create new tree!", newTree.status + ": " + newTree.statusText, true);\r
+                       return false;\r
+               }\r
+               console.log("New tree: " + newTree.url);\r
+               var newCommit = Nitdoc.GitHub.API.createCommit(user, infos.message, localStorage.latestCommit, newTree);\r
+               if(!newCommit.sha) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to create new commit!", newCommit.status + ": " + newCommit.statusText, true);\r
+                       return false;\r
+               }\r
+               console.log("New commit: " + newCommit.url);\r
+               var pullRequest = Nitdoc.GitHub.API.createPullRequest(user, infos.message.split("\n\n")[0], infos.message, base, newCommit.sha);\r
+               if(!pullRequest.number) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to create pull request!", pullRequest.status + ": " + pullRequest.statusText, true);\r
+                       return false;\r
+               }\r
+               console.log("New pull request: " + pullRequest.url);\r
+               return pullRequest;\r
+       }\r
+\r
+       // close previously opened pull request\r
+       var closePullRequest = function(number) {\r
+               // close pull request\r
+               var res = Nitdoc.GitHub.API.updatePullRequest(user, "Canceled from Wikidoc", "", "closed", number);\r
+               if(!res.id) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to close pull request!", res.status + ": " + res.statusText, true);\r
+                       return false;\r
+               }\r
+               // update in localstorage\r
+               var requests = JSON.parse(localStorage.requests);\r
+               if(!!requests[number]) {\r
+                       requests[number].isClosed = true;\r
+               }\r
+               localStorage.requests = JSON.stringify(requests);\r
+       }\r
+\r
+       // Get file content from github\r
+       var getFileContent = function(githubUrl) {\r
+               var origFile = Nitdoc.GitHub.API.getFile(user, githubUrl, head);\r
+               if(!origFile.content) {\r
+                       Nitdoc.GitHub.ModalBox.open("Unable to locate source file!", origFile.status + ": " + origFile.statusText, true);\r
+                       return;\r
+               }\r
+               var base64Content = origFile.content.substring(0, origFile.content.length - 1)\r
+               return Base64.decode(base64Content);\r
+       }\r
+\r
+       // save pull request in local storage\r
+       var saveRequest = function(infos) {\r
+               var requests = [];\r
+               if(localStorage.requests) {requests = JSON.parse(localStorage.requests)}\r
+               requests[infos.request.number] = {\r
+                       request: infos.request,\r
+                       location: infos.location.origin,\r
+                       comment: Base64.encode(infos.newComment)\r
+               };\r
+               localStorage.requests = JSON.stringify(requests);\r
+       }\r
+\r
+       // save user in local storage\r
+       var saveSession = function(user) {\r
+               var session = {\r
+                       login: user.login,\r
+                       password: Base64.encode(user.password),\r
+                       repo: user.repo\r
+               };\r
+               localStorage.user = JSON.stringify(session);\r
+       }\r
+\r
+       // accessors\r
+\r
+       var getUser = function() { return user; }\r
+       var getBase = function() { return base; }\r
+       var getHead = function() { return head; }\r
+       var getOpenedComments = function() { return openedComments; }\r
+       var addOpenedComments = function() { openedComments += 1; }\r
+       var remOpenedComments = function() { openedComments -= 1; }\r
+\r
+       // public interface\r
+       var ui = {\r
+               init: init,\r
+               tryLogin: tryLogin,\r
+               activate: activate,\r
+               disactivate: disactivate,\r
+               getUser: getUser,\r
+               getBase: getBase,\r
+               getHead: getHead,\r
+               getOpenedComments: getOpenedComments,\r
+               addOpenedComments: addOpenedComments,\r
+               remOpenedComments: remOpenedComments,\r
+               saveChanges: saveChanges,\r
+               closePullRequest: closePullRequest,\r
+               reloadComments: reloadComments\r
+       }\r
+\r
+       return ui;\r
+}();\r
+\r
+/*\r
+ * GitHub API user object\r
+ */\r
+Nitdoc.GitHub.User = function(login, password, repo) {\r
+       this.login = login;\r
+       this.password = password;\r
+       this.repo = repo;\r
+       this.auth = "Basic " +  Base64.encode(login + ':' + password);\r
+};\r
+\r
+/* \r
+ * GitHub API module\r
+ */\r
+Nitdoc.GitHub.API = function() {\r
+\r
+       // try to login the user to github API\r
+       var login = function(user) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "GET",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo,\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function() {\r
+                               res = true;\r
+                       }\r
+               });\r
+               user.infos = getUserInfos(user);\r
+               user.signedOff = getSignedOff(user)\r
+               return res;\r
+       }\r
+\r
+       // request for user github account infos\r
+       var getUserInfos = function(user) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "GET",\r
+                           url: "https://api.github.com/users/" + user.login,\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+       }\r
+\r
+       // build signedoff user default signature\r
+       var getSignedOff = function(user) {\r
+               return user.infos.name + " &lt;" + user.infos.email + "&gt;";\r
+       }\r
+\r
+       /* GitHub commits */\r
+\r
+       // get the latest commit on `branchName`\r
+       var getLastCommit = function(user, branchName) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "GET",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/refs/heads/" + branchName,\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response.object;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+    }\r
+\r
+       // get the base tree for a commit sha\r
+       var getTree = function(user, sha) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "GET",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/trees/" + sha + "?recursive=1",\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+       }\r
+\r
+       // create a new blob\r
+       var createBlob = function(user, content) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "POST",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/blobs",\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       data: JSON.stringify({\r
+                               content: Base64.encode(content),\r
+                               encoding: "base64"\r
+                       }),\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+    }\r
+\r
+       // create a new tree from a base tree\r
+       var createTree = function(user, baseTree, path, blob) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "POST",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/trees",\r
+                       data: JSON.stringify({\r
+                               base_tree: baseTree.sha,\r
+                               tree: [{\r
+                                       path: path,\r
+                                       mode: 100644, // file (blob)\r
+                                       type: "blob",\r
+                                       sha: blob.sha\r
+                               }]\r
+                       }),\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+       }\r
+\r
+       // create a new commit\r
+       var createCommit = function(user, message, parentCommit, tree) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "POST",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/commits",\r
+                       data: JSON.stringify({\r
+                               message: message,\r
+                               parents: parentCommit,\r
+                               tree: tree.sha,\r
+                       }),\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+       }\r
+\r
+       // create a pull request\r
+       var createPullRequest = function(user, title, body, base, head) {\r
+               var res = false;\r
+               $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                               xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "POST",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/pulls",\r
+                       data: JSON.stringify({\r
+                               title: title,\r
+                               body: body,\r
+                               base: base,\r
+                               head: head\r
+                       }),\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+       }\r
+\r
+       // update a pull request\r
+       var updatePullRequest = function(user, title, body, state, number) {\r
+               var res = false;\r
+                       $.ajax({\r
+                       beforeSend: function (xhr) {\r
+                                       xhr.setRequestHeader ("Authorization", user.auth);\r
+                       },\r
+                       type: "PATCH",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/pulls/" + number,\r
+                       data: JSON.stringify({\r
+                               title: title,\r
+                               body: body,\r
+                               state: state\r
+                       }),\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+       }\r
+\r
+       /* Files */\r
+\r
+       var getFile = function(user, path, branch) {\r
+               var res = false;\r
+               $.ajax({\r
+                       type: "GET",\r
+                       url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/contents/" + path,\r
+                       data: {\r
+                               ref: branch\r
+                       },\r
+                       async: false,\r
+                       dataType: 'json',\r
+                       success: function(response) {\r
+                               res = response;\r
+                       },\r
+                       error: function(response) {\r
+                               res = response;\r
+                       }\r
+               });\r
+               return res;\r
+       }\r
+\r
+       var api = {\r
+               login: login,\r
+               getLastCommit: getLastCommit,\r
+               getTree: getTree,\r
+               createBlob: createBlob,\r
+               createTree: createTree,\r
+               createCommit: createCommit,\r
+               createPullRequest: createPullRequest,\r
+               updatePullRequest: updatePullRequest,\r
+               getFile: getFile\r
+       }\r
+\r
+       return api;\r
+}();\r
+\r
+/*\r
+ * Nitdoc GitHub loginbox module\r
+ */\r
+\r
+Nitdoc.GitHub.LoginBox = function() {\r
+       var loginBox;\r
+       var loginBoxLi;\r
+       var loginBoxContent;\r
+\r
+       var init = function(containerSelector) {\r
+               loginBoxLi = $(document.createElement("li"))\r
+               .attr("id", "nitdoc-github-li")\r
+               .append(\r
+                       $(document.createElement("a"))\r
+                       .append(\r
+                               $(document.createElement("img"))\r
+                               .attr({\r
+                                       src: "resources/icons/github-icon.png",\r
+                                       alt: "GitHub"\r
+                               })\r
+                               .addClass("nitdoc-github-li-img")\r
+                       )\r
+                       .click(function() { Nitdoc.GitHub.LoginBox.toggle() })\r
+               )\r
+\r
+               loginBoxContent = $(document.createElement("div"));\r
+               loginBox = $(document.createElement("div"))\r
+               .attr("id", "nitdoc-github-loginbox")\r
+               .css("display", "none")\r
+               .append(\r
+                       $(document.createElement("div"))\r
+                       .addClass("nitdoc-github-loginbox-arrow")\r
+                       .append("&nbsp;")\r
+               )\r
+               .append(\r
+                       $(document.createElement("h3"))\r
+                       .append("Github Sign In")\r
+               )\r
+               .append(loginBoxContent);\r
+\r
+               loginBoxLi.append(loginBox);\r
+               $(containerSelector).append(loginBoxLi);\r
+       }\r
+\r
+       // Panel of login box to display when the user is logged in\r
+       var displayLogout = function(base, head, user) {\r
+               var panel = $(document.createElement("div"))\r
+               .append(\r
+                       $(document.createElement("h4"))\r
+                       .append("Hello ")\r
+                       .append(\r
+                               $(document.createElement("a"))\r
+                               .attr("href", "https://github.com/" + user.login)\r
+                               .append(user.login)\r
+                       ).append("!")\r
+               )\r
+               .append(\r
+                       $(document.createElement("label"))\r
+                       .attr("for", "github-repo")\r
+                       .append("Repo")\r
+               )\r
+               .append(\r
+                       $(document.createElement("input"))\r
+                       .attr({\r
+                               id: "github-repo",\r
+                               type: "text",\r
+                               disabled: "disabled",\r
+                               value: user.repo\r
+                       })\r
+               )\r
+               .append(\r
+                       $(document.createElement("label"))\r
+                       .attr("for", "github-head")\r
+                       .append("Head")\r
+               )\r
+               .append(\r
+                       $(document.createElement("input"))\r
+                       .attr({\r
+                               id: "github-head",\r
+                               type: "text",\r
+                               disabled: "disabled",\r
+                               value: head\r
+                       })\r
+               )\r
+               .append(\r
+                       $(document.createElement("label"))\r
+                       .attr("for", "github-base")\r
+                       .append("Base")\r
+               )\r
+               .append(\r
+                       $(document.createElement("input"))\r
+                       .attr({\r
+                               id: "github-base",\r
+                               type: "text",\r
+                               disabled: "disabled",\r
+                               value: base\r
+                       })\r
+               )\r
+               .append(\r
+                       $(document.createElement("button"))\r
+                       .addClass("nitdoc-github-button")\r
+                       .append(\r
+                               $(document.createElement("img"))\r
+                               .attr("src", "resources/icons/github-icon.png")\r
+                       ).append("Sign Off")\r
+                       .click(function() { // log out user\r
+                               Nitdoc.GitHub.UI.disactivate();\r
+                               Nitdoc.GitHub.LoginBox.toggle();\r
+                       })\r
+               );\r
+               $(".nitdoc-github-li-img").attr("src", "resources/icons/github-icon-green.png");\r
+               loginBoxContent.empty()\r
+               loginBoxContent.append(panel);\r
+       }\r
+\r
+       // Panel of login box to display when the user is logged out\r
+       var displayLogin = function() {\r
+               var panel = $(document.createElement("form"))\r
+               .append(\r
+                       $(document.createElement("label"))\r
+                       .attr("for", "nitdoc-github-login-field")\r
+                       .append("Username")\r
+               )\r
+               .append(\r
+                       $(document.createElement("input"))\r
+                       .attr({\r
+                               id: "nitdoc-github-login-field",\r
+                               type: "text"\r
+                       })\r
+               )\r
+               .append(\r
+                       $(document.createElement("label"))\r
+                       .attr("for", "nitdoc-github-password-field")\r
+                       .append("Password")\r
+               )\r
+               .append(\r
+                       $(document.createElement("input"))\r
+                       .attr({\r
+                               id: "nitdoc-github-password-field",\r
+                               type: "password"\r
+                       })\r
+               )\r
+               .append(\r
+                       $(document.createElement("label"))\r
+                       .attr("for", "nitdoc-github-repo-field")\r
+                       .append("Repository")\r
+               )\r
+               .append(\r
+                       $(document.createElement("input"))\r
+                       .attr({\r
+                               id: "nitdoc-github-repo-field",\r
+                               type: "text"\r
+                       })\r
+               )\r
+               .append(\r
+                       $(document.createElement("button"))\r
+                       .addClass("nitdoc-github-button")\r
+                       .append(\r
+                               $(document.createElement("img"))\r
+                               .attr("src", "resources/icons/github-icon.png")\r
+                       ).append("Sign In")\r
+                       .click(function() {\r
+                               var login = $('#nitdoc-github-login-field').val();\r
+                               var password = $('#nitdoc-github-password-field').val();\r
+                               var repo = $('#nitdoc-github-repo-field').val();\r
+                               if(!login || !password || !repo) {\r
+                                       Nitdoc.GitHub.ModalBox.open("Sign in error", "Please enter your GitHub username, password and repository.", true);\r
+                               } else {\r
+                                       var user = Nitdoc.GitHub.UI.tryLogin(login, password, repo);\r
+                                       if(!user) {\r
+                                               Nitdoc.GitHub.ModalBox.open("Sign in error", "The username, password or repo you entered is incorrect.", true);\r
+                                       } else {\r
+                                               Nitdoc.GitHub.UI.activate(user);\r
+                                               var base = Nitdoc.GitHub.UI.getBase();\r
+                                               var head = Nitdoc.GitHub.UI.getHead();\r
+                                               Nitdoc.GitHub.LoginBox.displayLogout(base, head, user);\r
+                                       }\r
+                               }\r
+                               return false;\r
+                       })\r
+               )\r
+               $(".nitdoc-github-li-img").attr("src", "resources/icons/github-icon.png");\r
+               loginBoxContent.empty()\r
+               loginBoxContent.append(panel);\r
+       }\r
+\r
+       var toggle = function() {\r
+               if(loginBox.is(':hidden')) {\r
+                       loginBox.show();\r
+                       if (!$('#loginGit').is(':hidden')) { $('#loginGit').focus(); }\r
+               } else {\r
+                       loginBox.hide();\r
+               }\r
+       }\r
+\r
+       // Public interface\r
+       var loginbox = {\r
+               init: init,\r
+               displayLogin: displayLogin,\r
+               displayLogout: displayLogout,\r
+               toggle: toggle,\r
+               \r
+       };\r
+\r
+       return loginbox;\r
+}();\r
+\r
+/*\r
+ * Nitdoc.GitHub.CommentBox class\r
+ */\r
+\r
+// Init new modal box instance\r
+Nitdoc.GitHub.CommentBox = function(infos) {\r
+       this.infos = infos;\r
+       this.commentBoxDiv;\r
+}\r
+\r
+Nitdoc.GitHub.CommentBox.prototype.open = function(baseArea) {\r
+       Nitdoc.GitHub.UI.addOpenedComments();\r
+       var instance = this;\r
+\r
+       if(this.infos.requestID) {\r
+               // get comment from last pull request\r
+               var requests = JSON.parse(localStorage.requests);\r
+               this.infos.newComment = Base64.decode(requests[this.infos.requestID].comment);\r
+       } else {\r
+               this.infos.newComment = false;\r
+       }\r
+\r
+       // create comment box\r
+       var tarea = $(document.createElement("textarea"))\r
+       .append(this.infos.newComment === false? this.infos.oldComment: this.infos.newComment)\r
+       .keyup(function(event) {\r
+               $(event.target).css("height", (event.target.value.split(/\r|\n/).length * 16) + "px");\r
+               if ( (!instance.infos.requestID && $(event.target).val() != instance.infos.oldComment) || (instance.infos.requestID && $(event.target).val() != instance.infos.oldComment && $(event.target).val() != instance.infos.newComment) ) {\r
+                       $(event.target).parent().find("button.nitdoc-github-commit").removeAttr("disabled");\r
+               } else {\r
+                       $(event.target).parent().find("button.nitdoc-github-commit").attr("disabled", "disabled");\r
+               }\r
+       })\r
+       .keydown(function(event) {\r
+               if(event.keyCode == 13){\r
+                       $(event.target).css("height", ($(event.target).outerHeight() + 6) + "px");\r
+               }\r
+       });\r
+\r
+       this.commentBoxDiv = $(document.createElement("div"))\r
+       .addClass("nitdoc-github-commentbox")\r
+       .append(tarea)\r
+       .append(\r
+               $(document.createElement("a"))\r
+               .addClass("nitdoc-github-preview")\r
+               .click(function() {\r
+                       var converter = new Markdown.Converter()\r
+                       var html = converter.makeHtml(tarea.val());\r
+                       Nitdoc.GitHub.ModalBox.open("Preview", html, false);\r
+               })\r
+       )\r
+       .append(\r
+               $(document.createElement("button"))\r
+               .addClass("nitdoc-github-button")\r
+               .addClass("nitdoc-github-commit")\r
+               .append("Commit")\r
+               .click(function() {\r
+                       instance.infos.newComment = tarea.val();\r
+                       instance.infos.commentBox = instance;\r
+                       Nitdoc.GitHub.CommitBox.open(instance.infos);\r
+               })\r
+       )\r
+       .append(\r
+               $(document.createElement("button"))\r
+               .addClass("nitdoc-github-button")\r
+               .addClass("nitdoc-github-cancel")\r
+               .append("Cancel")\r
+               .click(function() {instance.close()})\r
+       );\r
+\r
+       baseArea.after(this.commentBoxDiv);\r
+       var cbWidth = this.commentBoxDiv.innerWidth();\r
+       var taWidth = tarea.outerWidth();\r
+       tarea.width(cbWidth - (taWidth - cbWidth));\r
+       tarea.trigger("keyup");\r
+       tarea.focus();\r
+}\r
+\r
+Nitdoc.GitHub.CommentBox.prototype.close = function() {\r
+       Nitdoc.GitHub.UI.remOpenedComments();\r
+       if(this.infos.isNew) {\r
+               this.commentBoxDiv.next().find("span.nitdoc-github-editComment").show();\r
+       } else if(this.infos.requestID) {\r
+               this.commentBoxDiv.next().show();\r
+               this.commentBoxDiv.next().next().show();\r
+       } else {\r
+               this.commentBoxDiv.next().show();\r
+               this.commentBoxDiv.next().next().find("span.nitdoc-github-editComment").show();\r
+       }\r
+       this.commentBoxDiv.remove();\r
+}\r
+\r
+/*\r
+ * Nitdoc.GitHub.ModalBox class\r
+ */\r
+\r
+// Init new modal box instance\r
+Nitdoc.GitHub.ModalBox = function() {\r
+\r
+       // Open modal box instance\r
+       var open = function(title, content, isError) {\r
+               $("body").append(\r
+                       $(document.createElement("div"))\r
+                       .attr("id", "nitdoc-github-modal-fade")\r
+                       .addClass("nitdoc-github-fade")\r
+               )\r
+               .append(\r
+                       $(document.createElement("div"))\r
+                       .attr("id", "nitdoc-github-modal")\r
+                       .addClass("nitdoc-github-modal")\r
+                       .append(\r
+                               $(document.createElement("a"))\r
+                               .addClass("nitdoc-github-close")\r
+                               .append(\r
+                                       $(document.createElement("img"))\r
+                                       .addClass("nitdoc-github-imgClose")\r
+                                       .attr({\r
+                                               src: "resources/icons/close.png",\r
+                                               title: "Close",\r
+                                               alt: "Close"\r
+                               \r
+                                       })\r
+                               ).click(function() { Nitdoc.GitHub.ModalBox.close() })\r
+                       )\r
+                       .append("<h3>" + title + "</h3>")\r
+                       .append("<div>" + content + "</div>")\r
+                       .append(\r
+                               $(document.createElement("div"))\r
+                               .addClass("nitdoc-github-buttons")\r
+                               .append(\r
+                                       $(document.createElement("button"))\r
+                                       .addClass("nitdoc-github-button")\r
+                                       .append("Ok")\r
+                                       .click(function() { Nitdoc.GitHub.ModalBox.close() })\r
+                               )\r
+                       )\r
+               );\r
+\r
+               if(isError) {\r
+                       $("#nitdoc-github-modal").addClass("nitdoc-github-error");\r
+               }\r
+\r
+               $("#nitdoc-github-modal").css({\r
+                       top: "50%",\r
+                       marginTop: -($("#nitdoc-github-modal").outerHeight() / 2) + "px",\r
+                       left: "50%",\r
+                       marginLeft: -($("#nitdoc-github-modal").outerWidth() / 2) + "px"\r
+               });\r
+       }\r
+\r
+       // Close modal box instance\r
+       var close = function() {\r
+               $("#nitdoc-github-modal").remove();\r
+               $("#nitdoc-github-modal-fade").remove();\r
+       }\r
+\r
+       // Public interface\r
+       var modalBox = {\r
+               open: open,\r
+               close: close\r
+       };\r
+\r
+       return modalBox;\r
+}();\r
+\r
+/*\r
+ * Nitdoc.GitHub.CommitBox instance\r
+ */\r
+\r
+// Init new commit box instance\r
+Nitdoc.GitHub.CommitBox = function() {\r
+\r
+       // Open commit box instance\r
+       var open = function(infos) {\r
+               $("body").append(\r
+                       $(document.createElement("div"))\r
+                       .attr("id", "nitdoc-github-commitBox-fade")\r
+                       .addClass("nitdoc-github-fade")\r
+               );\r
+               $("body").append(\r
+                       $(document.createElement("div"))\r
+                       .attr("id", "nitdoc-github-commitBox")\r
+                       .addClass("nitdoc-github-modal")\r
+                       .append(\r
+                               $(document.createElement("a"))\r
+                               .addClass("nitdoc-github-close")\r
+                               .append(\r
+                                       $(document.createElement("img"))\r
+                                       .addClass("nitdoc-github-imgClose")\r
+                                       .attr({\r
+                                               src: "resources/icons/close.png",\r
+                                               title: "Close",\r
+                                               alt: "Close"\r
+                               \r
+                                       })\r
+                               ).click(function() { Nitdoc.GitHub.CommitBox.close() })\r
+                       )\r
+                       .append("<h3>Commit changes</h3>")\r
+                       .append(\r
+                               $(document.createElement("div"))\r
+                               .append(\r
+                                       $(document.createElement("label"))\r
+                                       .attr("for", "nitdoc-github-commit-message")\r
+                               )\r
+                               .append("<br/>")\r
+                               .append(\r
+                                       $(document.createElement("textarea"))\r
+                                       .attr("id", "nitdoc-github-commit-message")\r
+                                       .append("doc: " + (infos.isNew ? "added" : "modified") + " comment for " + infos.namespace)\r
+                               )\r
+                               .append("<br/>")\r
+                               .append(\r
+                                       $(document.createElement("input"))\r
+                                       .attr({\r
+                                               id: "nitdoc-github-commit-signedoff",\r
+                                               type: "checkbox",\r
+                                               value: "Signed-off-by: " + infos.user.signedOff\r
+                                       })\r
+                                       .change(function(e) {\r
+                                               if ($(this).is(':checked')) {\r
+                                                       $("#nitdoc-github-commit-button").removeAttr("disabled");\r
+                                               } else {\r
+                                                       $("#nitdoc-github-commit-button").attr("disabled", "disabled");\r
+                                               }\r
+                                       })\r
+                               )\r
+                               .append(\r
+                                       $(document.createElement("label"))\r
+                                       .attr("for", "nitdoc-github-commit-signedoff")\r
+                                       .append("Signed-off-by: " + infos.user.signedOff)\r
+                               )\r
+                       ).append(\r
+                               $(document.createElement("div"))\r
+                               .addClass("nitdoc-github-buttons")\r
+                               .append(\r
+                                       $(document.createElement("button"))\r
+                                       .attr({\r
+                                               id: "nitdoc-github-commit-button",\r
+                                               disabled: "disabled"\r
+                                       })\r
+                                       .addClass("nitdoc-github-button")\r
+                                       .append(\r
+                                               $(document.createElement("img"))\r
+                                               .attr("src", "resources/icons/github-icon.png")\r
+                                       )\r
+                                       .append("Commit")\r
+                                       .mousedown(function() {\r
+                                               $(this).text("Commiting...");\r
+                                       })\r
+                                       .mouseup(function() {\r
+                                               infos.message = $("#nitdoc-github-commit-message").val() + "\n\n" + infos.user.signedOff;\r
+                                               Nitdoc.GitHub.UI.saveChanges(infos);\r
+                                       })\r
+                               )\r
+                       )\r
+               );\r
+\r
+               $("#nitdoc-github-commitBox").css({\r
+                       top: "50%",\r
+                       marginTop: -($("#nitdoc-github-commitBox").outerHeight() / 2) + "px",\r
+                       left: "50%",\r
+                       marginLeft: -($("#nitdoc-github-commitBox").outerWidth() / 2) + "px"\r
+               });\r
+       }\r
+\r
+       // Close commit box instance\r
+       var close = function() {\r
+               $("#nitdoc-github-commitBox").remove();\r
+               $("#nitdoc-github-commitBox-fade").remove();\r
+       }\r
+\r
+       // Public interface\r
+       var commitBox = {\r
+               open: open,\r
+               close: close\r
+       }\r
+       return commitBox;\r
+}();\r
+\r
+/*\r
+ * Nitdoc.GitHub.Utils module\r
+ */\r
+\r
+Nitdoc.GitHub.Utils = function() {\r
+       // Extract infos from string location "../lib/standard/collection/array.nit:457,1--458,0"\r
+       //FIXME this should be done by nitdoc\r
+       var parseLocation = function(location) {\r
+               var parts = location.split(":");\r
+               var loc = new Object();\r
+               loc.origin = location;\r
+               loc.path = parts[0].substr(3, parts[0].length);\r
+               loc.lstart = parseInt(parts[1].split("--")[0].split(",")[0]);\r
+               loc.tabpos = parseInt(parts[1].split("--")[0].split(",")[1]);\r
+               loc.lend = parseInt(parts[1].split("--")[1].split(",")[0]);\r
+               return loc;\r
+       }\r
+\r
+       // Meld modified comment into file content\r
+       var mergeComment = function(fileContent, comment, location) {\r
+               // replace comment in file content\r
+               var res = new String();\r
+               var lines = fileContent.split("\n");\r
+               // copy lines fron 0 to lstart\r
+               for(var i = 0; i < location.lstart - 1; i++) {\r
+                       res += lines[i] + "\n";\r
+               }\r
+               // set comment\r
+               if(comment && comment != "") {\r
+                       var commentLines = comment.split("\n");\r
+                       for(var i = 0; i < commentLines.length; i++) {\r
+                               var line = commentLines[i];\r
+                               var tab = location.tabpos > 1 ? "\t" : "";\r
+                               res += tab + (line.length > 0 ? "# " : "#") + line + "\n";\r
+                       }\r
+               }\r
+               // copy lines fron lend to end\r
+               for(var i = location.lend - 1; i < lines.length; i++) {\r
+                       res += lines[i];\r
+                       if(i < lines.length - 1) { res += "\n"; }\r
+               }\r
+               return res;\r
+       }\r
+\r
+       // Public interface\r
+       var utils = {\r
+               parseLocation: parseLocation,\r
+               mergeComment: mergeComment\r
+       };\r
+\r
+       return utils;\r
+}();\r
+\r
index a8b127c..25e3b94 100644 (file)
@@ -38,32 +38,27 @@ Nitdoc.QuickSearch = function() {
                        autocomplete: "off",
                        value: "quick search..."
                })
-               .addClass("nitdoc-qs-notused")
+               .addClass("nitdoc-qs-field-notused")
                .keyup(function(event) {
                        Nitdoc.QuickSearch.doKeyAction(event.keyCode);
                })
                .focusout(function() {
                        if($(this).val() == "") {
-                               $(this).addClass("nitdoc-qs-notused");
+                               $(this).addClass("nitdoc-qs-field-notused");
                                $(this).val("quick search...");
                        }
                })
                .focusin(function() {
                        if($(this).val() == "quick search...") {
-                               $(this).removeClass("nitdoc-qs-notused");
+                               $(this).removeClass("nitdoc-qs-field-notused");
                                $(this).val("");
                        }
                });
 
                $(containerSelector).append(
                        $(document.createElement("li"))
-                       .append(
-                               $(document.createElement("form"))
-                               .append(searchField)
-                               .submit(function() {
-                                       return false;
-                               })
-                       )
+                       .attr("id", "nitdoc-qs-li")
+                       .append(searchField)
                );
 
                // Close quicksearch list on click
index 5163c75..5988f06 100644 (file)
@@ -73,7 +73,8 @@ Nitdoc.UI = function() {
                .addClass("nitdoc-ui-filter")\r
                .append(\r
                        $(document.createElement("input"))\r
-                       .addClass("nitdoc-ui-notused")\r
+                       .addClass("nitdoc-ui-filter-field")\r
+                       .addClass("nitdoc-ui-filter-field-notused")\r
                        .attr("type", "text")\r
                        .attr("value",  "filter...")\r
                        .keyup(function() {\r
@@ -84,13 +85,13 @@ Nitdoc.UI = function() {
                        })\r
                        .focusout(function() {\r
                                if($(this).val() == "") {\r
-                                       $(this).addClass("nitdoc-ui-notused");\r
+                                       $(this).addClass("nitdoc-ui-filter-field-notused");\r
                                        $(this).val("filter...");\r
                                }\r
                        })\r
                        .focusin(function() {\r
                                if($(this).val() == "filter...") {\r
-                                       $(this).removeClass("nitdoc-ui-notused");\r
+                                       $(this).removeClass("nitdoc-ui-filter-field-notused");\r
                                        $(this).val("");\r
                                }\r
                        })\r
diff --git a/share/ni_nitdoc/scripts/github.js b/share/ni_nitdoc/scripts/github.js
deleted file mode 100644 (file)
index 37daf4a..0000000
+++ /dev/null
@@ -1,825 +0,0 @@
-$(document).ready(function() {\r
-       // set ui elements\r
-       ui = new GitHubUI();\r
-       ui.init();\r
-\r
-       // check cookie at startup\r
-       sessionCookie = new SessionCookie("nitdoc_github_session");\r
-       var session = sessionCookie.getSession();\r
-       //checkCookie()\r
-       if(session) {\r
-               githubAPI = new GitHubAPI(session.user, session.password, session.repo)\r
-               ui.activate();\r
-               console.log("Session started from cookie (head: "+ $("body").attr("data-github-head") +", base: "+ $("body").attr("data-github-base") +")");\r
-\r
-       } else {\r
-               console.log("No cookie found");\r
-       }\r
-});\r
-\r
-// Check if a comment is editing\r
-window.onbeforeunload = function() {\r
-       if(ui.openedComments > 0){\r
-       return 'Are you sure you want to leave this page?';\r
-       }\r
-};\r
-\r
-/* GitHub API */\r
-\r
-function GitHubAPI(login, password, repo) {\r
-       this.login = login;\r
-       this.password = password;\r
-       this.repo = repo;\r
-       this.auth = "Basic " +  Base64.encode(login + ':' + password);\r
-\r
-       /* GitHub Account */\r
-\r
-       // try to login to github API\r
-       this.tryLogin = function() {\r
-               var res = false;\r
-               $.ajax({\r
-                       beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-                       },\r
-                       type: "GET",\r
-                       url: "https://api.github.com/repos/" + this.login+ "/" + this.repo,\r
-                       async: false,\r
-                       dataType: 'json',\r
-                       success: function() {\r
-                               res = true;\r
-                       }\r
-               });\r
-               return res;\r
-       }\r
-\r
-       this.getUserInfos = function() {\r
-               var res = false;\r
-               $.ajax({\r
-                       beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-                       },\r
-                       type: "GET",\r
-                       url: "https://api.github.com/users/" + this.login,\r
-                       async: false,\r
-                       dataType: 'json',\r
-                       success: function(response) {\r
-                               res = response;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-               });\r
-               return res;\r
-       }\r
-\r
-       this.getSignedOff = function() {\r
-               var infos = this.getUserInfos();\r
-               return infos.name + " &lt;" + infos.email + "&gt;";\r
-       }\r
-\r
-       /* GitHub Repos */\r
-\r
-       this.getFile = function(path, branch){\r
-               var res = false;\r
-               $.ajax({\r
-               type: "GET",\r
-                       url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/contents/" + path,\r
-                       data: {\r
-                               ref: branch\r
-                       },\r
-                       async: false,\r
-               dataType: 'json',\r
-               success: function(response) {\r
-                               res = response;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-       });\r
-               return res;\r
-       }\r
-\r
-       /* GitHub commits */\r
-\r
-       // get the latest commit on `branchName`\r
-       this.getLastCommit = function(branchName) {\r
-               var res = false;\r
-               $.ajax({\r
-               beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-               },\r
-               type: "GET",\r
-               url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/git/refs/heads/" + branchName,\r
-                       async: false,\r
-               dataType: 'json',\r
-               success: function(response) {\r
-                               res = response.object;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-       });\r
-               return res;\r
-        }\r
-\r
-       // get the base tree for commit\r
-       this.getTree = function(sha) {\r
-               var res = false;\r
-               $.ajax({\r
-               beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-               },\r
-               type: "GET",\r
-               url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/git/trees/" + sha + "?recursive=1",\r
-                       async: false,\r
-               dataType: 'json',\r
-               success: function(response) {\r
-                               res = response;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-       });\r
-               return res;\r
-        }\r
-\r
-       // create a new blob\r
-       this.createBlob = function(content) {\r
-               var res = false;\r
-               $.ajax({\r
-               beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-               },\r
-               type: "POST",\r
-               url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/git/blobs",\r
-                       async: false,\r
-               dataType: 'json',\r
-                       data: JSON.stringify({\r
-                               content: Base64.encode(content),\r
-                               encoding: "base64"\r
-                       }),\r
-               success: function(response) {\r
-                               res = response;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-       });\r
-               return res;\r
-        }\r
-\r
-       // create a new tree from a base tree\r
-       this.createTree = function(baseTree, path, blob) {\r
-               var res = false;\r
-               $.ajax({\r
-               beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-               },\r
-               type: "POST",\r
-               url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/git/trees",\r
-                       data: JSON.stringify({\r
-                               base_tree: baseTree.sha,\r
-                               tree: [{\r
-                                       path: path,\r
-                                       mode: 100644, // file (blob)\r
-                                       type: "blob",\r
-                                       sha: blob.sha\r
-                               }]\r
-                       }),\r
-                       async: false,\r
-               dataType: 'json',\r
-               success: function(response) {\r
-                               res = response;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-       });\r
-               return res;\r
-       }\r
-\r
-       // create a new commit\r
-       this.createCommit = function(message, parentCommit, tree) {\r
-               var res = false;\r
-               $.ajax({\r
-               beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-               },\r
-               type: "POST",\r
-               url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/git/commits",\r
-                       data: JSON.stringify({\r
-                               message: message,\r
-                               parents: parentCommit,\r
-                               tree: tree.sha,\r
-                       }),\r
-                       async: false,\r
-               dataType: 'json',\r
-               success: function(response) {\r
-                               res = response;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-       });\r
-               return res;\r
-       }\r
-\r
-       // create a pull request\r
-       this.createPullRequest = function(title, body, base, head) {\r
-               var res = false;\r
-               $.ajax({\r
-               beforeSend: function (xhr) {\r
-                               xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-               },\r
-               type: "POST",\r
-               url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/pulls",\r
-                       data: JSON.stringify({\r
-                               title: title,\r
-                               body: body,\r
-                               base: base,\r
-                               head: head\r
-                       }),\r
-                       async: false,\r
-               dataType: 'json',\r
-               success: function(response) {\r
-                               res = response;\r
-                       },\r
-                       error: function(response) {\r
-                               res = response;\r
-                       }\r
-       });\r
-               return res;\r
-       }\r
-\r
-       // update a pull request\r
-       this.updatePullRequest = function(title, body, state, number) {\r
-               var res = false;\r
-                       $.ajax({\r
-                       beforeSend: function (xhr) {\r
-                                       xhr.setRequestHeader ("Authorization", githubAPI.auth);\r
-                       },\r
-                       type: "PATCH",\r
-                       url: "https://api.github.com/repos/" + this.login + "/" + this.repo + "/pulls/" + number,\r
-                               data: JSON.stringify({\r
-                                       title: title,\r
-                                       body: body,\r
-                                       state: state\r
-                               }),\r
-                               async: false,\r
-                       dataType: 'json',\r
-                       success: function(response) {\r
-                                       res = response;\r
-                               },\r
-                               error: function(response) {\r
-                                       res = response;\r
-                               }\r
-               });\r
-               return res;\r
-       }\r
-}\r
-var githubAPI;\r
-\r
-/* GitHub cookie management */\r
-\r
-function SessionCookie(cookieName) {\r
-       this.cookieName = cookieName\r
-\r
-       this.setSession = function (user, password, repo) {\r
-               var value = Base64.encode(JSON.stringify({\r
-                       user: user,\r
-                       password: password,\r
-                       repo: repo\r
-               }));\r
-               var exdate = new Date();\r
-               exdate.setDate(exdate.getDate() + 1);\r
-               document.cookie = this.cookieName + "=" + value + "; expires=" + exdate.toUTCString();\r
-       }\r
-\r
-       this.delSession = function() {\r
-           document.cookie = this.cookieName + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';\r
-       }\r
-\r
-       this.getCookieDatas = function() {\r
-               var c_name = this.cookieName;\r
-               var c_value = document.cookie;\r
-               var c_start = c_value.indexOf(" " + c_name + "=");\r
-               if (c_start == -1) { c_start = c_value.indexOf(c_name + "="); }\r
-               if (c_start == -1) {\r
-                       c_value = null;\r
-               } else {\r
-                       c_start = c_value.indexOf("=", c_start) + 1;\r
-                       var c_end = c_value.indexOf(";", c_start);\r
-                       if (c_end == -1) { c_end = c_value.length; }\r
-                       c_value = unescape(c_value.substring(c_start,c_end));\r
-               }\r
-               return c_value;\r
-       }\r
-\r
-       this.getSession = function() {\r
-               var cookie = this.getCookieDatas();\r
-               if (!!cookie) {\r
-                       return JSON.parse(Base64.decode(cookie));\r
-               }\r
-               return false;\r
-       }\r
-}\r
-var sessionCookie;\r
-\r
-/* GitHub login box */\r
-\r
-function LoginBox() {\r
-       // Add login box\r
-       $("nav.main ul").append(\r
-               $("<li id='liGitHub'></li>")\r
-               .append(\r
-                       $("<a class='btn' id='logGitHub'><img id='imgGitHub' src='resources/icons/github-icon.png' alt='GitHub'/></a>")\r
-                       .click(function() { ui.loginBox.toggle() })\r
-               )\r
-               .append(\r
-                       "  <div id='loginBox' style='display: none;'>" +\r
-                       "    <div class='arrow'>&nbsp;</div>" +\r
-                       "      <h3>Github Sign In</h3>" +\r
-                       "        <div id='signedIn' style='display: none'>" +\r
-                       "          <label id='logginMessage'>Hello " +\r
-                       "            <a id='githubAccount'><strong id='nickName'></strong></a>!" +\r
-                       "          </label>" +\r
-                       "          <label for='github-repo'>Repo</label>" +\r
-                       "          <input id='github-repo' disabled='disabled' type='text'/>" +\r
-                       "          <label for='github-head'>Head</label>" +\r
-                       "          <input id='github-head' disabled='disabled' type='text'/>" +\r
-                       "          <label for='github-base'>Base</label>" +\r
-                       "          <input id='github-base' disabled='disabled' type='text'/>" +\r
-                       "          <button class='signIn github'><img src='resources/icons/github-icon.png'/>Sign Off</button>" +\r
-                       "        </div>" +\r
-                       "        <div id='signedOff'>" +\r
-                       "         <form>" +\r
-                       "          <label for='loginGit'>Username</label>" +\r
-                       "          <input id='loginGit' type='text'/>" +\r
-                       "          <label for='passwordGit'>Password</label>" +\r
-                       "          <input id='passwordGit' type='password'/>" +\r
-                       "          <label for='repositoryGit'>Repository</label>" +\r
-                       "          <input id='repositoryGit' type='text'/>" +\r
-                       "          <button class='signIn github'><img src='resources/icons/github-icon.png'/>Sign In</button>" +\r
-                       "         </form>" +\r
-                       "      </div>" +\r
-                       "    </div>" +\r
-                       "  </div>"\r
-               )\r
-       );\r
-\r
-       // Login with github user or logout current session\r
-       $("#loginBox .signIn").click(function(){\r
-               if($('#signedIn').is(':hidden')){\r
-                       if(!$('#loginGit').val() || !$('#passwordGit').val() || !$('#repositoryGit').val()) {\r
-                               ui.openModalBox("Login incorrect!", "Please enter your username, password and repository.", true);\r
-                       } else {\r
-                               githubAPI = new GitHubAPI($('#loginGit').val(),  $('#passwordGit').val(), $('#repositoryGit').val());\r
-                               if(githubAPI.tryLogin()) {\r
-                                       // open session and set cookie\r
-                                       sessionCookie.setSession(githubAPI.login, githubAPI.password, githubAPI.repo);\r
-                                       ui.activate();\r
-                               } else {\r
-                                       githubAPI = false;\r
-                                       ui.openModalBox("Login incorrect!", "Your login information was incorrect!", true);\r
-                               }\r
-                       }\r
-               } else {\r
-                       ui.disactivate();\r
-                       ui.loginBox.toggle();\r
-               }\r
-               return false;\r
-       });\r
-\r
-       this.toggle = function() {\r
-               if ($('#loginBox').is(':hidden')) {\r
-                       $('#loginBox').show();\r
-                       if (!$('#loginGit').is(':hidden')) { $('#loginGit').focus(); }\r
-               } else {\r
-                       $('#loginBox').hide();\r
-               }\r
-       }\r
-}\r
-\r
-/* Comment edition UI */\r
-\r
-function GitHubUI() {\r
-       this.loginBox = new LoginBox();\r
-       this.openedComments = 0;\r
-\r
-       this.init = function() {\r
-               $("body").append("<div id='modal'></div>");\r
-               $('body').append('<div id="fade"></div>');\r
-       }\r
-\r
-       this.disactivate = function() {\r
-               // close session and purge cookie\r
-               sessionCookie.delSession();\r
-               localStorage.clear();\r
-               window.location.reload();\r
-       }\r
-\r
-       this.activate = function() {\r
-               // get lastest commit\r
-               var latest = githubAPI.getLastCommit($("body").attr("data-github-head"));\r
-               if(!latest || !latest.sha) {\r
-                       this.openModalBox("Head branch not found!", latest.status + ": " + latest.statusText, true)\r
-                       return;\r
-               }\r
-               if(localStorage.latestCommit != latest.sha) {\r
-                       console.log("Latest commit changed: cleaned cache");\r
-                       localStorage.requests = "[]";\r
-                       localStorage.latestCommit = latest.sha;\r
-               }\r
-               console.log("Latest commit sha: " + localStorage.latestCommit);\r
-\r
-               // reload loginBox\r
-               $('#signedOff').hide();\r
-               $('#signedIn').show();\r
-               $("#imgGitHub").attr("src", "resources/icons/github-icon-w.png");\r
-               $("#liGitHub").addClass("current");\r
-\r
-               // login form values\r
-               $('#nickName').text(githubAPI.login);\r
-               $('#githubAccount').attr("href", "https://github.com/" + githubAPI.login);\r
-               $('#github-repo').val(githubAPI.repo);\r
-               $('#github-base').val($("body").attr("data-github-base"));\r
-               $('#github-head').val($("body").attr("data-github-head"));\r
-\r
-               // Activate edit mode\r
-\r
-               // Add hidden <pre> to empty commits\r
-               $("span.noComment").each(function() {\r
-                       $(this).addClass("editComment");\r
-                       var baseComment = $(this).parent().prev();\r
-                       var location = ui.parseLocation(baseComment.attr("data-comment-location"));\r
-                       location.lend = location.lstart;\r
-                       var locString = "../" + location.path + ":" + location.lstart + "," + location.tabpos + "--" + location.lend + ",0";\r
-                       baseComment.attr("data-comment-location", locString);\r
-                       $(this).html("<a class='editComment noComment'>add comment</a> for ");\r
-               });\r
-               $('.description div.comment').each(function() {\r
-                       var p = $(this).next();\r
-                       p.prepend("<span class='editComment'><a class='editComment'>edit comment</a> for </span>")\r
-               });\r
-               $('a.editComment').each(function() {\r
-                       $(this).css("cursor", "pointer")\r
-                       $(this).click(function() {\r
-                               $(this).parent().hide();\r
-                               if(!$(this).hasClass("noComment")) {\r
-                                       $(this).parent().parent().prev().hide();\r
-                                       ui.openCommentBox($(this).parent().parent().prev().prev());\r
-                               } else {\r
-                                       ui.openCommentBox($(this).parent().parent().prev());\r
-                               }\r
-                       });\r
-               });\r
-\r
-               // load comment from current branch\r
-               this.reloadComments();\r
-       }\r
-\r
-       this.openModalBox = function(title, msg, isError) {\r
-               $('#fade').show();\r
-               $('#modal')\r
-                       .empty()\r
-                       .append($('<a class="close"><img src="resources/icons/close.png" class="btnClose" title="Close" alt="Close"/></a>').click(function() {ui.closeModalBox()}))\r
-                       .append("<h3>" + title + "</h3>")\r
-                       .append("<div>" + msg + "</div>")\r
-                       .append(\r
-                               $("<div class='buttonArea'>")\r
-                               .append($("<button>Ok</button>").click(function() {ui.closeModalBox()}))\r
-                       )\r
-                       .show()\r
-                       .css("top", "50%")\r
-                       .css("margin-top", -($('#modal').outerHeight() / 2) + "px")\r
-                       .css("left", "50%")\r
-                       .css("margin-left", -($('#modal').outerWidth() / 2) + "px");\r
-               if(isError) {\r
-                       $("#modal h3").addClass("error");\r
-               }\r
-       }\r
-\r
-       this.closeModalBox = function() {\r
-               $('#fade , #modal').hide();\r
-       }\r
-\r
-       this.openCommentBox = function(baseArea, requestID) {\r
-               this.openedComments += 1;\r
-               // get text and format it\r
-               var originalComment = baseArea.text();\r
-               var modifiedComment;\r
-               if(!!requestID) {\r
-                       // get comment from last pull request\r
-                       var requests = JSON.parse(localStorage.requests);\r
-                       modifiedComment = Base64.decode(requests[requestID].comment);\r
-               }\r
-               // create comment box\r
-               var tarea = $("<textarea>" + (!modifiedComment? originalComment: modifiedComment) + "</textarea>");\r
-               var width = width = baseArea.parent().innerWidth() - 13;\r
-               tarea.css("width", width + "px");\r
-               tarea.css("display", "block");\r
-               tarea.keyup(function(event) {\r
-                       $(event.target).css("height", (event.target.value.split(/\r|\n/).length * 16) + "px");\r
-                       if ( (!requestID && $(event.target).val() != originalComment) || (requestID && $(event.target).val() != originalComment && $(event.target).val() != modifiedComment) ) {\r
-                               $(event.target).parent().find("button.commit").removeAttr("disabled");\r
-                       } else {\r
-                               $(event.target).parent().find("button.commit").attr("disabled", "disabled");\r
-                       }\r
-               });\r
-               tarea.keydown(function(event) {\r
-                       if(event.keyCode == 13){\r
-                               $(event.target).css("height", ($(event.target).outerHeight() + 6) + "px");\r
-                       }\r
-               });\r
-               var commentBox = $("<div class='commentBox'></div>")\r
-                       .attr("data-comment-namespace", baseArea.attr("data-comment-namespace"))\r
-                       .attr("data-comment-location", baseArea.attr("data-comment-location"))\r
-                       .append(tarea)\r
-                       .append(\r
-                               $("<a class='preview'>preview</a>")\r
-                               .click(function() {\r
-                                       var converter = new Markdown.Converter()\r
-                                       var html = converter.makeHtml(tarea.val());\r
-                                       ui.openModalBox("Preview", html, false);\r
-                               })\r
-                       )\r
-                       .append(\r
-                               $("<button class='commit'>Commit</button>")\r
-                               .click(function() {\r
-                                       ui.openCommitBox($(this).parent(), requestID);\r
-                               })\r
-                       )\r
-                       .append(\r
-                               $("<button class='cancel'>Cancel</button>")\r
-                               .click(function() {ui.closeCommentBox($(this).parent())})\r
-                       );\r
-               if(!baseArea.text()) {\r
-                       commentBox.addClass("newComment");\r
-               }\r
-               baseArea.after(commentBox);\r
-               tarea.trigger("keyup");\r
-       }\r
-\r
-       this.closeCommentBox = function(commentBox) {\r
-               this.openedComments -= 1;\r
-               var target = commentBox.next();\r
-               if(!commentBox.hasClass("newComment")) {\r
-                       target.show();\r
-                       target = target.next();\r
-               }\r
-               target.find("span.editComment").show();\r
-               commentBox.remove();\r
-       }\r
-\r
-       this.openCommitBox = function(commentBox,  requestID) {\r
-               $('#fade').show();\r
-               $('#modal')\r
-                       .empty()\r
-                       .append($('<a class="close"><img src="resources/icons/close.png" class="btnClose" title="Close" alt="Close"/></a>').click(function() {ui.closeModalBox()}))\r
-                       .append("<h3>Commit changes</h3><br/>")\r
-                       .append("<label for='message'>Message:</label><br/>")\r
-                       .append("<textarea id='message'>Wikidoc: " + (commentBox.hasClass("newComment") ? "added" : "modified") + " comment for " + commentBox.attr("data-comment-namespace") + "</textarea><br/>")\r
-                       .append("<input id='signOff' type='checkbox' value='Signed-off-by: " + githubAPI.getSignedOff() + "'/>")\r
-                               .change(function(e) {\r
-                                       if ($(e.target).is(':checked')) {\r
-                                               $("#commitBtn").removeAttr("disabled");\r
-                                       } else {\r
-                                               $("#commitBtn").attr("disabled", "disabled");\r
-                                       }\r
-                               })\r
-                       .append("<label for='signOff'> Signed-off-by: " + githubAPI.getSignedOff() + "</label>")\r
-                       .append(\r
-                               $("<div class='buttonArea'>")\r
-                               .append(\r
-                                       $("<button id='commitBtn' disabled='disabled' class='github'><img src='resources/icons/github-icon.png'/>Commit</button>")\r
-                                       .mousedown(function() {\r
-                                               $(this).text("Commiting...");\r
-                                       })\r
-                                       .mouseup(function() {\r
-                                               ui.commit($(this).parent().parent(), commentBox, requestID)\r
-                                       })\r
-                               )\r
-                       )\r
-                       .show()\r
-                       .css("top", "50%")\r
-                       .css("margin-top", -($('#modal').outerHeight() / 2) + "px")\r
-                       .css("left", "50%")\r
-                       .css("margin-left", -($('#modal').outerWidth() / 2) + "px");\r
-       }\r
-\r
-\r
-       this.commit = function(commitBox, commentBox,  requestID) {\r
-               // close existing pull request for the comment\r
-               if(!!requestID) {\r
-                       this.closePullRequest(requestID);\r
-               }\r
-\r
-               // get comments datas\r
-               var location = this.parseLocation(commentBox.attr("data-comment-location"));\r
-               var comment = commentBox.find("textarea").val();\r
-\r
-               // get file content from github\r
-               var origFile = githubAPI.getFile(location.path, $('#github-head').val());\r
-               if(!origFile.content) {\r
-                       this.openModalBox("Unable to locate source file!", origFile.status + ": " + origFile.statusText);\r
-                       return;\r
-               }\r
-               var base64Content = origFile.content.substring(0, origFile.content.length - 1)\r
-               var fileContent = Base64.decode(base64Content);\r
-\r
-               // commit\r
-               var newContent = this.mergeComment(fileContent, comment, location);\r
-               var message = commitBox.find("#message").val() + "\n\n" + commitBox.find("#signOff").val();\r
-               var response = this.pushComment($('#github-base').val(), $('#github-head').val(), location.path, newContent, message)\r
-               if(!response) {\r
-                       // abort procedure\r
-                       return;\r
-               }\r
-\r
-               // save pull request in cookie\r
-               var requests = [];\r
-               if(!!localStorage.requests) {requests = JSON.parse(localStorage.requests)}\r
-               requests[response.number] = {\r
-                       request: response,\r
-                       location: commentBox.attr("data-comment-location"),\r
-                       comment: Base64.encode(comment)\r
-               };\r
-               localStorage.requests = JSON.stringify(requests);\r
-               // close boxes\r
-               this.closeModalBox()\r
-               this.closeCommentBox(commentBox);\r
-               // reload comments\r
-               this.reloadComments();\r
-       }\r
-\r
-       /*\r
-          Creating a new pull request with the new comment take 5 steps:\r
-               1. get the base tree from latest commit\r
-               2. create a new blob with updated file content\r
-               3. post a new tree from base tree and blob\r
-               4. post the new commit with new tree\r
-               5. create the pull request\r
-       */\r
-       this.pushComment = function(base, branch, path, content, message) {\r
-               var baseTree = githubAPI.getTree(localStorage.latestCommit);\r
-               if(!baseTree.sha) {\r
-                       this.openModalBox("Unable to locate base tree!", baseTree.status + ": " + baseTree.statusText, true);\r
-                       return false;\r
-               }\r
-               console.log("Base tree: " + baseTree.url);\r
-               var newBlob = githubAPI.createBlob(content);\r
-               if(!newBlob.sha) {\r
-                       this.openModalBox("Unable to create new blob!", newBlob.status + ": " + newBlob.statusText, true);\r
-                       return false;\r
-               }\r
-               console.log("New blob: " + newBlob.url);\r
-               var newTree = githubAPI.createTree(baseTree, path, newBlob);\r
-               if(!newTree.sha) {\r
-                       this.openModalBox("Unable to create new tree!", newTree.status + ": " + newTree.statusText, true);\r
-                       return false;\r
-               }\r
-               console.log("New tree: " + newTree.url);\r
-               var newCommit = githubAPI.createCommit(message, localStorage.latestCommit, newTree);\r
-               if(!newCommit.sha) {\r
-                       this.openModalBox("Unable to create new commit!", newCommit.status + ": " + newCommit.statusText, true);\r
-                       return false;\r
-               }\r
-               console.log("New commit: " + newCommit.url);\r
-               var pullRequest = githubAPI.createPullRequest(message.split("\n\n")[0], message, base, newCommit.sha);\r
-               if(!pullRequest.number) {\r
-                       this.openModalBox("Unable to create pull request!", pullRequest.status + ": " + pullRequest.statusText, true);\r
-                       return false;\r
-               }\r
-               console.log("New pull request: " + pullRequest.url);\r
-               return pullRequest;\r
-       }\r
-\r
-       this.reloadComments = function() {\r
-               if(!localStorage.requests){ return; }\r
-               var requests = JSON.parse(localStorage.requests);\r
-               var converter = new Markdown.Converter();\r
-               // Look for modified comments in page\r
-               for(i in requests) {\r
-                       if(!requests[i]) { continue; }\r
-                       var request = requests[i];\r
-                       $("textarea[data-comment-location=\"" + request.location + "\"]").each(function () {\r
-                               var div = $(this).next();\r
-                               if(request.isClosed) {\r
-                                       if(div.is("div.comment.newComment")) {\r
-                                               // hide empty comment\r
-                                               div.next().remove();\r
-                                               div.next().find("span.noComment").show();\r
-                                               div.remove();\r
-                                       } else if(div.is("div.comment.locked")) {\r
-                                               // unlock comment\r
-                                               div.empty();\r
-                                               div.append(converter.makeHtml($(this).text()));\r
-                                               div.removeClass("locked");\r
-                                               div.css("cursor", "pointer")\r
-                                               div.next().remove();\r
-                                               div.next().find("span.editComment").show();\r
-                                       }\r
-                               } else {\r
-                                       // create div for the new coment\r
-                                       if(!div.is("div.comment")) {\r
-                                               $(this).after("<div class='comment newComment'></div>");\r
-                                               div = $(this).next();\r
-                                       }\r
-                                       // lock modified comment\r
-                                       if(!div.hasClass("locked")) {\r
-                                               // convert modified comment to markdown\r
-                                               div.empty()\r
-                                               div.append(converter.makeHtml(Base64.decode(request.comment)));\r
-                                               // lock click\r
-                                               div.css("cursor", "auto");\r
-                                               div.addClass("locked");\r
-                                               div.next().find("span.editComment").hide();\r
-                                               div.after(\r
-                                                       $("<p class='locked inheritance'>")\r
-                                                       .text("comment modified in ")\r
-                                                       .append("<a href='"+ request.request.html_url +"' target='_blank' title='Review on GitHub'>pull request #"+ request.request.number +"</a>")\r
-                                                       .append(" ")\r
-                                                       .append(\r
-                                                               $("<a data-pullrequest-number='"+ request.request.number +"' class='update'>update</a>")\r
-                                                               .click(function (){\r
-                                                                       div.hide();\r
-                                                                       ui.openCommentBox(div.prev(), $(this).attr("data-pullrequest-number"));\r
-                                                               })\r
-                                                       )\r
-                                                       .append(" ")\r
-                                                       .append(\r
-                                                               $("<a data-pullrequest-number='"+ request.request.number +"' class='cancel'>cancel</a>")\r
-                                                               .click(function (){\r
-                                                                       ui.closePullRequest($(this).attr("data-pullrequest-number"));\r
-                                                                       ui.reloadComments();\r
-                                                               })\r
-                                                       )\r
-                                               );\r
-                                       }\r
-                                       // hide "add comment" link\r
-                                       if(div.hasClass("newComment")) {\r
-                                               div.next().next().find("span.noComment").hide();\r
-                                       }\r
-                               }\r
-\r
-                       });\r
-               }\r
-       }\r
-\r
-       this.closePullRequest = function(number) {\r
-               // close pull request\r
-               var res = githubAPI.updatePullRequest("Canceled from Wikidoc", "", "closed", number);\r
-               if(!res.id) {\r
-                       this.openModalBox("Unable to close pull request!", res.status + ": " + res.statusText, true);\r
-                       return false;\r
-               }\r
-               // update in localstorage\r
-               var requests = JSON.parse(localStorage.requests);\r
-               if(!!requests[number]) {\r
-                       requests[number].isClosed = true;\r
-               }\r
-               localStorage.requests = JSON.stringify(requests);\r
-       }\r
-\r
-       /* Utility */\r
-\r
-       // Extract infos from string location "../lib/standard/collection/array.nit:457,1--458,0"\r
-       this.parseLocation = function(location) {\r
-               var parts = location.split(":");\r
-               var loc = new Object();\r
-               loc.path = parts[0].substr(3, parts[0].length);\r
-               loc.lstart = parseInt(parts[1].split("--")[0].split(",")[0]);\r
-               loc.tabpos = parseInt(parts[1].split("--")[0].split(",")[1]);\r
-               loc.lend = parseInt(parts[1].split("--")[1].split(",")[0]);\r
-               return loc;\r
-       }\r
-\r
-       // Meld modified comment into file content\r
-       this.mergeComment = function(fileContent, comment, location) {\r
-               // replace comment in file content\r
-               var res = new String();\r
-               var lines = fileContent.split("\n");\r
-               // copy lines fron 0 to lstart\r
-               for(var i = 0; i < location.lstart - 1; i++) {\r
-                       res += lines[i] + "\n";\r
-               }\r
-               // set comment\r
-               if(comment && comment != "") {\r
-                       var commentLines = comment.split("\n");\r
-                       for(var i = 0; i < commentLines.length; i++) {\r
-                               var line = commentLines[i];\r
-                               var tab = location.tabpos > 1 ? "\t" : "";\r
-                               res += tab + (line.length > 0 ? "# " : "#") + line + "\n";\r
-                       }\r
-               }\r
-               // copy lines fron lend to end\r
-               for(var i = location.lend - 1; i < lines.length; i++) {\r
-                       res += lines[i];\r
-                       if(i < lines.length - 1) { res += "\n"; }\r
-               }\r
-               return res;\r
-       }\r
-\r
-}\r
-var ui;\r
-\r
similarity index 71%
rename from share/ni_nitdoc/styles/github.css
rename to share/ni_nitdoc/styles/Nitdoc.GitHub.css
index 6280f96..7351332 100644 (file)
-button {\r
-       display: inline-block;\r
-       cursor: pointer;\r
-       background-color: #92C929;\r
-       background-image: -webkit-gradient(linear, left top, left bottom, from(#92C929), to(#1d7900)); /* Saf4+, Chrome */\r
-       background-image: -webkit-linear-gradient(top, #92C929, #1d7900); /* Chrome 10+, Saf5.1+ */\r
-       background-image:    -moz-linear-gradient(top, #92C929, #1d7900); /* FF3.6 */\r
-       background-image:     -ms-linear-gradient(top, #92C929, #1d7900); /* IE10 */\r
-       background-image:      -o-linear-gradient(top, #92C929, #1d7900); /* Opera 11.10+ */\r
-       background-image:         linear-gradient(top, #92C929, #1d7900);\r
-       filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#92C929', EndColorStr='#1d7900'); /* IE6–IE9 */\r
-       border-radius: 4px;\r
-       -moz-border-radius: 4px;\r
-       -webkit-border-radius: 4px;\r
-       -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;\r
-       box-shadow: 0px 2px 4px rgba(0,0,0, .2);\r
-       -moz-box-shadow: 0px 2px 4px rgba(0,0,0, .2);\r
-       -webkit-box-shadow: 0px 2px 4px rgba(0,0,0, .2);\r
-       text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);\r
-       -moz-text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);\r
-       -webkit-text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);\r
-       border: 1px solid #1d7900;\r
-       color: #fff;\r
-       font-weight: bold;\r
-       font-size: 14px;\r
-       padding: 5px 7px 5px 7px;\r
-       text-align: center;\r
-}\r
+/* This file is part of NIT ( http://www.nitlanguage.org ).\r
 \r
-button[disabled=disabled] {\r
-       background-color: #999999;\r
-       background-image: -webkit-gradient(linear, left top, left bottom, from(#999999), to(#333333)); /* Saf4+, Chrome */\r
-       background-image: -webkit-linear-gradient(top, #999999, #333333); /* Chrome 10+, Saf5.1+ */\r
-       background-image:    -moz-linear-gradient(top, #999999, #333333); /* FF3.6 */\r
-       background-image:     -ms-linear-gradient(top, #999999, #333333); /* IE10 */\r
-       background-image:      -o-linear-gradient(top, #999999, #333333); /* Opera 11.10+ */\r
-       background-image:         linear-gradient(top, #999999, #333333);\r
-       filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#999999', EndColorStr='#333333'); /* IE6–IE9 */\r
-       border: 1px solid #333333;\r
-}\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
 \r
-button.github {\r
-       width: 200px;\r
-}\r
+   http://www.apache.org/licenses/LICENSE-2.0\r
 \r
-button.github img {\r
-       margin-right: 7px;\r
-       margin-bottom: -3px;\r
-       height: 16px;\r
-       width: 16px;\r
-}\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
 \r
-/* Menu items */\r
+   Documentation generator for the nit language.\r
+   Generate API documentation in HTML format from nit source code.\r
+*/\r
 \r
-#liGitHub{\r
-       float:right;\r
-       margin-top:-4px;\r
-       height: 20px;\r
-       cursor: pointer;\r
+/* \r
+ * Nitdoc Github Login Box\r
+ */\r
+\r
+#nitdoc-github-li {\r
+       float: right;\r
+       padding: 0;\r
+       margin: -2px 15px 5px 5px;\r
 }\r
 \r
-#liGitHub.current {\r
+#nitdoc-github-li.current {\r
        color: #999;\r
 }\r
 \r
-#imgGitHub {\r
+#nitdoc-github-li .nitdoc-github-li-img {\r
        width: 20px;\r
-}\r
-\r
-/* Modal Box */\r
-\r
-#fade {\r
-       display: none;\r
-       background: #000;\r
-       position: fixed; left: 0; top: 0;\r
-       width: 100%; height: 100%;\r
-       opacity: .80;\r
-       filter: alpha(opacity=80);\r
-       z-index: 9999;\r
-}\r
-\r
-#modal{\r
-       display: none;\r
-       background: #fff;\r
-       padding: 20px;\r
-       border: 3px solid #ddd;\r
-       float: left;\r
-       position: fixed;\r
-       z-index: 99999;\r
-       /* fix Box Shadow CSS3 */\r
-       -webkit-box-shadow: 0px 0px 20px #000;\r
-       -moz-box-shadow: 0px 0px 20px #000;\r
-       box-shadow: 0px 0px 20px #000;\r
-       /* round corners CSS3 */\r
-       -webkit-border-radius: 10px;\r
-       -moz-border-radius: 10px;\r
-       border-radius: 10px;\r
-       text-align: left;\r
-}\r
-\r
-#modal .buttonArea, #modal h3 {\r
-       text-align: center;\r
-}\r
-\r
-#modal textarea {\r
-       min-width: 300px;\r
-       width: 100%;\r
-}\r
-\r
-#modal button {\r
-       line-height: 20px;\r
-       margin-bottom: 0;\r
-       padding: 4px 12px;\r
-       margin-top: 10px;\r
-}\r
-\r
-#modal .btnClose {\r
-       float: right;\r
-       margin: -35px -35px 0 0;\r
        cursor: pointer;\r
 }\r
 \r
-#modal h3.error {\r
-       color: red;\r
-}\r
-\r
-/* Login box */\r
-\r
-#loginBox {\r
+#nitdoc-github-loginbox {\r
        cursor: default;\r
        position: absolute;\r
        width : 220px;\r
        margin-top: 10px;\r
-       margin-left: -194px;\r
-       z-index: 1010;\r
+       margin-left: -215px;\r
        display: block;\r
        padding: 10px;\r
        text-align: left;\r
@@ -151,7 +59,7 @@ button.github img {
        background-clip: padding-box;\r
 }\r
 \r
-#loginBox .arrow {\r
+#nitdoc-github-loginbox .nitdoc-github-loginbox-arrow {\r
        position: absolute;\r
        display: block;\r
        width: 0;\r
@@ -161,13 +69,13 @@ button.github img {
        border-width: 11px;\r
        top: -11px;\r
        left: 50%;\r
-       margin-left: 71px;\r
+       margin-left: 93px;\r
        border-bottom-color: #999;\r
        border-bottom-color: rgba(0, 0, 0, 0.25);\r
        border-top-width: 0;\r
 }\r
 \r
-#loginBox .arrow:after {\r
+#nitdoc-github-loginbox .nitdoc-github-loginbox-arrow:after {\r
        position: absolute;\r
        display: block;\r
        width: 0;\r
@@ -182,11 +90,11 @@ button.github img {
        border-top-width: 0;\r
 }\r
 \r
-#loginBox h3 {\r
+#nitdoc-github-loginbox h3 {\r
        text-align:center;\r
 }\r
 \r
-#loginBox input {\r
+#nitdoc-github-loginbox input {\r
        width: 212px;\r
        height: 20px;\r
        padding: 3px;\r
@@ -197,11 +105,12 @@ button.github img {
        border: 1px solid #CCC;\r
 }\r
 \r
-#loginBox button {\r
+#nitdoc-github-loginbox button {\r
+       margin-top: 15px;\r
        width: 220px;\r
 }\r
 \r
-#loginBox #logginMessage {\r
+#nitdoc-github-loginbox h4 {\r
        display: block;\r
        width: 100%;\r
        color: black;\r
@@ -210,22 +119,122 @@ button.github img {
        margin-bottom: 20px;\r
 }\r
 \r
-#loginBox #logginBranches {\r
-       margin-bottom: 20px;\r
+/* \r
+ * Nitdoc Github buttons\r
+ */\r
+\r
+button.nitdoc-github-button {\r
+       display: inline-block;\r
+       cursor: pointer;\r
+       background-color: #92C929;\r
+       background-image: -webkit-gradient(linear, left top, left bottom, from(#92C929), to(#1d7900)); /* Saf4+, Chrome */\r
+       background-image: -webkit-linear-gradient(top, #92C929, #1d7900); /* Chrome 10+, Saf5.1+ */\r
+       background-image:    -moz-linear-gradient(top, #92C929, #1d7900); /* FF3.6 */\r
+       background-image:     -ms-linear-gradient(top, #92C929, #1d7900); /* IE10 */\r
+       background-image:      -o-linear-gradient(top, #92C929, #1d7900); /* Opera 11.10+ */\r
+       background-image:         linear-gradient(top, #92C929, #1d7900);\r
+       filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#92C929', EndColorStr='#1d7900'); /* IE6–IE9 */\r
+       border-radius: 4px;\r
+       -moz-border-radius: 4px;\r
+       -webkit-border-radius: 4px;\r
+       -moz-background-clip: padding; -webkit-background-clip: padding-box; background-clip: padding-box;\r
+       box-shadow: 0px 2px 4px rgba(0,0,0, .2);\r
+       -moz-box-shadow: 0px 2px 4px rgba(0,0,0, .2);\r
+       -webkit-box-shadow: 0px 2px 4px rgba(0,0,0, .2);\r
+       text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);\r
+       -moz-text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);\r
+       -webkit-text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.2);\r
+       border: 1px solid #1d7900;\r
+       color: #fff;\r
+       font-weight: bold;\r
+       font-size: 14px;\r
+       padding: 5px 7px 5px 7px;\r
+       text-align: center;\r
+}\r
+\r
+button.nitdoc-github-button[disabled=disabled] {\r
+       background-color: #999999;\r
+       background-image: -webkit-gradient(linear, left top, left bottom, from(#999999), to(#333333)); /* Saf4+, Chrome */\r
+       background-image: -webkit-linear-gradient(top, #999999, #333333); /* Chrome 10+, Saf5.1+ */\r
+       background-image:    -moz-linear-gradient(top, #999999, #333333); /* FF3.6 */\r
+       background-image:     -ms-linear-gradient(top, #999999, #333333); /* IE10 */\r
+       background-image:      -o-linear-gradient(top, #999999, #333333); /* Opera 11.10+ */\r
+       background-image:         linear-gradient(top, #999999, #333333);\r
+       filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#999999', EndColorStr='#333333'); /* IE6–IE9 */\r
+       border: 1px solid #333333;\r
+}\r
+\r
+button.nitdoc-github-button img {\r
+       margin-right: 7px;\r
+       margin-bottom: -3px;\r
+       height: 16px;\r
+       width: 16px;\r
+}\r
+\r
+/*\r
+ * Modal Box\r
+ */\r
+\r
+.nitdoc-github-fade {\r
+       background: #000;\r
+       position: fixed; left: 0; top: 0;\r
+       width: 100%; height: 100%;\r
+       opacity: .80;\r
+       filter: alpha(opacity=80);\r
+       z-index: 9999;\r
+}\r
+\r
+.nitdoc-github-modal {\r
+       background: #fff;\r
+       padding: 20px;\r
+       border: 3px solid #ddd;\r
+       float: left;\r
+       position: fixed;\r
+       z-index: 99999;\r
+       /* fix Box Shadow CSS3 */\r
+       -webkit-box-shadow: 0px 0px 20px #000;\r
+       -moz-box-shadow: 0px 0px 20px #000;\r
+       box-shadow: 0px 0px 20px #000;\r
+       /* round corners CSS3 */\r
+       -webkit-border-radius: 10px;\r
+       -moz-border-radius: 10px;\r
+       border-radius: 10px;\r
+       text-align: left;\r
+}\r
+\r
+.nitdoc-github-buttons, .nitdoc-github-modal h3 {\r
+       text-align: center;\r
+}\r
+\r
+.nitdoc-github-modal.nitdoc-github-error h3 {\r
+       color: red;\r
 }\r
 \r
-#loginBox #dropBranches{\r
-       margin-bottom: 10px;\r
-       width: 169px;\r
+.nitdoc-github-modal textarea {\r
+       min-width: 300px;\r
+       width: 100%;\r
+}\r
+\r
+.nitdoc-github-modal button {\r
+       line-height: 20px;\r
+       margin-bottom: 0;\r
+       padding: 4px 12px;\r
+       margin-top: 20px;\r
+}\r
+\r
+.nitdoc-github-close {\r
+       float: right;\r
+       margin: -35px -35px 0 0;\r
+       cursor: pointer;\r
 }\r
 \r
 /* Comment editing */\r
 \r
-.commentBox {\r
+.nitdoc-github-commentbox {\r
        text-align: right;\r
 }\r
 \r
-.commentBox textarea {\r
+.nitdoc-github-commentbox textarea {\r
        font-family: monospace;\r
        font-size: 1em;\r
        width: 100%;\r
@@ -233,14 +242,15 @@ button.github img {
        padding: 4px;\r
        padding-left: 11px;\r
        overflow-y: hidden;\r
+       border: 1px solid #CCC;\r
 }\r
 \r
-.commentBox .preview {\r
+.nitdoc-github-preview {\r
        margin: 0 15px;\r
        cursor: pointer;\r
 }\r
 \r
-.commentBox .cancel {\r
+.nitdoc-github-button.nitdoc-github-cancel {\r
        background-color: #b33630;\r
        background-image: -webkit-gradient(linear, left top, left bottom, from(#b33630), to(#9f312c)); /* Saf4+, Chrome */\r
        background-image: -webkit-linear-gradient(top, #b33630, #9f312c); /* Chrome 10+, Saf5.1+ */\r
@@ -259,12 +269,12 @@ p.locked {
        color: black;\r
 }\r
 \r
-a.cancel {\r
+a.nitdoc-github-cancel {\r
        color: #b33630;\r
        cursor: pointer;\r
 }\r
 \r
-a.update {\r
+a.nitdoc-github-update {\r
        color: orange;\r
        cursor: pointer;\r
 }\r
index 09cdaec..98f5728 100644 (file)
  * Nitdoc Quick Search JS module \r
  */\r
 \r
+#nitdoc-qs-li {\r
+       float: right;\r
+       padding: 0;\r
+       margin: 0;\r
+}\r
+\r
 #nitdoc-qs-field {\r
        width: 300px;\r
 }\r
 \r
-#nitdoc-qs-field.nitdoc-qs-notused {\r
+#nitdoc-qs-field.nitdoc-qs-field-notused {\r
        color: #999;\r
        font-style: italic;\r
 }\r
@@ -33,7 +39,7 @@
        background-color: #FFFFFF;\r
        border: 1px solid #E0E0E0;\r
        border-spacing: 0px;\r
-       z-index: 10; /* the menu must be over the rest of the page. */\r
+       z-index: 1000;\r
 }\r
 \r
 #nitdoc-qs-table .nitdoc-qs-active {\r
index 38c52f1..3265cc0 100644 (file)
@@ -60,16 +60,21 @@ article:hover > .signature button.nitdoc-ui-copy, button.nitdoc-ui-copy.zeroclip
 \r
 /* Side bar boxes text filtering */\r
 \r
-.nitdoc-ui-filter .nitdoc-ui-notused {\r
-       color: #999;\r
-       font-style: italic;\r
-}\r
-\r
 .nitdoc-ui-filter {\r
        text-align: center;\r
        padding: 5px;\r
 }\r
 \r
+.nitdoc-ui-filter-field {\r
+       width: 150px;\r
+       margin-right: 5px;\r
+}\r
+\r
+.nitdoc-ui-filter-field-notused {\r
+       color: #999;\r
+       font-style: italic;\r
+}\r
+\r
 /* Side bar boxes type filtering */\r
 \r
 a.nitdoc-ui-filter-link {\r
index 8e38d25..166ef8a 100644 (file)
@@ -76,6 +76,7 @@ body {
 \r
 header {\r
        position: fixed;\r
+       z-index: 600;\r
        left: 0;\r
        right: 0;\r
 }\r
@@ -87,6 +88,7 @@ header {
 \r
 .sidebar {\r
        position: fixed;\r
+       z-index: 500;\r
        top: 50px;\r
        bottom: 1em;\r
        width: 250px;\r
@@ -99,6 +101,7 @@ header {
 \r
 .content {\r
        position: fixed;\r
+       z-index: 500;\r
        top: 50px;\r
        bottom: 1em;\r
        left: 0;\r
@@ -120,6 +123,7 @@ header {
 \r
 footer {\r
        position: fixed;\r
+       z-index: 500;\r
        bottom: 0;\r
        width: 100%;\r
 }\r
@@ -400,9 +404,7 @@ article .info .code {
 /* Form elements */\r
 \r
 input[type=text] {\r
-       width: 150px;\r
        border: 1px solid #CCC;\r
-       margin-right: 5px;\r
        padding: 1px 2px;\r
 }\r
 \r
@@ -412,10 +414,6 @@ nav.main input[type=text] {
        font-style: normal;\r
 }\r
 \r
-nav.main form {\r
-       float: right;\r
-}\r
-\r
 /* New comments style */\r
 \r
 .content .nitdoc {\r
index 36b98df..26ad41d 100644 (file)
@@ -213,13 +213,13 @@ abstract class NitdocPage
                append("<script type='text/javascript' src='scripts/Nitdoc.UI.js'></script>")
                append("<script type='text/javascript' src='scripts/Markdown.Converter.js'></script>")
                append("<script type='text/javascript' src='scripts/base64.js'></script>")
-               append("<script type='text/javascript' src='scripts/github.js'></script>")
+               append("<script type='text/javascript' src='scripts/Nitdoc.GitHub.js'></script>")
                append("<script type='text/javascript' src='quicksearch-list.js'></script>")
                append("<script type='text/javascript' src='scripts/Nitdoc.QuickSearch.js'></script>")
                append("<link rel='stylesheet' href='styles/main.css' type='text/css' media='screen'/>")
                append("<link rel='stylesheet' href='styles/Nitdoc.UI.css' type='text/css' media='screen'/>")
                append("<link rel='stylesheet' href='styles/Nitdoc.QuickSearch.css' type='text/css' media='screen'/>")
-               append("<link rel='stylesheet' href='styles/github.css' type='text/css' media='screen'/>")
+               append("<link rel='stylesheet' href='styles/Nitdoc.GitHub.css' type='text/css' media='screen'/>")
                var title = ""
                if ctx.opt_custom_title.value != null then
                        title = " | {ctx.opt_custom_title.value.to_s}"