Commit c2b45e21 authored by Cristian Berner's avatar Cristian Berner 💎
Browse files

Fixes ISSUE-45004: Remove obsolete org.openbravo.client.kernel/docs

Those docs were previously generated from javascript with
code-illuminated library. The syntax is very different to the jsdoc used
currently. So it is removed as obsolete, and both library and license
for it are also removed.

Template docs.js.ftl and class DocumentationComponent are also removed
because they're not needed anymore by the module.
parent a6c67996
......@@ -280,10 +280,6 @@ A modified version of scopeleaks by Rui Lopes available from https://github.com/
(The MIT License), Copyright © 2011 Rui Lopes
The full license text is embedded within the scopeleaks.js file
# web/org.openbravo.client.kernel/docs
Beautiful documentation, dynamically generated from source code in the browser.
From the code-illuminated project at: http://code.google.com/p/code-illuminated/, under the MPL 1.1
# jsbeautifier.py
Under the MIT license (available at https://github.com/beautify-web/js-beautify/blob/master/LICENSE)
......
......@@ -26,19 +26,6 @@
<!--96DA67B541E243FC9A7C6AEBC3752952--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--96DA67B541E243FC9A7C6AEBC3752952--></OBCLKER_TEMPLATE>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--><OBCLKER_TEMPLATE>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <OBCLKER_TEMPLATE_ID><![CDATA[DBAC211182304F7784DAB4EDE7B6AA1D]]></OBCLKER_TEMPLATE_ID>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <AD_MODULE_ID><![CDATA[4B828F4D03264080AA1D2057B13F613C]]></AD_MODULE_ID>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <NAME><![CDATA[Documentation Template]]></NAME>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <DESCRIPTION><![CDATA[Kernel Component]]></DESCRIPTION>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <TEMPLATECLASSPATHLOCATION><![CDATA[/org/openbravo/client/kernel/templates/docs.js.ftl]]></TEMPLATECLASSPATHLOCATION>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <TEMPLATE_LANGUAGE><![CDATA[OBCLFRE_Freemarker]]></TEMPLATE_LANGUAGE>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <COMPONENT_TYPE><![CDATA[OBCLKER_Kernel]]></COMPONENT_TYPE>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--> <ISACTIVE><![CDATA[Y]]></ISACTIVE>
<!--DBAC211182304F7784DAB4EDE7B6AA1D--></OBCLKER_TEMPLATE>
<!--FF8081812E297131012E2A061112001C--><OBCLKER_TEMPLATE>
<!--FF8081812E297131012E2A061112001C--> <OBCLKER_TEMPLATE_ID><![CDATA[FF8081812E297131012E2A061112001C]]></OBCLKER_TEMPLATE_ID>
<!--FF8081812E297131012E2A061112001C--> <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
......
/*
*************************************************************************
* The contents of this file are subject to the Openbravo Public License
* Version 1.1 (the "License"), being the Mozilla Public License
* Version 1.1 with a permitted attribution clause; you may not use this
* file except in compliance with the License. You may obtain a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2010-2011 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
*/
package org.openbravo.client.kernel;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import org.openbravo.base.session.OBPropertiesProvider;
import org.openbravo.dal.service.OBDal;
import org.openbravo.model.ad.module.Module;
/**
* @author iperdomo
*
*/
public class DocumentationComponent extends BaseTemplateComponent {
private static final String SOURCE_PATH_PROPERTY = "source.path";
private static final String JS_DIRECTORY_PATH = "@javapackage@" + File.separator + "web"
+ File.separator + "@javapackage@" + File.separator + "js";
@Override
protected Template getComponentTemplate() {
return OBDal.getInstance().get(Template.class, KernelConstants.DOCUMENTATION_TEMPLATE_ID);
}
public List<String> getDocumentationResources() {
final Properties obProps = OBPropertiesProvider.getInstance().getOpenbravoProperties();
String modulesPath = obProps.getProperty(SOURCE_PATH_PROPERTY);
if (modulesPath == null) {
return Collections.emptyList();
}
File modulesFolder = new File(modulesPath + File.separator + "modules");
if (!modulesFolder.exists()) {
return Collections.emptyList();
}
final List<Module> modules = KernelUtils.getInstance().getModulesOrderedByDependency();
final List<String> result = new ArrayList<String>();
final FilenameFilter jsFilter = new FilenameFilter() {
@Override
public boolean accept(File dir, String fileName) {
return fileName.endsWith(".js");
}
};
for (Module mod : modules) {
if (mod.getId().equals("0")) { // Skip core
continue;
}
final File jsModFolder = new File(modulesFolder,
JS_DIRECTORY_PATH.replace("@javapackage@", mod.getJavaPackage()));
if (!jsModFolder.exists()) {
continue;
}
File[] files = jsModFolder.listFiles(jsFilter);
for (int i = 0; i < files.length; i++) {
result.add(
"#" + getContextUrl() + "web/" + mod.getJavaPackage() + "/js/" + files[i].getName());
}
}
return result;
}
}
......@@ -65,8 +65,6 @@ public class KernelComponentProvider extends BaseComponentProvider {
SessionDynamicResourceComponent.class);
sessionDynamicComponent.setParameters(parameters);
return sessionDynamicComponent;
} else if (componentId.equals(KernelConstants.DOCUMENT_COMPONENT_ID)) {
return getComponent(DocumentationComponent.class);
}
throw new IllegalArgumentException("Component " + componentId + " not supported here");
}
......
......@@ -65,7 +65,6 @@ public class KernelConstants {
public static final String STYLE_SHEET_COMPONENT_ID = "StyleSheetResources";
public static final String RESOURCE_COMPONENT_ID = "StaticResources";
public static final String DOCUMENT_COMPONENT_ID = "DocumentResources";
public static final String RESOURCE_CONTEXT_URL_PARAMETER = "#{contextUrl}";
public static final String CONTEXT_URL = "_contextUrl";
......
/*
*************************************************************************
* The contents of this file are subject to the Openbravo Public License
* Version 1.1 (the "License"), being the Mozilla Public License
* Version 1.1 with a permitted attribution clause; you may not use this
* file except in compliance with the License. You may obtain a copy of
* the License at http://www.openbravo.com/legal/license.html
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
* The Original Code is Openbravo ERP.
* The Initial Developer of the Original Code is Openbravo SLU
* All portions are Copyright (C) 2010-2019 Openbravo SLU
* All Rights Reserved.
* Contributor(s): ______________________________________.
************************************************************************
*/
(function(w) {
var d = w.document, ul, li, a;
ul = d.getElementById('js-files');
if(ul === null) {
return;
}
<#list data.documentationResources as doc>
li = d.createElement('li');
a = d.createElement('a');
a.setAttribute('href', '${doc}');
a.appendChild(d.createTextNode('${doc}'));
li.appendChild(a);
ul.appendChild(li);
</#list>
})(window);
\ No newline at end of file
body {
font-family: palatino, palatino linotype, georgia, serif;
font-size: 10pt;
text-align: center;
}
.popup-enabled {
cursor: pointer;
border-bottom: dotted 1px black;
}
.popup {
position: absolute;
z-index: 100;
}
.popup .item {
cursor: pointer;
font-family: helvetica neue, arial, sans-serif;
background-color: #f0f0f0;
color: black;
padding: 3px;
border: black dotted;
border-width: 1px 1px 0 1px;
}
.popup .selected {
background-color: black;
color: white;
}
.popup .bottom {
border-bottom: 1px black dotted;
}
#content {
text-align: left;
margin: 0 auto;
}
.documentation {
float: left;
line-height: 1.4em;
}
.documentation h1, .documentation h2 {
font-weight: normal;
line-height: 1.4em;
}
.documentation pre {
font-family: monaco, consolas, andale mono, monospace;
font-size: 6pt;
line-height: 1.4em;
}
.code {
font-family: monaco, consolas, andale mono, monospace;
float: left;
white-space: pre;
font-size: 6pt;
background-color: #f0f0f0;
margin: 0;
}
.divider {
clear: both;
height: 0;
line-height: 0;
}
.intra-wiki {
color: black;
text-decoration: none;
border-bottom: solid 1px gray;
}
.highlight {
background-color: yellow;
}
a {
color: black;
text-decoration: underline;
}
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (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.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Ubiquity.
*
* The Initial Developer of the Original Code is Mozilla.
* Portions created by the Initial Developer are Copyright (C) 2007
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Atul Varma <atul@mozilla.com>
* Sander Dijkhuis <sander.dijkhuis@gmail.com>
* Alberto Santini <albertosantini@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
// = App =
//
// This is the application that processes the code and lets the user
// navigate through and read the documentation.
var App = {
};
// ** {{{ App.trim() }}} **
//
// Returns {{{str}}} without whitespace at the beginning and the end.
App.trim = function trim(str) {
return str.replace(/^\s+|\s+$/g,"");
};
// ** {{{ App.processors }}} **
//
// An array of user-defined processor functions. They should take one
// argument, the DOM node containing the documentation. User-defined
// processor functions are called after standard processing is done.
App.processors = [];
App.menuItems = {}; // Has a {label, urlOrCallback} dict for each keyword.
// ** {{{ App.processCode() }}} **
//
// Splits {{{code}}} in documented blocks and puts them in {{{div}}}.
// The used structure for each block is:
// {{{
// <div class="documentation"> (...) </div>
// <pre class="code prettyprint"> (...) </pre>
// <div class="divider"/>
// }}}
// Documentation is parsed using [[http://wikicreole.org/|Creole]].
App.processCode = function processCode(code, div) {
var lines = code.replace(/\r\n/g,'\n').replace(/\r/g,'\n').split('\n');
var blocks = [];
var blockText = "";
var codeText = "";
var firstCommentLine;
var lastCommentLine;
function maybeAppendBlock() {
if (blockText)
blocks.push({text: blockText,
lineno: firstCommentLine,
numLines: lastCommentLine - firstCommentLine + 1,
code: codeText});
}
jQuery.each(
lines,
function(lineNum) {
var line = this;
var isCode = true;
var isComment = (App.trim(line).indexOf("//") == 0);
if (isComment) {
var startIndex = line.indexOf("//");
var text = App.trim(line.slice(startIndex + 3));
if (lineNum == lastCommentLine + 1) {
blockText += text + "\n";
lastCommentLine += 1;
isCode = false;
} else if (text.charAt(0) == "=" || text.charAt(0) == "*") {
maybeAppendBlock();
firstCommentLine = lineNum;
lastCommentLine = lineNum;
blockText = text + "\n";
codeText = "";
isCode = false;
}
}
if (isCode)
codeText += line + "\r\n";
});
maybeAppendBlock();
var creole = new Parse.Simple.Creole(
{
forIE: document.all,
interwiki: {
WikiCreole: 'http://www.wikicreole.org/wiki/',
Wikipedia: 'http://en.wikipedia.org/wiki/'
},
linkFormat: ''
});
jQuery.each(
blocks,
function(i) {
var docs = $('<div class="documentation">');
$(docs).css(App.columnCss);
creole.parse(docs.get(0), this.text);
$(div).append(docs);
var code = $('<pre class="code prettyprint">');
$(code).css(App.columnCss);
code.text(this.code);
$(div).append(code);
// Make sure the block ends with a blank line to make it high enough.
// For IE8 an extra space is needed, because otherwise the \n is ignored.
// FIXME: This doesn't fix issue 13 in IE7 yet.
code.append('\n ');
var docsSurplus = docs.height() - code.height() + 1;
if (docsSurplus > 0)
code.css({paddingBottom: docsSurplus + "px"});
$(div).append('<div class="divider">');
});
// Run the user-defined processors.
jQuery.each(
App.processors,
function(i) {
App.processors[i]($(div).find(".documentation"));
});
};
// ** {{{ App.addMenuItem() }}} **
//
// Adds a menu item to the {{{element}}} DOM node showing the {{{label}}}
// text. If {{{urlOrCallback}}} is an URL, choosing the item causes a new
// window to be opened with that URL. If it's a function, it will be called
// when choosing the item.
//
// If the node does not have a menu yet, one will be created.
App.addMenuItem = function addMenuItem(element, label, urlOrCallback) {
var text = $(element).text();
if (!$(element).parent().hasClass("popup-enabled")) {
App.menuItems[text] = [];
$(element).wrap('<span class="popup-enabled"></span>');
$(element).mousedown(
function(evt) {
evt.preventDefault();
var popup = $('<div class="popup"></div>');
function addItemToPopup(label, urlOrCallback) {
var callback;
var menuItem = $('<div class="item"></div>');
menuItem.text(label);
function onOverOrOut() { $(this).toggleClass("selected"); }
menuItem.mouseover(onOverOrOut);
menuItem.mouseout(onOverOrOut);
if (typeof(urlOrCallback) == "string")
callback = function() {
window.open(urlOrCallback);
};
else
callback = urlOrCallback;
menuItem.mouseup(callback);
popup.append(menuItem);
}
jQuery.each(
App.menuItems[text],
function(i) {
var item = App.menuItems[text][i];
addItemToPopup(item.label, item.urlOrCallback);
});
popup.find(".item:last").addClass("bottom");
popup.css({left: evt.pageX + "px"});
$(window).mouseup(
function mouseup() {
popup.remove();
$(window).unbind("mouseup", mouseup);
});
$(this).append(popup);
});
}
App.menuItems[text].push({ label: label, urlOrCallback: urlOrCallback });
};
App.currentPage = null;
App.pages = {};
// ** {{{ App.navigate() }}} **
//
// Navigates to a different view if needed. The appropriate view is
// fetched from the URL hash. If that is empty, the original page content
// is shown.
App.navigate = function navigate() {
var newPage;
if (window.location.hash)
newPage = window.location.hash.slice(1);
else
newPage = "overview";
if (App.currentPage != newPage) {
if (App.currentPage)
$(App.pages[App.currentPage]).hide();
if (!App.pages[newPage]) {
var newDiv = $("<div>");
newDiv.attr("name", newPage);
$("#content").append(newDiv);
App.pages[newPage] = newDiv;
jQuery.get(newPage,
{},
function(code) {
App.processCode(code, newDiv);
prettyPrint();
},
"text");
}
$(App.pages[newPage]).show();
App.currentPage = newPage;
}
};
App.CHARS_PER_ROW = 80;
App.initColumnSizes = function initSizes() {
// Get the width of a single monospaced character of code.
var oneCodeCharacter = $('<div class="code">M</div>');
$("#content").append(oneCodeCharacter);
App.charWidth = oneCodeCharacter.width();
App.columnWidth = App.charWidth * App.CHARS_PER_ROW;
$(oneCodeCharacter).remove();
// Dynamically determine the column widths and padding based on
// the font size.
var padding = App.charWidth * 2;
App.columnCss = {width: App.columnWidth,
paddingLeft: padding,
paddingRight: padding};
$("#content").css({width: (App.columnWidth + padding*2) * 2});
$(".documentation").css(App.columnCss);
$(".code").css(App.columnCss);
};
$(window).ready(
function() {
App.pages["overview"] = $("#overview").get(0);
App.initColumnSizes();
window.setInterval(
function() { App.navigate(); },
100
);
App.navigate();
// Get the selected text in a cross-browser fashion
function getSelectedText(){
if(window.getSelection){
return window.getSelection().toString();
} else if (document.getSelection) {
return document.getSelection();
} else if(document.selection){
return document.selection.createRange().text;