From: Alexandre Terrasa Date: Tue, 19 Dec 2017 18:34:00 +0000 (-0500) Subject: src/nitdoc: remove old nitdoc X-Git-Url: http://nitlanguage.org src/nitdoc: remove old nitdoc Signed-off-by: Alexandre Terrasa --- diff --git a/share/nitdoc/css/Nitdoc.GitHub.css b/share/nitdoc/css/Nitdoc.GitHub.css deleted file mode 100644 index a2d675f..0000000 --- a/share/nitdoc/css/Nitdoc.GitHub.css +++ /dev/null @@ -1,231 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * Nitdoc Github Login Box - */ - -#nitdoc-github-li.current { - color: #999; -} - -#nitdoc-github-li .glyphicon { - cursor: pointer; -} - -#nitdoc-github-loginbox { - cursor: default; - position: absolute; - width : 220px; - margin-top: 2px; - margin-left: -10px; - display: block; - padding: 10px; - text-align: left; - white-space: normal; - background-color: #ffffff; - border: 1px solid #ccc; - border: 1px solid rgba(0, 0, 0, 0.2); - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; - -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); - -moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); - -webkit-background-clip: padding-box; - -moz-background-clip: padding; - background-clip: padding-box; -} - -#nitdoc-github-loginbox .nitdoc-github-loginbox-arrow { - position: absolute; - display: block; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; - border-width: 7px; - top: -7px; - margin-left: 2px; - border-bottom-color: #999; - border-bottom-color: rgba(0, 0, 0, 0.25); - border-top-width: 0; -} - -#nitdoc-github-loginbox .nitdoc-github-loginbox-arrow:after { - position: absolute; - display: block; - width: 0; - height: 0; - border-color: transparent; - border-style: solid; - border-width: 10px; - content: ""; - top: 1px; - margin-left: -10px; - border-bottom-color: #ffffff; - border-top-width: 0; -} - -#nitdoc-github-loginbox h3 { - text-align:center; -} - -#nitdoc-github-loginbox h4 { - display: block; - width: 100%; - color: #6C6C6C; - font-style: normal; - text-align: center; - margin-bottom: 20px; -} - - -#nitdoc-github-loginbox a.nitdoc-github-loginbox-githublink { - display: block; - margin: 10px; - color: #0D8921; -} - -/* Comment editing */ - -.nitdoc-github-commentbox { - margin: 1em 5px; - border: 1px solid #eee; - padding: 1em; - background: #fff; - -moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); - -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); - box-shadow: 0 0 5px rgba(0, 0, 0, 0.2); -} - -.nitdoc-github-commentbox h3 { - margin: 0; -} - -.nitdoc-github-commentbox-buttons { - text-align: right; -} - -.nitdoc-github-commentbox dl { - margin-bottom: 0; -} - -.nitdoc-github-commentbox dt { - margin-bottom: 0.5em; -} - -.nitdoc-github-commentbox dd { - margin: 0 0 1em 0; -} - -.nitdoc-github-commentbox textarea { - display: block; - font-family: monospace; - font-size: 1em; - width: 100%; - padding: 4px; - padding-left: 11px; - overflow-y: hidden; - border: 1px solid #CCC; -} - -.nitdoc-github-preview { - margin: 0 15px; - cursor: pointer; -} - -.nitdoc-github-button.nitdoc-github-cancel { - background-color: #b33630; - background-image: -webkit-gradient(linear, left top, left bottom, from(#E97A74), to(#9f312c)); /* Saf4+, Chrome */ - background-image: -webkit-linear-gradient(top, #E97A74, #9f312c); /* Chrome 10+, Saf5.1+ */ - background-image: -moz-linear-gradient(top, #E97A74, #9f312c); /* FF3.6 */ - background-image: -ms-linear-gradient(top, #E97A74, #9f312c); /* IE10 */ - background-image: -o-linear-gradient(top, #E97A74, #9f312c); /* Opera 11.10+ */ - background-image: linear-gradient(top, #E97A74, #9f312c); - filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#E97A74', EndColorStr='#9f312c'); /* IE6–IE9 */ - border: 1px solid #9f312c; -} - -div.comment.locked { - color: gray; -} -p.locked { - color: black; -} - -a.nitdoc-github-cancel { - color: #b33630; - cursor: pointer; -} - -a.nitdoc-github-update { - color: orange; - cursor: pointer; -} - -.nitdoc-dialog h4 { - font-weight: bold; -} - -/* hljs */ - -.hljs.nitcode { - padding-left: 10px; -} - -.hljs-comment, .hljs-comment-block { - color: #777; -} - -.hljs-keyword { - color: #000; - font-weight: bold; -} - -.hljs-title { - font-weight: bold; -} - -.hljs-module { - color: #3762E4; -} - -.hljs-class .hljs-title { - color: #3762E4; -} - -.hljs-type { - color: #3762E4; -} - -.hljs-string { - color: #8F1546; -} - -.hljs-subst { - color: #9E6BEB; -} - -.hljs-fun .hljs-title { - color: #3762E4; -} - -.hljs-char, .hljs-number { - color: #009999; -} diff --git a/share/nitdoc/css/Nitdoc.ModalBox.css b/share/nitdoc/css/Nitdoc.ModalBox.css deleted file mode 100644 index bf9f9aa..0000000 --- a/share/nitdoc/css/Nitdoc.ModalBox.css +++ /dev/null @@ -1,110 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * Nitdoc ModalBox style - */ - -.nitdoc-dialog-fade { - background: #000; - position: fixed; left: 0; top: 0; - width: 100%; height: 100%; - opacity: .80; - filter: alpha(opacity=80); - z-index: 9999; -} - -.nitdoc-dialog { - background: #fff; - border: 1px solid #ddd; - float: left; - position: fixed; - z-index: 99999; - -webkit-box-shadow: 0px 0px 20px #000; - -moz-box-shadow: 0px 0px 20px #000; - box-shadow: 0px 0px 20px #000; - -webkit-border-radius: 2px; - -moz-border-radius: 2px; - border-radius: 2px; - text-align: left; - min-width: 300px; -} - -.nitdoc-dialog-header { - padding: 10px 10px 10px 20px; - background: #f1f1f1; - border-bottom: 1px solid #ddd; -} - -.nitdoc-dialog-error .nitdoc-dialog-header { - background: #C92020; -} -.nitdoc-dialog-error .nitdoc-dialog-header h3 { - color: white; -} - -.nitdoc-dialog h3 { - display: inline; - margin: 0; -} - -.nitdoc-dialog-content { - max-height: 450px; - overflow-y: scroll; - padding: 10px; -} - -.nitdoc-dialog-buttons { - text-align: right; - padding: 5px; - border-top: 1px solid #ddd; -} - -.nitdoc-dialog textarea { - min-width: 300px; - width: 100%; -} - -.nitdoc-dialog button { - cursor: pointer; - border-radius: 2px; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - font-size: 14px; - padding: 5px 7px 5px 7px; - text-align: center; - background: #eee; - color: #333; - border: 1px solid #ddd; - font-weight: bold; -} - -.nitdoc-dialog button:hover { - background: #0D8921; - color: #fff; - border: 1px solid #1d7900; -} - -.nitdoc-dialog-close { - float: right; - padding: 5px; - margin: 0px; - line-height: 10px; - text-transform: lowercase; -} - diff --git a/share/nitdoc/css/Nitdoc.QuickSearch.css b/share/nitdoc/css/Nitdoc.QuickSearch.css deleted file mode 100644 index 81bba5d..0000000 --- a/share/nitdoc/css/Nitdoc.QuickSearch.css +++ /dev/null @@ -1,87 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * Nitdoc Quick Search JS module - */ - -#nitdoc-qs-field { - width: 300px; - margin-top: 3px; -} - -#nitdoc-qs-table { - background-color: #FFFFFF; - border: 1px solid #E0E0E0; - border-spacing: 0px; - z-index: 1000; - -webkit-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); - -moz-box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); -} - -#nitdoc-qs-table .nitdoc-qs-active { - cursor: pointer; - background: #EEE; -} - -#nitdoc-qs-table td, th { - white-space: nowrap; - overflow: hidden; - line-height: 22px; - padding: 2px; -} - -#nitdoc-qs-table td.nitdoc-qs-sub { - color: #6C6C6C; - padding-left: 12px; -} - -#nitdoc-qs-table td.nitdoc-qs-info { - color: #0D8921; - font-size: smaller; - text-align: right; -} - -#nitdoc-qs-table tr.nitdoc-qs-noresult td { - color: #6C6C6C; - font-size: small; - line-height: 15px; -} - -#nitdoc-qs-table tr.nitdoc-qs-overflow td { - text-align: center; - font-size: x-small; - line-height: 10px; - color: #FFF; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -#nitdoc-qs-table tr.nitdoc-qs-overflow-active td { - color: #0D8921; - cursor: pointer; -} - -#nitdoc-qs-table tr.nitdoc-qs-overflow-active td:hover { - background-color: #E0E0E0; -} diff --git a/share/nitdoc/css/Nitdoc.UI.css b/share/nitdoc/css/Nitdoc.UI.css deleted file mode 100644 index 17b248d..0000000 --- a/share/nitdoc/css/Nitdoc.UI.css +++ /dev/null @@ -1,75 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * Nitdoc UI JS module - */ - - -/* Folding */ - -a.nitdoc-ui-fold { - margin: 0 5px; - color: #999; - font-family: monospace; - font-weight: bold; - font-size: 120%; -} - -/* Search page field */ - -.nitdoc-ui-searchpage-field { - width: 750px; -} - -/* Side bar boxes text filtering */ - -.nitdoc-ui-filter { - text-align: center; - padding: 5px; -} - -.nitdoc-ui-filter-field { - width: 150px; - margin-right: 5px; -} - -.nitdoc-ui-filter-field-notused { - color: #999; - font-style: italic; -} - -/* Side bar boxes type filtering */ - -a.nitdoc-ui-filter-link { - color: #0D8921; - cursor: pointer; - font-family: monospace; - margin-right: 5px; - font-weight: bold; -} - -a.nitdoc-ui-filter-link:hover { - text-decoration: underline; -} - -a.nitdoc-ui-filter-hidden { - color: #999; - font-weight: normal; -} - diff --git a/share/nitdoc/js/lib/github-api.js b/share/nitdoc/js/lib/github-api.js deleted file mode 100644 index f03188a..0000000 --- a/share/nitdoc/js/lib/github-api.js +++ /dev/null @@ -1,295 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * GitHub API wrapper for github plugin - */ -define([ - "jquery", - "utils" -], function($, Utils) { - return { - - // try to login the user to github API - login: function(user) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "GET", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo, - async: false, - dataType: 'json', - success: function() { - res = true; - } - }); - user.infos = this.getUserInfos(user); - user.signedOff = this.getSignedOff(user) - return res; - }, - - // request for user github account infos - getUserInfos: function(user) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "GET", - url: "https://api.github.com/users/" + user.login, - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - // build signedoff user default signature - getSignedOff: function(user) { - return user.infos.name + " <" + user.infos.email + ">"; - }, - - // get the branches list from a repo - getBranches: function(user) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "GET", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/branches", - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - /* GitHub commits */ - - // get the latest commit on `branchName` - getCommit: function(user, sha) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "GET", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/commits/" + sha, - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - // get the base tree for a commit sha - getTree: function(user, sha) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "GET", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/trees/" + sha + "?recursive=1", - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - // create a new blob - createBlob: function(user, content) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "POST", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/blobs", - async: false, - dataType: 'json', - data: JSON.stringify({ - content: content.base64Encode(), - encoding: "base64" - }), - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - // create a new tree from a base tree - createTree: function(user, baseTree, path, blob) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "POST", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/trees", - data: JSON.stringify({ - base_tree: baseTree.sha, - tree: [{ - path: path, - mode: "100644", // file (blob) - type: "blob", - sha: blob.sha - }] - }), - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - // create a new commit - createCommit: function(user, message, parentCommit, tree) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "POST", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/git/commits", - data: JSON.stringify({ - message: message, - parents: parentCommit, - tree: tree.sha, - }), - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - // create a pull request - createPullRequest: function(user, title, body, origin, head) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "POST", - url: "https://api.github.com/repos/" + origin.user + "/" + origin.repo + "/pulls", - data: JSON.stringify({ - title: title, - body: body, - base: origin.branch, - head: user.login + ":" + head - }), - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - // update a pull request - updatePullRequest: function(user, title, body, state, request) { - var res = false; - $.ajax({ - beforeSend: function (xhr) { - xhr.setRequestHeader ("Authorization", user.auth); - }, - type: "PATCH", - url: request.url, - data: JSON.stringify({ - title: title, - body: body, - state: state - }), - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - }, - - /* Files */ - - getFile: function(user, path, branch) { - var res = false; - $.ajax({ - type: "GET", - url: "https://api.github.com/repos/" + user.login + "/" + user.repo + "/contents/" + path, - data: { - ref: branch - }, - async: false, - dataType: 'json', - success: function(response) { - res = response; - }, - error: function(response) { - res = response; - } - }); - return res; - } - } -}); diff --git a/share/nitdoc/js/lib/highlight.js b/share/nitdoc/js/lib/highlight.js deleted file mode 100644 index bd277ee..0000000 --- a/share/nitdoc/js/lib/highlight.js +++ /dev/null @@ -1,715 +0,0 @@ -/* Copyright (c) 2006, Ivan Sagalaev - All rights reserved. - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of highlight.js nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY - EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY - DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -var hljs = new function() { - - /* Utility functions */ - - function escape(value) { - return value.replace(/&/gm, '&').replace(//gm, '>'); - } - - function tag(node) { - return node.nodeName.toLowerCase(); - } - - function testRe(re, lexeme) { - var match = re && re.exec(lexeme); - return match && match.index == 0; - } - - function blockLanguage(block) { - var classes = (block.className + ' ' + (block.parentNode ? block.parentNode.className : '')).split(/\s+/); - classes = classes.map(function(c) {return c.replace(/^lang(uage)?-/, '');}); - return classes.filter(function(c) {return getLanguage(c) || c == 'no-highlight';})[0]; - } - - function inherit(parent, obj) { - var result = {}; - for (var key in parent) - result[key] = parent[key]; - if (obj) - for (var key in obj) - result[key] = obj[key]; - return result; - }; - - /* Stream merging */ - - function nodeStream(node) { - var result = []; - (function _nodeStream(node, offset) { - for (var child = node.firstChild; child; child = child.nextSibling) { - if (child.nodeType == 3) - offset += child.nodeValue.length; - else if (tag(child) == 'br') - offset += 1; - else if (child.nodeType == 1) { - result.push({ - event: 'start', - offset: offset, - node: child - }); - offset = _nodeStream(child, offset); - result.push({ - event: 'stop', - offset: offset, - node: child - }); - } - } - return offset; - })(node, 0); - return result; - } - - function mergeStreams(original, highlighted, value) { - var processed = 0; - var result = ''; - var nodeStack = []; - - function selectStream() { - if (!original.length || !highlighted.length) { - return original.length ? original : highlighted; - } - if (original[0].offset != highlighted[0].offset) { - return (original[0].offset < highlighted[0].offset) ? original : highlighted; - } - - /* - To avoid starting the stream just before it should stop the order is - ensured that original always starts first and closes last: - - if (event1 == 'start' && event2 == 'start') - return original; - if (event1 == 'start' && event2 == 'stop') - return highlighted; - if (event1 == 'stop' && event2 == 'start') - return original; - if (event1 == 'stop' && event2 == 'stop') - return highlighted; - - ... which is collapsed to: - */ - return highlighted[0].event == 'start' ? original : highlighted; - } - - function open(node) { - function attr_str(a) {return ' ' + a.nodeName + '="' + escape(a.value) + '"';} - result += '<' + tag(node) + Array.prototype.map.call(node.attributes, attr_str).join('') + '>'; - } - - function close(node) { - result += ''; - } - - function render(event) { - (event.event == 'start' ? open : close)(event.node); - } - - while (original.length || highlighted.length) { - var stream = selectStream(); - result += escape(value.substr(processed, stream[0].offset - processed)); - processed = stream[0].offset; - if (stream == original) { - /* - On any opening or closing tag of the original markup we first close - the entire highlighted node stack, then render the original tag along - with all the following original tags at the same offset and then - reopen all the tags on the highlighted stack. - */ - nodeStack.reverse().forEach(close); - do { - render(stream.splice(0, 1)[0]); - stream = selectStream(); - } while (stream == original && stream.length && stream[0].offset == processed); - nodeStack.reverse().forEach(open); - } else { - if (stream[0].event == 'start') { - nodeStack.push(stream[0].node); - } else { - nodeStack.pop(); - } - render(stream.splice(0, 1)[0]); - } - } - return result + escape(value.substr(processed)); - } - - /* Initialization */ - - function compileLanguage(language) { - - function reStr(re) { - return (re && re.source) || re; - } - - function langRe(value, global) { - return RegExp( - reStr(value), - 'm' + (language.case_insensitive ? 'i' : '') + (global ? 'g' : '') - ); - } - - function compileMode(mode, parent) { - if (mode.compiled) - return; - mode.compiled = true; - - mode.keywords = mode.keywords || mode.beginKeywords; - if (mode.keywords) { - var compiled_keywords = {}; - - function flatten(className, str) { - if (language.case_insensitive) { - str = str.toLowerCase(); - } - str.split(' ').forEach(function(kw) { - var pair = kw.split('|'); - compiled_keywords[pair[0]] = [className, pair[1] ? Number(pair[1]) : 1]; - }); - } - - if (typeof mode.keywords == 'string') { // string - flatten('keyword', mode.keywords); - } else { - Object.keys(mode.keywords).forEach(function (className) { - flatten(className, mode.keywords[className]); - }); - } - mode.keywords = compiled_keywords; - } - mode.lexemesRe = langRe(mode.lexemes || /\b[A-Za-z0-9_]+\b/, true); - - if (parent) { - if (mode.beginKeywords) { - mode.begin = '\\b(' + mode.beginKeywords.split(' ').join('|') + ')\\b'; - } - if (!mode.begin) - mode.begin = /\B|\b/; - mode.beginRe = langRe(mode.begin); - if (!mode.end && !mode.endsWithParent) - mode.end = /\B|\b/; - if (mode.end) - mode.endRe = langRe(mode.end); - mode.terminator_end = reStr(mode.end) || ''; - if (mode.endsWithParent && parent.terminator_end) - mode.terminator_end += (mode.end ? '|' : '') + parent.terminator_end; - } - if (mode.illegal) - mode.illegalRe = langRe(mode.illegal); - if (mode.relevance === undefined) - mode.relevance = 1; - if (!mode.contains) { - mode.contains = []; - } - var expanded_contains = []; - mode.contains.forEach(function(c) { - if (c.variants) { - c.variants.forEach(function(v) {expanded_contains.push(inherit(c, v));}); - } else { - expanded_contains.push(c == 'self' ? mode : c); - } - }); - mode.contains = expanded_contains; - mode.contains.forEach(function(c) {compileMode(c, mode);}); - - if (mode.starts) { - compileMode(mode.starts, parent); - } - - var terminators = - mode.contains.map(function(c) { - return c.beginKeywords ? '\\.?(' + c.begin + ')\\.?' : c.begin; - }) - .concat([mode.terminator_end, mode.illegal]) - .map(reStr) - .filter(Boolean); - mode.terminators = terminators.length ? langRe(terminators.join('|'), true) : {exec: function(s) {return null;}}; - - mode.continuation = {}; - } - - compileMode(language); - } - - /* - Core highlighting function. Accepts a language name, or an alias, and a - string with the code to highlight. Returns an object with the following - properties: - - - relevance (int) - - value (an HTML string with highlighting markup) - - */ - function highlight(name, value, ignore_illegals, continuation) { - - function subMode(lexeme, mode) { - for (var i = 0; i < mode.contains.length; i++) { - if (testRe(mode.contains[i].beginRe, lexeme)) { - return mode.contains[i]; - } - } - } - - function endOfMode(mode, lexeme) { - if (testRe(mode.endRe, lexeme)) { - return mode; - } - if (mode.endsWithParent) { - return endOfMode(mode.parent, lexeme); - } - } - - function isIllegal(lexeme, mode) { - return !ignore_illegals && testRe(mode.illegalRe, lexeme); - } - - function keywordMatch(mode, match) { - var match_str = language.case_insensitive ? match[0].toLowerCase() : match[0]; - return mode.keywords.hasOwnProperty(match_str) && mode.keywords[match_str]; - } - - function buildSpan(classname, insideSpan, leaveOpen, noPrefix) { - var classPrefix = noPrefix ? '' : options.classPrefix, - openSpan = ''; - - return openSpan + insideSpan + closeSpan; - } - - function processKeywords() { - if (!top.keywords) - return escape(mode_buffer); - var result = ''; - var last_index = 0; - top.lexemesRe.lastIndex = 0; - var match = top.lexemesRe.exec(mode_buffer); - while (match) { - result += escape(mode_buffer.substr(last_index, match.index - last_index)); - var keyword_match = keywordMatch(top, match); - if (keyword_match) { - relevance += keyword_match[1]; - result += buildSpan(keyword_match[0], escape(match[0])); - } else { - result += escape(match[0]); - } - last_index = top.lexemesRe.lastIndex; - match = top.lexemesRe.exec(mode_buffer); - } - return result + escape(mode_buffer.substr(last_index)); - } - - function processSubLanguage() { - if (top.subLanguage && !languages[top.subLanguage]) { - return escape(mode_buffer); - } - var result = top.subLanguage ? highlight(top.subLanguage, mode_buffer, true, top.continuation.top) : highlightAuto(mode_buffer); - // Counting embedded language score towards the host language may be disabled - // with zeroing the containing mode relevance. Usecase in point is Markdown that - // allows XML everywhere and makes every XML snippet to have a much larger Markdown - // score. - if (top.relevance > 0) { - relevance += result.relevance; - } - if (top.subLanguageMode == 'continuous') { - top.continuation.top = result.top; - } - return buildSpan(result.language, result.value, false, true); - } - - function processBuffer() { - return top.subLanguage !== undefined ? processSubLanguage() : processKeywords(); - } - - function startNewMode(mode, lexeme) { - var markup = mode.className? buildSpan(mode.className, '', true): ''; - if (mode.returnBegin) { - result += markup; - mode_buffer = ''; - } else if (mode.excludeBegin) { - result += escape(lexeme) + markup; - mode_buffer = ''; - } else { - result += markup; - mode_buffer = lexeme; - } - top = Object.create(mode, {parent: {value: top}}); - } - - function processLexeme(buffer, lexeme) { - - mode_buffer += buffer; - if (lexeme === undefined) { - result += processBuffer(); - return 0; - } - - var new_mode = subMode(lexeme, top); - if (new_mode) { - result += processBuffer(); - startNewMode(new_mode, lexeme); - return new_mode.returnBegin ? 0 : lexeme.length; - } - - var end_mode = endOfMode(top, lexeme); - if (end_mode) { - var origin = top; - if (!(origin.returnEnd || origin.excludeEnd)) { - mode_buffer += lexeme; - } - result += processBuffer(); - do { - if (top.className) { - result += ''; - } - relevance += top.relevance; - top = top.parent; - } while (top != end_mode.parent); - if (origin.excludeEnd) { - result += escape(lexeme); - } - mode_buffer = ''; - if (end_mode.starts) { - startNewMode(end_mode.starts, ''); - } - return origin.returnEnd ? 0 : lexeme.length; - } - - if (isIllegal(lexeme, top)) - throw new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.className || '') + '"'); - - /* - Parser should not reach this point as all types of lexemes should be caught - earlier, but if it does due to some bug make sure it advances at least one - character forward to prevent infinite looping. - */ - mode_buffer += lexeme; - return lexeme.length || 1; - } - - var language = getLanguage(name); - if (!language) { - throw new Error('Unknown language: "' + name + '"'); - } - - compileLanguage(language); - var top = continuation || language; - var result = ''; - for(var current = top; current != language; current = current.parent) { - if (current.className) { - result += buildSpan(current.className, result, true); - } - } - var mode_buffer = ''; - var relevance = 0; - try { - var match, count, index = 0; - while (true) { - top.terminators.lastIndex = index; - match = top.terminators.exec(value); - if (!match) - break; - count = processLexeme(value.substr(index, match.index - index), match[0]); - index = match.index + count; - } - processLexeme(value.substr(index)); - for(var current = top; current.parent; current = current.parent) { // close dangling modes - if (current.className) { - result += ''; - } - }; - return { - relevance: relevance, - value: result, - language: name, - top: top - }; - } catch (e) { - if (e.message.indexOf('Illegal') != -1) { - return { - relevance: 0, - value: escape(value) - }; - } else { - throw e; - } - } - } - - /* - Highlighting with language detection. Accepts a string with the code to - highlight. Returns an object with the following properties: - - - language (detected language) - - relevance (int) - - value (an HTML string with highlighting markup) - - second_best (object with the same structure for second-best heuristically - detected language, may be absent) - - */ - function highlightAuto(text, languageSubset) { - languageSubset = languageSubset || options.languages || Object.keys(languages); - var result = { - relevance: 0, - value: escape(text) - }; - var second_best = result; - languageSubset.forEach(function(name) { - if (!getLanguage(name)) { - return; - } - var current = highlight(name, text, false); - current.language = name; - if (current.relevance > second_best.relevance) { - second_best = current; - } - if (current.relevance > result.relevance) { - second_best = result; - result = current; - } - }); - if (second_best.language) { - result.second_best = second_best; - } - return result; - } - - /* - Post-processing of the highlighted markup: - - - replace TABs with something more useful - - replace real line-breaks with '
' for non-pre containers - - */ - function fixMarkup(value) { - if (options.tabReplace) { - value = value.replace(/^((<[^>]+>|\t)+)/gm, function(match, p1, offset, s) { - return p1.replace(/\t/g, options.tabReplace); - }); - } - if (options.useBR) { - value = value.replace(/\n/g, '
'); - } - return value; - } - - /* - Applies highlighting to a DOM node containing code. Accepts a DOM node and - two optional parameters for fixMarkup. - */ - function highlightBlock(block) { - var text = options.useBR ? block.innerHTML - .replace(/\n/g,'').replace(/
|
]*>/g, '\n').replace(/<[^>]*>/g,'') - : block.textContent; - var language = blockLanguage(block); - if (language == 'no-highlight') - return; - var result = language ? highlight(language, text, true) : highlightAuto(text); - var original = nodeStream(block); - if (original.length) { - var pre = document.createElementNS('http://www.w3.org/1999/xhtml', 'pre'); - pre.innerHTML = result.value; - result.value = mergeStreams(original, nodeStream(pre), text); - } - result.value = fixMarkup(result.value); - - block.innerHTML = result.value; - block.className += ' hljs ' + (!language && result.language || ''); - block.result = { - language: result.language, - re: result.relevance - }; - if (result.second_best) { - block.second_best = { - language: result.second_best.language, - re: result.second_best.relevance - }; - } - } - - var options = { - classPrefix: 'hljs-', - tabReplace: null, - useBR: false, - languages: undefined - }; - - /* - Updates highlight.js global options with values passed in the form of an object - */ - function configure(user_options) { - options = inherit(options, user_options); - } - - /* - Applies highlighting to all
..
blocks on a page. - */ - function initHighlighting() { - if (initHighlighting.called) - return; - initHighlighting.called = true; - - var blocks = document.querySelectorAll('pre code'); - Array.prototype.forEach.call(blocks, highlightBlock); - } - - /* - Attaches highlighting to the page load event. - */ - function initHighlightingOnLoad() { - addEventListener('DOMContentLoaded', initHighlighting, false); - addEventListener('load', initHighlighting, false); - } - - var languages = {}; - var aliases = {}; - - function registerLanguage(name, language) { - var lang = languages[name] = language(this); - if (lang.aliases) { - lang.aliases.forEach(function(alias) {aliases[alias] = name;}); - } - } - - function listLanguages() { - return Object.keys(languages); - } - - function getLanguage(name) { - return languages[name] || languages[aliases[name]]; - } - - /* Interface definition */ - - this.highlight = highlight; - this.highlightAuto = highlightAuto; - this.fixMarkup = fixMarkup; - this.highlightBlock = highlightBlock; - this.configure = configure; - this.initHighlighting = initHighlighting; - this.initHighlightingOnLoad = initHighlightingOnLoad; - this.registerLanguage = registerLanguage; - this.listLanguages = listLanguages; - this.getLanguage = getLanguage; - this.inherit = inherit; - - // Common regexps - this.IDENT_RE = '[a-zA-Z][a-zA-Z0-9_]*'; - this.UNDERSCORE_IDENT_RE = '[a-zA-Z_][a-zA-Z0-9_]*'; - this.NUMBER_RE = '\\b\\d+(\\.\\d+)?'; - this.C_NUMBER_RE = '(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)'; // 0x..., 0..., decimal, float - this.BINARY_NUMBER_RE = '\\b(0b[01]+)'; // 0b... - this.RE_STARTERS_RE = '!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~'; - - // Common modes - this.BACKSLASH_ESCAPE = { - begin: '\\\\[\\s\\S]', relevance: 0 - }; - this.APOS_STRING_MODE = { - className: 'string', - begin: '\'', end: '\'', - illegal: '\\n', - contains: [this.BACKSLASH_ESCAPE] - }; - this.QUOTE_STRING_MODE = { - className: 'string', - begin: '"', end: '"', - illegal: '\\n', - contains: [this.BACKSLASH_ESCAPE] - }; - this.PHRASAL_WORDS_MODE = { - begin: /\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such)\b/ - }; - this.C_LINE_COMMENT_MODE = { - className: 'comment', - begin: '//', end: '$', - contains: [this.PHRASAL_WORDS_MODE] - }; - this.C_BLOCK_COMMENT_MODE = { - className: 'comment', - begin: '/\\*', end: '\\*/', - contains: [this.PHRASAL_WORDS_MODE] - }; - this.HASH_COMMENT_MODE = { - className: 'comment', - begin: '#', end: '$', - contains: [this.PHRASAL_WORDS_MODE] - }; - this.NUMBER_MODE = { - className: 'number', - begin: this.NUMBER_RE, - relevance: 0 - }; - this.C_NUMBER_MODE = { - className: 'number', - begin: this.C_NUMBER_RE, - relevance: 0 - }; - this.BINARY_NUMBER_MODE = { - className: 'number', - begin: this.BINARY_NUMBER_RE, - relevance: 0 - }; - this.CSS_NUMBER_MODE = { - className: 'number', - begin: this.NUMBER_RE + '(' + - '%|em|ex|ch|rem' + - '|vw|vh|vmin|vmax' + - '|cm|mm|in|pt|pc|px' + - '|deg|grad|rad|turn' + - '|s|ms' + - '|Hz|kHz' + - '|dpi|dpcm|dppx' + - ')?', - relevance: 0 - }; - this.REGEXP_MODE = { - className: 'regexp', - begin: /\//, end: /\/[gim]*/, - illegal: /\n/, - contains: [ - this.BACKSLASH_ESCAPE, - { - begin: /\[/, end: /\]/, - relevance: 0, - contains: [this.BACKSLASH_ESCAPE] - } - ] - }; - this.TITLE_MODE = { - className: 'title', - begin: this.IDENT_RE, - relevance: 0 - }; - this.UNDERSCORE_TITLE_MODE = { - className: 'title', - begin: this.UNDERSCORE_IDENT_RE, - relevance: 0 - }; -}; diff --git a/share/nitdoc/js/lib/nit.js b/share/nitdoc/js/lib/nit.js deleted file mode 100644 index 1b4aff3..0000000 --- a/share/nitdoc/js/lib/nit.js +++ /dev/null @@ -1,144 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -hljs.registerLanguage('nit', function(hljs) { - var METHOD_RE = '[a-z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?'; - var KEYWORDS = { - keyword: 'abort abstract and as assert break class continue do else end enum extern for fun ' + - 'if import in init interface intern intrude is isa isset label loop module new nullable not ' + - 'once or protected private redef return self super then type universal var ' + - 'when while writable', - literal: "true false null" - }; - var COMMENT = { - className: 'comment', - begin: '#', end: '$', - }; - var SUBST = { - className: 'subst', - begin: '{', end: '}', - keywords: KEYWORDS - }; - var STRING = { - className: 'string', - contains: [hljs.BACKSLASH_ESCAPE, SUBST], - variants: [ - {begin: /"/, end: /"/}, - ] - }; - var CHAR = { - className: 'char', - contains: [hljs.BACKSLASH_ESCAPE, SUBST], - begin: /'/, end: /'/, - }; - var TYPE = { - className: 'type', - begin: '[A-Z]\\w*' - } - var PARAMS = { - className: 'params', - begin: '\\(', end: '\\)', - keywords: KEYWORDS, - contains: [TYPE] - }; - var RET_TYPE = { - className: 'rettype', - begin: ':', end: '$|do|is|=', - keywords: 'nullable', - returnEnd: true, - contains: [TYPE] - } - var DO_BLOCK = { - className: 'block', - begin: 'do', end: '$|end', - keywords: KEYWORDS - } - var IS_BLOCK = { - className: 'modifiers', - begin: 'is', end: '$', - keywords: KEYWORDS - } - var CONTAINS = [ - STRING, - CHAR, - COMMENT, - TYPE, - { - className: 'module', - beginKeywords: 'module', end: '$', - contains: [ - hljs.inherit(hljs.TITLE_MODE, {begin: '[a-z_]\\w*'}), - COMMENT - ] - }, - { - className: 'import', - begin: '(intrude )?import', end: '$', - keywords: 'intrude import', - contains: [ - { - className: 'module', - begin: '[a-z_]\\w*' - }, - COMMENT - ] - }, - { - className: 'class', - begin: '(redef |private |protected )?(abstract )?(class|interface)', end: '$', - keywords: 'redef private protected abstract class interface', - contains: [ - hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Z]\\w*'}), - { - className: 'super', - begin: '\\bsuper', end: '$', - keywords: 'super', - contains: [TYPE] - }, - COMMENT - ] - }, - { - className: 'fun', - begin: '(redef |private |protected )?(fun|init|type)\\b', end: '$', - keywords: KEYWORDS, - contains: [ - PARAMS, - RET_TYPE, - DO_BLOCK, - IS_BLOCK, - { - className: 'title', - begin: '\\b[a-zA-Z_][a-zA-Z_]*\\b' - }, - COMMENT - ] - }, - { - className: 'number', - begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b', - relevance: 0 - } - ]; - SUBST.contains = CONTAINS; - - return { - keywords: KEYWORDS, - contains: CONTAINS - }; -}); diff --git a/share/nitdoc/js/lib/utils.js b/share/nitdoc/js/lib/utils.js deleted file mode 100644 index 26304d8..0000000 --- a/share/nitdoc/js/lib/utils.js +++ /dev/null @@ -1,204 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * Utils module - */ -String.prototype.startsWith = function(prefix, caseSensitive) { - if(caseSensitive) { - return this.toUpperCase().indexOf(prefix.toUpperCase()) === 0; - } - return this.indexOf(prefix) === 0; -} - -// Compare two strings using Sorensen-Dice Coefficient -// see: http://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient -String.prototype.dice = function(other) { - var length1 = this.length - 1; - var length2 = other.length - 1; - if(length1 < 1 || length2 < 1) return 0; - - var bigrams2 = []; - for(var i = 0; i < length2; i++) { - bigrams2.push(other.substr(i, 2)); - } - - var intersection = 0; - for(var i = 0; i < length1; i++) { - var bigram1 = this.substr(i, 2); - for(var j = 0; j < length2; j++) { - if(bigram1 == bigrams2[j]) { - intersection++; - bigrams2[j] = null; - break; - } - } - } - return (2.0 * intersection) / (length1 + length2); -} - -/* base64 */ - -String.prototype._keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; - -// public method for encoding -String.prototype.base64Encode = function () { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - - input = this._utf8_encode(); - - while (i < input.length) { - - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + - this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + - this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4); - - } - return output; -}; - -// public method for decoding -String.prototype.base64Decode = function () { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - input = this.replace(/[^A-Za-z0-9\+\/\=]/g, ""); - - while (i < input.length) { - - enc1 = this._keyStr.indexOf(input.charAt(i++)); - enc2 = this._keyStr.indexOf(input.charAt(i++)); - enc3 = this._keyStr.indexOf(input.charAt(i++)); - enc4 = this._keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - - } - return output._utf8_decode();; -}; - -// private method for UTF-8 encoding -String.prototype._utf8_encode = function () { - string = this.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < string.length; n++) { - - var c = string.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - - } - return utftext; -}; - -// private method for UTF-8 decoding -String.prototype._utf8_decode = function () { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while ( i < this.length ) { - - c = this.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = this.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = this.charCodeAt(i+1); - c3 = this.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - - } - return string; -}; - -// JQuery Case Insensitive :icontains selector -$.expr[':'].icontains = function(obj, index, meta, stack){ - return (obj.textContent.replace(/\[[0-9]+\]/g, "") || obj.innerText.replace(/\[[0-9]+\]/g, "") || jQuery(obj).text().replace(/\[[0-9]+\]/g, "") || '').toLowerCase().indexOf(meta[3].toLowerCase()) >= 0; -}; - -var Utils = { - // Extract anchor part (after #) from URL string - extractAnchor: function(url) { - var index = url.indexOf("#"); - if (index >= 0) { - return url.substring(index + 1); - } - return null; - }, - - delayEvent: function(handler, event) { - if(this.delayEvent.timeout) { - clearTimeout(this.delayEvent.timeout); - } - this.delayEvent.timeout = setTimeout(function() { - handler.call(event); - }, 50); - } -}; diff --git a/share/nitdoc/js/plugins/filtering.js b/share/nitdoc/js/plugins/filtering.js deleted file mode 100644 index fa0f12e..0000000 --- a/share/nitdoc/js/plugins/filtering.js +++ /dev/null @@ -1,158 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * Nitdoc Filtering - * - * Allow user to filter sidebar entries and search page - */ -var Filtering = { - - // Allow user to filter sidebar box entries by name - enableSidebarTextFilters: function(filterSelector) { - var div = $(document.createElement("div")) - .addClass("nitdoc-ui-filter") - .append( - $(document.createElement("input")) - .addClass("nitdoc-ui-filter-field") - .addClass("nitdoc-ui-filter-field-notused") - .attr("type", "text") - .attr("value", "filter...") - .keyup(function() { - var box = $(this).parents("nav.filterable"); - var value = $(this).val(); - box.find("ul li:not(:icontains('" + value + "'))").hide(); - box.find("ul li:icontains('" + value + "')").show(); - }) - .focusout(function() { - if($(this).val() == "") { - $(this).addClass("nitdoc-ui-filter-field-notused"); - $(this).val("filter..."); - } - }) - .focusin(function() { - if($(this).val() == "filter...") { - $(this).removeClass("nitdoc-ui-filter-field-notused"); - $(this).val(""); - } - }) - ); - $(filterSelector).after(div); - this.preloadSidebarTextFilters(); - }, - - // Prealod filters using search query - preloadSidebarTextFilters: function() { - var anchor = Utils.extractAnchor(document.location.hash); - if(!anchor || anchor.indexOf("q=") == -1) return; - - var query = anchor.substring(2); - if(!query) return; - - $(".nitdoc-ui-filter input:text") - .val(query) - .removeClass("nitdoc-ui-notused") - .trigger("keyup"); - }, - - // Allow user to filter side bar box entries by Introduced/Refined/inHerited type - enableSidebarTypeFilters: function(filterSelector) { - var box = $(filterSelector); - var types = {}; - - box.find("li").each(function() { - var span = $(this).find("span:first"); - if(!types[span.html()]) types[span.html()] = { - title: span.attr("title"), - class: $(this).attr("class") - } - }); - - for(var type in types) { - var a = $(document.createElement("a")) - .addClass("nitdoc-ui-filter-link") - .html(type) - .attr("title", "Hide " + types[type].title) - .attr("data-filter-class", types[type].class) - .toggle( - function() { - var hclass = $(this).attr("data-filter-class"); - $(this).parents(filterSelector).find("li." + hclass).hide(); - $(this).addClass("nitdoc-ui-filter-hidden") - }, - function() { - var hclass = $(this).attr("data-filter-class"); - $(this).parents(filterSelector).find("li." + hclass).show(); - $(this).removeClass("nitdoc-ui-filter-hidden") - } - ) - $(filterSelector).find(".nitdoc-ui-filter").append(a); - } - }, - - // Allow user to filter sidebar box entries by name - enableSearchPageField: function(filterSelector) { - var div = $(document.createElement("div")) - .addClass("nitdoc-ui-searchpage-filter") - .append( - $(document.createElement("input")) - .addClass("nitdoc-ui-searchpage-field") - .addClass("nitdoc-ui-filter-field-notused") - .attr("type", "text") - .attr("value", "filter...") - .keyup(function() { - var box = $(this).parents(".content.fullpage").find("article.filterable"); - var value = $(this).val(); - box.find("ul li:not(:icontains('" + value + "'))").hide(); - box.find("ul li:icontains('" + value + "')").show(); - }) - .focusout(function() { - if($(this).val() == "") { - $(this).addClass("nitdoc-ui-filter-field-notused"); - $(this).val("filter..."); - } - }) - .focusin(function() { - if($(this).val() == "filter...") { - $(this).removeClass("nitdoc-ui-filter-field-notused"); - $(this).val(""); - } - }) - ); - $(filterSelector).after(div); - this.preloadSearchPageField(); - }, - - // Prealod filter using search query - preloadSearchPageField: function() { - var anchor = Utils.extractAnchor(document.location.hash); - if(!anchor || anchor.indexOf("q=") == -1) return; - - var query = anchor.substring(2); - if(!query) return; - - $(".nitdoc-ui-searchpage-field") - .val(query) - .removeClass("nitdoc-ui-notused") - .trigger("keyup"); - } -}; - -Filtering.enableSidebarTextFilters("nav.filterable h3"); -Filtering.enableSidebarTypeFilters("nav.filterable"); -Filtering.enableSearchPageField(".content.fullpage h1:contains('Search')"); diff --git a/share/nitdoc/js/plugins/github.js b/share/nitdoc/js/plugins/github.js deleted file mode 100644 index c77c0d0..0000000 --- a/share/nitdoc/js/plugins/github.js +++ /dev/null @@ -1,593 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Documentation generator for the nit language. - Generate API documentation in HTML format from nit source code. -*/ - -/* - * Nitdoc.Github comment edition module - * - * Allows user to modify source code comments directly from the Nitdoc - */ -define([ - "jquery", - "github-api", - "highlight", - "marked", - "nit", - "plugins/modalbox", - "plugins/github/loginbox", - "plugins/github/commentbox", - "utils" -], function($, GithubAPI, hljs, marked) { - var GithubUser = function(login, password, repo, branch) { - this.login = login; - this.password = password; - this.repo = repo; - this.auth = "Basic " + (login + ':' + password).base64Encode(); - this.branch = branch; - } - - var GithubUI = { - init: function(upstream, basesha1) { - console.info("Github plugin: init GitHub module (upstream: "+ upstream +", base: " + basesha1 + ")"); - this.origin = this._parseUpstream(upstream); - this._initMarked(); - // Add github menu - $("#topmenu>.container-fluid").append( - $("") - .attr({ - "id": "nitdoc-github-li", - "type": "button", - "class": "navbar-btn navbar-right btn-link", - "href": "#", - "data-container": "body", - "data-toggle": "popover", - "data-placement": "bottom", - "data-content": "bottom", - "data-html": "true", - }) - .loginbox() - //.loginbox("displayLogin") - .bind("loginbox_logoff", function() { - GithubUI.disactivate(); - }) - .bind("loginbox_login", function(event, infos) { - GithubUI._tryLoginFromCredentials(infos); - }) - ); - // check local session - this._tryLoginFromLocalSession(); - }, - - activate: function(user, origin) { - this.openedComments = 0; - this._saveSession(user); - $("#nitdoc-github-li").loginbox("displayLogout", origin, user); - this._attachCommentBoxes(); - this._reloadComments(); - - // Prevent page unload if there is comments in editing mode - $(window).on('beforeunload', function() { - if(GithubUI.openedComments > 0){ - return "There is uncommited modified comments. Are you sure you want to leave this page?"; - } - }); - }, - - disactivate: function() { - if(this.openedComments > 0){ - if(!confirm('There is uncommited modified comments. Are you sure you want to leave this page?')) { - return false; - } - } - - localStorage.clear(); - $("#nitdoc-github-li").loginbox("toggle"); - $("#nitdoc-github-li").loginbox("displayLogin"); - $(window).unbind('beforeunload'); - //window.location.reload(); - }, - - /* login */ - - _checkLoginInfos: function(infos) { - if(!infos.login || !infos.password || !infos.repo || !infos.branch) { - $("

") - .text("Please enter your GitHub username, password, repository and branch.") - .modalbox({ - title: "Sign in error", - isError: true - }) - .modalbox("open"); - return false; - } else { - return true; - } - }, - - _tryLoginFromCredentials: function(infos) { - if(this._checkLoginInfos(infos)) { - var isok = this._tryLogin(infos.login, infos.password, infos.repo, infos.branch); - if(isok === true) { - this.activate(this.user, this.origin); - } else { - if(isok == "error:login") { - $("

") - .text("The username, password, repo or branch you entered is incorrect.") - .modalbox({ - title: "Github sign in error", - isError: true - }) - .modalbox("open"); - } else if(isok == "error:sha") { - $("

") - .text("The provided Github repository must contain the base commit '" + this.origin.sha + "'.") - .modalbox({ - title: "Github base commit error", - isError: true - }) - .modalbox("open"); - } else if(isok == "error:profile") { - $("

") - .text("Please set your public name and email in your " + - "GitHub profile." + - "

Your public profile informations are used to sign-off your commits.") - .modalbox({ - title: "Github profile error", - isError: true - }) - .modalbox("open"); - } - } - } - }, - - _tryLoginFromLocalSession: function() { - if(localStorage.user) { - var session = JSON.parse(localStorage.user); - var isok = this._tryLogin( - session.login, - session.password.base64Decode(), - session.repo, - session.branch - ); - if(isok === true) { - this.activate(this.user, this.origin); - } else { - console.debug("Github plugin: Session found but authentification failed"); - localStorage.clear(); - } - } else { - console.debug("Github plugin: No session found"); - } - }, - - _tryLogin: function(login, password, repo, branch) { - var tmpUser = new GithubUser(login, password, repo, branch); - if(!GithubAPI.login(tmpUser)) { - return "error:login"; - } - if(!tmpUser.infos.name || !tmpUser.infos.email) { - return "error:profile"; - } - var commit = GithubAPI.getCommit(tmpUser, this.origin.sha); - if(!commit || !commit.sha) { - return "error:sha"; - } - this.user = tmpUser; - return true; - }, - - _saveSession: function(user) { - localStorage.user = JSON.stringify({ - login: user.login, - password: user.password.base64Encode(), - repo: user.repo, - branch: user.branch, - }); - // check local storage synchro with branch - if(localStorage.base != this.origin.sha) { - console.log("Base changed: cleaned cache"); - localStorage.requests = "[]"; - localStorage.base = this.origin.sha; - } - }, - - /* html decoration */ - - // Attach edit button on each comment - _attachCommentBoxes: function() { - $("textarea.baseComment").each(function() { - $(this).commentbox(); - - var isNew = false; - if(!$(this).val()) { - isNew = true; - $(this).nextAll(".info:first").find(".noComment").hide() - $(this).nextAll(".info:first").before( - $("

") - .hide() - .addClass("comment") - .append( - $("
").addClass("nitdoc") - ) - ) - } - - $(this).nextAll(".info:first").prepend( - $("") - .addClass("nitdoc-github-editComment") - .css("cursor", "pointer") - .text((isNew ? "add" : "edit") + " comment") - .click($.proxy(GithubUI._openCommentBox, GithubUI, null, $(this))) - .after(" for ") - ) - - $(this).bind("commentbox_commit", function(event, data) { - GithubUI._saveChanges(data); - $(this).commentbox("close"); - GithubUI._reloadComments(); - }) - .bind("commentbox_preview", function(event, data) { - $("
") - .append($("

").text("Comment:")) - .append( - $("
") - .addClass("description") - .append( - $("
") - .addClass("comment") - .append( - $("
") - .addClass("nitdoc") - .html(marked(data.value)) - ) - ) - ) - .append($("

").text("Message:")) - .append( - $("
") - .addClass("description") - .append( - $("
") - .addClass("comment") - .append( - $("
").html(marked(data.message)) - ) - ) - ) - .modalbox({ - title: "Preview comment", - css: {"min-width": "500px"} - }) - .modalbox("open"); - }) - .bind("commentbox_open", function(event, data) { - GithubUI.openedComments++; - $(this).nextAll(".comment").hide(); - }) - .bind("commentbox_close", function(event, data) { - GithubUI.openedComments--; - $(this).nextAll(".comment").show(); - }); - }); - }, - - // reload comments from saved pull request - _reloadComments: function() { - if(!localStorage.requests){ return; } - $("p.pullRequest").remove(); - var requests = JSON.parse(localStorage.requests); - // Look for modified comments in page - for(i in requests) { - if(!requests[i]) { continue; } - var request = requests[i]; - $("textarea[data-comment-location=\"" + request.location + "\"]").each(function () { - if(request.isClosed) { - var oldComment = request.oldComment.base64Decode(); - var htmlComment = marked(oldComment); - $(this).val(oldComment); - if(!$(this).val()) { - $(this).nextAll("div.comment:first").hide(); - } else { - $(this).nextAll("div.comment:first").show(); - } - $(this).nextAll("div.comment").find("div.nitdoc").empty().html(htmlComment); - $(this).nextAll("p.info").find("a.nitdoc-github-editComment").show(); - } else { - var newComment = request.comment.base64Decode(); - var htmlComment = marked(newComment); - $(this).val(newComment); - if(!$(this).val()) { - $(this).nextAll("div.comment:first").hide(); - } else { - $(this).nextAll("div.comment:first").show(); - } - $(this).nextAll("div.comment").find("div.nitdoc").empty().html(htmlComment); - GithubUI._addPullRequestLink($(this), request); - $(this).nextAll("p.info").find("a.nitdoc-github-editComment").hide(); - } - }); - } - }, - - _addPullRequestLink: function(baseArea, request) { - baseArea.nextAll("p.info").before( - $("

") - .addClass("pullRequest inheritance") - .text("comment modified in ") - .append( - $("") - .attr({ - href: request.request.html_url, - title: "Review on GitHub" - }) - .text("pull request #" + request.request.number) - ) - .append(" ") - .append( - $("") - .data("pullrequest-number", request.request.number) - .addClass("nitdoc-github-update") - .text("update") - .click($.proxy(GithubUI._doUpdateRequest, GithubUI, null, baseArea, request)) - ) - .append(" ") - .append( - $("") - .data("pullrequest-number", request.request.number) - .addClass("nitdoc-github-cancel") - .text("cancel") - .click($.proxy(GithubUI._doCancelRequest, GithubUI, null, baseArea, request)) - ) - ); - }, - - /* github calls */ - - _saveChanges: function(edit) { - // if pull request update close existing pull request for the comment - if(edit.requestID) { - this._closePullRequest(edit.requestID); - } - edit.oldContent = this._getFileContent(edit.location.path); - edit.newContent = this._mergeComment(edit.oldContent, edit.newComment, edit.location); - edit.request = this._pushChanges(edit) - if(!edit.request) { - $("

") - .text("Unable to commit changes.
" + response) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return; - } - this._saveRequest(edit); - }, - - // save pull request in local storage - _saveRequest: function(edit) { - var requests = {}; - if(localStorage.requests) {requests = JSON.parse(localStorage.requests)} - requests[edit.request.number] = { - request: edit.request, - location: edit.location.origin, - comment: edit.newComment.base64Encode(), - oldComment: edit.oldComment.base64Encode() - }; - localStorage.requests = JSON.stringify(requests); - }, - - /* - Creating a new pull request with the new comment take 5 steps: - 1. get the base tree from latest commit - - 2. create a new blob with updated file content - 3. post a new tree from base tree and blob - 4. post the new commit with new tree - 5. create the pull request - */ - _pushChanges: function(edit) { - var baseTree = GithubAPI.getTree(this.user, this.origin.sha); - if(!baseTree.sha) { - $("

") - .text("Unable to locate base tree.
" + baseTree.status + ": " + baseTree.statusText) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return false; - } - console.log("Base tree: " + baseTree.url); - var newBlob = GithubAPI.createBlob(this.user, edit.newContent); - if(!newBlob.sha) { - $("

") - .text("Unable to create new blob.
" + newBlob.status + ": " + newBlob.statusText) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return false; - } - console.log("New blob: " + newBlob.url); - var newTree = GithubAPI.createTree(this.user, baseTree, edit.location.path, newBlob); - if(!newTree.sha) { - $("

") - .text("Unable to create new tree.
" + newTree.status + ": " + newTree.statusText) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return false; - } - console.log("New tree: " + newTree.url); - var newCommit = GithubAPI.createCommit(this.user, edit.message, baseTree.sha, newTree); - if(!newCommit.sha) { - $("

") - .text("Unable to create new commit.
" + newCommit.status + ": " + newCommit.statusText) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return false; - } - console.log("New commit: " + newCommit.url); - var pullRequest = GithubAPI.createPullRequest(this.user, edit.title, "Pull request from Nitdoc", this.origin, newCommit.sha); - if(!pullRequest.number) { - $("

") - .text("Unable to create pull request.
" + pullRequest.status + ": " + pullRequest.statusText) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return false; - } - console.log("New pull request: " + pullRequest.url); - return pullRequest; - }, - - // close previously opened pull request - _closePullRequest: function(number) { - var requests = JSON.parse(localStorage.requests); - if(!requests[number]) { - $("

") - .text("Unable to close pull request.
" + "Pull request " + number + "not found") - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return false; - } - // close pull request - var res = GithubAPI.updatePullRequest(this.user, "Closed from Nitdoc", "", "closed", requests[number].request); - if(!res.id) { - $("

") - .text("Unable to close pull request.
" + res.status + ": " + res.statusText) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return false; - } - // update in localstorage - requests[number].isClosed = true; - localStorage.requests = JSON.stringify(requests); - }, - - /* internals */ - - _initMarked: function() { - var renderer = new marked.Renderer(); - renderer.code = function(code) { - return '

' + hljs.highlight('nit', code).value + '
'; - } - renderer.codespan = function(code) { - return '' + hljs.highlight('nit', code).value + ''; - } - marked.setOptions({ - renderer: renderer, - gfm: true, - tables: true, - breaks: true, - pedantic: false, - sanitize: true, - smartLists: true, - smartypants: false - }); - }, - - _parseUpstream: function(upstream) { - var parts = upstream.split(":"); - return { - user: parts[0], - repo: parts[1], - branch: parts[2], - sha: basesha1 - }; - }, - - _getFileContent: function(githubUrl) { - var origFile = GithubAPI.getFile(this.user, githubUrl); - if(!origFile.content) { - $("

") - .text("Unable to locate source file.
" + origFile.status + ": " + origFile.statusText) - .modalbox({ - title: "Github commit error", - isError: true - }) - .modalbox("open"); - return; - } - var base64Content = origFile.content.substring(0, origFile.content.length - 1) - return base64Content.base64Decode(); - }, - - _mergeComment: function(fileContent, comment, location) { - // replace comment in file content - var res = new String(); - var lines = fileContent.split("\n"); - // copy lines fron 0 to lstart - for(var i = 0; i < location.lstart - 1; i++) { - res += lines[i] + "\n"; - } - // set comment - if(comment && comment != "") { - var commentLines = comment.split("\n"); - for(var i = 0; i < commentLines.length; i++) { - var line = commentLines[i]; - var tab = location.tabpos > 1 ? "\t" : ""; - res += tab + (line.length > 0 ? "# " : "#") + line + "\n"; - } - } - // copy lines fron lend to end - for(var i = location.lend - 1; i < lines.length; i++) { - res += lines[i]; - if(i < lines.length - 1) { res += "\n"; } - } - return res; - }, - - /* events */ - - _openCommentBox: function(event, baseArea) { - baseArea.commentbox("open", this.user); - }, - - _doCancelRequest: function(event, baseArea, request) { - this._closePullRequest(request.request.number); - this._reloadComments(); - }, - - _doUpdateRequest: function(event, baseArea, request) { - baseArea.commentbox("open", this.user, request.request.number); - }, - } - - // Get github plugin data - var upstream = $("body").attr("data-github-upstream"); - var basesha1 = $("body").attr("data-github-base-sha1"); - if(upstream && basesha1) { - GithubUI.init(upstream, basesha1); - } -}); diff --git a/share/nitdoc/js/plugins/github/commentbox.js b/share/nitdoc/js/plugins/github/commentbox.js deleted file mode 100644 index 2bb6a18..0000000 --- a/share/nitdoc/js/plugins/github/commentbox.js +++ /dev/null @@ -1,231 +0,0 @@ -/* This file is part of NIT ( http://www.nitlanguage.org ). - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/* - * CommentBox allows user to edit comments then preview, commit or cancel the changes - */ -define([ - "jquery", - "jQueryUI" -], function($) { - var Location = function(location) { - var parts = location.split(":"); - this.origin = location; - this.path = parts[0]; - this.lstart = parseInt(parts[1].split("--")[0].split(",")[0]); - this.tabpos = parseInt(parts[1].split("--")[0].split(",")[1]); - this.lend = parseInt(parts[1].split("--")[1].split(",")[0]); - this.toString = function() { - return this.path + ":" + this.lstart + "," + this.tabpos + "--" + this.lend + ",0"; - } - } - - $.widget("nitdoc.commentbox", { - - options: { - previewTxt: "preview", - commitTxt: "Commit", - cancelTxt: "Cancel", - commentboxTitle: "Edit comment", - messageTxt: "Commit message" - }, - - _create: function() { - this._id = $(".nitdoc-github-commentbox").length - this._oldComment = this.element.val(); - this._namespace = this.element.data("comment-namespace"); - this._location = new Location(this.element.data("comment-location")); - this.commentBox = $("

") - .hide() - .addClass("nitdoc-github-commentbox") - .append( - $("

") - .text(this.options.commentboxTitle) - ) - .append( - $("
") - .addClass("nitdoc-github-commentbox-fields") - .append( - $("
") - .append( - $("