Merge remote-tracking branch 'manage/master' into subtree

this merges master branch of https://github.com/helma-org/apps-manage-mirror into helma
This commit is contained in:
Simon Oberhammer 2012-03-27 11:47:36 +02:00
commit ca2b08a5df
58 changed files with 2678 additions and 0 deletions

View file

@ -0,0 +1,59 @@
function read_action() {
this.readApplication();
res.redirect(this.href("main"));
}
function main_action() {
if (checkAddress() == false)
return;
if (checkAuth(this.getParentElement()) == false)
return;
this.renderSkin("frameset");
}
function prototypes_action() {
if (checkAddress() == false)
return;
if (checkAuth(this.getParentElement()) == false)
return;
res.data.body = this.renderSkinAsString("prototypes");
renderSkin("api");
}
function summary_action() {
if (checkAddress() == false)
return;
if (checkAuth(this.getParentElement()) == false)
return;
res.data.body = this.renderSkinAsString("summary");
renderSkin("api");
}
function functionindex_action() {
if (checkAddress() == false)
return;
if (checkAuth(this.getParentElement()) == false)
return;
res.data.body = this.renderSkinAsString("functionindex");
renderSkin("api");
}
function render_action() {
// set res.data.rendering, this will suppress the link back to the manage
// console in the apidocs actions
res.data.rendering = true;
if (checkAddress() == false)
return;
if (checkAuth(this.getParentElement()) == false)
return;
var ct = this.renderApi();
res.data.body = '<body>rendering API ...<br/>wrote ' + ct + ' files<br/><br/>';
res.data.body += '<a href="' + root.href("main") + '">back to manage console</a>';
res.data.title = "rendering helma api";
res.data.head = renderSkinAsString("head");
renderSkin("basic");
}

View file

@ -0,0 +1,31 @@
<html>
<head>
<title>helma api / <% this.name %></title>
<script language="javascript"><!--
function changePrototypeList (obj) {
if (obj.href.indexOf (".html")>-1)
var newhref = obj.href.substring (0, obj.href.length-9) + "list.html";
else
var newhref = obj.href.substring (0, obj.href.length-4) + "list";
functions.location.href = newhref;
}
//--></script>
</head>
<frameset cols="30%,70%">
<frameset rows="40%,60%">
<frame src="<% this.href action="prototypes" %>" name="prototypes">
<frame src="<% this.hrefRoot action="list" %>" name="functions">
</frameset>
<frame src="<% this.href action="summary" %>" name="main">
</frameset>
<noframes>
<h2>
Frame Alert</h2>
<p>
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
</noframes>
</html>

View file

@ -0,0 +1,24 @@
<table width="90%" border="0" cellspacing="1" cellpadding="5">
<tr>
<td class="headline">
<big class="top">Application <% this.headline %></tt></b></big><br>
</td>
</tr>
</table>
<a class="navig" href="<% this.href action="summary"%>">SUMMARY</a> |
<a class="navig" href="<% this.href action="functionindex" %>">INDEX</a> |
<a class="navig" href="#A">A</a>|<a class="navig" href="#B">B</a>|<a class="navig" href="#C">C</a>|<a class="navig" href="#D">D</a>|<a class="navig" href="#E">E</a>|<a class="navig" href="#F">F</a>|<a class="navig" href="#G">G</a>|<a class="navig" href="#H">H</a>|<a class="navig" href="#I">I</a>|<a class="navig" href="#J">J</a>|<a class="navig" href="#K">K</a>|<a class="navig" href="#L">L</a>|<a class="navig" href="#M">M</a>|<a class="navig" href="#N">N</a>|<a class="navig" href="#O">O</a>|<a class="navig" href="#P">P</a>|<a class="navig" href="#Q">Q</a>|<a class="navig" href="#R">R</a>|<a class="navig" href="#S">S</a>|<a class="navig" href="#T">T</a>|<a class="navig" href="#U">U</a>|<a class="navig" href="#V">V</a>|<a class="navig" href="#W">W</a>|<a class="navig" href="#X">X</a>|<a class="navig" href="#Y">Y</a>|<a class="navig" href="#Z">Z</a>|
<table width="90%" border="0" cellspacing="1" cellpadding="5">
<% this.functions skin="asIndexItem"
separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
%>
</table>
<a class="navig" href="<% this.href action="summary"%>">SUMMARY</a> |
<a class="navig" href="<% this.href action="functionindex" %>">INDEX</a> |
<a class="navig" href="#A">A</a>|<a class="navig" href="#B">B</a>|<a class="navig" href="#C">C</a>|<a class="navig" href="#D">D</a>|<a class="navig" href="#E">E</a>|<a class="navig" href="#F">F</a>|<a class="navig" href="#G">G</a>|<a class="navig" href="#H">H</a>|<a class="navig" href="#I">I</a>|<a class="navig" href="#J">J</a>|<a class="navig" href="#K">K</a>|<a class="navig" href="#L">L</a>|<a class="navig" href="#M">M</a>|<a class="navig" href="#N">N</a>|<a class="navig" href="#O">O</a>|<a class="navig" href="#P">P</a>|<a class="navig" href="#Q">Q</a>|<a class="navig" href="#R">R</a>|<a class="navig" href="#S">S</a>|<a class="navig" href="#T">T</a>|<a class="navig" href="#U">U</a>|<a class="navig" href="#V">V</a>|<a class="navig" href="#W">W</a>|<a class="navig" href="#X">X</a>|<a class="navig" href="#Y">Y</a>|<a class="navig" href="#Z">Z</a>|

View file

@ -0,0 +1,97 @@
/**
* Get the prototype of any doc-object (either a prototype, a function or a tag)
*/
function getDocPrototype(obj) {
var tmp = obj;
while (tmp != null && tmp.getType() != this.PROTOTYPE) {
tmp = tmp.getParentElement();
}
return tmp;
}
/**
* Get a prototype of this docapplication, ie get on of the children of this object
*/
function getPrototype(name) {
return this.getChildElement("prototype_" + name);
}
/**
* Method used by Helma for URL composition.
*/
function href(action) {
var base = this.getParentElement().href() + "api/";
return action ? base + action : base;
}
function getDir(dir, obj) {
dir.mkdir();
if (obj.getType() == this.APPLICATION) {
return dir;
} else {
var protoObj = this.getDocPrototype(obj);
var dir = new File (dir, protoObj.getElementName());
dir.mkdir();
return dir;
}
}
function renderApi() {
var prefix = this.href("");
this.storePage(this, "main", "", "index.html");
this.storePage(this, "prototypes");
this.storePage(this, "summary");
this.storePage(this, "functionindex");
var ct = 4;
var arr = this.listChildren();
for (var i = 0; i < arr.length; i++) {
this.storePage(arr[i], "list", "../");
this.storePage(arr[i], "main", "../");
ct += 2;
var subarr = arr[i].listChildren();
for (var j = 0; j < subarr.length; j++) {
this.storePage(subarr[j], "main", "../", subarr[j].getElementName() + ".html");
ct += 1;
}
}
return ct;
}
function storePage(obj, action, backPath, filename) {
if (filename == null)
var filename = action + ".html";
var str = this.getPage(obj, action, backPath);
var appObj = this.getParentElement();
var dir = new File (appObj.getAppDir().getAbsolutePath(), ".docs");
dir = this.getDir(dir, obj);
var f = new File (dir, filename);
f.remove();
f.open();
f.write(str);
f.close();
app.log("wrote file " + f.getAbsolutePath());
}
function getPage(obj, action, backPath) {
backPath = (backPath == null) ? "" : backPath;
res.pushStringBuffer();
eval("obj." + action + "_action ();");
var str = res.popStringBuffer();
// get the baseURI out of the url and replace
// it with the given relative prefix
// (keep anchors in regex!)
var reg = new RegExp ("href=\"" + this.href("") + "([^\"#]+)([^\"]*)\"", "gim");
str = str.replace(reg, "href=\"" + backPath + "$1.html$2\"");
var reg = new RegExp ("src=\"" + this.href("") + "([^\"#]+)([^\"]*)\"", "gim");
str = str.replace(reg, "src=\"" + backPath + "$1.html$2\"");
// shorten links, so that function files can move up one directory
// in the hierarchy
var reg = new RegExp ("(prototype_[^/]+/[^/]+)/main.html", "gim");
str = str.replace(reg, "$1.html");
return str;
}

View file

@ -0,0 +1,3 @@
<tr><td class='headline'><a name="<% param.letter %>"><!-- --></a>
<big><% param.letter %></big>
</td></tr>

View file

@ -0,0 +1,106 @@
/**
* macro rendering a skin
* @param name name of skin
*/
function skin_macro(par) {
if (par && par.name) {
this.renderSkin(par.name);
}
}
/**
* macro-wrapper for href-function
* @param action name of action to call on this prototype, default main
*/
function href_macro(param) {
return this.href((param && param.action) ? param.action : "main");
}
function comment_macro(param) {
return renderComment(this, param);
}
function content_macro(param) {
return this.getContent();
}
function tags_macro(param) {
return renderTags(this, param);
}
function location_macro(param) {
return renderLocation(this, param);
}
function link_macro(param) {
return renderLink(this, param);
}
//// END OF COPIED FUNCTIONS
function linkToManage_macro(param) {
if (res.data.rendering != true) {
return ('<a href="' + root.href("main") + '" target="_top">back to manage console</a>');
}
}
function headline_macro(param) {
res.write(this.getName());
}
function hrefRoot_macro(param) {
var obj = this.getChildElement("prototype_root");
if (obj == null) {
var obj = this.getChildElement("prototype_Root");
}
if (obj != null) {
var action = (param.action) ? param.action : "main";
return obj.href(action);
}
}
/**
* list all prototypes of this application
* @param skin name of skin to render on prototype
* @param separator
*/
function prototypes_macro(param) {
var skin = (param.skin) ? param.skin : "asPrototypeList";
var separator = (param.separator) ? param.separator : "";
var arr = this.listChildren();
for (var i = 0; i < arr.length; i++) {
arr[i].renderSkin(skin);
if (i < arr.length - 1)
res.write(separator);
}
}
/**
* list all methods of all prototypes, sort them alphabetically
* @param skin name of skin to render on each method
* @param skinSeparator name of skin to render as separator between each letters
*/
function functions_macro(param) {
var skinname = (param.skin) ? param.skin : "asListItem";
var skinIndexSeparator = (param.indexSeparator) ? param.indexSeparator : "indexSeparator";
var separator = (param.separator) ? param.separator : "";
var arr = this.listFunctions();
var lastLetter = "";
for (var i = 0; i < arr.length; i++) {
if (arr[i].getName().substring(0, 1) != lastLetter) {
lastLetter = arr[i].getName().substring(0, 1);
var tmp = new Object ();
tmp.letter = lastLetter.toUpperCase();
this.renderSkin(skinIndexSeparator, tmp);
}
arr[i].renderSkin(skinname);
if (i < arr.length - 1)
res.write(separator);
}
}

View file

@ -0,0 +1,10 @@
<% this.linkToManage suffix="<br/><br/>" %>
<big class="top">Application <a href="<% this.href action="summary" %>" target="main"><% this.name %></a></big><br><br>
<% this.prototypes %>

View file

@ -0,0 +1,29 @@
<table width="90%" border="0" cellspacing="1" cellpadding="5">
<tr>
<td class="headline">
<big class="top">Application <% this.headline %></tt></b></big><br>
</td>
</tr>
</table>
<a class="navig" href="<% this.href action="summary"%>">SUMMARY</a> |
<a class="navig" href="<% this.href action="functionindex" %>">INDEX</a> |
<% this.comment encoding="html" %>
<hr>
<table width="90%" border="0" cellspacing="1" cellpadding="5">
<% this.prototypes skin="asSummary"
separator="<tr><td class='mainbox'><img src='' width=0 height=0></td></tr>"
%>
</table>
<a class="navig" href="<% this.href action="summary"%>">SUMMARY</a> |
<a class="navig" href="<% this.href action="functionindex" %>">INDEX</a> |