From 4a7616d5a0a4995fbecc74dad7146bd50d28e384 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 11 Mar 2002 13:49:50 +0000 Subject: [PATCH 01/82] This commit was generated by cvs2svn to compensate for changes in r2155, which included commits to RCS files with non-trunk default branches. --- Application/functions.js | 35 ++++ Application/head.skin | 10 ++ Application/macros.js | 172 +++++++++++++++++++ Application/main.hac | 10 ++ Application/main.skin | 42 +++++ Application/mrtg.hac | 23 +++ Application/navig_active.skin | 15 ++ Application/navig_disabled.skin | 10 ++ Application/redirectpublic.hac | 10 ++ DocApplication/functions.js | 14 ++ DocApplication/head.skin | 8 + DocApplication/index.skin | 11 ++ DocApplication/macros.js | 74 +++++++++ DocApplication/main.hac | 23 +++ DocApplication/main.skin | 11 ++ DocApplication/navig.skin | 14 ++ DocFunction/functions.js | 20 +++ DocFunction/indexList.skin | 5 + DocFunction/indexListSeparator.skin | 3 + DocFunction/listElementAction.skin | 7 + DocFunction/listElementFunction.skin | 7 + DocFunction/listElementMacro.skin | 9 + DocFunction/listElementSkin.skin | 7 + DocFunction/listElementTemplate.skin | 7 + DocFunction/macros.js | 136 +++++++++++++++ DocFunction/main.hac | 8 + DocFunction/main.skin | 14 ++ DocPrototype/appList.skin | 10 ++ DocPrototype/functions.js | 14 ++ DocPrototype/listFooter.skin | 3 + DocPrototype/listHeader.skin | 7 + DocPrototype/macros.js | 90 ++++++++++ DocPrototype/main.hac | 8 + DocPrototype/main.skin | 9 + DocPrototype/navig.skin | 2 + DocTag/renderfunctions.js | 46 +++++ Global/api.skin | 17 ++ Global/functions.js | 155 +++++++++++++++++ Global/global.skin | 14 ++ Global/head.skin | 53 ++++++ Global/macros.js | 97 +++++++++++ Global/md5.js | 178 ++++++++++++++++++++ Global/navig.skin | 17 ++ Root/functions.js | 36 ++++ Root/image.hac | 11 ++ Root/macros.js | 240 +++++++++++++++++++++++++++ Root/main.hac | 46 +++++ Root/main.skin | 101 +++++++++++ Root/makekey.hac | 10 ++ app.properties | 5 + class.properties | 11 ++ 51 files changed, 1885 insertions(+) create mode 100644 Application/functions.js create mode 100644 Application/head.skin create mode 100644 Application/macros.js create mode 100644 Application/main.hac create mode 100644 Application/main.skin create mode 100644 Application/mrtg.hac create mode 100644 Application/navig_active.skin create mode 100644 Application/navig_disabled.skin create mode 100644 Application/redirectpublic.hac create mode 100644 DocApplication/functions.js create mode 100644 DocApplication/head.skin create mode 100644 DocApplication/index.skin create mode 100644 DocApplication/macros.js create mode 100644 DocApplication/main.hac create mode 100644 DocApplication/main.skin create mode 100644 DocApplication/navig.skin create mode 100644 DocFunction/functions.js create mode 100644 DocFunction/indexList.skin create mode 100644 DocFunction/indexListSeparator.skin create mode 100644 DocFunction/listElementAction.skin create mode 100644 DocFunction/listElementFunction.skin create mode 100644 DocFunction/listElementMacro.skin create mode 100644 DocFunction/listElementSkin.skin create mode 100644 DocFunction/listElementTemplate.skin create mode 100644 DocFunction/macros.js create mode 100644 DocFunction/main.hac create mode 100644 DocFunction/main.skin create mode 100644 DocPrototype/appList.skin create mode 100644 DocPrototype/functions.js create mode 100644 DocPrototype/listFooter.skin create mode 100644 DocPrototype/listHeader.skin create mode 100644 DocPrototype/macros.js create mode 100644 DocPrototype/main.hac create mode 100644 DocPrototype/main.skin create mode 100644 DocPrototype/navig.skin create mode 100644 DocTag/renderfunctions.js create mode 100644 Global/api.skin create mode 100644 Global/functions.js create mode 100644 Global/global.skin create mode 100644 Global/head.skin create mode 100644 Global/macros.js create mode 100644 Global/md5.js create mode 100644 Global/navig.skin create mode 100644 Root/functions.js create mode 100644 Root/image.hac create mode 100644 Root/macros.js create mode 100644 Root/main.hac create mode 100644 Root/main.skin create mode 100644 Root/makekey.hac create mode 100644 app.properties create mode 100644 class.properties diff --git a/Application/functions.js b/Application/functions.js new file mode 100644 index 00000000..04cda7fa --- /dev/null +++ b/Application/functions.js @@ -0,0 +1,35 @@ +/** + * construct an application object so that we can use + * skins for non-active applications too + * @arg name + */ +function constructor(name) { + this.name = name; +} + + +/** + * overrides the internal href-function, as + * helma.framework.core.Application.getNodeHref(Object,String) + * isn't able to compute correct urls for non-node objects. + * @arg action of application + */ +function href(action) { + var url = getProperty("baseURI"); + url = (url==null || url=="null") ? "" : url; + url += this.name + "/" + ( (action!=null && action!="") ? action : "main" ); + return url; +} + + +/** + * return true/false to determine if application is running + */ +function isActive() { + if ( root.getApplication(this.name)==null ) + return false; + else + return true; +} + + diff --git a/Application/head.skin b/Application/head.skin new file mode 100644 index 00000000..a52e6407 --- /dev/null +++ b/Application/head.skin @@ -0,0 +1,10 @@ +

AppManager <% this.title %> +<% this.description prefix="
" %> +
+ -> + /main">AppDoc | + public | + ?app=<% this.title %>&action=flush">flush | + ?app=<% this.title %>&action=restart">restart | + ?app=<% this.title %>&action=stop">stop +

diff --git a/Application/macros.js b/Application/macros.js new file mode 100644 index 00000000..9eec3fe5 --- /dev/null +++ b/Application/macros.js @@ -0,0 +1,172 @@ +/** + * 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(par) { + return this.href( (par&&par.action)?par.action:"main" ); +} + + +/** + * Macro returning the URL of an application. + * using absoluteURI if set in app.properties, otherwise we go for the href calculated by + * the application (which is using baseURI if set) + */ +function url_macro() { + var str = this.getProperty("absoluteuri"); + if ( str!=null && str!="" ) { + return str; + } else { + return this.getRootHref(); + } +} + + +/** + * Macro returning the title of an application + */ +function title_macro() { + var title = this.name; + return(title); +} + + +/** + * Macro rendering a description of an application from a + * file called description.txt or doc.html located in the + * app's root. Limits description to 200 chars. + * @param Object Macro parameter object + */ +function description_macro(param) { + var str = ""; + var appHome = this.getAppDir(); + var f = new File(this.getAppDir().toString(), "description.txt"); + if (!f.exists()) + f = new File(this.getAppDir().toString(), "doc.html"); + if (f.exists()) { + str = f.readAll(); + if (str.length > 200) + str = str.substring(0, 200) + "..."; + } + return(str); +} + + +/** + * Macro returning the server's uptime nicely formatted + */ +function uptime_macro() { + return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 ); +} + + +/** + * Macro returning the number of active sessions. + * parameter used by global.formatCount + * @see global.formatCount + */ +function countSessions_macro(par) { + if ( this.isActive()==true ) + return this.sessions.size() + formatCount(this.sessions.size(),par); + else + return 0; +} + + +/** + * Macro returning the number of logged-in users or the list + * of logged-in users if http-parameter showusers is set to true. + * Makes use of this.countUsers_macro and this.listUsers_macro + * @see application.countUsers_macro + * @see application.listUsers_macro + */ +function users_macro(par) { + if ( req.data.showusers=="true" ) { + this.listUsers_macro(par); + } else { + this.countUsers_macro(par); + } +} + + +/** + * Macro returning the number of logged-in users if application + * is active + * parameter used by global.formatCount + * @see global.formatCount + */ +function countUsers_macro(par) { + if ( this.isActive()==true ) + return this.activeUsers.size() + formatCount(this.activeUsers.size(),par); + else + return 0; +} + + +/** + * Macro rendering the list of logged-in users if application is active + * @param separator html-code written between elements + */ +function listUsers_macro(par) { + var separator = (par && par.separator) ? par.separator : ", "; + if ( this.activeUsers.size()==0 ) + return ""; + var e = this.activeUsers.keys(); + while ( e.hasMoreElements() ) { + res.write ( e.nextElement() ); + if ( e.hasMoreElements() ) { + res.write ( separator ); + } + } +} + + +/** + * Macro returning the number of active evaluators (=threads) + */ +function countActiveEvaluators_macro() { + return this.countActiveEvaluators(); +} + + +/** + * Macro returning the number of free evaluators (=threads) + */ +function countFreeEvaluators_macro() { + return this.countFreeEvaluators(); +} + + +/** + * Macro formatting the 5min average of requests. + */ +function getRequestAvg_macro(par) { + if ( app.requestStat==null || app.requestStat.get(this.name)==null ) + return 0; + if ( this.isActive() ) { + var obj = app.requestStat.get(this.name); + return obj.last5Min + formatCount(obj.last5Min,par); + } else { + return 0 + formatCount(0,par); + } +} + + +/** + * Macro formatting app.properties + */ +function properties_macro(par) { + formatProperties( this.getProperties(), par ); +} + diff --git a/Application/main.hac b/Application/main.hac new file mode 100644 index 00000000..40a43c35 --- /dev/null +++ b/Application/main.hac @@ -0,0 +1,10 @@ +/** + * renders AppManager + */ + +if ( checkAddress()==false ) return; +if ( checkAuth(this)==false ) return; + +res.skin="global"; +res.body = this.renderSkinAsString("main"); + diff --git a/Application/main.skin b/Application/main.skin new file mode 100644 index 00000000..0b05f12d --- /dev/null +++ b/Application/main.skin @@ -0,0 +1,42 @@ +<% this.skin name="head" %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<% this.properties prefix="" %> +
application
active sessions: <% this.countSessions %>
?showusers=true">logged-in users: <% this.users %> 
active evaluators: <% this.countActiveEvaluators %>
free evaluators: <% this.countFreeEvaluators %>
5min-request-avg: <% this.getRequestAvg %>
uptime: <% this.uptime %>
app.properties
" separator=" " suffix="
+ diff --git a/Application/mrtg.hac b/Application/mrtg.hac new file mode 100644 index 00000000..fb324794 --- /dev/null +++ b/Application/mrtg.hac @@ -0,0 +1,23 @@ +/** + * prints session- and thread-stats for mrtg-tool + * doesn't check username or password, so that we don't have + * to write them cleartext in a mrtg-configfile + */ + +if ( checkAddress()==false ) return; + +if ( this.isActive()==false ) { + res.write ( "0\n0\n0\n0\n"); + return; +} + +if ( req.data.action=="sessions" ) { + res.write ( this.sessions.size() + "\n0\n0\n0\n" ); + return; +} + +if ( req.data.action=="threads" ) { + res.write ( this.countActiveEvaluators() + "\n" + this.countFreeEvaluators() + "\n0\n0\n"); + return; +} + diff --git a/Application/navig_active.skin b/Application/navig_active.skin new file mode 100644 index 00000000..afd05311 --- /dev/null +++ b/Application/navig_active.skin @@ -0,0 +1,15 @@ +
+ "><% this.title %>
+ <% this.countSessions singular=" Session" plural=" Sessions" %>, <% this.getRequestAvg singular=" Request" plural=" Requests" %>/5min +
+ +
+
diff --git a/Application/navig_disabled.skin b/Application/navig_disabled.skin new file mode 100644 index 00000000..c49223d1 --- /dev/null +++ b/Application/navig_disabled.skin @@ -0,0 +1,10 @@ +
+ + + + +
+ ?app=<% this.title %>&action=start">start +
+ <% this.title %> +
diff --git a/Application/redirectpublic.hac b/Application/redirectpublic.hac new file mode 100644 index 00000000..7ead5169 --- /dev/null +++ b/Application/redirectpublic.hac @@ -0,0 +1,10 @@ +/** + * performs a redirect to the public site + * (workaround, we can't access application object from docapplication for some reason) + * @see application.url_macro + */ + +if ( checkAddress()==false ) return; +if ( checkAuth(this)==false ) return; + +res.redirect ( this.url_macro() ); diff --git a/DocApplication/functions.js b/DocApplication/functions.js new file mode 100644 index 00000000..fbbd7872 --- /dev/null +++ b/DocApplication/functions.js @@ -0,0 +1,14 @@ +/** + * overrides the internal href-function, as + * helma.framework.core.Application.getNodeHref(Object,String) + * isn't able to compute correct urls for non-node objects. + * @arg action of application + */ +function href(action) { + var url = getProperty("baseURI"); + url = (url==null || url=="null") ? "" : url; + url += this.name + "/api/" + ( (action!=null && action!="") ? action : "main" ); + return url; +} + + diff --git a/DocApplication/head.skin b/DocApplication/head.skin new file mode 100644 index 00000000..1bd8e6a2 --- /dev/null +++ b/DocApplication/head.skin @@ -0,0 +1,8 @@ +

AppDoc <% this.name %> +
+ -> + AppManager | + ">public +

+ + diff --git a/DocApplication/index.skin b/DocApplication/index.skin new file mode 100644 index 00000000..51fc7746 --- /dev/null +++ b/DocApplication/index.skin @@ -0,0 +1,11 @@ + +

AppDoc <% this.name %>

+ + + + +<% this.index skin="indexList" %> +
+ +
+ diff --git a/DocApplication/macros.js b/DocApplication/macros.js new file mode 100644 index 00000000..a18e1142 --- /dev/null +++ b/DocApplication/macros.js @@ -0,0 +1,74 @@ +/** + * 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(par) { + return this.href( (par&&par.action)?par.action:"main" ); +} + + +/** + * link to the "real" application object (ie not the DocApplication) + */ +function parentlink_macro(par) { + var url = getProperty("baseURI"); + url = (url==null || url=="null") ? "" : url; + url += this.name + "/"; + url += (par&&par.action)?par.action:"main"; + return url; +} + + +/** + * list all prototypes of this application + * @param skin name of skin to render on prototype + */ +function prototypes_macro(par) { + var skin = (par && par.skin&&par.skin!="")?par.skin:"appList"; + var arr = this.listPrototypes(); + for ( var i=0; i + + + + + + <% this.prototypes skin="appList" %> +
Prototypes
+ +
+ diff --git a/DocApplication/navig.skin b/DocApplication/navig.skin new file mode 100644 index 00000000..f639e52a --- /dev/null +++ b/DocApplication/navig.skin @@ -0,0 +1,14 @@ +<% this.name %> + + + +

+

+ Prototypes:
+ <% this.prototypes skin="navig" %> +

+ diff --git a/DocFunction/functions.js b/DocFunction/functions.js new file mode 100644 index 00000000..4fac6021 --- /dev/null +++ b/DocFunction/functions.js @@ -0,0 +1,20 @@ + +/** + * overrides the internal href-function, as + * helma.framework.core.Application.getNodeHref(Object,String) + * isn't able to compute correct urls for non-node objects. + * @arg action of prototype + */ +function href(action) { + var url = getProperty("baseURI"); + url = (url==null || url=="null") ? "" : url; + url += this.getParentElement().getParentElement().getName() + "/api/" + this.getParentElement().getName() + "/" + this.getTypeName().toLowerCase()+"_"+this.name + "/" + ( (action!=null && action!="") ? action : "main" ); + return url; +} + + +function getApplication() { + return this.getParentElement().getParentElement(); +} + + diff --git a/DocFunction/indexList.skin b/DocFunction/indexList.skin new file mode 100644 index 00000000..3c0bc71f --- /dev/null +++ b/DocFunction/indexList.skin @@ -0,0 +1,5 @@ + + <% this.name %> + <% this.typename %> in <% this.prototypename %> + ("><% this.prototypename %>/<% this.location %>) + diff --git a/DocFunction/indexListSeparator.skin b/DocFunction/indexListSeparator.skin new file mode 100644 index 00000000..f8d0edd0 --- /dev/null +++ b/DocFunction/indexListSeparator.skin @@ -0,0 +1,3 @@ + +  <% param.letter %> + diff --git a/DocFunction/listElementAction.skin b/DocFunction/listElementAction.skin new file mode 100644 index 00000000..67c5da69 --- /dev/null +++ b/DocFunction/listElementAction.skin @@ -0,0 +1,7 @@ + + +  <% param.group %> +
+ "><% this.name %>
<% this.comment %>
<% this.tags %>
+ + diff --git a/DocFunction/listElementFunction.skin b/DocFunction/listElementFunction.skin new file mode 100644 index 00000000..b692f1ca --- /dev/null +++ b/DocFunction/listElementFunction.skin @@ -0,0 +1,7 @@ + + +  <% param.group %> +
+ "><% this.name %>(<% this.args %>) in <% docprototype.name %>/<% this.location %>
<% this.comment %>
<% this.tags %>
+ + diff --git a/DocFunction/listElementMacro.skin b/DocFunction/listElementMacro.skin new file mode 100644 index 00000000..52a10dbd --- /dev/null +++ b/DocFunction/listElementMacro.skin @@ -0,0 +1,9 @@ + + +  <% param.group %> +
+ "><% docprototype.name %>.<% this.name %> + in <% docprototype.name %>/<% this.location %> +
<% this.comment %>
<% this.tags %>
+ + diff --git a/DocFunction/listElementSkin.skin b/DocFunction/listElementSkin.skin new file mode 100644 index 00000000..71185419 --- /dev/null +++ b/DocFunction/listElementSkin.skin @@ -0,0 +1,7 @@ + + +  <% param.group %> +
+ "><% docprototype.name %>.<% this.name %>
<% this.comment %>
<% this.tags %>
+ + diff --git a/DocFunction/listElementTemplate.skin b/DocFunction/listElementTemplate.skin new file mode 100644 index 00000000..81893dd8 --- /dev/null +++ b/DocFunction/listElementTemplate.skin @@ -0,0 +1,7 @@ + + +  <% param.group %> +
+ "><% this.name %>()
<% this.comment %>
<% this.tags %>
+ + diff --git a/DocFunction/macros.js b/DocFunction/macros.js new file mode 100644 index 00000000..2f58e1ce --- /dev/null +++ b/DocFunction/macros.js @@ -0,0 +1,136 @@ +/** + * 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(par) { + return this.href( (par&&par.action)?par.action:"main" ); +} + + +/** + * macro returning name of file this method resides in + */ +function location_macro(par) { + var f = new File ( this.getLocation() ); + return f.getName(); +} + + +/** + * macro returning the type of this method (Action, Template, Skin, Macro, Function) + */ +function typename_macro(par) { + return this.getTypeName(); +} + + +/** + * macro returning a link to the prototype page + * @param action name of action to call on this prototype, default main + */ +function prototypehref_macro(par) { + return this.getDocPrototype().href( (par&&par.action)?par.action:"main" ) +} + + +/** + * macro returning the name of the prototype this method belongs to + */ +function prototypename_macro(par) { + return this.getDocPrototype().getName(); +} + + +/** + * macro returning the comment text of this method + * (excluding the tags!) + * @param size (optional) text is cutoff after a number of chars + */ +function comment_macro(par) { + var str = this.getComment(); + if ( par && par.length && str.length > par.size ) { + return ( str.substring(0,par.size) ); + } else { + return ( str ); + } +} + + +/** + * macro rendering the list of tags + */ +function tags_macro() { + var arr = this.listTags(); + var argCt = 0; + for ( var i in arr ) { + if ( arr[i].getKind()==Packages.helma.doc.DocTag.ARG ) + argCt++; + res.write( arr[i].render(argCt,this) ); + } +} + + +/** + * macro rendering sequence of arg1, arg2 etc + * according to number of arguments in doctags. + */ +function args_macro() { + var ct = this.countTags(Packages.helma.doc.DocTag.ARG); + for ( var i=0; i"); + var str4 = ""; + for ( var i=0; i ' + if ( i<100 ) str4+=' '; + str4 += arr[i] + "
"; + } + return ( str4 ); +} + + +/** + * macro returning the fullname of this method + */ +function fullname_macro(par) { + return this.getFullName(); +} + + diff --git a/DocFunction/main.hac b/DocFunction/main.hac new file mode 100644 index 00000000..ef413f29 --- /dev/null +++ b/DocFunction/main.hac @@ -0,0 +1,8 @@ +if ( checkAddress()==false ) return; +if ( checkAuth(this)==false ) return; + +res.body = this.renderSkinAsString("main"); +res.skin = "api"; +res.title = "Application " + this.name; + + diff --git a/DocFunction/main.skin b/DocFunction/main.skin new file mode 100644 index 00000000..29a7bc8f --- /dev/null +++ b/DocFunction/main.skin @@ -0,0 +1,14 @@ + + +

+ ">Prototype <% docprototype.name %>
+ <% this.fullname %> +

+ +
+ in <% docprototype.name%>/<% this.location %>: +
+ + +
<% this.source %>
+ diff --git a/DocPrototype/appList.skin b/DocPrototype/appList.skin new file mode 100644 index 00000000..e132ca63 --- /dev/null +++ b/DocPrototype/appList.skin @@ -0,0 +1,10 @@ + + +  Prototype +
+ "><% this.name %>
+ <% this.comment %> +
+ + + diff --git a/DocPrototype/functions.js b/DocPrototype/functions.js new file mode 100644 index 00000000..053c0541 --- /dev/null +++ b/DocPrototype/functions.js @@ -0,0 +1,14 @@ + +/** + * overrides the internal href-function, as + * helma.framework.core.Application.getNodeHref(Object,String) + * isn't able to compute correct urls for non-node objects. + * @arg action of prototype + */ +function href(action) { + var url = getProperty("baseURI"); + url = (url==null || url=="null") ? "" : url; + url += this.getParentElement().getName() + "/api/" + this.name + "/" + ( (action!=null && action!="") ? action : "main" ); + return url; +} + diff --git a/DocPrototype/listFooter.skin b/DocPrototype/listFooter.skin new file mode 100644 index 00000000..d3f6097b --- /dev/null +++ b/DocPrototype/listFooter.skin @@ -0,0 +1,3 @@ + +
+ diff --git a/DocPrototype/listHeader.skin b/DocPrototype/listHeader.skin new file mode 100644 index 00000000..bbe57421 --- /dev/null +++ b/DocPrototype/listHeader.skin @@ -0,0 +1,7 @@ + + + + + + + diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js new file mode 100644 index 00000000..3db36027 --- /dev/null +++ b/DocPrototype/macros.js @@ -0,0 +1,90 @@ +/** + * 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(par) { + return this.href( (par&&par.action)?par.action:"main" ); +} + + +/** + * macro returning the comment for this prototype + */ +function comment_macro(par) { + return this.getComment(); +} + + +/** + * macro formatting list of actions of this prototype + */ +function actions_macro(par) { + this.printMethods( Packages.helma.doc.DocElement.ACTION, "listElementAction","Actions" ); +} + + +/** + * macro formatting list of templates of this prototype + */ +function templates_macro(par) { + this.printMethods( Packages.helma.doc.DocElement.TEMPLATE, "listElementTemplate","Templates" ); +} + + +/** + * macro formatting list of functions of this prototype + */ +function functions_macro(par) { + this.printMethods( Packages.helma.doc.DocElement.FUNCTION, "listElementFunction","Functions" ); +} + + +/** + * macro formatting list of skins of this prototype + */ +function skins_macro(par) { + this.printMethods( Packages.helma.doc.DocElement.SKIN, "listElementSkin","Skins" ); +} + + +/** + * macro formatting list of macros of this prototype + */ +function macros_macro(par) { + this.printMethods( Packages.helma.doc.DocElement.MACRO, "listElementMacro","Macros" ); +} + + +/** + * macro-utility: renders a list of methods of this prototype + * usage of docprototype.listHeader/listFooter skin is hardcoded + * @arg type integer - which type of methods are listed + * @arg skin skin to be called on method + * @arg desc string describing the type of method (ie "Skins", "Actions") + */ +function printMethods(type,skin,desc) { + var arr = this.listFunctions(type); + if ( arr.length > 0 ) { + var obj = new Object(); + obj.desc = desc; + this.renderSkin("listHeader",obj); + for ( var i in arr ) { + arr[i].renderSkin(skin,obj); + } + this.renderSkin("listFooter",obj); + } +} + + + diff --git a/DocPrototype/main.hac b/DocPrototype/main.hac new file mode 100644 index 00000000..ef413f29 --- /dev/null +++ b/DocPrototype/main.hac @@ -0,0 +1,8 @@ +if ( checkAddress()==false ) return; +if ( checkAuth(this)==false ) return; + +res.body = this.renderSkinAsString("main"); +res.skin = "api"; +res.title = "Application " + this.name; + + diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin new file mode 100644 index 00000000..71821440 --- /dev/null +++ b/DocPrototype/main.skin @@ -0,0 +1,9 @@ + +

Prototype <% this.name %>

+ +<% this.actions %> +<% this.skins %> +<% this.macros %> +<% this.functions %> +<% this.templates %> + diff --git a/DocPrototype/navig.skin b/DocPrototype/navig.skin new file mode 100644 index 00000000..cc6f041f --- /dev/null +++ b/DocPrototype/navig.skin @@ -0,0 +1,2 @@ + +"><% this.name %>
diff --git a/DocTag/renderfunctions.js b/DocTag/renderfunctions.js new file mode 100644 index 00000000..ede11b25 --- /dev/null +++ b/DocTag/renderfunctions.js @@ -0,0 +1,46 @@ +/** + * function renders list of tags, language is hardcoded here + * @arg number of current argument (for formatting arg1, arg2 etc) + * @arg method method-object from which we try to find other prototypes/methods + * when we're formatting a see tag + */ +function render(argCt,docFunc) { + var str = ""; + if ( this.getKind() == this.ARG ) { + str = "arg" + argCt + ": " + format(this.text); + } else if ( this.getKind() == this.PARAM ) { + str = "Parameter " + this.name; + if ( this.text!=null && this.text!="" ) { + str += ": " + format(this.text); + } + } else if ( this.getKind() == this.RETURNS ) { + str = "Returns: " + format(this.text); + } else if ( this.getKind() == this.AUTHOR ) { + str = "by " + format(this.text) + ""; + } else if ( this.getKind() == this.VERSION ) { + str = "Version " + format(this.text) + ""; + } else if ( this.getKind() == this.RELEASE ) { + str = "since" + format(this.text) + ""; + } else if ( this.getKind() == this.SEE ) { + if ( this.text.indexOf("http://")==0 ) { + str = '' + this.text + ''; + } else { + var tmp = new java.lang.String(this.text); + tmp = tmp.trim(); + var arr = tmp.split("."); + var obj = docFunc.getApplication().getDocPrototype(arr[0]); + if( arr.length>1 && obj.getFunction(arr[1])!=null ) { + str = 'See also: ' + format(tmp) + ''; + } else if ( obj!=null ) { + str = 'See also: ' + format(tmp) + ''; + } + } + if ( str=="" ) { + str = "See also: " + format(this.text); + } + } + return str + "
"; +} + + + diff --git a/Global/api.skin b/Global/api.skin new file mode 100644 index 00000000..d152e04d --- /dev/null +++ b/Global/api.skin @@ -0,0 +1,17 @@ + + +<% skin name="head" %> + + +
<% param.desc %>
+ + + + +
+

">" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;">

+ <% docapplication.skin name="navig" %>
<% response.body %>
+ + + + diff --git a/Global/functions.js b/Global/functions.js new file mode 100644 index 00000000..62858d0b --- /dev/null +++ b/Global/functions.js @@ -0,0 +1,155 @@ + + +/** + * scheduler function, runs global.appStat every minute + */ +function scheduler() { + appStat(); + return 60000; +} + + +/** + * initializes requestStat storage on startup + */ +function onStart() { + app.requestStat = new HopObject(); + app.addressFilter = new Packages.helma.util.InetAddressFilter(); + var str = root.getProperty("allowadmin"); + if ( str!=null && str!="" ) { + var arr = str.split(","); + for ( var i in arr ) { + var str = new java.lang.String(arr[i]); + app.addressFilter.addAddress(str.trim()); + } + } +} + + +/** + * updates the request stats in app.requestStat every 5 minutes + */ +function appStat() { + if ( app.requestStat==null ) { + app.requestStat = new HopObject(); + } + if( (new Date()-300000) < app.requestStat.lastRun ) { + return; + } + var arr = root.getApplications(); + for ( var i=0; ib.name ) + return 1; + else if ( a.name==b.name ) + return 0; + else + return -1; +} + + +/** + * utility function to sort property-arrays by key + */ +function sortProps(a,b) { + if ( a>b ) + return 1; + else if ( a==b ) + return 0; + else + return -1; +} + +/** + * check access to an application or the whole server, authenticate against md5-encrypted + * properties of base-app or the particular application. if username or password aren't set + * go into stealth-mode and return a 404. if username|password are wrong, prepare response- + * object for http-auth and return false. + * @arg application-object + */ +function checkAuth(appObj) { + var ok = false; + + // check against root + var rootUsername = root.getProperty("adminusername"); + var rootPassword = root.getProperty("adminpassword"); + + if ( rootUsername==null || rootUsername=="" || rootPassword==null || rootPassword=="" ) + return forceStealth(); + + var uname = req.getUsername(); + var pwd = req.getPassword(); + + if ( uname==null || uname=="" || pwd==null || pwd=="" ) + return forceAuth(); + + var md5password = calcMD5(uname); + var md5username = calcMD5(pwd); + + if ( md5username==rootUsername && md5password==rootPassword ) + return true; + + if ( appObj!=null && appObj.isActive() ) { + // check against application + var appUsername = appObj.getProperty("adminusername"); + var appPassword = appObj.getProperty("adminpassword"); + if ( appUsername==null || appUsername=="" || appPassword==null || appPassword=="" ) + return forceStealth(); + if ( md5username==appUsername && md5password==appPassword ) + return true; + } + return forceAuth(); +} + + +/** + * check access to the base-app by ip-addresses + */ +function checkAddress() { + if ( !app.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) + return forceStealth(); + else + return true; +} + + +/** + * response is reset to 401 / authorization required + */ +function forceAuth(appObj) { + res.status = 401; + res.realm = (appObj==null) ? "helma" : appObj.name; + res.reset(); + res.write ("Authorization Required. The server could not verify that you are authorized to access the requested page."); + return false; +} + +/** + * response is reset to 404 / notfound + */ +function forceStealth() { + res.reset(); + res.status = 404; + return false; +} + + + diff --git a/Global/global.skin b/Global/global.skin new file mode 100644 index 00000000..a80b0da1 --- /dev/null +++ b/Global/global.skin @@ -0,0 +1,14 @@ + + +<% skin name="head" %> + + + + + + + +
<% skin name="navig" %><% response.body %>
+ + + diff --git a/Global/head.skin b/Global/head.skin new file mode 100644 index 00000000..4f5659c0 --- /dev/null +++ b/Global/head.skin @@ -0,0 +1,53 @@ + + <% response.title %> + + \ No newline at end of file diff --git a/Global/macros.js b/Global/macros.js new file mode 100644 index 00000000..5f0b72c5 --- /dev/null +++ b/Global/macros.js @@ -0,0 +1,97 @@ +/** + * macro rendering a skin + * @param name name of skin + */ +function skin_macro(par) { + if ( par && par.name ) { + renderSkin(par.name); + } +} + + +/** + * Macro returning the actual date and time. + */ +function now_macro() { + var date = new Date(); + return(date.format("dd.MM.yyyy, HH:mm'h' zzz")); +} + + +/** + * macro-utility: formatting property lists + */ +function formatProperties(props,par) { + var prefix = (par && par.prefix) ? par.prefix : ""; + var suffix = (par && par.suffix) ? par.suffix : ""; + var separator = (par && par.separator) ? par.separator : ""; + var e = props.keys(); + var arr = new Array(); + if ( e==null ) + return ""; + while ( e.hasMoreElements() ) { + arr[arr.length] = e.nextElement(); + } + arr.sort(sortProps); + for ( var i in arr ) { + // don't print the admin-password + if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue; + res.write ( prefix + arr[i] + separator + props.getProperty(arr[i]) + suffix ); + } +} + + +/** + * macro-utility: formatting an integer value as human readable bytes + */ +function formatBytes(bytes) { + if ( bytes > Math.pow(2,30) ) { + res.write( Math.round( 100*bytes/Math.pow(2,30) ) / 100 + "gb" ); + } else if ( bytes > Math.pow(2,20) ) { + res.write( Math.round( 100*bytes/Math.pow(2,20) ) / 100 + "mb" ); + } else { + res.write( Math.round( 100*bytes/Math.pow(2,10) ) / 100 + "kb" ); + } +} + + +/** + * macro-utility: formatting time in millis as human readable age + */ +function formatAge(age) { + var str = ""; + var days = Math.floor(age/86400); + var age = age - days * 86400; + var hours = Math.floor(age / 3600); + var age = age - hours * 3600; + var minutes = Math.floor(age / 60); + var seconds = Math.floor(age - minutes * 60); + if (days > 0) + str += (days + " days, "); + if (hours>0) + str += (hours + "h, "); + str += (minutes + "min"); + if (days == 0) str += (", " + seconds + "sec"); + return(str); +} + + +/** + * macro-utility: formatting a number-suffix by choosing between singular and plural + * @arg value number to be formatted + * @arg param-object object to get fields + * @param singular string used for value==1 + * @param plural string used for value!=1 + */ +function formatCount(ct, par) { + if ( !par || !par.singular || !par.plural ) { + return ""; + } + if ( ct==1 ) + return par.singular; + else + return par.plural; +} + + + diff --git a/Global/md5.js b/Global/md5.js new file mode 100644 index 00000000..3d31a709 --- /dev/null +++ b/Global/md5.js @@ -0,0 +1,178 @@ +/* + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Copyright (C) Paul Johnston 1999 - 2000. + * Updated by Greg Holt 2000 - 2001. + * See http://pajhome.org.uk/site/legal.html for details. + */ + + +/** + * Take a string and return the hex representation of its MD5. + * @arg string + */ +function calcMD5(str) +{ + x = str2blks_MD5(str); + a = 1732584193; + b = -271733879; + c = -1732584194; + d = 271733878; + + for(i = 0; i < x.length; i += 16) + { + olda = a; + oldb = b; + oldc = c; + oldd = d; + + a = ff(a, b, c, d, x[i+ 0], 7 , -680876936); + d = ff(d, a, b, c, x[i+ 1], 12, -389564586); + c = ff(c, d, a, b, x[i+ 2], 17, 606105819); + b = ff(b, c, d, a, x[i+ 3], 22, -1044525330); + a = ff(a, b, c, d, x[i+ 4], 7 , -176418897); + d = ff(d, a, b, c, x[i+ 5], 12, 1200080426); + c = ff(c, d, a, b, x[i+ 6], 17, -1473231341); + b = ff(b, c, d, a, x[i+ 7], 22, -45705983); + a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416); + d = ff(d, a, b, c, x[i+ 9], 12, -1958414417); + c = ff(c, d, a, b, x[i+10], 17, -42063); + b = ff(b, c, d, a, x[i+11], 22, -1990404162); + a = ff(a, b, c, d, x[i+12], 7 , 1804603682); + d = ff(d, a, b, c, x[i+13], 12, -40341101); + c = ff(c, d, a, b, x[i+14], 17, -1502002290); + b = ff(b, c, d, a, x[i+15], 22, 1236535329); + + a = gg(a, b, c, d, x[i+ 1], 5 , -165796510); + d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632); + c = gg(c, d, a, b, x[i+11], 14, 643717713); + b = gg(b, c, d, a, x[i+ 0], 20, -373897302); + a = gg(a, b, c, d, x[i+ 5], 5 , -701558691); + d = gg(d, a, b, c, x[i+10], 9 , 38016083); + c = gg(c, d, a, b, x[i+15], 14, -660478335); + b = gg(b, c, d, a, x[i+ 4], 20, -405537848); + a = gg(a, b, c, d, x[i+ 9], 5 , 568446438); + d = gg(d, a, b, c, x[i+14], 9 , -1019803690); + c = gg(c, d, a, b, x[i+ 3], 14, -187363961); + b = gg(b, c, d, a, x[i+ 8], 20, 1163531501); + a = gg(a, b, c, d, x[i+13], 5 , -1444681467); + d = gg(d, a, b, c, x[i+ 2], 9 , -51403784); + c = gg(c, d, a, b, x[i+ 7], 14, 1735328473); + b = gg(b, c, d, a, x[i+12], 20, -1926607734); + + a = hh(a, b, c, d, x[i+ 5], 4 , -378558); + d = hh(d, a, b, c, x[i+ 8], 11, -2022574463); + c = hh(c, d, a, b, x[i+11], 16, 1839030562); + b = hh(b, c, d, a, x[i+14], 23, -35309556); + a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060); + d = hh(d, a, b, c, x[i+ 4], 11, 1272893353); + c = hh(c, d, a, b, x[i+ 7], 16, -155497632); + b = hh(b, c, d, a, x[i+10], 23, -1094730640); + a = hh(a, b, c, d, x[i+13], 4 , 681279174); + d = hh(d, a, b, c, x[i+ 0], 11, -358537222); + c = hh(c, d, a, b, x[i+ 3], 16, -722521979); + b = hh(b, c, d, a, x[i+ 6], 23, 76029189); + a = hh(a, b, c, d, x[i+ 9], 4 , -640364487); + d = hh(d, a, b, c, x[i+12], 11, -421815835); + c = hh(c, d, a, b, x[i+15], 16, 530742520); + b = hh(b, c, d, a, x[i+ 2], 23, -995338651); + + a = ii(a, b, c, d, x[i+ 0], 6 , -198630844); + d = ii(d, a, b, c, x[i+ 7], 10, 1126891415); + c = ii(c, d, a, b, x[i+14], 15, -1416354905); + b = ii(b, c, d, a, x[i+ 5], 21, -57434055); + a = ii(a, b, c, d, x[i+12], 6 , 1700485571); + d = ii(d, a, b, c, x[i+ 3], 10, -1894986606); + c = ii(c, d, a, b, x[i+10], 15, -1051523); + b = ii(b, c, d, a, x[i+ 1], 21, -2054922799); + a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359); + d = ii(d, a, b, c, x[i+15], 10, -30611744); + c = ii(c, d, a, b, x[i+ 6], 15, -1560198380); + b = ii(b, c, d, a, x[i+13], 21, 1309151649); + a = ii(a, b, c, d, x[i+ 4], 6 , -145523070); + d = ii(d, a, b, c, x[i+11], 10, -1120210379); + c = ii(c, d, a, b, x[i+ 2], 15, 718787259); + b = ii(b, c, d, a, x[i+ 9], 21, -343485551); + + a = add(a, olda); + b = add(b, oldb); + c = add(c, oldc); + d = add(d, oldd); + } + return rhex(a) + rhex(b) + rhex(c) + rhex(d); +} + + + +/* + * Convert a 32-bit number to a hex string with ls-byte first + */ +var hex_chr = "0123456789abcdef"; +function rhex(num) +{ + str = ""; + for(j = 0; j <= 3; j++) + str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) + + hex_chr.charAt((num >> (j * 8)) & 0x0F); + return str; +} + +/* + * Convert a string to a sequence of 16-word blocks, stored as an array. + * Append padding bits and the length, as described in the MD5 standard. + */ +function str2blks_MD5(str) +{ + nblk = ((str.length + 8) >> 6) + 1; + blks = new Array(nblk * 16); + for(i = 0; i < nblk * 16; i++) blks[i] = 0; + for(i = 0; i < str.length; i++) + blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8); + blks[i >> 2] |= 0x80 << ((i % 4) * 8); + blks[nblk * 16 - 2] = str.length * 8; + return blks; +} + +/* + * Add integers, wrapping at 2^32. This uses 16-bit operations internally + * to work around bugs in some JS interpreters. + */ +function add(x, y) +{ + var lsw = (x & 0xFFFF) + (y & 0xFFFF); + var msw = (x >> 16) + (y >> 16) + (lsw >> 16); + return (msw << 16) | (lsw & 0xFFFF); +} + +/* + * Bitwise rotate a 32-bit number to the left + */ +function rol(num, cnt) +{ + return (num << cnt) | (num >>> (32 - cnt)); +} + +/* + * These functions implement the basic operation for each round of the + * algorithm. + */ +function cmn(q, a, b, x, s, t) +{ + return add(rol(add(add(a, q), add(x, t)), s), b); +} +function ff(a, b, c, d, x, s, t) +{ + return cmn((b & c) | ((~b) & d), a, b, x, s, t); +} +function gg(a, b, c, d, x, s, t) +{ + return cmn((b & d) | (c & (~d)), a, b, x, s, t); +} +function hh(a, b, c, d, x, s, t) +{ + return cmn(b ^ c ^ d, a, b, x, s, t); +} +function ii(a, b, c, d, x, s, t) +{ + return cmn(c ^ (b | (~d)), a, b, x, s, t); +} diff --git a/Global/navig.skin b/Global/navig.skin new file mode 100644 index 00000000..87cc3ae5 --- /dev/null +++ b/Global/navig.skin @@ -0,0 +1,17 @@ +

">" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;">

+ + +
+ <% root.appCount filter="active" singular=" app" plural=" apps"%> on <% root.hostname %> +
+ +<% root.appList filter="active" %> + +

+ +
+ and <% root.appCount filter="disabled" %> disabled apps: +
+ +<% root.appList filter="disabled" skin="navig_disabled" %> + diff --git a/Root/functions.js b/Root/functions.js new file mode 100644 index 00000000..55a0baea --- /dev/null +++ b/Root/functions.js @@ -0,0 +1,36 @@ + +/** + * lists all applications in appdir. + * for active apps use this.getApplications() = helma.main.Server.getApplications() + */ +function getAllApplications() { + var appsDir = this.getAppsHome(); + var dir = appsDir.list(); + var arr = new Array(); + for ( var i=0; i str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/'); + res.write ( arr[i].substring(pos+1) + ".jar" ); + if ( i < arr.length-1 ) res.write ( separator ); + } +} + + +/** + * Macro that returns the name and version of the server's os + */ +function os_macro() { + return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version"); +} + + +/** + * Macro that returns anything from server.properties + */ +function property_macro(par) { + if ( par && par.key ) { + return this.getProperty(key); + } else { + return ""; + } +} + + +/** + * Macro formatting server.properties + */ +function properties_macro(par) { + formatProperties(this.getProperties(),par); +} + + +/** + * Macro that returns the timezone of this server + */ +function timezone_macro(par) { + return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")"; +} + + diff --git a/Root/main.hac b/Root/main.hac new file mode 100644 index 00000000..5cb4d0e3 --- /dev/null +++ b/Root/main.hac @@ -0,0 +1,46 @@ + +/** + * main action, show server-stats + * perform start, stop, restart and flush-action + * + */ + + +if ( checkAddress()==false ) return; + +if ( req.data.app!=null && req.data.app!="" && req.data.action!=null && req.data.action!="" ) { + + var appObj = root.getApp(req.data.app); + // check access for application. md5-encoded uname/pwd can also be put in + // app.properties to limit access to a single app + if ( checkAuth(appObj)==false ) return; + + if ( req.data.action=="start" ) { + this.startApplication(req.data.app); + res.redirect ( appObj.href("main") ); + + } else if ( req.data.action=="stop" ) { + if ( checkAuth()==false ) return; + this.stopApplication(req.data.app); + res.redirect ( root.href("main") ); + + } else if ( req.data.action=="restart" ) { + this.stopApplication(req.data.app); + this.startApplication(req.data.app); + res.redirect ( appObj.href("main") ); + + } else if ( req.data.action=="flush" ) { + appObj.clearAppCache(); + res.redirect ( appObj.href("main") ); + + } + +} + +// output only to root +if ( checkAuth()==false ) return; + +res.skin = "global"; +res.title = "Helma Object Publisher - Serverinfo"; +res.body = this.renderSkinAsString("main"); + diff --git a/Root/main.skin b/Root/main.skin new file mode 100644 index 00000000..f3e7910b --- /dev/null +++ b/Root/main.skin @@ -0,0 +1,101 @@ +<% this.hostname %> (<% this.hostaddress %>)

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +<% this.properties prefix="" %> +
helma
uptime: <% this.uptime %>
version: <% this.version %>
homedir: <% this.home %>
total active sessions <% this.countSessions %>
total request 5-min-avg <% this.countRequests %>
jre
free memory: <% this.jvmFreeMemory %>
used memory: <% this.jvmUsedMemory %>
total memory: <% this.jvmTotalMemory %>
java: <% this.jvm %>
javahome: <% this.jvmHome %>
os: <% this.os %>
localtime: <% now %>
timezone: <% this.timezone %>
loaded Jars: <% this.jvmJars %>
server.properties
" separator=" " suffix="
+ + + + diff --git a/Root/makekey.hac b/Root/makekey.hac new file mode 100644 index 00000000..cadf28c0 --- /dev/null +++ b/Root/makekey.hac @@ -0,0 +1,10 @@ + +if ( checkAddress()==false ) return; +if ( checkAuth()==false ) return; + +if ( req.data.value!=null ) { + res.write ( calcMD5(req.data.value) ); +} else { + res.write ( '
' ); +} + diff --git a/app.properties b/app.properties new file mode 100644 index 00000000..544f3805 --- /dev/null +++ b/app.properties @@ -0,0 +1,5 @@ +# Set this property according to your +# server configuration: + +baseURI = /manage/ + diff --git a/class.properties b/class.properties new file mode 100644 index 00000000..181c3887 --- /dev/null +++ b/class.properties @@ -0,0 +1,11 @@ +# +# Map Java classes to the prototype used to script them +# + +helma.main.Server = root +helma.framework.core.Application = application +helma.doc.DocApplication = docapplication +helma.doc.DocPrototype = docprototype +helma.doc.DocFunction = docfunction +helma.doc.DocTag = doctag + From 69f391d2d67bdb1ae07ba6a9cfd9a41f7ae74d5b Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 11 Mar 2002 14:46:30 +0000 Subject: [PATCH 02/82] modified header in apidocs --- DocApplication/head.skin | 6 +++--- DocApplication/macros.js | 18 ++++++++++++++++++ DocApplication/main.skin | 2 +- DocFunction/macros.js | 21 +++++++++++++++++++++ DocFunction/main.skin | 7 +------ DocPrototype/macros.js | 22 ++++++++++++++++++++++ DocPrototype/main.skin | 3 +-- 7 files changed, 67 insertions(+), 12 deletions(-) diff --git a/DocApplication/head.skin b/DocApplication/head.skin index 1bd8e6a2..56c9c797 100644 --- a/DocApplication/head.skin +++ b/DocApplication/head.skin @@ -1,6 +1,6 @@ -

AppDoc <% this.name %> -
- -> +

AppDoc <% this.name %>

+

<% param.path %>

+

-> AppManager | ">public

diff --git a/DocApplication/macros.js b/DocApplication/macros.js index a18e1142..beb71311 100644 --- a/DocApplication/macros.js +++ b/DocApplication/macros.js @@ -18,6 +18,24 @@ function href_macro(par) { } +/** + * macro rendering page head + */ +function head_macro(par) { + var obj = new Object(); + obj.path = this.getPath(); + this.renderSkin("head",obj); +} + + +/** + * utility function for head_macro, rendering link to app + */ +function getPath() { + return( '' + this.name + '' ); +} + + /** * link to the "real" application object (ie not the DocApplication) */ diff --git a/DocApplication/main.skin b/DocApplication/main.skin index 2a8c5681..72cbefc0 100644 --- a/DocApplication/main.skin +++ b/DocApplication/main.skin @@ -1,4 +1,4 @@ -<% this.skin name="head" %> +<% this.head %> diff --git a/DocFunction/macros.js b/DocFunction/macros.js index 2f58e1ce..ced4f0e9 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -18,6 +18,27 @@ function href_macro(par) { } +/** + * macro rendering page head + */ +function head_macro(par) { + var obj = new Object(); + obj.path = this.getPath(); + var appObj = this.getApplication(); + appObj.renderSkin("head",obj); +} + + +/** + * utility function for head_macro, rendering link to app and to prototype + */ +function getPath() { + var protoObj = this.getDocPrototype(); + var str = protoObj.getPath() + "/" + this.getFullName(); + return( str ); +} + + /** * macro returning name of file this method resides in */ diff --git a/DocFunction/main.skin b/DocFunction/main.skin index 29a7bc8f..26420fb2 100644 --- a/DocFunction/main.skin +++ b/DocFunction/main.skin @@ -1,9 +1,4 @@ - - -

- ">Prototype <% docprototype.name %>
- <% this.fullname %> -

+<% this.head %>
in <% docprototype.name%>/<% this.location %>: diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index 3db36027..4334e1bf 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -18,6 +18,28 @@ function href_macro(par) { } +/** + * macro rendering page head + */ +function head_macro(par) { + var obj = new Object(); + obj.path = this.getPath(); + var appObj = this.getApplication(); + appObj.renderSkin("head",obj); +} + + +/** + * utility function for head_macro, rendering link to app and to prototype + */ +function getPath() { + var appObj = this.getApplication(); + var str = appObj.getPath(); + str += '/' + this.name + ''; + return( str ); +} + + /** * macro returning the comment for this prototype */ diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin index 71821440..20cc8ec5 100644 --- a/DocPrototype/main.skin +++ b/DocPrototype/main.skin @@ -1,5 +1,4 @@ - -

Prototype <% this.name %>

+<% this.head %> <% this.actions %> <% this.skins %> From 3c21f1a7d2418c4df8abfc765ab9232213d9eb69 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 11 Mar 2002 15:03:09 +0000 Subject: [PATCH 03/82] ouch --- Global/functions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index 62858d0b..e5f20291 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -101,8 +101,8 @@ function checkAuth(appObj) { if ( uname==null || uname=="" || pwd==null || pwd=="" ) return forceAuth(); - var md5password = calcMD5(uname); - var md5username = calcMD5(pwd); + var md5username = calcMD5(uname); + var md5password = calcMD5(pwd); if ( md5username==rootUsername && md5password==rootPassword ) return true; From b46c2f1f4f3705f3a7b18e089127ad7226490d94 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 19 Mar 2002 19:32:41 +0000 Subject: [PATCH 04/82] The duplicate clearAppCache() method in Application() isn't necessary anymore because a JavaScript prototype without all the HopObject crap is used for scripting Java objects now. Calling clearCache() will reach through to the Java method. --- Root/main.hac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Root/main.hac b/Root/main.hac index 5cb4d0e3..f2f4bd0c 100644 --- a/Root/main.hac +++ b/Root/main.hac @@ -30,7 +30,7 @@ if ( req.data.app!=null && req.data.app!="" && req.data.action!=null && req.data res.redirect ( appObj.href("main") ); } else if ( req.data.action=="flush" ) { - appObj.clearAppCache(); + appObj.clearCache(); res.redirect ( appObj.href("main") ); } From c8be51599bea68ae965700b238bb9349b70c541e Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 19 Mar 2002 19:33:49 +0000 Subject: [PATCH 05/82] Calling href() on Java objects does indeed work. The problem was that getParentElement() method in Application always returned null (due to a very hard to find bug in helma.main.Server). --- Application/functions.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/Application/functions.js b/Application/functions.js index 04cda7fa..e0e3ca18 100644 --- a/Application/functions.js +++ b/Application/functions.js @@ -8,19 +8,6 @@ function constructor(name) { } -/** - * overrides the internal href-function, as - * helma.framework.core.Application.getNodeHref(Object,String) - * isn't able to compute correct urls for non-node objects. - * @arg action of application - */ -function href(action) { - var url = getProperty("baseURI"); - url = (url==null || url=="null") ? "" : url; - url += this.name + "/" + ( (action!=null && action!="") ? action : "main" ); - return url; -} - /** * return true/false to determine if application is running From cc36746efb59b8f6bcb79a36c2f03d4a6e8c8f59 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 17:55:25 +0000 Subject: [PATCH 06/82] changed typo --- Application/main.skin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/main.skin b/Application/main.skin index 0b05f12d..2c9e3cf1 100644 --- a/Application/main.skin +++ b/Application/main.skin @@ -25,7 +25,7 @@
- + From 6374ce94fc5ac7c2f1ff11d050803807058aab85 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 17:56:26 +0000 Subject: [PATCH 07/82] improved addressFilter, switched to helma embedded md5-function --- Global/functions.js | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index e5f20291..4655a2d1 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -10,19 +10,39 @@ function scheduler() { /** - * initializes requestStat storage on startup + * initializes app.requestStat storage on startup, + * creates app.addressFilter */ function onStart() { app.requestStat = new HopObject(); - app.addressFilter = new Packages.helma.util.InetAddressFilter(); + app.addressFilter = createAddressFilter(); +} + +/** + * initializes addressFilter from app.properties, + * hostnames are converted, wildcards are only allowed in ip-addresses + * (so, no network-names, sorry) + */ +function createAddressFilter() { + var filter = new Packages.helma.util.InetAddressFilter(); var str = root.getProperty("allowadmin"); if ( str!=null && str!="" ) { var arr = str.split(","); for ( var i in arr ) { var str = new java.lang.String(arr[i]); - app.addressFilter.addAddress(str.trim()); + var result = tryEval("filter.addAddress(str.trim());"); + if ( result.error!=null ) { + var str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); + var result = tryEval("filter.addAddress(str);"); + } + if ( result.error==null ) { + app.__app__.logEvent( "allowed address for app manage: " + str ); + } } + } else { + app.__app__.logEvent("no addresses allowed for app manage, all access will be denied"); } + return filter; } @@ -92,8 +112,10 @@ function checkAuth(appObj) { var rootUsername = root.getProperty("adminusername"); var rootPassword = root.getProperty("adminpassword"); - if ( rootUsername==null || rootUsername=="" || rootPassword==null || rootPassword=="" ) + if ( rootUsername==null || rootUsername=="" || rootPassword==null || rootPassword=="" ) { + app.__app__.logEvent("adminUsername or adminPassword not set in server.properties!"); return forceStealth(); + } var uname = req.getUsername(); var pwd = req.getPassword(); @@ -101,8 +123,8 @@ function checkAuth(appObj) { if ( uname==null || uname=="" || pwd==null || pwd=="" ) return forceAuth(); - var md5username = calcMD5(uname); - var md5password = calcMD5(pwd); + var md5username = Packages.helma.util.MD5Encoder.encode(uname); + var md5password = Packages.helma.util.MD5Encoder.encode(pwd); if ( md5username==rootUsername && md5password==rootPassword ) return true; @@ -124,10 +146,12 @@ function checkAuth(appObj) { * check access to the base-app by ip-addresses */ function checkAddress() { - if ( !app.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) + if ( !app.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) { + app.__app__.logEvent("denied request from " + req.data.http_remotehost ); return forceStealth(); - else + } else { return true; + } } From eb6f593913994a07a4cbf5db4126542365050e2c Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 17:57:38 +0000 Subject: [PATCH 08/82] obsolete after switch to helma embedded md5-function --- Global/md5.js | 178 -------------------------------------------------- 1 file changed, 178 deletions(-) delete mode 100644 Global/md5.js diff --git a/Global/md5.js b/Global/md5.js deleted file mode 100644 index 3d31a709..00000000 --- a/Global/md5.js +++ /dev/null @@ -1,178 +0,0 @@ -/* - * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message - * Digest Algorithm, as defined in RFC 1321. - * Copyright (C) Paul Johnston 1999 - 2000. - * Updated by Greg Holt 2000 - 2001. - * See http://pajhome.org.uk/site/legal.html for details. - */ - - -/** - * Take a string and return the hex representation of its MD5. - * @arg string - */ -function calcMD5(str) -{ - x = str2blks_MD5(str); - a = 1732584193; - b = -271733879; - c = -1732584194; - d = 271733878; - - for(i = 0; i < x.length; i += 16) - { - olda = a; - oldb = b; - oldc = c; - oldd = d; - - a = ff(a, b, c, d, x[i+ 0], 7 , -680876936); - d = ff(d, a, b, c, x[i+ 1], 12, -389564586); - c = ff(c, d, a, b, x[i+ 2], 17, 606105819); - b = ff(b, c, d, a, x[i+ 3], 22, -1044525330); - a = ff(a, b, c, d, x[i+ 4], 7 , -176418897); - d = ff(d, a, b, c, x[i+ 5], 12, 1200080426); - c = ff(c, d, a, b, x[i+ 6], 17, -1473231341); - b = ff(b, c, d, a, x[i+ 7], 22, -45705983); - a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416); - d = ff(d, a, b, c, x[i+ 9], 12, -1958414417); - c = ff(c, d, a, b, x[i+10], 17, -42063); - b = ff(b, c, d, a, x[i+11], 22, -1990404162); - a = ff(a, b, c, d, x[i+12], 7 , 1804603682); - d = ff(d, a, b, c, x[i+13], 12, -40341101); - c = ff(c, d, a, b, x[i+14], 17, -1502002290); - b = ff(b, c, d, a, x[i+15], 22, 1236535329); - - a = gg(a, b, c, d, x[i+ 1], 5 , -165796510); - d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632); - c = gg(c, d, a, b, x[i+11], 14, 643717713); - b = gg(b, c, d, a, x[i+ 0], 20, -373897302); - a = gg(a, b, c, d, x[i+ 5], 5 , -701558691); - d = gg(d, a, b, c, x[i+10], 9 , 38016083); - c = gg(c, d, a, b, x[i+15], 14, -660478335); - b = gg(b, c, d, a, x[i+ 4], 20, -405537848); - a = gg(a, b, c, d, x[i+ 9], 5 , 568446438); - d = gg(d, a, b, c, x[i+14], 9 , -1019803690); - c = gg(c, d, a, b, x[i+ 3], 14, -187363961); - b = gg(b, c, d, a, x[i+ 8], 20, 1163531501); - a = gg(a, b, c, d, x[i+13], 5 , -1444681467); - d = gg(d, a, b, c, x[i+ 2], 9 , -51403784); - c = gg(c, d, a, b, x[i+ 7], 14, 1735328473); - b = gg(b, c, d, a, x[i+12], 20, -1926607734); - - a = hh(a, b, c, d, x[i+ 5], 4 , -378558); - d = hh(d, a, b, c, x[i+ 8], 11, -2022574463); - c = hh(c, d, a, b, x[i+11], 16, 1839030562); - b = hh(b, c, d, a, x[i+14], 23, -35309556); - a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060); - d = hh(d, a, b, c, x[i+ 4], 11, 1272893353); - c = hh(c, d, a, b, x[i+ 7], 16, -155497632); - b = hh(b, c, d, a, x[i+10], 23, -1094730640); - a = hh(a, b, c, d, x[i+13], 4 , 681279174); - d = hh(d, a, b, c, x[i+ 0], 11, -358537222); - c = hh(c, d, a, b, x[i+ 3], 16, -722521979); - b = hh(b, c, d, a, x[i+ 6], 23, 76029189); - a = hh(a, b, c, d, x[i+ 9], 4 , -640364487); - d = hh(d, a, b, c, x[i+12], 11, -421815835); - c = hh(c, d, a, b, x[i+15], 16, 530742520); - b = hh(b, c, d, a, x[i+ 2], 23, -995338651); - - a = ii(a, b, c, d, x[i+ 0], 6 , -198630844); - d = ii(d, a, b, c, x[i+ 7], 10, 1126891415); - c = ii(c, d, a, b, x[i+14], 15, -1416354905); - b = ii(b, c, d, a, x[i+ 5], 21, -57434055); - a = ii(a, b, c, d, x[i+12], 6 , 1700485571); - d = ii(d, a, b, c, x[i+ 3], 10, -1894986606); - c = ii(c, d, a, b, x[i+10], 15, -1051523); - b = ii(b, c, d, a, x[i+ 1], 21, -2054922799); - a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359); - d = ii(d, a, b, c, x[i+15], 10, -30611744); - c = ii(c, d, a, b, x[i+ 6], 15, -1560198380); - b = ii(b, c, d, a, x[i+13], 21, 1309151649); - a = ii(a, b, c, d, x[i+ 4], 6 , -145523070); - d = ii(d, a, b, c, x[i+11], 10, -1120210379); - c = ii(c, d, a, b, x[i+ 2], 15, 718787259); - b = ii(b, c, d, a, x[i+ 9], 21, -343485551); - - a = add(a, olda); - b = add(b, oldb); - c = add(c, oldc); - d = add(d, oldd); - } - return rhex(a) + rhex(b) + rhex(c) + rhex(d); -} - - - -/* - * Convert a 32-bit number to a hex string with ls-byte first - */ -var hex_chr = "0123456789abcdef"; -function rhex(num) -{ - str = ""; - for(j = 0; j <= 3; j++) - str += hex_chr.charAt((num >> (j * 8 + 4)) & 0x0F) + - hex_chr.charAt((num >> (j * 8)) & 0x0F); - return str; -} - -/* - * Convert a string to a sequence of 16-word blocks, stored as an array. - * Append padding bits and the length, as described in the MD5 standard. - */ -function str2blks_MD5(str) -{ - nblk = ((str.length + 8) >> 6) + 1; - blks = new Array(nblk * 16); - for(i = 0; i < nblk * 16; i++) blks[i] = 0; - for(i = 0; i < str.length; i++) - blks[i >> 2] |= str.charCodeAt(i) << ((i % 4) * 8); - blks[i >> 2] |= 0x80 << ((i % 4) * 8); - blks[nblk * 16 - 2] = str.length * 8; - return blks; -} - -/* - * Add integers, wrapping at 2^32. This uses 16-bit operations internally - * to work around bugs in some JS interpreters. - */ -function add(x, y) -{ - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); -} - -/* - * Bitwise rotate a 32-bit number to the left - */ -function rol(num, cnt) -{ - return (num << cnt) | (num >>> (32 - cnt)); -} - -/* - * These functions implement the basic operation for each round of the - * algorithm. - */ -function cmn(q, a, b, x, s, t) -{ - return add(rol(add(add(a, q), add(x, t)), s), b); -} -function ff(a, b, c, d, x, s, t) -{ - return cmn((b & c) | ((~b) & d), a, b, x, s, t); -} -function gg(a, b, c, d, x, s, t) -{ - return cmn((b & d) | (c & (~d)), a, b, x, s, t); -} -function hh(a, b, c, d, x, s, t) -{ - return cmn(b ^ c ^ d, a, b, x, s, t); -} -function ii(a, b, c, d, x, s, t) -{ - return cmn(c ^ (b | (~d)), a, b, x, s, t); -} From fd73f252a03d3a48a53c2b712121e241f2c17b18 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 17:58:19 +0000 Subject: [PATCH 09/82] bugfixed and improved calculation of 5-minute request count --- Root/macros.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Root/macros.js b/Root/macros.js index 535c81b7..3f5f3be5 100644 --- a/Root/macros.js +++ b/Root/macros.js @@ -26,7 +26,9 @@ function countSessions_macro(par) { var arr = this.getApplications(); var sum = 0; for ( var i=0; i Date: Mon, 25 Mar 2002 17:58:28 +0000 Subject: [PATCH 10/82] typo --- Root/main.skin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Root/main.skin b/Root/main.skin index f3e7910b..fcecd6ef 100644 --- a/Root/main.skin +++ b/Root/main.skin @@ -25,12 +25,12 @@ - + - + From 891b5056c8b2e7cef91c22cbf2261575989f1a4a Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 17:58:45 +0000 Subject: [PATCH 11/82] no message --- description.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 description.txt diff --git a/description.txt b/description.txt new file mode 100644 index 00000000..44be5f58 --- /dev/null +++ b/description.txt @@ -0,0 +1 @@ +Helma's server management console. Start applications, introspection etc. \ No newline at end of file From bf86d54c6733b60eb9393604cde4f3e84730f723 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 18:36:56 +0000 Subject: [PATCH 12/82] removed obsolete functions: calling href() on Java objects does indeed work. The problem was that getParentElement() method in Application always returned null (due to a very hard to find bug in helma.main.Server). --- DocApplication/functions.js | 14 -------------- DocFunction/functions.js | 13 ------------- DocPrototype/functions.js | 14 -------------- 3 files changed, 41 deletions(-) delete mode 100644 DocApplication/functions.js delete mode 100644 DocPrototype/functions.js diff --git a/DocApplication/functions.js b/DocApplication/functions.js deleted file mode 100644 index fbbd7872..00000000 --- a/DocApplication/functions.js +++ /dev/null @@ -1,14 +0,0 @@ -/** - * overrides the internal href-function, as - * helma.framework.core.Application.getNodeHref(Object,String) - * isn't able to compute correct urls for non-node objects. - * @arg action of application - */ -function href(action) { - var url = getProperty("baseURI"); - url = (url==null || url=="null") ? "" : url; - url += this.name + "/api/" + ( (action!=null && action!="") ? action : "main" ); - return url; -} - - diff --git a/DocFunction/functions.js b/DocFunction/functions.js index 4fac6021..c903ff5f 100644 --- a/DocFunction/functions.js +++ b/DocFunction/functions.js @@ -1,17 +1,4 @@ -/** - * overrides the internal href-function, as - * helma.framework.core.Application.getNodeHref(Object,String) - * isn't able to compute correct urls for non-node objects. - * @arg action of prototype - */ -function href(action) { - var url = getProperty("baseURI"); - url = (url==null || url=="null") ? "" : url; - url += this.getParentElement().getParentElement().getName() + "/api/" + this.getParentElement().getName() + "/" + this.getTypeName().toLowerCase()+"_"+this.name + "/" + ( (action!=null && action!="") ? action : "main" ); - return url; -} - function getApplication() { return this.getParentElement().getParentElement(); diff --git a/DocPrototype/functions.js b/DocPrototype/functions.js deleted file mode 100644 index 053c0541..00000000 --- a/DocPrototype/functions.js +++ /dev/null @@ -1,14 +0,0 @@ - -/** - * overrides the internal href-function, as - * helma.framework.core.Application.getNodeHref(Object,String) - * isn't able to compute correct urls for non-node objects. - * @arg action of prototype - */ -function href(action) { - var url = getProperty("baseURI"); - url = (url==null || url=="null") ? "" : url; - url += this.getParentElement().getName() + "/api/" + this.name + "/" + ( (action!=null && action!="") ? action : "main" ); - return url; -} - From 078769bb43f688a8f21fd9b2703f9adc582add35 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 18:37:19 +0000 Subject: [PATCH 13/82] no message --- readme.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 readme.txt diff --git a/readme.txt b/readme.txt new file mode 100644 index 00000000..4086841c --- /dev/null +++ b/readme.txt @@ -0,0 +1,27 @@ +To get the manage-application to work you must: + + - add it to the apps.properties file with the following line + + manage=self + + instead of just the application name. This is to let the + application manager know that the subject of the application + is the server itself. + + - use snapshot 200203xx or later. + + - add the following properties to server.properties: + + allowAdmin=[comma-separated list of hosts or ip-addresses that + are allowed to access this application, wildcards + are only allowed in addresses, not in hostnames] + adminUsername= + adminPassword= + + MD5-encoding can be done either on the shell: + java -classpath helma.jar helma.util.MD5Encode + + Or - once you've got the application up and running - on the web: + http:///manage/makekey + http:///base/makekey + From 7d607250b66923d31549fcf3f87dadff50e06bec Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 25 Mar 2002 18:50:29 +0000 Subject: [PATCH 14/82] added link to helma.org, aehm --- Global/navig.skin | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Global/navig.skin b/Global/navig.skin index 87cc3ae5..441b2e22 100644 --- a/Global/navig.skin +++ b/Global/navig.skin @@ -1,8 +1,13 @@ -

">" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;">

- + +

">" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;"> + helma.org + docs + mailinglist +

- <% root.appCount filter="active" singular=" app" plural=" apps"%> on <% root.hostname %> + <% root.appCount filter="active" singular=" app" plural=" apps"%> on + "><% root.hostname %>
<% root.appList filter="active" %> From fb264c63e59a140f69808a4cda02572c5a18c9a1 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 12:47:49 +0000 Subject: [PATCH 15/82] replaced javascript-md5-library with method in helma.util.MD5Encoder --- Root/makekey.hac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Root/makekey.hac b/Root/makekey.hac index cadf28c0..f032c96f 100644 --- a/Root/makekey.hac +++ b/Root/makekey.hac @@ -3,7 +3,7 @@ if ( checkAddress()==false ) return; if ( checkAuth()==false ) return; if ( req.data.value!=null ) { - res.write ( calcMD5(req.data.value) ); + res.write ( Packages.helma.util.MD5Encoder.encode(req.data.value) ); } else { res.write ( '
' ); } From 41fdae647f6d6caa2d026d2b51d0cd3ca1578366 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 16:04:45 +0000 Subject: [PATCH 16/82] added style-class formEl --- Global/head.skin | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Global/head.skin b/Global/head.skin index 4f5659c0..45680b8e 100644 --- a/Global/head.skin +++ b/Global/head.skin @@ -8,6 +8,12 @@ font-size: 10pt; } + .formEl { + border-color:#000000; + border-style:solid; + border-width:1px; + } + .list_apps { border-color:#ffffff; padding-top:5px; From 9e8d43a015b4f706c3f62fbba514e2be754ba180 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 16:07:48 +0000 Subject: [PATCH 17/82] html-form to set adminUsername and adminPassword --- Global/pwdform.skin | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Global/pwdform.skin diff --git a/Global/pwdform.skin b/Global/pwdform.skin new file mode 100644 index 00000000..0825e3ab --- /dev/null +++ b/Global/pwdform.skin @@ -0,0 +1,30 @@ + + +
<% this.countFreeEvaluators %>
5min-request-avg:requests / 5 min:   <% this.getRequestAvg %>
total active sessionstotal active sessions:   <% this.countSessions %>
total request 5-min-avgtotal requests / 5 min:   <% this.countRequests %>
+ + +
+ +Choose username and password for helma's manager:
+ +Please choose an username and password combination to access the +manage application of this server. They will be saved md5-encoded +to the server.properties file. Later you can change these settings +either manually by editing the server.properties file or through +this webinterface in manage/makekey + +<% param.msg %> +
+ (username)
+ (password)
+ (password retyped)

+
+
+ +Username and password are transmitted in an unsafe cleartext way. +Therefore you're strongly discouraged to use any given combination +that is normally protected through ssh. + +
+ + From 2a25fd3054d02648f05e8e3cb841fb22d60503fd Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 16:08:03 +0000 Subject: [PATCH 18/82] very basic skin --- Global/basic.skin | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Global/basic.skin diff --git a/Global/basic.skin b/Global/basic.skin new file mode 100644 index 00000000..8b300a8a --- /dev/null +++ b/Global/basic.skin @@ -0,0 +1,5 @@ + + +<% response.head %> +<% response.body %> + From ddd6149251d51f3ee973c232c09295256af31d7a Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 16:10:28 +0000 Subject: [PATCH 19/82] added createAuth() if no username/password are set and request comes from localhost checkAuth() now goes into createAuth() to let user enter uname/passwd combination. --- Global/functions.js | 57 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index 4655a2d1..348c1eb7 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -103,7 +103,7 @@ function sortProps(a,b) { * properties of base-app or the particular application. if username or password aren't set * go into stealth-mode and return a 404. if username|password are wrong, prepare response- * object for http-auth and return false. - * @arg application-object + * @arg appObj application object to check against (if adminUsername etc are set in app.properties) */ function checkAuth(appObj) { var ok = false; @@ -113,8 +113,7 @@ function checkAuth(appObj) { var rootPassword = root.getProperty("adminpassword"); if ( rootUsername==null || rootUsername=="" || rootPassword==null || rootPassword=="" ) { - app.__app__.logEvent("adminUsername or adminPassword not set in server.properties!"); - return forceStealth(); + return createAuth(); } var uname = req.getUsername(); @@ -157,11 +156,12 @@ function checkAddress() { /** * response is reset to 401 / authorization required + * @arg realm realm for http-auth */ -function forceAuth(appObj) { - res.status = 401; - res.realm = (appObj==null) ? "helma" : appObj.name; +function forceAuth(realm) { res.reset(); + res.status = 401; + res.realm = (realm!=null) ? realm : "helma"; res.write ("Authorization Required. The server could not verify that you are authorized to access the requested page."); return false; } @@ -176,4 +176,49 @@ function forceStealth() { } +/** + * response is either a html form to enter auth data or input from + * html form is saved to server.properties + * access is only allowed if remote host is in the list of friendly + * ip-adresses in server.properties + */ +function createAuth() { + if ( checkAddress()!=true ) { + // double check + return false; + } + var obj = new Object(); + obj.msg = ""; + + if ( req.data.username!=null && req.data.password!=null && req.data.password2!=null ) { + // we have input from webform + if ( req.data.username=="" ) + obj.msg += "username can't be left empty!
"; + if ( req.data.password=="" ) + obj.msg += "password can't be left empty!
"; + else if ( req.data.password!=req.data.password2 ) + obj.msg += "password and re-typed password don't match!
"; + if ( obj.msg!="" ) { + obj.username = req.data.username; + res.reset(); + renderSkin("pwdform",obj); + return false; + } + var props = root.getProperties(); + props.put("adminUsername", Packages.helma.util.MD5Encoder.encode(req.data.username) ); + props.put("adminPassword", Packages.helma.util.MD5Encoder.encode(req.data.password) ); + props.store( new java.io.FileOutputStream( new java.io.File(root.getHopHome(),"server.properties") ), "# properties saved from application 'manage'" ); + app.__app__.logEvent( req.data.http_remotehost + " saved new adminUsername/adminPassword to server.properties"); + res.redirect ( root.href("main") ); + + } else { + // no input from webform, so print it + res.reset(); + res.skin = "basic"; + res.title = "username & password on " + root.hostname_macro(); + res.head = renderSkinAsString("head"); + res.body = renderSkinAsString("pwdform",obj); + return false; + } +} From 660ea666d99a81fc405e4a39dd80317a307653bb Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 16:11:18 +0000 Subject: [PATCH 20/82] makekey now uses createAuth() and shows a nice form. --- Root/makekey.hac | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Root/makekey.hac b/Root/makekey.hac index f032c96f..1ba50f12 100644 --- a/Root/makekey.hac +++ b/Root/makekey.hac @@ -1,10 +1,11 @@ -if ( checkAddress()==false ) return; -if ( checkAuth()==false ) return; - -if ( req.data.value!=null ) { - res.write ( Packages.helma.util.MD5Encoder.encode(req.data.value) ); -} else { - res.write ( '
' ); +// strictly limit access to localhost: +if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) { + app.__app__.logEvent( req.data.http_remotehost + " tried to access makekey"); + return; } +if ( checkAuth()==false ) return; + +createAuth(); + From 0dbab772a68c6d287c7881e3347d436865af2a9c Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 19:00:03 +0000 Subject: [PATCH 21/82] saving of username and password now works through appending and not by saving the whole properties list. --- Global/functions.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index 348c1eb7..97d90318 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -204,10 +204,15 @@ function createAuth() { renderSkin("pwdform",obj); return false; } - var props = root.getProperties(); - props.put("adminUsername", Packages.helma.util.MD5Encoder.encode(req.data.username) ); - props.put("adminPassword", Packages.helma.util.MD5Encoder.encode(req.data.password) ); - props.store( new java.io.FileOutputStream( new java.io.File(root.getHopHome(),"server.properties") ), "# properties saved from application 'manage'" ); + var f = new File(root.getHopHome().toString, "server.properties"); + var str = f.readAll(); + var sep = java.lang.System.getProperty("line.separator"); + str += sep + "adminUsername=" + Packages.helma.util.MD5Encoder.encode(req.data.username) + sep; + str += "adminPassword=" + Packages.helma.util.MD5Encoder.encode(req.data.password) + sep; + f.remove(); + f.open(); + f.write(str); + f.close(); app.__app__.logEvent( req.data.http_remotehost + " saved new adminUsername/adminPassword to server.properties"); res.redirect ( root.href("main") ); From 8f6503ae6b6745df075d7ff6cbd0bf7c415fdc98 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 26 Mar 2002 19:00:25 +0000 Subject: [PATCH 22/82] changed instructions --- Global/pwdform.skin | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Global/pwdform.skin b/Global/pwdform.skin index 0825e3ab..641aaa2d 100644 --- a/Global/pwdform.skin +++ b/Global/pwdform.skin @@ -4,13 +4,16 @@ -Choose username and password for helma's manager:
+Username and password for helma's manager:
-Please choose an username and password combination to access the -manage application of this server. They will be saved md5-encoded -to the server.properties file. Later you can change these settings -either manually by editing the server.properties file or through -this webinterface in manage/makekey +

Please choose an username and password combination to access the +manage application of this server. They will be appended md5-encoded +to the server.properties file. You can change the settings manually +by editing the server.properties file or through this webinterface +in manage/makekey (from localhost only!).

+

This is a stupid script and doesn't check wheter these properties +are already set in this file. So if you've already set username and +password you need to delete the old values manually.

<% param.msg %>
@@ -20,9 +23,9 @@ this webinterface in manage/makekey
-Username and password are transmitted in an unsafe cleartext way. -Therefore you're strongly discouraged to use any given combination -that is normally protected through ssh. +

Warning: The used http-authorization transmits username and password +in an unsafe cleartext way. Therefore you're strongly discouraged to +use any given combination that is normally protected through SSH.

From a48d2fefc9d5f707f30c2b46053feb7cb0c4909c Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 8 Apr 2002 08:49:41 +0000 Subject: [PATCH 23/82] make app work again with new way of retrieving a custom root object (helma.main.Server, that is) --- class.properties | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/class.properties b/class.properties index 181c3887..57808b22 100644 --- a/class.properties +++ b/class.properties @@ -1,5 +1,20 @@ + +# +# define the root class of this application +# +root = helma.main.Server + +# +# root.factory is used to retrieve the root class of the application +# when the instance has already been created when the application comes up. +# this is true for the helma server that is scripted here. +# +root.factory.class = helma.main.Server +root.factory.method = getServer + # # Map Java classes to the prototype used to script them +# and, yes, map the root class again. # helma.main.Server = root From 0524f54a470c7ce56822c2c9026254ffeb69b47e Mon Sep 17 00:00:00 2001 From: stefanp Date: Thu, 18 Apr 2002 09:37:55 +0000 Subject: [PATCH 24/82] failure to catch an empty enumeration from javascript caused a bug when an application had no app.properties. workaround: check against new method SystemProperties.size(). --- Global/macros.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Global/macros.js b/Global/macros.js index 5f0b72c5..ace6eaae 100644 --- a/Global/macros.js +++ b/Global/macros.js @@ -25,10 +25,10 @@ function formatProperties(props,par) { var prefix = (par && par.prefix) ? par.prefix : ""; var suffix = (par && par.suffix) ? par.suffix : ""; var separator = (par && par.separator) ? par.separator : ""; + if ( props.size()==0 ) + return ""; var e = props.keys(); var arr = new Array(); - if ( e==null ) - return ""; while ( e.hasMoreElements() ) { arr[arr.length] = e.nextElement(); } From 52822f59e39860b68fe020c1f54afdcfca7688ff Mon Sep 17 00:00:00 2001 From: p3k Date: Tue, 23 Apr 2002 11:46:23 +0000 Subject: [PATCH 25/82] moved description from text file description.txt to property "description" in app.properties --- app.properties | 2 ++ description.txt | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) delete mode 100644 description.txt diff --git a/app.properties b/app.properties index 544f3805..d796f8d5 100644 --- a/app.properties +++ b/app.properties @@ -3,3 +3,5 @@ baseURI = /manage/ +# A short description of what this application is about: +description = Helma's server management console. Start applications, introspection etc. \ No newline at end of file diff --git a/description.txt b/description.txt deleted file mode 100644 index 44be5f58..00000000 --- a/description.txt +++ /dev/null @@ -1 +0,0 @@ -Helma's server management console. Start applications, introspection etc. \ No newline at end of file From 0e9738e95d764e9bbe66f835907ee670c3589528 Mon Sep 17 00:00:00 2001 From: stefanp Date: Wed, 24 Apr 2002 16:04:29 +0000 Subject: [PATCH 26/82] updated to fit the last changes --- readme.txt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/readme.txt b/readme.txt index 4086841c..74e2e6c3 100644 --- a/readme.txt +++ b/readme.txt @@ -1,14 +1,10 @@ To get the manage-application to work you must: - - add it to the apps.properties file with the following line + - add it to the apps.properties file with the following line: - manage=self + manage - instead of just the application name. This is to let the - application manager know that the subject of the application - is the server itself. - - - use snapshot 200203xx or later. + - use snapshot 20020326 or later. - add the following properties to server.properties: @@ -18,10 +14,12 @@ To get the manage-application to work you must: adminUsername= adminPassword= - MD5-encoding can be done either on the shell: - java -classpath helma.jar helma.util.MD5Encode + MD5-encoding can be done - once you've got the application + up and running - on the web: - Or - once you've got the application up and running - on the web: http:///manage/makekey http:///base/makekey + or you can use a shell-tool integrated in helma: + java -classpath helma.jar helma.util.MD5Encoder + From 32d2230ef5d5f7dc46c6cf5ce2b28e8da2c433c9 Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 31 May 2002 14:14:37 +0000 Subject: [PATCH 27/82] Updated code to new session/app/req/res object layout. --- Application/main.hac | 4 ++-- DocApplication/main.hac | 8 ++++---- DocFunction/main.hac | 6 +++--- DocPrototype/main.hac | 6 +++--- Global/functions.js | 41 +++++++++++++++++++++-------------------- Root/main.hac | 8 +++----- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Application/main.hac b/Application/main.hac index 40a43c35..016058d0 100644 --- a/Application/main.hac +++ b/Application/main.hac @@ -5,6 +5,6 @@ if ( checkAddress()==false ) return; if ( checkAuth(this)==false ) return; -res.skin="global"; -res.body = this.renderSkinAsString("main"); +res.data.body = this.renderSkinAsString("main"); +renderSkin ("global"); diff --git a/DocApplication/main.hac b/DocApplication/main.hac index cac9f238..f61fec7c 100644 --- a/DocApplication/main.hac +++ b/DocApplication/main.hac @@ -12,12 +12,12 @@ if ( req.data.action=="reload" ) { } if ( req.data.action=="index" ) { - res.body = this.renderSkinAsString("index"); + res.data.body = this.renderSkinAsString("index"); } else { - res.body = this.renderSkinAsString("main"); + res.data.body = this.renderSkinAsString("main"); } -res.skin = "api"; -res.title = "Application " + this.name; +res.data.title = "Application " + this.name; +renderSkin("api"); diff --git a/DocFunction/main.hac b/DocFunction/main.hac index ef413f29..6faae50d 100644 --- a/DocFunction/main.hac +++ b/DocFunction/main.hac @@ -1,8 +1,8 @@ if ( checkAddress()==false ) return; if ( checkAuth(this)==false ) return; -res.body = this.renderSkinAsString("main"); -res.skin = "api"; -res.title = "Application " + this.name; +res.data.body = this.renderSkinAsString("main"); +res.data.title = "Application " + this.name; +renderSkin("api"); diff --git a/DocPrototype/main.hac b/DocPrototype/main.hac index ef413f29..77ebcb02 100644 --- a/DocPrototype/main.hac +++ b/DocPrototype/main.hac @@ -1,8 +1,8 @@ if ( checkAddress()==false ) return; if ( checkAuth(this)==false ) return; -res.body = this.renderSkinAsString("main"); -res.skin = "api"; -res.title = "Application " + this.name; +res.data.body = this.renderSkinAsString("main"); +res.data.title = "Application " + this.name; +renderSkin ("api"); diff --git a/Global/functions.js b/Global/functions.js index 97d90318..14c917ad 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -3,19 +3,19 @@ /** * scheduler function, runs global.appStat every minute */ -function scheduler() { +function scheduler() { appStat(); return 60000; } /** - * initializes app.requestStat storage on startup, - * creates app.addressFilter + * initializes app.data.requestStat storage on startup, + * creates app.data.addressFilter */ -function onStart() { - app.requestStat = new HopObject(); - app.addressFilter = createAddressFilter(); +function onStart() { + app.data.requestStat = new HopObject(); + app.data.addressFilter = createAddressFilter(); } /** @@ -36,29 +36,29 @@ function createAddressFilter() { var result = tryEval("filter.addAddress(str);"); } if ( result.error==null ) { - app.__app__.logEvent( "allowed address for app manage: " + str ); + app.log( "allowed address for app manage: " + str ); } } } else { - app.__app__.logEvent("no addresses allowed for app manage, all access will be denied"); + app.log("no addresses allowed for app manage, all access will be denied"); } return filter; } /** - * updates the request stats in app.requestStat every 5 minutes + * updates the request stats in app.data.requestStat every 5 minutes */ function appStat() { - if ( app.requestStat==null ) { - app.requestStat = new HopObject(); + if ( app.data.requestStat==null ) { + app.data.requestStat = new HopObject(); } - if( (new Date()-300000) < app.requestStat.lastRun ) { + if( (new Date()-300000) < app.data.requestStat.lastRun ) { return; } var arr = root.getApplications(); for ( var i=0; i Date: Thu, 20 Jun 2002 17:20:38 +0000 Subject: [PATCH 28/82] made line numbers work again (bug due to xhtml-switch) --- DocFunction/macros.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DocFunction/macros.js b/DocFunction/macros.js index ced4f0e9..24b45320 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -109,9 +109,9 @@ function tags_macro() { function args_macro() { var ct = this.countTags(Packages.helma.doc.DocTag.ARG); for ( var i=0; i"); + var arr = str3.split("
"); var str4 = ""; for ( var i=0; i ' From 32663df930a7069b25f2803f5d0fa75606c604c9 Mon Sep 17 00:00:00 2001 From: stefanp Date: Thu, 20 Jun 2002 17:20:53 +0000 Subject: [PATCH 29/82] spacing-fix --- DocFunction/listElementFunction.skin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DocFunction/listElementFunction.skin b/DocFunction/listElementFunction.skin index b692f1ca..67686f30 100644 --- a/DocFunction/listElementFunction.skin +++ b/DocFunction/listElementFunction.skin @@ -2,6 +2,6 @@  <% param.group %>
- "><% this.name %>(<% this.args %>) in <% docprototype.name %>/<% this.location %>
<% this.comment %>
<% this.tags %>
+ "><% this.name %> (<% this.args %>)
in <% docprototype.name %>/<% this.location %>
<% this.comment %>
<% this.tags %>
From 2daf832db0224e85180a7fac4ea656d9d1d5823b Mon Sep 17 00:00:00 2001 From: stefanp Date: Thu, 20 Jun 2002 17:21:21 +0000 Subject: [PATCH 30/82] made the "create username/password"-part work with the newer snapshots. --- Global/functions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index 14c917ad..04d5ce1a 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -219,10 +219,10 @@ function createAuth() { } else { // no input from webform, so print it res.reset(); - res.skin = "basic"; - res.title = "username & password on " + root.hostname_macro(); - res.head = renderSkinAsString("head"); - res.body = renderSkinAsString("pwdform",obj); + res.data.title = "username & password on " + root.hostname_macro(); + res.data.head = renderSkinAsString("head"); + res.data.body = renderSkinAsString("pwdform",obj); + renderSkin("basic"); return false; } } From 601f2d688504fe3e4059fc52089599e5486c7bcf Mon Sep 17 00:00:00 2001 From: p3k Date: Tue, 25 Jun 2002 14:03:05 +0000 Subject: [PATCH 31/82] added valign="top" to tags in macro call for this.properties --- Application/main.skin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/main.skin b/Application/main.skin index 2c9e3cf1..630e6e8c 100644 --- a/Application/main.skin +++ b/Application/main.skin @@ -37,6 +37,6 @@ app.properties -<% this.properties prefix="" separator=" " suffix="" %> +<% this.properties prefix="" separator=" " suffix="" %> From c3b41519bfa5150afee1e77758b43824ea8c5539 Mon Sep 17 00:00:00 2001 From: p3k Date: Tue, 25 Jun 2002 14:04:29 +0000 Subject: [PATCH 32/82] moved format functions from macros.js to functions.js (where they belong to, imho) --- Global/functions.js | 74 ++++++++++++++++++++++++++++++++++++++++++ Global/macros.js | 79 --------------------------------------------- 2 files changed, 74 insertions(+), 79 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index 04d5ce1a..dc4939f9 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -228,3 +228,77 @@ function createAuth() { } +/** + * macro-utility: formatting property lists + */ +function formatProperties(props,par) { + var prefix = (par && par.prefix) ? par.prefix : ""; + var suffix = (par && par.suffix) ? par.suffix : ""; + var separator = (par && par.separator) ? par.separator : ""; + if ( props.size()==0 ) + return ""; + var e = props.keys(); + var arr = new Array(); + while ( e.hasMoreElements() ) { + arr[arr.length] = e.nextElement(); + } + arr.sort(sortProps); + for ( var i in arr ) { + // don't print the admin-password + if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue; + res.write ( prefix + arr[i] + separator + props.getProperty(arr[i]) + suffix ); + } +} + + +/** + * macro-utility: formatting an integer value as human readable bytes + */ +function formatBytes(bytes) { + if ( bytes > Math.pow(2,30) ) { + res.write( Math.round( 100*bytes/Math.pow(2,30) ) / 100 + "gb" ); + } else if ( bytes > Math.pow(2,20) ) { + res.write( Math.round( 100*bytes/Math.pow(2,20) ) / 100 + "mb" ); + } else { + res.write( Math.round( 100*bytes/Math.pow(2,10) ) / 100 + "kb" ); + } +} + + +/** + * macro-utility: formatting time in millis as human readable age + */ +function formatAge(age) { + var str = ""; + var days = Math.floor(age/86400); + var age = age - days * 86400; + var hours = Math.floor(age / 3600); + var age = age - hours * 3600; + var minutes = Math.floor(age / 60); + var seconds = Math.floor(age - minutes * 60); + if (days > 0) + str += (days + " days, "); + if (hours>0) + str += (hours + "h, "); + str += (minutes + "min"); + if (days == 0) str += (", " + seconds + "sec"); + return(str); +} + + +/** + * macro-utility: formatting a number-suffix by choosing between singular and plural + * @arg value number to be formatted + * @arg param-object object to get fields + * @param singular string used for value==1 + * @param plural string used for value!=1 + */ +function formatCount(ct, par) { + if ( !par || !par.singular || !par.plural ) { + return ""; + } + if ( ct==1 ) + return par.singular; + else + return par.plural; +} diff --git a/Global/macros.js b/Global/macros.js index ace6eaae..13408e7a 100644 --- a/Global/macros.js +++ b/Global/macros.js @@ -16,82 +16,3 @@ function now_macro() { var date = new Date(); return(date.format("dd.MM.yyyy, HH:mm'h' zzz")); } - - -/** - * macro-utility: formatting property lists - */ -function formatProperties(props,par) { - var prefix = (par && par.prefix) ? par.prefix : ""; - var suffix = (par && par.suffix) ? par.suffix : ""; - var separator = (par && par.separator) ? par.separator : ""; - if ( props.size()==0 ) - return ""; - var e = props.keys(); - var arr = new Array(); - while ( e.hasMoreElements() ) { - arr[arr.length] = e.nextElement(); - } - arr.sort(sortProps); - for ( var i in arr ) { - // don't print the admin-password - if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue; - res.write ( prefix + arr[i] + separator + props.getProperty(arr[i]) + suffix ); - } -} - - -/** - * macro-utility: formatting an integer value as human readable bytes - */ -function formatBytes(bytes) { - if ( bytes > Math.pow(2,30) ) { - res.write( Math.round( 100*bytes/Math.pow(2,30) ) / 100 + "gb" ); - } else if ( bytes > Math.pow(2,20) ) { - res.write( Math.round( 100*bytes/Math.pow(2,20) ) / 100 + "mb" ); - } else { - res.write( Math.round( 100*bytes/Math.pow(2,10) ) / 100 + "kb" ); - } -} - - -/** - * macro-utility: formatting time in millis as human readable age - */ -function formatAge(age) { - var str = ""; - var days = Math.floor(age/86400); - var age = age - days * 86400; - var hours = Math.floor(age / 3600); - var age = age - hours * 3600; - var minutes = Math.floor(age / 60); - var seconds = Math.floor(age - minutes * 60); - if (days > 0) - str += (days + " days, "); - if (hours>0) - str += (hours + "h, "); - str += (minutes + "min"); - if (days == 0) str += (", " + seconds + "sec"); - return(str); -} - - -/** - * macro-utility: formatting a number-suffix by choosing between singular and plural - * @arg value number to be formatted - * @arg param-object object to get fields - * @param singular string used for value==1 - * @param plural string used for value!=1 - */ -function formatCount(ct, par) { - if ( !par || !par.singular || !par.plural ) { - return ""; - } - if ( ct==1 ) - return par.singular; - else - return par.plural; -} - - - From 2b491ebe3937c69e64a501d6bbf2c577a1493f53 Mon Sep 17 00:00:00 2001 From: p3k Date: Thu, 11 Jul 2002 15:35:15 +0000 Subject: [PATCH 33/82] renamed app property "description" to "_description" to indicate internal status --- app.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.properties b/app.properties index d796f8d5..41d1e161 100644 --- a/app.properties +++ b/app.properties @@ -4,4 +4,4 @@ baseURI = /manage/ # A short description of what this application is about: -description = Helma's server management console. Start applications, introspection etc. \ No newline at end of file +_description = Helma's server management console. Start applications, introspection etc. \ No newline at end of file From 1b3d6adc796bcf956a6e3c088c4f5fe5e7e8ee64 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 16 Jul 2002 14:45:34 +0000 Subject: [PATCH 34/82] Show message when client IP address is not allowed instead of going stealth mode. --- Global/functions.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index dc4939f9..94acd536 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -142,12 +142,15 @@ function checkAuth(appObj) { /** - * check access to the base-app by ip-addresses + * check access to the manage-app by ip-addresses */ function checkAddress() { if ( !app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) { app.log("denied request from " + req.data.http_remotehost ); - return forceStealth(); + // forceStealth seems a bit like overkill here. + // display a message that the ip address must be added to server.properties + res.write ("Access to address "+req.data.http_remotehost+" denied."); + return false; } else { return true; } From ad6e93aa3830475d8907c817aefcc9e8bd60c219 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 16 Jul 2002 15:06:01 +0000 Subject: [PATCH 35/82] Do not set baseUri, since this is not necessary with the embedded web server anymore. --- app.properties | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.properties b/app.properties index 41d1e161..e8473eaa 100644 --- a/app.properties +++ b/app.properties @@ -1,7 +1,6 @@ # Set this property according to your # server configuration: - -baseURI = /manage/ +# baseURI = /manage/ # A short description of what this application is about: -_description = Helma's server management console. Start applications, introspection etc. \ No newline at end of file +_description = Helma's server management console. Start applications, introspection etc. From 38ec696cf2dbcadad0aa50d6e28604081df45501 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 23 Sep 2002 12:21:47 +0000 Subject: [PATCH 36/82] temporary fix to have a working list of apps --- Root/macros.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Root/macros.js b/Root/macros.js index 3f5f3be5..fa4e77c9 100644 --- a/Root/macros.js +++ b/Root/macros.js @@ -113,7 +113,7 @@ function appList_macro(par) { } else { var apps = root.getAllApplications(); } - apps = apps.sort(sortByName); +// apps = apps.sort(sortByName); var html = ""; var param = new Object(); for (var n in apps) { From d3837363e96fef497846bc14a61d90f182cb6a12 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 23 Sep 2002 12:22:13 +0000 Subject: [PATCH 37/82] added blank onRequest() --- Application/functions.js | 7 +++++++ Root/functions.js | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Application/functions.js b/Application/functions.js index e0e3ca18..63d7278f 100644 --- a/Application/functions.js +++ b/Application/functions.js @@ -1,3 +1,4 @@ + /** * construct an application object so that we can use * skins for non-active applications too @@ -8,6 +9,12 @@ function constructor(name) { } +/** + * of no use, just to avoid error message + */ +function onRequest () { +} + /** * return true/false to determine if application is running diff --git a/Root/functions.js b/Root/functions.js index 55a0baea..342e79ea 100644 --- a/Root/functions.js +++ b/Root/functions.js @@ -1,4 +1,10 @@ +/** + * of no use, just to avoid error message + */ +function onRequest () { +} + /** * lists all applications in appdir. * for active apps use this.getApplications() = helma.main.Server.getApplications() From 5e1913d98b48f389f8642e610b4a333e3ba149dd Mon Sep 17 00:00:00 2001 From: p3k Date: Tue, 24 Sep 2002 08:56:04 +0000 Subject: [PATCH 38/82] sort works again, uncommented line 116 --- Root/macros.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Root/macros.js b/Root/macros.js index fa4e77c9..3f5f3be5 100644 --- a/Root/macros.js +++ b/Root/macros.js @@ -113,7 +113,7 @@ function appList_macro(par) { } else { var apps = root.getAllApplications(); } -// apps = apps.sort(sortByName); + apps = apps.sort(sortByName); var html = ""; var param = new Object(); for (var n in apps) { From 0e1ea8b8c0d9abd999fd348b70cf0d7be056cd76 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 24 Sep 2002 09:04:19 +0000 Subject: [PATCH 39/82] show loaded extensions --- Root/macros.js | 12 +++++++++++- Root/main.skin | 9 +++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Root/macros.js b/Root/macros.js index 3f5f3be5..8108ec3f 100644 --- a/Root/macros.js +++ b/Root/macros.js @@ -56,7 +56,17 @@ function countRequests_macro(par) { } - +function extensions_macro (par) { + var vec = this.getExtensions (); + var str = ""; + for (var i=0; i total active sessions:   - <% this.countSessions %> + <% this.countSessions default=" " %> total requests / 5 min:   - <% this.countRequests %> + <% this.countRequests default=" " %> + + + loaded extensions: +   + <% this.extensions default=" " %> From 1d1da15b10339be93f3a007931c7e291934600e9 Mon Sep 17 00:00:00 2001 From: p3k Date: Fri, 4 Oct 2002 15:43:37 +0000 Subject: [PATCH 40/82] made some decent rearrangements --- app.properties | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app.properties b/app.properties index e8473eaa..267d3c92 100644 --- a/app.properties +++ b/app.properties @@ -1,6 +1,5 @@ -# Set this property according to your -# server configuration: -# baseURI = /manage/ +# Set baseURI for application generated URLs, if necessary. +#baseURI = /manage # A short description of what this application is about: _description = Helma's server management console. Start applications, introspection etc. From 76bbe4053b6482524384e2a384f94c388f8b482b Mon Sep 17 00:00:00 2001 From: p3k Date: Sat, 26 Oct 2002 11:07:50 +0000 Subject: [PATCH 41/82] replaced "prefix" and "suffix" parameters in global formatProperties() function and corresponding skins by "itemprefix" and "itemsuffix" due to incorrect HTML output. --- Application/main.skin | 2 +- Global/functions.js | 5 +---- Root/main.skin | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Application/main.skin b/Application/main.skin index 630e6e8c..4bc3e011 100644 --- a/Application/main.skin +++ b/Application/main.skin @@ -37,6 +37,6 @@ app.properties -<% this.properties prefix="" separator=" " suffix="" %> +<% this.properties itemprefix='' separator=' ' itemsuffix='' % --> diff --git a/Global/functions.js b/Global/functions.js index 94acd536..578ef6eb 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -235,9 +235,6 @@ function createAuth() { * macro-utility: formatting property lists */ function formatProperties(props,par) { - var prefix = (par && par.prefix) ? par.prefix : ""; - var suffix = (par && par.suffix) ? par.suffix : ""; - var separator = (par && par.separator) ? par.separator : ""; if ( props.size()==0 ) return ""; var e = props.keys(); @@ -249,7 +246,7 @@ function formatProperties(props,par) { for ( var i in arr ) { // don't print the admin-password if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue; - res.write ( prefix + arr[i] + separator + props.getProperty(arr[i]) + suffix ); + res.write ( par.itemprefix + arr[i] + par.separator + props.getProperty(arr[i]) + par.itemsuffix ); } } diff --git a/Root/main.skin b/Root/main.skin index 306c6761..fd84cdc4 100644 --- a/Root/main.skin +++ b/Root/main.skin @@ -98,7 +98,7 @@ server.properties -<% this.properties prefix="" separator=" " suffix="" %> +<% this.properties itemprefix='' separator=' ' itemsuffix='' %> From 7633e98eea2834e1e4bd330cddd5301902d5a4ae Mon Sep 17 00:00:00 2001 From: stefanp Date: Thu, 21 Nov 2002 18:36:03 +0000 Subject: [PATCH 42/82] major overhaul of the manage app's api-documentation functions. things can now be rendered to static html, new helma features are supported (prototype extension), everyhting is done in a nice and clean way with skins. --- Application/macros.js | 54 ++++++-- Application/main.hac | 6 +- Application/main.skin | 40 ++++-- Application/mrtg.hac | 37 ++++-- Application/navig_active.skin | 5 +- DocApplication/actions.js | 95 ++++++++++++++ DocApplication/frameset.skin | 31 +++++ DocApplication/head.skin | 8 -- DocApplication/index.skin | 11 -- DocApplication/macros.js | 100 +++++++-------- DocApplication/main.hac | 23 ---- DocApplication/main.skin | 11 -- DocApplication/navig.skin | 14 --- DocApplication/prototypes.skin | 10 ++ DocApplication/summary.skin | 4 + DocFunction/actions.js | 8 ++ DocFunction/asLargeListItem.skin | 7 ++ DocFunction/asLargeListItemSkin.skin | 8 ++ DocFunction/asListItem.skin | 2 + DocFunction/asParentListItem.skin | 1 + DocFunction/functions.js | 7 -- DocFunction/indexList.skin | 5 - DocFunction/indexListSeparator.skin | 3 - DocFunction/listElementAction.skin | 7 -- DocFunction/listElementFunction.skin | 7 -- DocFunction/listElementMacro.skin | 9 -- DocFunction/listElementSkin.skin | 7 -- DocFunction/listElementTemplate.skin | 7 -- DocFunction/macros.js | 156 +++++++++-------------- DocFunction/main.hac | 8 -- DocFunction/main.skin | 35 +++++- DocPrototype/actions.js | 10 ++ DocPrototype/appList.skin | 10 -- DocPrototype/asInheritanceLink.skin | 1 + DocPrototype/asParentList.skin | 17 +++ DocPrototype/asPrototypeList.skin | 10 ++ DocPrototype/functions.js | 29 +++++ DocPrototype/list.skin | 11 ++ DocPrototype/listFooter.skin | 3 - DocPrototype/listHeader.skin | 7 -- DocPrototype/macros.js | 177 ++++++++++++++------------- DocPrototype/main.hac | 8 -- DocPrototype/main.skin | 86 ++++++++++++- DocPrototype/navig.skin | 2 - DocTag/author.skin | 2 + DocTag/deprecated.skin | 2 + DocTag/main.skin | 1 + DocTag/overrides.skin | 3 + DocTag/parameter.skin | 2 + DocTag/renderfunctions.js | 46 ------- DocTag/return.skin | 2 + DocTag/see.skin | 2 + Global/api.skin | 72 +++++++++-- Global/functions.js | 68 +++++----- Global/renderFunctions.js | 176 ++++++++++++++++++++++++++ Root/macros.js | 62 +++++++--- Root/main.skin | 45 ++++--- Root/makekey.hac | 13 +- Root/mrtg.hac | 37 ++++++ 59 files changed, 1052 insertions(+), 578 deletions(-) create mode 100644 DocApplication/actions.js create mode 100644 DocApplication/frameset.skin delete mode 100644 DocApplication/head.skin delete mode 100644 DocApplication/index.skin delete mode 100644 DocApplication/main.hac delete mode 100644 DocApplication/main.skin delete mode 100644 DocApplication/navig.skin create mode 100644 DocApplication/prototypes.skin create mode 100644 DocApplication/summary.skin create mode 100644 DocFunction/actions.js create mode 100644 DocFunction/asLargeListItem.skin create mode 100644 DocFunction/asLargeListItemSkin.skin create mode 100644 DocFunction/asListItem.skin create mode 100644 DocFunction/asParentListItem.skin delete mode 100644 DocFunction/functions.js delete mode 100644 DocFunction/indexList.skin delete mode 100644 DocFunction/indexListSeparator.skin delete mode 100644 DocFunction/listElementAction.skin delete mode 100644 DocFunction/listElementFunction.skin delete mode 100644 DocFunction/listElementMacro.skin delete mode 100644 DocFunction/listElementSkin.skin delete mode 100644 DocFunction/listElementTemplate.skin delete mode 100644 DocFunction/main.hac create mode 100644 DocPrototype/actions.js delete mode 100644 DocPrototype/appList.skin create mode 100644 DocPrototype/asInheritanceLink.skin create mode 100644 DocPrototype/asParentList.skin create mode 100644 DocPrototype/asPrototypeList.skin create mode 100644 DocPrototype/functions.js create mode 100644 DocPrototype/list.skin delete mode 100644 DocPrototype/listFooter.skin delete mode 100644 DocPrototype/listHeader.skin delete mode 100644 DocPrototype/main.hac delete mode 100644 DocPrototype/navig.skin create mode 100644 DocTag/author.skin create mode 100644 DocTag/deprecated.skin create mode 100644 DocTag/main.skin create mode 100644 DocTag/overrides.skin create mode 100644 DocTag/parameter.skin delete mode 100644 DocTag/renderfunctions.js create mode 100644 DocTag/return.skin create mode 100644 DocTag/see.skin create mode 100644 Global/renderFunctions.js create mode 100644 Root/mrtg.hac diff --git a/Application/macros.js b/Application/macros.js index 9eec3fe5..219a2a86 100644 --- a/Application/macros.js +++ b/Application/macros.js @@ -149,20 +149,53 @@ function countFreeEvaluators_macro() { /** - * Macro formatting the 5min average of requests. + * Macro returning the current number of objects in the cache */ -function getRequestAvg_macro(par) { - if ( app.requestStat==null || app.requestStat.get(this.name)==null ) - return 0; - if ( this.isActive() ) { - var obj = app.requestStat.get(this.name); - return obj.last5Min + formatCount(obj.last5Min,par); +function cacheusage_macro (param) { + return this.getCacheUsage (); +} + + +/** + * Macro returning the number of objects allowed in the cache + */ +function cachesize_macro (param) { + return this.getProperty ("cachesize", "1000"); +} + + +/** + * Macro formatting the number of requests in the last 5 minutes + */ +function requestCount_macro(par) { + if (app.data.stat==null || app.data.stat.get (this.name)==null) + return "not available"; + if (this.isActive()) { + var obj = app.data.stat.get (this.name); + return obj.requestCount + formatCount (obj.requestCount, par); } else { - return 0 + formatCount(0,par); + return 0 + formatCount (0,par); } } +/** + * Macro formatting the number of errors in the last 5 minutes + */ +function errorCount_macro(par) { + if (app.data.stat==null || app.data.stat.get (this.name)==null) + return "not available"; + if (this.isActive()) { + var obj = app.data.stat.get (this.name); + return obj.errorCount + formatCount (obj.errorCount, par); + } else { + return 0 + formatCount (0,par); + } +} + + + + /** * Macro formatting app.properties */ @@ -170,3 +203,8 @@ function properties_macro(par) { formatProperties( this.getProperties(), par ); } + +function appdir_macro (param) { + return this.getAppDir ().toString (); +} + diff --git a/Application/main.hac b/Application/main.hac index 016058d0..7faa81af 100644 --- a/Application/main.hac +++ b/Application/main.hac @@ -2,8 +2,10 @@ * renders AppManager */ -if ( checkAddress()==false ) return; -if ( checkAuth(this)==false ) return; +if (checkAddress()==false) + return; +if (checkAuth(this)==false) + return; res.data.body = this.renderSkinAsString("main"); renderSkin ("global"); diff --git a/Application/main.skin b/Application/main.skin index 4bc3e011..c689c6a9 100644 --- a/Application/main.skin +++ b/Application/main.skin @@ -1,42 +1,62 @@ <% this.skin name="head" %> - +
application
+ + - + - + - + - + - + - + - + + + + + + + + + + + - + + + -<% this.properties itemprefix='' % --> +
active sessions:active sessions   <% this.countSessions %>
?showusers=true">logged-in users:?showusers=true">logged-in users   <% this.users %> 
active evaluators:active evaluators   <% this.countActiveEvaluators %>
free evaluators:free evaluators   <% this.countFreeEvaluators %>
requests / 5 min:requests / 5 min  <% this.getRequestAvg %><% this.requestCount %>
uptime:errors / 5 min <% this.errorCount %>
cache usage <% this.cacheusage %> objects of <% this.cachesize %>
uptime   <% this.uptime %>
app.propertiesapp directory <% this.appdir %>
' separator=' ' itemsuffix='
+ + + + + +<% this.properties itemprefix='' %>
app.properties
' separator=' ' itemsuffix='
diff --git a/Application/mrtg.hac b/Application/mrtg.hac index fb324794..b6129f21 100644 --- a/Application/mrtg.hac +++ b/Application/mrtg.hac @@ -1,23 +1,42 @@ + /** * prints session- and thread-stats for mrtg-tool * doesn't check username or password, so that we don't have - * to write them cleartext in a mrtg-configfile + * to write them cleartext in a mrtg-configfile but checks the + * remote address. */ -if ( checkAddress()==false ) return; +if ( checkAddress()==false ) + return; if ( this.isActive()==false ) { res.write ( "0\n0\n0\n0\n"); return; } -if ( req.data.action=="sessions" ) { - res.write ( this.sessions.size() + "\n0\n0\n0\n" ); - return; -} +if (req.data.action=="sessions") { -if ( req.data.action=="threads" ) { - res.write ( this.countActiveEvaluators() + "\n" + this.countFreeEvaluators() + "\n0\n0\n"); - return; + res.write (this.sessions.size()); + res.write ("\n0\n0\n0\n"); + +} else if (req.data.action=="threads") { + + res.write (this.countActiveEvaluators () + "\n"); + res.write (this.countEvaluators () + "\n"); + res.write ("0\n0\n"); + +} else if (req.data.action=="cache") { + + res.write (this.getCacheUsage () + "\n"); + res.write (this.getProperty ("cachesize", "1000") + "\n"); + res.write ("0\n0\n"); + +} else if (req.data.action=="requests") { + +// res.write ( + +} else { + res.write ( "0\n0\n0\n0\n"); } + diff --git a/Application/navig_active.skin b/Application/navig_active.skin index afd05311..9bb568a8 100644 --- a/Application/navig_active.skin +++ b/Application/navig_active.skin @@ -2,14 +2,15 @@ "><% this.title %>
<% this.countSessions singular=" Session" plural=" Sessions" %>, <% this.getRequestAvg singular=" Request" plural=" Requests" %>/5min
- +
diff --git a/DocApplication/actions.js b/DocApplication/actions.js new file mode 100644 index 00000000..cbc1d907 --- /dev/null +++ b/DocApplication/actions.js @@ -0,0 +1,95 @@ +function main_action () { + this.renderSkin ("frameset"); +} + + +function prototypes_action () { + res.data.body = this.renderSkinAsString ("prototypes"); + renderSkin ("api"); +} + + +function summary_action () { + res.data.body = this.renderSkinAsString ("summary"); + renderSkin ("api"); +} + + + +function render_action () { + res.write ("renderrendering ... " + new Date () ); + var prefix = this.href (""); + this.storePage (this, "main"); + this.storePage (this, "prototypes"); + this.storePage (this, "summary"); + var arr = this.listChildren (); + for (var i=0; i + + helma api / <% this.name %> + + + + + +" name="prototypes"> +" name="functions"> + +" name="main"> + + +<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. + + + + diff --git a/DocApplication/head.skin b/DocApplication/head.skin deleted file mode 100644 index 56c9c797..00000000 --- a/DocApplication/head.skin +++ /dev/null @@ -1,8 +0,0 @@ -

AppDoc <% this.name %>

-

<% param.path %>

-

-> - AppManager | - ">public -

- - diff --git a/DocApplication/index.skin b/DocApplication/index.skin deleted file mode 100644 index 51fc7746..00000000 --- a/DocApplication/index.skin +++ /dev/null @@ -1,11 +0,0 @@ - -

AppDoc <% this.name %>

- - - - -<% this.index skin="indexList" %> -
- -
- diff --git a/DocApplication/macros.js b/DocApplication/macros.js index beb71311..d14126df 100644 --- a/DocApplication/macros.js +++ b/DocApplication/macros.js @@ -1,3 +1,4 @@ + /** * macro rendering a skin * @param name name of skin @@ -8,43 +9,33 @@ function skin_macro(par) { } } - /** * macro-wrapper for href-function * @param action name of action to call on this prototype, default main */ -function href_macro(par) { - return this.href( (par&&par.action)?par.action:"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 headline_macro (param) { + res.write (this.getName ()); } -/** - * macro rendering page head - */ -function head_macro(par) { - var obj = new Object(); - obj.path = this.getPath(); - this.renderSkin("head",obj); -} - -/** - * utility function for head_macro, rendering link to app - */ -function getPath() { - return( '' + this.name + '' ); -} - - -/** - * link to the "real" application object (ie not the DocApplication) - */ -function parentlink_macro(par) { - var url = getProperty("baseURI"); - url = (url==null || url=="null") ? "" : url; - url += this.name + "/"; - url += (par&&par.action)?par.action:"main"; - return url; +function hrefRoot_macro (param) { + var obj = this.getChildElement ("prototype_root"); + if (obj!=null) { + var action = (param.action) ? param.action : "main"; + return obj.href (action); + } } @@ -53,40 +44,33 @@ function parentlink_macro(par) { * @param skin name of skin to render on prototype */ function prototypes_macro(par) { - var skin = (par && par.skin&&par.skin!="")?par.skin:"appList"; - var arr = this.listPrototypes(); + var skin = (par && par.skin&&par.skin!="") ? par.skin : "asPrototypeList"; + var arr = this.listChildren (); for ( var i=0; i - - - - - - <% this.prototypes skin="appList" %> -
Prototypes
- -
- diff --git a/DocApplication/navig.skin b/DocApplication/navig.skin deleted file mode 100644 index f639e52a..00000000 --- a/DocApplication/navig.skin +++ /dev/null @@ -1,14 +0,0 @@ -<% this.name %> - - - -

-

- Prototypes:
- <% this.prototypes skin="navig" %> -

- diff --git a/DocApplication/prototypes.skin b/DocApplication/prototypes.skin new file mode 100644 index 00000000..cdbcc472 --- /dev/null +++ b/DocApplication/prototypes.skin @@ -0,0 +1,10 @@ + + +Application " target="main"><% this.name %>

+ +<% this.prototypes %> + + + + + diff --git a/DocApplication/summary.skin b/DocApplication/summary.skin new file mode 100644 index 00000000..a030a136 --- /dev/null +++ b/DocApplication/summary.skin @@ -0,0 +1,4 @@ +

Application <% this.headline %>

+ +<% this.comment encoding="html" %> + diff --git a/DocFunction/actions.js b/DocFunction/actions.js new file mode 100644 index 00000000..b7ce0e01 --- /dev/null +++ b/DocFunction/actions.js @@ -0,0 +1,8 @@ +function main_action () { + this.getParentElement ().readFiles (); + res.data.body = this.renderSkinAsString ("main"); + renderSkin ("api"); +} + + + diff --git a/DocFunction/asLargeListItem.skin b/DocFunction/asLargeListItem.skin new file mode 100644 index 00000000..584d72f1 --- /dev/null +++ b/DocFunction/asLargeListItem.skin @@ -0,0 +1,7 @@ + +" target="main"><% this.link %>
+<% this.comment length="200" %> + + + + diff --git a/DocFunction/asLargeListItemSkin.skin b/DocFunction/asLargeListItemSkin.skin new file mode 100644 index 00000000..c659c611 --- /dev/null +++ b/DocFunction/asLargeListItemSkin.skin @@ -0,0 +1,8 @@ + +" target="main"><% this.link %>
+<% this.comment length="200" %> +<% this.skinparameters separator=", "%> + + + + diff --git a/DocFunction/asListItem.skin b/DocFunction/asListItem.skin new file mode 100644 index 00000000..30df0ea1 --- /dev/null +++ b/DocFunction/asListItem.skin @@ -0,0 +1,2 @@ +<% this.link %>
+ diff --git a/DocFunction/asParentListItem.skin b/DocFunction/asParentListItem.skin new file mode 100644 index 00000000..0822c4cc --- /dev/null +++ b/DocFunction/asParentListItem.skin @@ -0,0 +1 @@ +<% this.link %> \ No newline at end of file diff --git a/DocFunction/functions.js b/DocFunction/functions.js deleted file mode 100644 index c903ff5f..00000000 --- a/DocFunction/functions.js +++ /dev/null @@ -1,7 +0,0 @@ - - -function getApplication() { - return this.getParentElement().getParentElement(); -} - - diff --git a/DocFunction/indexList.skin b/DocFunction/indexList.skin deleted file mode 100644 index 3c0bc71f..00000000 --- a/DocFunction/indexList.skin +++ /dev/null @@ -1,5 +0,0 @@ - - <% this.name %> - <% this.typename %> in <% this.prototypename %> - ("><% this.prototypename %>/<% this.location %>) - diff --git a/DocFunction/indexListSeparator.skin b/DocFunction/indexListSeparator.skin deleted file mode 100644 index f8d0edd0..00000000 --- a/DocFunction/indexListSeparator.skin +++ /dev/null @@ -1,3 +0,0 @@ - -  <% param.letter %> - diff --git a/DocFunction/listElementAction.skin b/DocFunction/listElementAction.skin deleted file mode 100644 index 67c5da69..00000000 --- a/DocFunction/listElementAction.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% this.name %>
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementFunction.skin b/DocFunction/listElementFunction.skin deleted file mode 100644 index 67686f30..00000000 --- a/DocFunction/listElementFunction.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% this.name %> (<% this.args %>) in <% docprototype.name %>/<% this.location %>
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementMacro.skin b/DocFunction/listElementMacro.skin deleted file mode 100644 index 52a10dbd..00000000 --- a/DocFunction/listElementMacro.skin +++ /dev/null @@ -1,9 +0,0 @@ - - -  <% param.group %> -
- "><% docprototype.name %>.<% this.name %> - in <% docprototype.name %>/<% this.location %> -
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementSkin.skin b/DocFunction/listElementSkin.skin deleted file mode 100644 index 71185419..00000000 --- a/DocFunction/listElementSkin.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% docprototype.name %>.<% this.name %>
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/listElementTemplate.skin b/DocFunction/listElementTemplate.skin deleted file mode 100644 index 81893dd8..00000000 --- a/DocFunction/listElementTemplate.skin +++ /dev/null @@ -1,7 +0,0 @@ - - -  <% param.group %> -
- "><% this.name %>()
<% this.comment %>
<% this.tags %>
- - diff --git a/DocFunction/macros.js b/DocFunction/macros.js index 24b45320..679de5ba 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -1,3 +1,4 @@ + /** * macro rendering a skin * @param name name of skin @@ -8,120 +9,83 @@ function skin_macro(par) { } } - /** * macro-wrapper for href-function * @param action name of action to call on this prototype, default main */ -function href_macro(par) { - return this.href( (par&&par.action)?par.action:"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 -/** - * macro rendering page head - */ -function head_macro(par) { - var obj = new Object(); - obj.path = this.getPath(); - var appObj = this.getApplication(); - appObj.renderSkin("head",obj); -} - - -/** - * utility function for head_macro, rendering link to app and to prototype - */ -function getPath() { - var protoObj = this.getDocPrototype(); - var str = protoObj.getPath() + "/" + this.getFullName(); - return( str ); -} - - -/** - * macro returning name of file this method resides in - */ -function location_macro(par) { - var f = new File ( this.getLocation() ); - return f.getName(); -} - - -/** - * macro returning the type of this method (Action, Template, Skin, Macro, Function) - */ -function typename_macro(par) { - return this.getTypeName(); -} - - -/** - * macro returning a link to the prototype page - * @param action name of action to call on this prototype, default main - */ -function prototypehref_macro(par) { - return this.getDocPrototype().href( (par&&par.action)?par.action:"main" ) -} - - -/** - * macro returning the name of the prototype this method belongs to - */ -function prototypename_macro(par) { - return this.getDocPrototype().getName(); -} - - -/** - * macro returning the comment text of this method - * (excluding the tags!) - * @param size (optional) text is cutoff after a number of chars - */ -function comment_macro(par) { - var str = this.getComment(); - if ( par && par.length && str.length > par.size ) { - return ( str.substring(0,par.size) ); - } else { - return ( str ); +function headline_macro (param) { + var p = this.getParentElement (); + var handler = (p!=null) ? p.getName () : ""; + if (this.getType () == this.ACTION) { + res.write ("/" + this.getName ()); + } else if (this.getType () == this.FUNCTION) { + if (handler!="" && handler!="global") + res.write (handler + "."); + res.write (this.getName () + " ("); + var arr = this.listParameters (); + for (var i=0; i-1) + name = name.substring (0, name.length-6); + res.write (name); + res.write (" %>"); + } else if (this.getType () == this.SKIN) { + if (handler!="" && handler!="global") + res.write (handler + "/"); + res.write (this.getName ()); + res.write (".skin"); } } -/** - * macro rendering the list of tags - */ -function tags_macro() { - var arr = this.listTags(); - var argCt = 0; - for ( var i in arr ) { - if ( arr[i].getKind()==Packages.helma.doc.DocTag.ARG ) - argCt++; - res.write( arr[i].render(argCt,this) ); +function skinparameters_macro (param) { + if (this.getType () == this.SKIN) { + this.parameters_macro (param); } } -/** - * macro rendering sequence of arg1, arg2 etc - * according to number of arguments in doctags. - */ -function args_macro() { - var ct = this.countTags(Packages.helma.doc.DocTag.ARG); - for ( var i=0; i ' - if ( i<100 ) str4+=' '; + if (i<99) str4+=' '; + if (i<9) str4+=' '; str4 += arr[i] + "
"; } return ( str4 ); } -/** - * macro returning the fullname of this method - */ -function fullname_macro(par) { - return this.getFullName(); -} - diff --git a/DocFunction/main.hac b/DocFunction/main.hac deleted file mode 100644 index 6faae50d..00000000 --- a/DocFunction/main.hac +++ /dev/null @@ -1,8 +0,0 @@ -if ( checkAddress()==false ) return; -if ( checkAuth(this)==false ) return; - -res.data.body = this.renderSkinAsString("main"); -res.data.title = "Application " + this.name; -renderSkin("api"); - - diff --git a/DocFunction/main.skin b/DocFunction/main.skin index 26420fb2..f9546829 100644 --- a/DocFunction/main.skin +++ b/DocFunction/main.skin @@ -1,9 +1,34 @@ -<% this.head %> + + + + -
- in <% docprototype.name%>/<% this.location %>: -
+ + + +
+ <% this.headline %>
+
+ <% this.comment suffix="

" %> + <% this.skinparameters prefix="general parameters used in this skin:
  • " separator="
  • " suffix="

" %> +
    + <% this.tags type="param" skin="parameter" %> + <% this.tags type="return" skin="return" %> + <% this.tags type="author" skin="author" %> + <% this.tags type="see" skin="see" %> + <% this.tags type="deprecated" skin="deprecated" %> + <% this.tags type="overrides" skin="overrides" %> +
+
+ + + + + + +
Sourcecode in <% this.location %>: +
<% this.source %>
+
-
<% this.source %>
diff --git a/DocPrototype/actions.js b/DocPrototype/actions.js new file mode 100644 index 00000000..62ee1460 --- /dev/null +++ b/DocPrototype/actions.js @@ -0,0 +1,10 @@ +function list_action () { + res.data.body = this.renderSkinAsString ("list"); + renderSkin ("api"); +} + +function main_action () { + res.data.body = this.renderSkinAsString ("main"); + renderSkin ("api"); +} + diff --git a/DocPrototype/appList.skin b/DocPrototype/appList.skin deleted file mode 100644 index e132ca63..00000000 --- a/DocPrototype/appList.skin +++ /dev/null @@ -1,10 +0,0 @@ - - -  Prototype -
- "><% this.name %>
- <% this.comment %> -
- - - diff --git a/DocPrototype/asInheritanceLink.skin b/DocPrototype/asInheritanceLink.skin new file mode 100644 index 00000000..42449c89 --- /dev/null +++ b/DocPrototype/asInheritanceLink.skin @@ -0,0 +1 @@ +extends Prototype "><% this.name %> \ No newline at end of file diff --git a/DocPrototype/asParentList.skin b/DocPrototype/asParentList.skin new file mode 100644 index 00000000..cfdc8989 --- /dev/null +++ b/DocPrototype/asParentList.skin @@ -0,0 +1,17 @@ + +Inherited from prototype <% this.link %>:
+ + + +<% this.methods separator=", " filter="actions" skin="asParentListItem" prefix="Actions: " suffix="
" %> +<% this.methods separator=", " filter="functions" skin="asParentListItem" prefix="Functions: " suffix="
" %> +<% this.methods separator=", " filter="macros" skin="asParentListItem" prefix="Macros: " suffix="
" %> +<% this.methods separator=", " filter="skins" skin="asParentListItem" prefix="Skins: " suffix="
" %> +<% this.methods separator=", " filter="templates" skin="asParentListItem" prefix="Templates: " suffix="
" %> + + + + + + + diff --git a/DocPrototype/asPrototypeList.skin b/DocPrototype/asPrototypeList.skin new file mode 100644 index 00000000..0f3762aa --- /dev/null +++ b/DocPrototype/asPrototypeList.skin @@ -0,0 +1,10 @@ + +" onClick="parent.changePrototypeList(this);" target="main"><% this.name %> + +<% + this.inheritance action="main" target="main" + onClick="parent.changePrototypeList(this);" hopobject="false" + prefix=" (extends " suffix=")" +%> + +
diff --git a/DocPrototype/functions.js b/DocPrototype/functions.js new file mode 100644 index 00000000..c0bb39c9 --- /dev/null +++ b/DocPrototype/functions.js @@ -0,0 +1,29 @@ + +///** +// * utility function for head_macro, rendering link to app and to prototype +// */ +//function getPath() { +// var appObj = this.getParentElement (); +// var str = appObj.getPath(); +// str += '/' + this.name + ''; +// return( str ); +//} + + + +function translateType (filter) { + if (filter=="actions") + return Packages.helma.doc.DocElement.ACTION; + else if (filter=="templates") + return Packages.helma.doc.DocElement.TEMPLATE; + else if (filter=="functions") + return Packages.helma.doc.DocElement.FUNCTION; + else if (filter=="macros") + return Packages.helma.doc.DocElement.MACRO; + else if (filter=="skins") + return Packages.helma.doc.DocElement.SKIN; + else + return -1; +} + + diff --git a/DocPrototype/list.skin b/DocPrototype/list.skin new file mode 100644 index 00000000..afb66787 --- /dev/null +++ b/DocPrototype/list.skin @@ -0,0 +1,11 @@ +

Prototype " target="main"><% this.name %>

+<% this.inheritance action="list" %> +<% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="
" %>
+ + +<% this.methods filter="actions" skin="asListItem" prefix="

Actions:
" suffix="

%> +<% this.methods filter="functions" skin="asListItem" prefix="

Functions:
" suffix="

%> +<% this.methods filter="macros" skin="asListItem" prefix="

Macros:
" suffix="

%> +<% this.methods filter="skins" skin="asListItem" prefix="

Skins:
" suffix="

%> +<% this.methods filter="templates" skin="asListItem" prefix="

Templates:
" suffix="

%> + diff --git a/DocPrototype/listFooter.skin b/DocPrototype/listFooter.skin deleted file mode 100644 index d3f6097b..00000000 --- a/DocPrototype/listFooter.skin +++ /dev/null @@ -1,3 +0,0 @@ - -
- diff --git a/DocPrototype/listHeader.skin b/DocPrototype/listHeader.skin deleted file mode 100644 index bbe57421..00000000 --- a/DocPrototype/listHeader.skin +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index 4334e1bf..9d509458 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -1,3 +1,4 @@ + /** * macro rendering a skin * @param name name of skin @@ -8,105 +9,105 @@ function skin_macro(par) { } } - /** * macro-wrapper for href-function * @param action name of action to call on this prototype, default main */ -function href_macro(par) { - return this.href( (par&&par.action)?par.action:"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 headline_macro (param) { + res.write (this.getName ()); } - /** - * macro rendering page head + * macro formatting list of methods of this prototype + * @param filter actions | functions | macros | templates | skins + * @param skin skin to apply to the docfunction object + * @param separator + * @param desc Description that is passed on to the called skin */ -function head_macro(par) { - var obj = new Object(); - obj.path = this.getPath(); - var appObj = this.getApplication(); - appObj.renderSkin("head",obj); -} - - -/** - * utility function for head_macro, rendering link to app and to prototype - */ -function getPath() { - var appObj = this.getApplication(); - var str = appObj.getPath(); - str += '/' + this.name + ''; - return( str ); -} - - -/** - * macro returning the comment for this prototype - */ -function comment_macro(par) { - return this.getComment(); -} - - -/** - * macro formatting list of actions of this prototype - */ -function actions_macro(par) { - this.printMethods( Packages.helma.doc.DocElement.ACTION, "listElementAction","Actions" ); -} - - -/** - * macro formatting list of templates of this prototype - */ -function templates_macro(par) { - this.printMethods( Packages.helma.doc.DocElement.TEMPLATE, "listElementTemplate","Templates" ); -} - - -/** - * macro formatting list of functions of this prototype - */ -function functions_macro(par) { - this.printMethods( Packages.helma.doc.DocElement.FUNCTION, "listElementFunction","Functions" ); -} - - -/** - * macro formatting list of skins of this prototype - */ -function skins_macro(par) { - this.printMethods( Packages.helma.doc.DocElement.SKIN, "listElementSkin","Skins" ); -} - - -/** - * macro formatting list of macros of this prototype - */ -function macros_macro(par) { - this.printMethods( Packages.helma.doc.DocElement.MACRO, "listElementMacro","Macros" ); -} - - -/** - * macro-utility: renders a list of methods of this prototype - * usage of docprototype.listHeader/listFooter skin is hardcoded - * @arg type integer - which type of methods are listed - * @arg skin skin to be called on method - * @arg desc string describing the type of method (ie "Skins", "Actions") - */ -function printMethods(type,skin,desc) { - var arr = this.listFunctions(type); - if ( arr.length > 0 ) { - var obj = new Object(); - obj.desc = desc; - this.renderSkin("listHeader",obj); - for ( var i in arr ) { - arr[i].renderSkin(skin,obj); +function methods_macro (param) { + var skinname = (param.skin) ? param.skin : "list"; + var separator = (param.separator) ? param.separator : ""; + var arr = this.listChildren (); + var type = this.translateType (param.filter); + var sb = new java.lang.StringBuffer (); + for (var i=0; i0) + return str.substring (0, str.length - separator.length); + else + return str; +} + + +function inheritance_macro (param) { + var action = param.action ? param.action : "main"; + var target = param.target ? ('target="' + param.target + '" ') : ''; + var obj = this.getParentPrototype (); + if (obj!=null) { + obj = this.inheritanceUtil (obj, param); + } + if (param.deep=="true") { + while (obj!=null) { + obj = this.inheritanceUtil (obj, param); + } + } +} + +function inheritanceUtil (obj, param) { + if (obj.getName ()=="hopobject" && param.hopobject!="true") + return null; + var tmp = new Object (); + for (var i in param) + tmp[i] = param[i]; + tmp.href = obj.href ((param.action) ? param.action : "main"); + delete tmp.hopobject; + delete tmp.action; + delete tmp.deep; + delete tmp.separator; + res.write (renderLinkTag (tmp)); + res.write (obj.getName () + ""); + if (obj.getParentPrototype ()) + res.write (param.separator); + return obj.getParentPrototype (); +} + + +/** + * loops through the parent prototypes and renders a skin on each + * @param skin + */ +function parentPrototype_macro (param) { + var skinname = (param.skin) ? param.skin : "asParentList"; + var obj = this.getParentPrototype (); + while (obj!=null) { + obj.renderSkin (skinname); + obj = obj.getParentPrototype (); } } +function typeProperties_macro (param) { + var props = this.getTypeProperties (); + if (props!=null) { + res.encode(props.getContent ()); + } +} + diff --git a/DocPrototype/main.hac b/DocPrototype/main.hac deleted file mode 100644 index 77ebcb02..00000000 --- a/DocPrototype/main.hac +++ /dev/null @@ -1,8 +0,0 @@ -if ( checkAddress()==false ) return; -if ( checkAuth(this)==false ) return; - -res.data.body = this.renderSkinAsString("main"); -res.data.title = "Application " + this.name; -renderSkin ("api"); - - diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin index 20cc8ec5..ec24d999 100644 --- a/DocPrototype/main.skin +++ b/DocPrototype/main.skin @@ -1,8 +1,82 @@ -<% this.head %> +
<% param.desc %>
+ + + +
+ Prototype <% this.headline %>
+ <% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="
" %> +
+ +ACTIONS | +FUNCTIONS | +MACROS | +SKINS | +TEMPLATES | +TYPE.PROPERTIES + + + + + + + +
+ <% this.comment suffix="

" %> +
    + <% this.tags type="author" skin="author" %> + <% this.tags type="see" skin="see" %> + <% this.tags type="deprecated" skin="deprecated" %> + <% this.tags type="overrides" skin="overrides" %> +
+
+ + + + <% this.methods separator="" + filter="actions" + skin="asLargeListItem" + prefix="" + %> + + <% this.methods separator="" + filter="functions" + skin="asLargeListItem" + prefix="" + %> + + <% this.methods separator="" + filter="macros" + skin="asLargeListItem" + prefix="" + %> + + <% this.methods separator="" + filter="skins" + skin="asLargeListItemSkin" + prefix="" + %> + + <% this.methods separator="" + filter="templates" + skin="asLargeListItem" + prefix="" + %> + + <% this.parentPrototype skin="asParentList" %> +
Actions
Functions
Macros
Skins
Templates
+ +

+ + + + + +
type.properties
<% this.typeProperties prefix="
" suffix="
" %>
+ + + + + + -<% this.actions %> -<% this.skins %> -<% this.macros %> -<% this.functions %> -<% this.templates %> diff --git a/DocPrototype/navig.skin b/DocPrototype/navig.skin deleted file mode 100644 index cc6f041f..00000000 --- a/DocPrototype/navig.skin +++ /dev/null @@ -1,2 +0,0 @@ - -"><% this.name %>
diff --git a/DocTag/author.skin b/DocTag/author.skin new file mode 100644 index 00000000..c319829d --- /dev/null +++ b/DocTag/author.skin @@ -0,0 +1,2 @@ +
  • Author
    +<% this.text %> \ No newline at end of file diff --git a/DocTag/deprecated.skin b/DocTag/deprecated.skin new file mode 100644 index 00000000..57cb4d4e --- /dev/null +++ b/DocTag/deprecated.skin @@ -0,0 +1,2 @@ +
  • Deprecated
    +<% this.text %> diff --git a/DocTag/main.skin b/DocTag/main.skin new file mode 100644 index 00000000..dca81089 --- /dev/null +++ b/DocTag/main.skin @@ -0,0 +1 @@ +
  • <% this.text %> \ No newline at end of file diff --git a/DocTag/overrides.skin b/DocTag/overrides.skin new file mode 100644 index 00000000..4616af7f --- /dev/null +++ b/DocTag/overrides.skin @@ -0,0 +1,3 @@ +
  • Overrides
    +<% param.link %> + diff --git a/DocTag/parameter.skin b/DocTag/parameter.skin new file mode 100644 index 00000000..deeed157 --- /dev/null +++ b/DocTag/parameter.skin @@ -0,0 +1,2 @@ +
  • Parameter <% this.name %>:
    +<% this.text %> \ No newline at end of file diff --git a/DocTag/renderfunctions.js b/DocTag/renderfunctions.js deleted file mode 100644 index ede11b25..00000000 --- a/DocTag/renderfunctions.js +++ /dev/null @@ -1,46 +0,0 @@ -/** - * function renders list of tags, language is hardcoded here - * @arg number of current argument (for formatting arg1, arg2 etc) - * @arg method method-object from which we try to find other prototypes/methods - * when we're formatting a see tag - */ -function render(argCt,docFunc) { - var str = ""; - if ( this.getKind() == this.ARG ) { - str = "arg" + argCt + ": " + format(this.text); - } else if ( this.getKind() == this.PARAM ) { - str = "Parameter " + this.name; - if ( this.text!=null && this.text!="" ) { - str += ": " + format(this.text); - } - } else if ( this.getKind() == this.RETURNS ) { - str = "Returns: " + format(this.text); - } else if ( this.getKind() == this.AUTHOR ) { - str = "by " + format(this.text) + ""; - } else if ( this.getKind() == this.VERSION ) { - str = "Version " + format(this.text) + ""; - } else if ( this.getKind() == this.RELEASE ) { - str = "since" + format(this.text) + ""; - } else if ( this.getKind() == this.SEE ) { - if ( this.text.indexOf("http://")==0 ) { - str = '' + this.text + ''; - } else { - var tmp = new java.lang.String(this.text); - tmp = tmp.trim(); - var arr = tmp.split("."); - var obj = docFunc.getApplication().getDocPrototype(arr[0]); - if( arr.length>1 && obj.getFunction(arr[1])!=null ) { - str = 'See also: ' + format(tmp) + ''; - } else if ( obj!=null ) { - str = 'See also: ' + format(tmp) + ''; - } - } - if ( str=="" ) { - str = "See also: " + format(this.text); - } - } - return str + "
    "; -} - - - diff --git a/DocTag/return.skin b/DocTag/return.skin new file mode 100644 index 00000000..a421d33c --- /dev/null +++ b/DocTag/return.skin @@ -0,0 +1,2 @@ +
  • Returns
    +<% this.text %> diff --git a/DocTag/see.skin b/DocTag/see.skin new file mode 100644 index 00000000..5e66957d --- /dev/null +++ b/DocTag/see.skin @@ -0,0 +1,2 @@ +
  • See also
    +<% param.link %> diff --git a/Global/api.skin b/Global/api.skin index d152e04d..9fb798d9 100644 --- a/Global/api.skin +++ b/Global/api.skin @@ -1,17 +1,67 @@ - -<% skin name="head" %> + + + + + + + - - - - - -
    -

    ">" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;">

    - <% docapplication.skin name="navig" %>
    <% response.body %>
    - +<% response.body %> diff --git a/Global/functions.js b/Global/functions.js index 578ef6eb..5e678c23 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -10,11 +10,10 @@ function scheduler() { /** - * initializes app.data.requestStat storage on startup, + * initializes app.data.stat storage on startup, * creates app.data.addressFilter */ function onStart() { - app.data.requestStat = new HopObject(); app.data.addressFilter = createAddressFilter(); } @@ -47,29 +46,28 @@ function createAddressFilter() { /** - * updates the request stats in app.data.requestStat every 5 minutes + * updates the stats in app.data.stat every 5 minutes */ -function appStat() { - if ( app.data.requestStat==null ) { - app.data.requestStat = new HopObject(); - } - if( (new Date()-300000) < app.data.requestStat.lastRun ) { +function appStat () { + if (app.data.stat==null) + app.data.stat = new HopObject (); + if ((new Date()-300000) < app.data.stat.lastRun) return; - } - var arr = root.getApplications(); - for ( var i=0; ib.name ) + if ( a.name>b.name) return 1; else if ( a.name==b.name ) return 0; @@ -132,8 +130,6 @@ function checkAuth(appObj) { // check against application var appUsername = appObj.getProperty("adminusername"); var appPassword = appObj.getProperty("adminpassword"); - if ( appUsername==null || appUsername=="" || appPassword==null || appPassword=="" ) - return forceStealth(); if ( md5username==appUsername && md5password==appPassword ) return true; } @@ -149,7 +145,7 @@ function checkAddress() { app.log("denied request from " + req.data.http_remotehost ); // forceStealth seems a bit like overkill here. // display a message that the ip address must be added to server.properties - res.write ("Access to address "+req.data.http_remotehost+" denied."); + res.write ("Access from address "+req.data.http_remotehost+" denied."); return false; } else { return true; @@ -169,14 +165,7 @@ function forceAuth(realm) { return false; } -/** - * response is reset to 404 / notfound - */ -function forceStealth() { - res.reset(); - res.status = 404; - return false; -} + /** @@ -302,3 +291,16 @@ function formatCount(ct, par) { else return par.plural; } + + +/** + * tries to make out if this server is running linux from java's system properties + */ +function isLinux () { + var str = java.lang.System.getProperty("os.name"); + return (str!=null && str.toLowerCase().indexOf("linux")!=-1); +} + + + + diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js new file mode 100644 index 00000000..c8c17ea7 --- /dev/null +++ b/Global/renderFunctions.js @@ -0,0 +1,176 @@ + + +function renderLink (docEl, param) { + var text = ""; + if (docEl.getType () == docEl.APPLICATION || docEl.getType () == docEl.PROTOTYPE) { + text = docEl.getName (); + } else if (docEl.getType () == docEl.SKIN) { + text = docEl.getName () + ".skin"; + } else if (docEl.getType () == docEl.MACRO) { + if (docEl.getParentElement () && docEl.getParentElement().getName()!="global") { + text = docEl.getParentElement ().getName () + "."; + } + var str = docEl.getName (); + if (str.indexOf("_macro")) { + text += str.substring (0, str.length-6); + } + } else if (docEl.getType () == docEl.FUNCTION) { + var text = docEl.getName () + " ("; + var arr = docEl.listParameters (); + for (var i=0; i'; +} + + + + +function renderLinkTag (param) { + var sb = new java.lang.StringBuffer (); + sb.append (''); + return sb.toString (); +} + + +/** + * renders the name of the location relative to the application + * root. + */ +function renderLocation (docEl, param) { + var f = docEl.getLocation (); + if (f.isDirectory ()) + return f.getName (); + else { + return f.getParentFile ().getName () + "/" + f.getName (); + } +} + + + +/** + * renders tag list. + * @param param.skin skin to render on found DocTags + * @param param.separator String printed between tags + * @param param.type type string (param|return|author|version|see) to filter tags. + */ +function renderTags (docEl, param) { + var skinname = (param.skin) ? param.skin : "main"; + var type = -1; + if (param.type=="param" || param.type=="params") + type = Packages.helma.doc.DocTag.PARAMETER; + else if (param.type=="return" || param.type=="returns") + type = Packages.helma.doc.DocTag.RETURN; + else if (param.type=="author") + type = Packages.helma.doc.DocTag.AUTHOR; + else if (param.type=="version") + type = Packages.helma.doc.DocTag.VERSION; + else if (param.type=="see") + type = Packages.helma.doc.DocTag.SEE; + else if (param.type=="deprecated") + type = Packages.helma.doc.DocTag.DEPRECATED; + else if (param.type=="overrides") + type = Packages.helma.doc.DocTag.OVERRIDES; + var str = ""; + var arr = docEl.listTags (); + for (var i=0; i' + text + ''; + } else { + // make sure we only use the first item in the text so that unlinked comments + // can follow, store & split the that + var tok = new java.util.StringTokenizer (text); + var tmp = tok.nextToken (); + text = " " + text.substring (tmp.length + 1); + var parts = tmp.split("."); + // try to find the application object + var obj = docEl; + while (obj!=null) { + if (obj.getType () == Packages.helma.doc.DocElement.APPLICATION) { + var appObj = obj; + break; + } + obj = obj.getParentElement (); + } + var protoObj = appObj.getChildElement ("prototype_" + parts[0]); + if (protoObj==null) { + // prototype wasn't found, return the unlinked tag + return tmp + text; + } + if (parts.length==1) { + // no function specified, return the linked prototype + return '' + format (tmp) + '' + text; + } + // try to find a function object: + var arr = protoObj.listChildren (); + for (var i=0; i' + format(tmp) + '' + text; + } + } + // function not found: + return tmp + text; + } +} + + + + +/** + * function rendering a comment. + * @param param.length comment is shortened to the given length. + * @returns string + */ +function renderComment (docEl, param) { + var str = docEl.getComment (); + if (param.length) { + if (param.length < str.length) { + return str.substring (0, param.length) + " ..."; + } + } + return str; +} + diff --git a/Root/macros.js b/Root/macros.js index 8108ec3f..fe3c30de 100644 --- a/Root/macros.js +++ b/Root/macros.js @@ -35,27 +35,50 @@ function countSessions_macro(par) { /** - * macro returning the total number of sessions on this server + * macro returning the number of requests during the last 5 minutes * @see global.formatCount */ -function countRequests_macro(par) { - if ( app.requestStat==null ) { +function requestCount_macro(par) { + if (app.data.stat==null) { return; } - var arr = this.getApplications(); + var arr = this.getApplications (); var sum = 0; - for ( var i=0; i - uptime: + uptime:   <% this.uptime %> - version: + version:   <% this.version %> - homedir: + homedir:   <% this.home %> - total active sessions: + total active sessions:   <% this.countSessions default=" " %> - total requests / 5 min: + total requests / 5 min:   - <% this.countRequests default=" " %> + <% this.requestCount default=" " %> - loaded extensions: + total errors / 5 min: +   + <% this.errorCount default=" " %> + + + loaded extensions:   <% this.extensions default=" " %> @@ -45,51 +50,51 @@ - free memory: + free memory:   - <% this.jvmFreeMemory %> + <% this.jvmFreeMemory hr="true" %> - used memory: + used memory:   - <% this.jvmUsedMemory %> + <% this.jvmUsedMemory hr="true" %> - total memory: + total memory:   - <% this.jvmTotalMemory %> + <% this.jvmTotalMemory hr="true" %> - java: + java:   <% this.jvm %> - javahome: + javahome:   <% this.jvmHome %> - os: + os:   <% this.os %> - localtime: + localtime:   <% now %> - timezone: + timezone:   <% this.timezone %> - loaded Jars: + loaded Jars:   <% this.jvmJars %> @@ -98,7 +103,7 @@ server.properties -<% this.properties itemprefix='' separator=' ' itemsuffix='' %> +<% this.properties itemprefix='' separator=' ' itemsuffix='' %> diff --git a/Root/makekey.hac b/Root/makekey.hac index 1ba50f12..4800e2e4 100644 --- a/Root/makekey.hac +++ b/Root/makekey.hac @@ -1,11 +1,12 @@ -// strictly limit access to localhost: -if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) { - app.__app__.logEvent( req.data.http_remotehost + " tried to access makekey"); - return; -} +//// strictly limit access to localhost: +//if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) { +// app.logEvent( req.data.http_remotehost + " tried to access makekey"); +// return; +//} -if ( checkAuth()==false ) return; +if ( checkAuth()==false ) + return; createAuth(); diff --git a/Root/mrtg.hac b/Root/mrtg.hac new file mode 100644 index 00000000..44b672c8 --- /dev/null +++ b/Root/mrtg.hac @@ -0,0 +1,37 @@ + +/** + * prints server-stats for mrtg-tool. + * doesn't check username or password, so that we don't have + * to write them cleartext in a mrtg-configfile but checks the + * remote address. + */ + +if ( checkAddress()==false ) + return; + + +if (req.data.action=="memory") { + + res.write (this.jvmTotalMemory_macro () + "\n"); + res.write (this.jvmFreeMemory_macro () + "\n"); + res.write ("0\n0\n"); + +} else if (req.data.action=="netstat" && isLinux ()) { + + var str = (new File("/proc/net/tcp")).readAll(); + var arr = str.split("\n"); + res.write (arr.length-2 + "\n"); + res.write ("0\n0\n0\n"); + +} else if (req.data.action=="loadavg" && isLinux ()) { + + // load average of last 5 minutes: + var str = (new File("/proc/loadavg")).readAll(); + var arr = str.split(" "); + res.write (arr[1]*100 + "\n"); + res.write ("0\n0\n0\n"); + +} else { + res.write ( "0\n0\n0\n0\n"); +} + From 604ab4f8ba15ad4beadc7bbaaabc3ab96c33fa9e Mon Sep 17 00:00:00 2001 From: stefanp Date: Fri, 22 Nov 2002 11:39:11 +0000 Subject: [PATCH 43/82] lots of formatting fixes, added functionindex to docapplication --- Application/head.skin | 3 +- Application/navig_active.skin | 12 +++-- DocApplication/actions.js | 73 +++++------------------------- DocApplication/functionindex.skin | 24 ++++++++++ DocApplication/functions.js | 58 ++++++++++++++++++++++++ DocApplication/indexSeparator.skin | 3 ++ DocApplication/macros.js | 51 ++++++++++++--------- DocApplication/summary.skin | 27 ++++++++++- DocFunction/asIndexItem.skin | 7 +++ DocFunction/asLargeListItem.skin | 2 - DocFunction/macros.js | 5 +- DocPrototype/asSummary.skin | 4 ++ DocPrototype/macros.js | 19 ++++++-- DocPrototype/main.skin | 18 ++++---- DocPrototype/typeproperties.skin | 9 ++++ Global/functions.js | 4 +- Global/navig.skin | 14 ++++-- Global/renderFunctions.js | 2 +- 18 files changed, 219 insertions(+), 116 deletions(-) create mode 100644 DocApplication/functionindex.skin create mode 100644 DocApplication/functions.js create mode 100644 DocApplication/indexSeparator.skin create mode 100644 DocFunction/asIndexItem.skin create mode 100644 DocPrototype/asSummary.skin create mode 100644 DocPrototype/typeproperties.skin diff --git a/Application/head.skin b/Application/head.skin index a52e6407..1a5b8604 100644 --- a/Application/head.skin +++ b/Application/head.skin @@ -2,7 +2,8 @@ <% this.description prefix="
    " %>
    -> - /main">AppDoc | + /main">showAPI | + /render">renderAPI | public | ?app=<% this.title %>&action=flush">flush | ?app=<% this.title %>&action=restart">restart | diff --git a/Application/navig_active.skin b/Application/navig_active.skin index 9bb568a8..c35d2472 100644 --- a/Application/navig_active.skin +++ b/Application/navig_active.skin @@ -1,13 +1,15 @@
    "><% this.title %>
    - <% this.countSessions singular=" Session" plural=" Sessions" %>, <% this.getRequestAvg singular=" Request" plural=" Requests" %>/5min + <% this.countSessions singular=" Session" plural=" Sessions" %>, + <% this.requestCount singular=" Request" plural=" Requests" %>/5min
    - diff --git a/DocApplication/actions.js b/DocApplication/actions.js index cbc1d907..27df09dd 100644 --- a/DocApplication/actions.js +++ b/DocApplication/actions.js @@ -15,81 +15,30 @@ function summary_action () { } +function functionindex_action () { + res.data.body = this.renderSkinAsString ("functionindex"); + renderSkin ("api"); +} + function render_action () { - res.write ("renderrendering ... " + new Date () ); + res.writeln("renderrendering API ... "); var prefix = this.href (""); this.storePage (this, "main"); this.storePage (this, "prototypes"); this.storePage (this, "summary"); + this.storePage (this, "functionindex"); + var ct = 4; var arr = this.listChildren (); for (var i=0; i + + + +
    - /render">render AppDoc - /main">AppDoc - ?app=<% this.title %>&action=flush">flush + + /main">showAPI | + /render">renderAPI | + public | + ?app=<% this.title %>&action=flush">flush | ?app=<% this.title %>&action=restart">restart
    + Application <% this.headline %>
    +
    + +">SUMMARY | +">INDEX | +A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z| + + + <% this.functions skin="asIndexItem" + separator="" + %> +
    + +">SUMMARY | +">INDEX | +A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z| + diff --git a/DocApplication/functions.js b/DocApplication/functions.js new file mode 100644 index 00000000..16dbe089 --- /dev/null +++ b/DocApplication/functions.js @@ -0,0 +1,58 @@ + + +function getDocPrototype (obj) { + var tmp = obj; + while (tmp!=null && tmp.getType () != this.PROTOTYPE) { + tmp = tmp.getParentElement (); + } + return tmp; +} + +function getDir (dir, obj) { + dir.mkdir (); + if (obj.getType () == this.APPLICATION) { + return dir; + } else if (obj.getType () == this.PROTOTYPE) { + var protoObj = this.getDocPrototype (obj); + var dir = new File (dir, protoObj.getElementName ()); + dir.mkdir (); + return dir; + } else { + var protoObj = this.getDocPrototype (obj); + var dir = this.getDir (dir, protoObj); + dir = new File (dir, obj.getElementName ()); + dir.mkdir (); + return dir; + } +} + + +function storePage (obj, action, backPath) { + 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, action + ".html"); + f.remove (); + f.open (); + f.write (str); + f.close (); + app.log ("wrote file " + f.toString ()); +} + + +function getPage (obj, action, backPath) { + backPath = (backPath==null) ? "" : backPath; + res.pushStringBuffer (); + eval ("obj." + action + "_action ();"); + var str = res.popStringBuffer (); + var reg = new RegExp ("href=\"" + this.href ("") + "([^\"]+)\""); + reg.global = true; + str = str.replace (reg, "href=\"" + backPath + "$1.html\""); + var reg = new RegExp ("src=\"" + this.href ("") + "([^\"]+)\""); + reg.global = true; + str = str.replace (reg, "src=\"" + backPath + "$1.html\""); + return str; +} + + diff --git a/DocApplication/indexSeparator.skin b/DocApplication/indexSeparator.skin new file mode 100644 index 00000000..beb8ee73 --- /dev/null +++ b/DocApplication/indexSeparator.skin @@ -0,0 +1,3 @@ + +<% param.letter %> + \ No newline at end of file diff --git a/DocApplication/macros.js b/DocApplication/macros.js index d14126df..f7b78ccd 100644 --- a/DocApplication/macros.js +++ b/DocApplication/macros.js @@ -42,35 +42,42 @@ function hrefRoot_macro (param) { /** * list all prototypes of this application * @param skin name of skin to render on prototype + * @param separator */ -function prototypes_macro(par) { - var skin = (par && par.skin&&par.skin!="") ? par.skin : "asPrototypeList"; +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; iApplication <% this.headline %> + + + + + + +
    + Application <% this.headline %>
    +
    + +">SUMMARY | +">INDEX | + + <% this.comment encoding="html" %> +
    + + + <% this.prototypes skin="asSummary" + separator="" + %> +
    + + +">SUMMARY | +">INDEX | + diff --git a/DocFunction/asIndexItem.skin b/DocFunction/asIndexItem.skin new file mode 100644 index 00000000..95a998ea --- /dev/null +++ b/DocFunction/asIndexItem.skin @@ -0,0 +1,7 @@ + +<% this.link handler="false" %> +- <% this.type %> in <% docprototype.name %> +
    +<% this.comment length="200" %> + + diff --git a/DocFunction/asLargeListItem.skin b/DocFunction/asLargeListItem.skin index 584d72f1..e11013b3 100644 --- a/DocFunction/asLargeListItem.skin +++ b/DocFunction/asLargeListItem.skin @@ -3,5 +3,3 @@ <% this.comment length="200" %> - - diff --git a/DocFunction/macros.js b/DocFunction/macros.js index 679de5ba..7eb66819 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -24,6 +24,7 @@ function link_macro (param) { return renderLink (this, param); } //// END OF COPIED FUNCTIONS + function headline_macro (param) { var p = this.getParentElement (); var handler = (p!=null) ? p.getName () : ""; @@ -77,7 +78,9 @@ function parameters_macro (param) { } - +function type_macro (param) { + return this.getTypeName (); +} /** diff --git a/DocPrototype/asSummary.skin b/DocPrototype/asSummary.skin new file mode 100644 index 00000000..5ce50bd5 --- /dev/null +++ b/DocPrototype/asSummary.skin @@ -0,0 +1,4 @@ + +"><% this.name %>
    +<% this.comment length="200" %> + diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index 9d509458..b7f852e1 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -91,23 +91,32 @@ function inheritanceUtil (obj, param) { /** * loops through the parent prototypes and renders a skin on each + * if it has got any functions. * @param skin */ function parentPrototype_macro (param) { var skinname = (param.skin) ? param.skin : "asParentList"; var obj = this.getParentPrototype (); while (obj!=null) { - obj.renderSkin (skinname); + if (obj.listChildren ().length>0) { + obj.renderSkin (skinname); + } obj = obj.getParentPrototype (); } } - +/** + * macro rendering a skin depending on wheter this prototype has got + * type-properties or not. + * @param skin + */ function typeProperties_macro (param) { var props = this.getTypeProperties (); - if (props!=null) { - res.encode(props.getContent ()); + if (props!=null && props.getContent ()!="" ) { + var tmp = new Object (); + tmp.content = props.getContent (); + var skinname = (param.skinname) ? param.skinname : "typeproperties"; + this.renderSkin (skinname, tmp); } } - diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin index ec24d999..318ffaed 100644 --- a/DocPrototype/main.skin +++ b/DocPrototype/main.skin @@ -14,6 +14,7 @@ TEMPLATES | TYPE.PROPERTIES +

    @@ -36,44 +37,43 @@ filter="actions" skin="asLargeListItem" prefix="" + suffix=" %> <% this.methods separator="" filter="functions" skin="asLargeListItem" prefix="" + suffix=" %> <% this.methods separator="" filter="macros" skin="asLargeListItem" prefix="" + suffix=" %> <% this.methods separator="" filter="skins" skin="asLargeListItemSkin" prefix="" + suffix=" %> <% this.methods separator="" filter="templates" skin="asLargeListItem" prefix="" + suffix=" %> <% this.parentPrototype skin="asParentList" %>
    Actions
     
    Functions
     
    Macros
     
    Skins
     
    Templates
     
    -

    - - - - - -
    type.properties
    <% this.typeProperties prefix="
    " suffix="
    " %>
    - - +

    + +<% this.typeProperties %> diff --git a/DocPrototype/typeproperties.skin b/DocPrototype/typeproperties.skin new file mode 100644 index 00000000..4eead93f --- /dev/null +++ b/DocPrototype/typeproperties.skin @@ -0,0 +1,9 @@ + + + + + + + +
    type.properties
    <% param.content encoding="html" %>
    + diff --git a/Global/functions.js b/Global/functions.js index 5e678c23..b95b947a 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -75,9 +75,9 @@ function appStat () { * utility function to sort object-arrays by name */ function sortByName(a,b) { - if ( a.name>b.name) + if ( a.getName () > b.getName ()) return 1; - else if ( a.name==b.name ) + else if (a.getName () == b.getName ()) return 0; else return -1; diff --git a/Global/navig.skin b/Global/navig.skin index 441b2e22..f19ff3df 100644 --- a/Global/navig.skin +++ b/Global/navig.skin @@ -1,22 +1,26 @@

    ">" title="helma" border="0" width="174" height="35" align="baseline" style="border-width:3px;border-color:white;"> - helma.org - docs - mailinglist

    <% root.appCount filter="active" singular=" app" plural=" apps"%> on - "><% root.hostname %> + "><% root.hostname %> (<% root.hostaddress %>)
    <% root.appList filter="active" %>

    -
    and <% root.appCount filter="disabled" %> disabled apps:
    <% root.appList filter="disabled" skin="navig_disabled" %> +

    +

    + Information on helma.org:
    +

  • reference
    +
  • mailinglist
    +
  • cvs
    +
  • download
    +

    diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js index c8c17ea7..84731b8b 100644 --- a/Global/renderFunctions.js +++ b/Global/renderFunctions.js @@ -7,7 +7,7 @@ function renderLink (docEl, param) { } else if (docEl.getType () == docEl.SKIN) { text = docEl.getName () + ".skin"; } else if (docEl.getType () == docEl.MACRO) { - if (docEl.getParentElement () && docEl.getParentElement().getName()!="global") { + if (param.handler!="false" && docEl.getParentElement () && docEl.getParentElement().getName()!="global") { text = docEl.getParentElement ().getName () + "."; } var str = docEl.getName (); From cd8ebdd41b259d4096dd3e170593dc4302bc2423 Mon Sep 17 00:00:00 2001 From: stefanp Date: Fri, 22 Nov 2002 11:55:42 +0000 Subject: [PATCH 44/82] re-added access check to actions --- DocApplication/actions.js | 20 ++++++++++++++++++++ DocFunction/actions.js | 5 ++++- DocPrototype/actions.js | 8 ++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/DocApplication/actions.js b/DocApplication/actions.js index 27df09dd..c80a63ff 100644 --- a/DocApplication/actions.js +++ b/DocApplication/actions.js @@ -1,27 +1,47 @@ 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 () { + if (checkAddress()==false) + return; + if (checkAuth(this.getParentElement ())==false) + return; res.writeln("renderrendering API ... "); var prefix = this.href (""); this.storePage (this, "main"); diff --git a/DocFunction/actions.js b/DocFunction/actions.js index b7ce0e01..4c86848c 100644 --- a/DocFunction/actions.js +++ b/DocFunction/actions.js @@ -1,5 +1,8 @@ function main_action () { - this.getParentElement ().readFiles (); + if (checkAddress()==false) + return; + if (checkAuth()==false) + return; res.data.body = this.renderSkinAsString ("main"); renderSkin ("api"); } diff --git a/DocPrototype/actions.js b/DocPrototype/actions.js index 62ee1460..853c8b66 100644 --- a/DocPrototype/actions.js +++ b/DocPrototype/actions.js @@ -1,9 +1,17 @@ function list_action () { + if (checkAddress()==false) + return; + if (checkAuth()==false) + return; res.data.body = this.renderSkinAsString ("list"); renderSkin ("api"); } function main_action () { + if (checkAddress()==false) + return; + if (checkAuth()==false) + return; res.data.body = this.renderSkinAsString ("main"); renderSkin ("api"); } From 7bd5803a33a49394df9fb87ffc22cb57db0b8980 Mon Sep 17 00:00:00 2001 From: stefanp Date: Fri, 22 Nov 2002 11:58:37 +0000 Subject: [PATCH 45/82] simplified editing of server authentication. as changes to server.properties are now immediately read and accessible from the manage-application we just have a md5-encoding utility and leave it to the admin to add the values to the server.properties file. this makes sure that nothing can be changed via the web. changes to allowadmin are effective immediately too. --- Global/functions.js | 32 ++++++++++++++------------------ Global/navig.skin | 4 ++++ Global/pwdform.skin | 17 ++++++----------- Root/makekey.hac | 7 ------- 4 files changed, 24 insertions(+), 36 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index b95b947a..b77db3dc 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -15,6 +15,7 @@ function scheduler() { */ function onStart() { app.data.addressFilter = createAddressFilter(); + app.data.addressString = root.getProperty ("allowadmin"); } /** @@ -75,9 +76,9 @@ function appStat () { * utility function to sort object-arrays by name */ function sortByName(a,b) { - if ( a.getName () > b.getName ()) + if (a.name > b.name) return 1; - else if (a.getName () == b.getName ()) + else if (a.name == b.name) return 0; else return -1; @@ -126,7 +127,7 @@ function checkAuth(appObj) { if ( md5username==rootUsername && md5password==rootPassword ) return true; - if ( appObj!=null && appObj.isActive() ) { + if (appObj!=null && appObj.isActive()) { // check against application var appUsername = appObj.getProperty("adminusername"); var appPassword = appObj.getProperty("adminpassword"); @@ -141,6 +142,12 @@ function checkAuth(appObj) { * check access to the manage-app by ip-addresses */ function checkAddress() { + // if allowadmin value in server.properties has changed, + // re-construct the addressFilter + if (app.data.addressString != root.getProperty ("allowadmin")){ + app.data.addressFilter = createAddressFilter(); + app.data.addressString = root.getProperty ("allowadmin"); + } if ( !app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) { app.log("denied request from " + req.data.http_remotehost ); // forceStealth seems a bit like overkill here. @@ -181,32 +188,21 @@ function createAuth() { } var obj = new Object(); obj.msg = ""; - - if ( req.data.username!=null && req.data.password!=null && req.data.password2!=null ) { + if (req.data.username!=null && req.data.password!=null) { // we have input from webform if ( req.data.username=="" ) obj.msg += "username can't be left empty!
    "; if ( req.data.password=="" ) obj.msg += "password can't be left empty!
    "; - else if ( req.data.password!=req.data.password2 ) - obj.msg += "password and re-typed password don't match!
    "; if ( obj.msg!="" ) { obj.username = req.data.username; res.reset(); renderSkin("pwdform",obj); return false; } - var f = new File(root.getHopHome().toString, "server.properties"); - var str = f.readAll(); - var sep = java.lang.System.getProperty("line.separator"); - str += sep + "adminUsername=" + Packages.helma.util.MD5Encoder.encode(req.data.username) + sep; - str += "adminPassword=" + Packages.helma.util.MD5Encoder.encode(req.data.password) + sep; - f.remove(); - f.open(); - f.write(str); - f.close(); - app.log( req.data.http_remotehost + " saved new adminUsername/adminPassword to server.properties"); - res.redirect ( root.href("main") ); + var str = "adminUsername=" + Packages.helma.util.MD5Encoder.encode(req.data.username) + "
    \n"; + str += "adminPassword=" + Packages.helma.util.MD5Encoder.encode(req.data.password) + "
    "; + res.write ("
    " + str + "
    "); } else { // no input from webform, so print it diff --git a/Global/navig.skin b/Global/navig.skin index f19ff3df..fecbbaf7 100644 --- a/Global/navig.skin +++ b/Global/navig.skin @@ -24,3 +24,7 @@
  • cvs
  • download

    + +

    +

  • ">generate server password +

    \ No newline at end of file diff --git a/Global/pwdform.skin b/Global/pwdform.skin index 641aaa2d..20eb1a01 100644 --- a/Global/pwdform.skin +++ b/Global/pwdform.skin @@ -1,26 +1,21 @@ - +
    diff --git a/DocPrototype/functions.js b/DocPrototype/functions.js index 020052d2..b418b24b 100644 --- a/DocPrototype/functions.js +++ b/DocPrototype/functions.js @@ -1,4 +1,3 @@ - ///** // * utility function for head_macro, rendering link to app and to prototype // */ @@ -10,25 +9,24 @@ //} - -function translateType (filter) { - if (filter=="actions") - return Packages.helma.doc.DocElement.ACTION; - else if (filter=="templates") - return Packages.helma.doc.DocElement.TEMPLATE; - else if (filter=="functions") - return Packages.helma.doc.DocElement.FUNCTION; - else if (filter=="macros") - return Packages.helma.doc.DocElement.MACRO; - else if (filter=="skins") - return Packages.helma.doc.DocElement.SKIN; - else - return -1; +function translateType(filter) { + if (filter == "actions") + return Packages.helma.doc.DocElement.ACTION; + else if (filter == "functions") + return Packages.helma.doc.DocElement.FUNCTION; + else if (filter == "macros") + return Packages.helma.doc.DocElement.MACRO; + else if (filter == "skins") + return Packages.helma.doc.DocElement.SKIN; + else if (filter == "properties") + return Packages.helma.doc.DocElement.PROPERTIES; + else + return -1; } -function getApplication () { - return this.getParentElement (); +function getApplication() { + return this.getParentElement(); } diff --git a/DocPrototype/list.skin b/DocPrototype/list.skin index b9a23cc5..55620dac 100644 --- a/DocPrototype/list.skin +++ b/DocPrototype/list.skin @@ -7,5 +7,4 @@ <% this.methods filter="functions" skin="asListItem" prefix="

    Functions:
    " suffix="

    %> <% this.methods filter="macros" skin="asListItem" prefix="

    Macros:
    " suffix="

    %> <% this.methods filter="skins" skin="asListItem" prefix="

    Skins:
    " suffix="

    %> -<% this.methods filter="templates" skin="asListItem" prefix="

    Templates:
    " suffix="

    %> diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index 7ffbaed9..7b2915e1 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -1,91 +1,105 @@ - /** - * macro rendering a skin - * @param name name of skin - */ -function skin_macro(par) { - if ( par && par.name ) { - this.renderSkin(par.name); - } +* 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 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); } +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 headline_macro (param) { - res.write (this.getName ()); +function headline_macro(param) { + res.write(this.getName()); } /** * macro formatting list of methods of this prototype - * @param filter actions | functions | macros | templates | skins + * @param filter actions | functions | macros | skins * @param skin skin to apply to the docfunction object * @param separator * @param desc Description that is passed on to the called skin */ -function methods_macro (param) { - var skinname = (param.skin) ? param.skin : "list"; - var separator = (param.separator) ? param.separator : ""; - var arr = this.listChildren (); - var type = this.translateType (param.filter); - var sb = new java.lang.StringBuffer (); - for (var i=0; i0) - return str.substring (0, str.length - separator.length); - else - return str; +function methods_macro(param) { + var skinname = (param.skin) ? param.skin : "list"; + var separator = (param.separator) ? param.separator : ""; + var arr = this.listChildren(); + var type = this.translateType(param.filter); + var sb = new java.lang.StringBuffer (); + for (var i = 0; i < arr.length; i++) { + if (arr[i].getType() == type) { + sb.append(arr[i].renderSkinAsString(skinname, param)); + sb.append(separator); + } + } + var str = sb.toString(); + if (str.length > 0) + return str.substring(0, str.length - separator.length); + else + return str; } -function inheritance_macro (param) { - var action = param.action ? param.action : "main"; - var target = param.target ? ('target="' + param.target + '" ') : ''; - var obj = this.getParentPrototype (); - if (obj!=null) { - obj = this.inheritanceUtil (obj, param); - } - if (param.deep=="true") { - while (obj!=null) { - obj = this.inheritanceUtil (obj, param); - } - } +function inheritance_macro(param) { + var action = param.action ? param.action : "main"; + var target = param.target ? ('target="' + param.target + '" ') : ''; + var obj = this.getParentPrototype(); + if (obj != null) { + obj = this.inheritanceUtil(obj, param); + } + if (param.deep == "true") { + while (obj != null) { + obj = this.inheritanceUtil(obj, param); + } + } } -function inheritanceUtil (obj, param) { - if (obj.getName ()=="hopobject" && param.hopobject!="true") - return null; - var tmp = new Object (); - for (var i in param) - tmp[i] = param[i]; - tmp.href = obj.href ((param.action) ? param.action : "main"); - delete tmp.hopobject; - delete tmp.action; - delete tmp.deep; - delete tmp.separator; - res.write (renderLinkTag (tmp)); - res.write (obj.getName () + ""); - if (obj.getParentPrototype ()) - res.write (param.separator); - return obj.getParentPrototype (); +function inheritanceUtil(obj, param) { + if (obj.getName() == "hopobject" && param.hopobject != "true") + return null; + var tmp = new Object (); + for (var i in param) + tmp[i] = param[i]; + tmp.href = obj.href((param.action) ? param.action : "main"); + delete tmp.hopobject; + delete tmp.action; + delete tmp.deep; + delete tmp.separator; + res.write(renderLinkTag(tmp)); + res.write(obj.getName() + ""); + if (obj.getParentPrototype()) + res.write(param.separator); + return obj.getParentPrototype(); } @@ -94,15 +108,15 @@ function inheritanceUtil (obj, param) { * if it has got any functions. * @param skin */ -function parentPrototype_macro (param) { - var skinname = (param.skin) ? param.skin : "asParentList"; - var obj = this.getParentPrototype (); - while (obj!=null) { - if (obj.listChildren ().length>0) { - obj.renderSkin (skinname); - } - obj = obj.getParentPrototype (); - } +function parentPrototype_macro(param) { + var skinname = (param.skin) ? param.skin : "asParentList"; + var obj = this.getParentPrototype(); + while (obj != null) { + if (obj.listChildren().length > 0) { + obj.renderSkin(skinname); + } + obj = obj.getParentPrototype(); + } } /** @@ -110,33 +124,42 @@ function parentPrototype_macro (param) { * type-properties or not. * @param skin */ -function typeProperties_macro (param) { - var props = this.getTypeProperties (); - if (props!=null && props.getContent ()!="" ) { - var sb = new java.lang.StringBuffer (); - // map of all mappings.... - var mappings = props.getMappings (); - // parse type.properties linewise: - var arr = props.getContent ().split ("\n"); - for (var i=0; i' + arr[i] + ''; - } - } - } - sb.append (arr[i] + "\n"); - } - var tmp = new Object (); - tmp.content = sb.toString (); - var skinname = (param.skinname) ? param.skinname : "typeproperties"; - this.renderSkin (skinname, tmp); - } +function typeProperties_macro(param) { + var props = this.getTypeProperties(); + var iter = props.getResources(); + while (iter.hasNext()) { + var tmp = this.renderTypePropertiesResource(iter.next(), props); + var skinname = (param.skinname) ? param.skinname : "typeproperties"; + this.renderSkin(skinname, tmp); + } +} + +function renderTypePropertiesResource(res, props) { + if (res.getContent() != "") { + var sb = new java.lang.StringBuffer (); + // map of all mappings.... + var mappings = props.getMappings(); + // parse type.properties linewise: + var arr = res.getContent().split("\n"); + for (var i = 0; i < arr.length; i++) { + arr [i] = arr[i].trim(); + // look up in mappings table if line matches: + for (var e = mappings.keys(); e.hasMoreElements();) { + var key = e.nextElement(); + var reg = new RegExp ('^' + key + '\\s'); + if (arr[i].match(reg)) { + // it matched, wrap line in a link to that prototype: + var docProtoObj = this.getApplication().getPrototype(mappings.getProperty(key)); + if (docProtoObj != null) { + arr[i] = '' + arr[i] + ''; + } + } + } + sb.append(arr[i] + "\n"); + } + var tmp = new Object (); + tmp.content = sb.toString(); + tmp.source = res.getName(); + return tmp; + } } diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin index 318ffaed..afaf2ab8 100644 --- a/DocPrototype/main.skin +++ b/DocPrototype/main.skin @@ -11,7 +11,6 @@ FUNCTIONS | MACROS | SKINS | -TEMPLATES | TYPE.PROPERTIES

    @@ -62,9 +61,9 @@ %> <% this.methods separator="
    " - filter="templates" - skin="asLargeListItem" - prefix="" + filter="properties" + skin="asLargeListItemSkin" + prefix="" suffix=" %> @@ -73,7 +72,7 @@

    -<% this.typeProperties %> + diff --git a/DocPrototype/typeproperties.skin b/DocPrototype/typeproperties.skin index 2a0ffd32..e1975b32 100644 --- a/DocPrototype/typeproperties.skin +++ b/DocPrototype/typeproperties.skin @@ -1,6 +1,6 @@
    Username and password for helma's manager:

    Please choose an username and password combination to access the -manage application of this server. They will be appended md5-encoded -to the server.properties file. You can change the settings manually -by editing the server.properties file or through this webinterface -in manage/makekey (from localhost only!).

    -

    This is a stupid script and doesn't check wheter these properties -are already set in this file. So if you've already set username and -password you need to delete the old values manually.

    +manage application of this server. They will be printed md5-encoded +in a format that you've got to copy/paste into the server.properties +file.

    <% param.msg %>
    (username)
    - (password)
    - (password retyped)

    -
    + (password)
    +

    Warning: The used http-authorization transmits username and password diff --git a/Root/makekey.hac b/Root/makekey.hac index 4800e2e4..edcf8857 100644 --- a/Root/makekey.hac +++ b/Root/makekey.hac @@ -1,10 +1,3 @@ - -//// strictly limit access to localhost: -//if ( req.data.http_remotehost!="localhost" && req.data.http_remotehost!="127.0.0.1" ) { -// app.logEvent( req.data.http_remotehost + " tried to access makekey"); -// return; -//} - if ( checkAuth()==false ) return; From 917502ba56ac5989084010dee0d0cb82f0ebdde3 Mon Sep 17 00:00:00 2001 From: stefanp Date: Fri, 22 Nov 2002 14:29:28 +0000 Subject: [PATCH 46/82] use higher request timeout because rendering the apidocs might take more than one minute on a slow computer --- app.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app.properties b/app.properties index 267d3c92..d8232b4f 100644 --- a/app.properties +++ b/app.properties @@ -3,3 +3,8 @@ # A short description of what this application is about: _description = Helma's server management console. Start applications, introspection etc. + +# use higher request timeout because rendering the apidocs +# might take more than one minute on a slow computer +requestTimeout = 300 + From c709dd4c59f614aba3b4d51e60d52b6fb194399e Mon Sep 17 00:00:00 2001 From: stefanp Date: Fri, 22 Nov 2002 14:31:28 +0000 Subject: [PATCH 47/82] server password is now encoded as one single entry in server.properties (adminAccess instead of adminUsername+adminPassword) --- Global/functions.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index b77db3dc..d56f4731 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -108,10 +108,9 @@ function checkAuth(appObj) { var ok = false; // check against root - var rootUsername = root.getProperty("adminusername"); - var rootPassword = root.getProperty("adminpassword"); + var adminAccess = root.getProperty("adminAccess"); - if ( rootUsername==null || rootUsername=="" || rootPassword==null || rootPassword=="" ) { + if (adminAccess==null || adminAccess=="") { return createAuth(); } @@ -121,10 +120,9 @@ function checkAuth(appObj) { if ( uname==null || uname=="" || pwd==null || pwd=="" ) return forceAuth(); - var md5username = Packages.helma.util.MD5Encoder.encode(uname); - var md5password = Packages.helma.util.MD5Encoder.encode(pwd); + var md5key = Packages.helma.util.MD5Encoder.encode(uname + "-" + pwd); - if ( md5username==rootUsername && md5password==rootPassword ) + if (md5key==adminAccess) return true; if (appObj!=null && appObj.isActive()) { @@ -200,9 +198,9 @@ function createAuth() { renderSkin("pwdform",obj); return false; } - var str = "adminUsername=" + Packages.helma.util.MD5Encoder.encode(req.data.username) + "
    \n"; - str += "adminPassword=" + Packages.helma.util.MD5Encoder.encode(req.data.password) + "
    "; + var str = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
    \n"; res.write ("

    " + str + "
    "); + return false; } else { // no input from webform, so print it From 4505fb1ffc19fa18b72a28d4a26a3a5bf2e9ef78 Mon Sep 17 00:00:00 2001 From: stefanp Date: Fri, 22 Nov 2002 14:32:46 +0000 Subject: [PATCH 48/82] - click on showApi-button calls docapplication/read_action to re-read the application each time a user enters the doc-frameset. - function docfiles aren't stored in their own directory each but moved up to the prototype directory, further regex-parsing of the resuting html-code necessary --- Application/head.skin | 2 +- Application/navig_active.skin | 2 +- DocApplication/actions.js | 9 +++++++-- DocApplication/functions.js | 21 ++++++++++++--------- 4 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Application/head.skin b/Application/head.skin index 1a5b8604..539aac0e 100644 --- a/Application/head.skin +++ b/Application/head.skin @@ -2,7 +2,7 @@ <% this.description prefix="
    " %>
    -> - /main">showAPI | + /read">showAPI | /render">renderAPI | public | ?app=<% this.title %>&action=flush">flush | diff --git a/Application/navig_active.skin b/Application/navig_active.skin index c35d2472..3c24b3bf 100644 --- a/Application/navig_active.skin +++ b/Application/navig_active.skin @@ -6,7 +6,7 @@ - +
    - /main">showAPI | + /read">showAPI | /render">renderAPI | public | ?app=<% this.title %>&action=flush">flush | diff --git a/DocApplication/actions.js b/DocApplication/actions.js index c80a63ff..1087d246 100644 --- a/DocApplication/actions.js +++ b/DocApplication/actions.js @@ -1,3 +1,8 @@ +function read_action () { + this.readApplication (); + res.redirect (this.href("main")); +} + function main_action () { if (checkAddress()==false) return; @@ -44,7 +49,7 @@ function render_action () { return; res.writeln("renderrendering API ... "); var prefix = this.href (""); - this.storePage (this, "main"); + this.storePage (this, "main", "", "index.html"); this.storePage (this, "prototypes"); this.storePage (this, "summary"); this.storePage (this, "functionindex"); @@ -56,7 +61,7 @@ function render_action () { ct += 2; var subarr = arr[i].listChildren (); for (var j=0; j Date: Mon, 2 Dec 2002 12:18:15 +0000 Subject: [PATCH 49/82] added getPrototype (string) --- DocApplication/functions.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/DocApplication/functions.js b/DocApplication/functions.js index 3de8ba86..88908e71 100644 --- a/DocApplication/functions.js +++ b/DocApplication/functions.js @@ -1,5 +1,7 @@ - +/** + * 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) { @@ -8,6 +10,15 @@ function getDocPrototype (obj) { 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); +} + + function getDir (dir, obj) { dir.mkdir (); if (obj.getType () == this.APPLICATION) { From c52925d41427fc292a372a787bbc832b08020634 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 2 Dec 2002 12:18:59 +0000 Subject: [PATCH 50/82] added getApplication () --- DocPrototype/functions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/DocPrototype/functions.js b/DocPrototype/functions.js index c0bb39c9..020052d2 100644 --- a/DocPrototype/functions.js +++ b/DocPrototype/functions.js @@ -27,3 +27,8 @@ function translateType (filter) { } +function getApplication () { + return this.getParentElement (); +} + + From 428b1ab1efc7c51eb44f4d5280502b4e3f233094 Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 2 Dec 2002 12:19:36 +0000 Subject: [PATCH 51/82] type.properties are now parsed, mappings to other prototypes are linked --- DocPrototype/macros.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index b7f852e1..f47045bc 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -113,10 +113,28 @@ function parentPrototype_macro (param) { function typeProperties_macro (param) { var props = this.getTypeProperties (); if (props!=null && props.getContent ()!="" ) { + var sb = new java.lang.StringBuffer (); + // map of all mappings.... + var mappings = props.getMappings (); + // parse type.properties linewise: + var arr = props.getContent ().split ("\n"); + for (var i=0; i' + arr[i] + ''; + } + } + sb.append (arr[i] + "\n"); + } var tmp = new Object (); - tmp.content = props.getContent (); + tmp.content = sb.toString (); var skinname = (param.skinname) ? param.skinname : "typeproperties"; this.renderSkin (skinname, tmp); } } - From 1f9846f157bf4c17419f316783f3b30fa3405f9a Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 2 Dec 2002 12:23:19 +0000 Subject: [PATCH 52/82] two formatting fixes --- DocPrototype/list.skin | 2 +- DocPrototype/macros.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DocPrototype/list.skin b/DocPrototype/list.skin index afb66787..b9a23cc5 100644 --- a/DocPrototype/list.skin +++ b/DocPrototype/list.skin @@ -1,4 +1,4 @@ -

    Prototype " target="main"><% this.name %>

    +Prototype " target="main"><% this.name %>
    <% this.inheritance action="list" %> <% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="
    " %>
    diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index f47045bc..53472148 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -123,7 +123,7 @@ function typeProperties_macro (param) { // look up in mappings table if line matches: for (var e = mappings.keys (); e.hasMoreElements (); ) { var key = e.nextElement (); - var reg = new RegExp ('^' + key + '\\W'); + var reg = new RegExp ('^' + key + '\\s'); if (arr[i].match (reg)) { // it matched, wrap line in a link to that prototype: var docProtoObj = this.getApplication ().getPrototype (mappings.getProperty (key)); From 544c791ddc78de9e8ca96dcc6a13c5da5714d525 Mon Sep 17 00:00:00 2001 From: stefanp Date: Wed, 4 Dec 2002 09:21:40 +0000 Subject: [PATCH 53/82] - moved key-generation from a global function to root/makekey.hac - added a nice feedback skin --- Global/functions.js | 44 +---------------------------------------- Global/pwdfeedback.skin | 20 +++++++++++++++++++ Root/makekey.hac | 32 ++++++++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 45 deletions(-) create mode 100644 Global/pwdfeedback.skin diff --git a/Global/functions.js b/Global/functions.js index d56f4731..b7c895e9 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -111,7 +111,7 @@ function checkAuth(appObj) { var adminAccess = root.getProperty("adminAccess"); if (adminAccess==null || adminAccess=="") { - return createAuth(); + res.redirect (root.href ("makekey")); } var uname = req.username; @@ -172,48 +172,6 @@ function forceAuth(realm) { - -/** - * response is either a html form to enter auth data or input from - * html form is saved to server.properties - * access is only allowed if remote host is in the list of friendly - * ip-adresses in server.properties - */ -function createAuth() { - if ( checkAddress()!=true ) { - // double check - return false; - } - var obj = new Object(); - obj.msg = ""; - if (req.data.username!=null && req.data.password!=null) { - // we have input from webform - if ( req.data.username=="" ) - obj.msg += "username can't be left empty!
    "; - if ( req.data.password=="" ) - obj.msg += "password can't be left empty!
    "; - if ( obj.msg!="" ) { - obj.username = req.data.username; - res.reset(); - renderSkin("pwdform",obj); - return false; - } - var str = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
    \n"; - res.write ("
    " + str + "
    "); - return false; - - } else { - // no input from webform, so print it - res.reset(); - res.data.title = "username & password on " + root.hostname_macro(); - res.data.head = renderSkinAsString("head"); - res.data.body = renderSkinAsString("pwdform",obj); - renderSkin("basic"); - return false; - } -} - - /** * macro-utility: formatting property lists */ diff --git a/Global/pwdfeedback.skin b/Global/pwdfeedback.skin new file mode 100644 index 00000000..f5003a67 --- /dev/null +++ b/Global/pwdfeedback.skin @@ -0,0 +1,20 @@ + + + + + +
    + +Generated username and password for helma's manager:
    + +

    Please copy/paste this line into the server.properties file of your +helma installation.

    + +
    <% param.propsString %>
    + +

    After that proceed to ">the manage console, +enter your credentials and you should be allowed in.

    + +
    + + diff --git a/Root/makekey.hac b/Root/makekey.hac index edcf8857..6eb739fb 100644 --- a/Root/makekey.hac +++ b/Root/makekey.hac @@ -1,5 +1,33 @@ -if ( checkAuth()==false ) + +if (checkAddress()==false) return; -createAuth(); +var obj = new Object(); +obj.msg = ""; +if (req.data.username!=null && req.data.password!=null) { + + // we have input from webform + if ( req.data.username=="" ) + obj.msg += "username can't be left empty!
    "; + if ( req.data.password=="" ) + obj.msg += "password can't be left empty!
    "; + if ( obj.msg!="" ) { + obj.username = req.data.username; + res.reset(); + res.data.body = renderSkinAsString ("pwdform",obj); + } else { + // render the md5-string: + obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
    \n"; + res.data.body = renderSkinAsString ("pwdfeedback", obj); + } +} else { + + // no input from webform, so print it + res.data.body = renderSkinAsString("pwdform",obj); + +} + +res.data.title = "username & password on " + root.hostname_macro(); +res.data.head = renderSkinAsString("head"); +renderSkin("basic"); From d5add243c7204524f7258c2b32e504b8e42d716b Mon Sep 17 00:00:00 2001 From: stefanp Date: Wed, 4 Dec 2002 09:35:09 +0000 Subject: [PATCH 54/82] render_action: fixed problem with regex parsing of links with anchors --- DocApplication/functions.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DocApplication/functions.js b/DocApplication/functions.js index 88908e71..aa586d6e 100644 --- a/DocApplication/functions.js +++ b/DocApplication/functions.js @@ -55,12 +55,13 @@ function getPage (obj, action, backPath) { var str = res.popStringBuffer (); // get the baseURI out of the url and replace // it with the given relative prefix - var reg = new RegExp ("href=\"" + this.href ("") + "([^\"]+)\""); + // (keep anchors in regex!) + var reg = new RegExp ("href=\"" + this.href ("") + "([^\"#]+)([^\"]*)\""); reg.global = true; - str = str.replace (reg, "href=\"" + backPath + "$1.html\""); - var reg = new RegExp ("src=\"" + this.href ("") + "([^\"]+)\""); + str = str.replace (reg, "href=\"" + backPath + "$1.html$2\""); + var reg = new RegExp ("src=\"" + this.href ("") + "([^\"#]+)([^\"]*)\""); reg.global = true; - str = str.replace (reg, "src=\"" + backPath + "$1.html\""); + 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"); From 862cdef847c38a43ac20c4eba74d61c1ae3990e2 Mon Sep 17 00:00:00 2001 From: stefanp Date: Wed, 4 Dec 2002 09:35:34 +0000 Subject: [PATCH 55/82] fixed problem with type.properties pointing to non-existing prototypes --- DocPrototype/macros.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DocPrototype/macros.js b/DocPrototype/macros.js index 53472148..7ffbaed9 100644 --- a/DocPrototype/macros.js +++ b/DocPrototype/macros.js @@ -127,7 +127,9 @@ function typeProperties_macro (param) { if (arr[i].match (reg)) { // it matched, wrap line in a link to that prototype: var docProtoObj = this.getApplication ().getPrototype (mappings.getProperty (key)); - arr[i] = '' + arr[i] + ''; + if (docProtoObj!=null) { + arr[i] = '' + arr[i] + ''; + } } } sb.append (arr[i] + "\n"); From 6b534edeab7382d69d49d33aedb91ec691e72d70 Mon Sep 17 00:00:00 2001 From: stefanp Date: Wed, 4 Dec 2002 09:36:21 +0000 Subject: [PATCH 56/82] - included link to manage console (but not if pages are rendered to static html) - nicer feedback after rendering --- DocApplication/actions.js | 10 ++++++++-- DocApplication/macros.js | 7 +++++++ DocApplication/prototypes.skin | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/DocApplication/actions.js b/DocApplication/actions.js index 1087d246..f071ac99 100644 --- a/DocApplication/actions.js +++ b/DocApplication/actions.js @@ -43,11 +43,13 @@ function functionindex_action () { 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; - res.writeln("renderrendering API ... "); var prefix = this.href (""); this.storePage (this, "main", "", "index.html"); this.storePage (this, "prototypes"); @@ -65,5 +67,9 @@ function render_action () { ct += 1; } } - res.writeln (" ... wrote " + ct + " files"); + res.data.body = 'rendering API ...
    wrote ' + ct + ' files

    '; + res.data.body += 'back to manage console'; + res.data.title = "rendering helma api"; + res.data.head = renderSkinAsString("head"); + renderSkin ("basic"); } diff --git a/DocApplication/macros.js b/DocApplication/macros.js index f7b78ccd..daccf992 100644 --- a/DocApplication/macros.js +++ b/DocApplication/macros.js @@ -24,6 +24,13 @@ function link_macro (param) { return renderLink (this, param); } //// END OF COPIED FUNCTIONS + +function linkToManage_macro (param) { + if (res.data.rendering != true) { + return ('back to manage console'); + } +} + function headline_macro (param) { res.write (this.getName ()); } diff --git a/DocApplication/prototypes.skin b/DocApplication/prototypes.skin index cdbcc472..2ff758fb 100644 --- a/DocApplication/prototypes.skin +++ b/DocApplication/prototypes.skin @@ -1,4 +1,4 @@ - +<% this.linkToManage suffix="

    " %> Application " target="main"><% this.name %>

    From c3e422c8ecc969759bee0adc2dbf014c19780c3a Mon Sep 17 00:00:00 2001 From: stefanp Date: Wed, 4 Dec 2002 10:07:35 +0000 Subject: [PATCH 57/82] updated to latest changes --- readme.txt | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/readme.txt b/readme.txt index 74e2e6c3..180a849d 100644 --- a/readme.txt +++ b/readme.txt @@ -1,25 +1,17 @@ To get the manage-application to work you must: - add it to the apps.properties file with the following line: - manage - - use snapshot 20020326 or later. + - use helma distribution 1.2-RC1 or later. - add the following properties to server.properties: - allowAdmin=[comma-separated list of hosts or ip-addresses that - are allowed to access this application, wildcards - are only allowed in addresses, not in hostnames] - adminUsername= - adminPassword= + allowAdmin = [comma-separated list of hosts or ip-addresses that + are allowed to access this application. wildcards + are only allowed in addresses, not in hostnames!] + adminAccess = - MD5-encoding can be done - once you've got the application - up and running - on the web: - - http:///manage/makekey - http:///base/makekey - - or you can use a shell-tool integrated in helma: - java -classpath helma.jar helma.util.MD5Encoder + Creating the credentials can be done after you've got the application + up and running at this address: http:///manage/makekey From 23c6c02b5c427396642108f9468ce2892cd9d872 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 16 Apr 2003 14:21:21 +0000 Subject: [PATCH 58/82] Use password input field for password in manage/makekey --- Global/pwdform.skin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Global/pwdform.skin b/Global/pwdform.skin index 20eb1a01..79b7c602 100644 --- a/Global/pwdform.skin +++ b/Global/pwdform.skin @@ -14,7 +14,7 @@ file.

    <% param.msg %>
    (username)
    - (password)
    + (password)

    From 710631429efb2dc185ea4cc1a53badd65872846d Mon Sep 17 00:00:00 2001 From: stefanp Date: Mon, 23 Jun 2003 15:03:34 +0000 Subject: [PATCH 59/82] replaced tryEval with try/catch --- Global/functions.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index b7c895e9..86db57d5 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -30,14 +30,16 @@ function createAddressFilter() { var arr = str.split(","); for ( var i in arr ) { var str = new java.lang.String(arr[i]); - var result = tryEval("filter.addAddress(str.trim());"); - if ( result.error!=null ) { - var str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); - var result = tryEval("filter.addAddress(str);"); - } - if ( result.error==null ) { - app.log( "allowed address for app manage: " + str ); - } + try { + filter.addAddress(str.trim()); + } catch (a) { + try { + var str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); + filter.addAddress (str); + } catch (b) { + app.log ("error using address " + arr[i] + ": " + b); + } + } } } else { app.log("no addresses allowed for app manage, all access will be denied"); From d42fa491704bdc1066b3d63f49244d9953a62c61 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 24 Jun 2003 14:43:40 +0000 Subject: [PATCH 60/82] modified to work with type-definition by strings and not by constants --- Global/renderFunctions.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js index 84731b8b..7381c031 100644 --- a/Global/renderFunctions.js +++ b/Global/renderFunctions.js @@ -74,26 +74,18 @@ function renderLocation (docEl, param) { */ function renderTags (docEl, param) { var skinname = (param.skin) ? param.skin : "main"; - var type = -1; - if (param.type=="param" || param.type=="params") - type = Packages.helma.doc.DocTag.PARAMETER; - else if (param.type=="return" || param.type=="returns") - type = Packages.helma.doc.DocTag.RETURN; - else if (param.type=="author") - type = Packages.helma.doc.DocTag.AUTHOR; - else if (param.type=="version") - type = Packages.helma.doc.DocTag.VERSION; - else if (param.type=="see") - type = Packages.helma.doc.DocTag.SEE; - else if (param.type=="deprecated") - type = Packages.helma.doc.DocTag.DEPRECATED; - else if (param.type=="overrides") - type = Packages.helma.doc.DocTag.OVERRIDES; + var type = param.type; + if (type=="params") + type = "param"; + else if (type=="returns") + type = "return"; + else if (type=="arg") + type = "param"; var str = ""; var arr = docEl.listTags (); for (var i=0; i Date: Thu, 6 Nov 2003 15:09:36 +0000 Subject: [PATCH 61/82] Adapt function line number output to changes in HtmlEncoder which adds line separators after the
    rather than before. --- DocFunction/macros.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/DocFunction/macros.js b/DocFunction/macros.js index 7eb66819..2f674bec 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -109,7 +109,11 @@ function source_macro(par) { str4 += '' + (i+1) + ': ' if (i<99) str4+=' '; if (i<9) str4+=' '; - str4 += arr[i] + "
    "; + // Hack: remove leading returns/line feeds in each line + while (arr[i].length>0 && + (arr[i][0] == '\n' || arr[i][0] == '\r')) + arr[i] = arr[i].substring(1); + str4 += arr[i] + "
    "; } return ( str4 ); } From 08d3a944295a5406405c6598d08015502201e0d8 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 6 Jan 2004 15:47:22 +0000 Subject: [PATCH 62/82] moved the actual rendering part in render_action into functions.js --- DocApplication/actions.js | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/DocApplication/actions.js b/DocApplication/actions.js index f071ac99..573947a5 100644 --- a/DocApplication/actions.js +++ b/DocApplication/actions.js @@ -46,29 +46,13 @@ 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 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
    '; - res.data.body += 'back to manage console'; + if (checkAddress()==false) + return; + if (checkAuth(this.getParentElement ())==false) + return; + var ct = this.renderApi(); + res.data.body = 'rendering API ...
    wrote ' + ct + ' files

    '; + res.data.body += 'back to manage console'; res.data.title = "rendering helma api"; res.data.head = renderSkinAsString("head"); renderSkin ("basic"); From 98ad7be09b8661f0b7b78842014eae13d49556a0 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 6 Jan 2004 15:50:29 +0000 Subject: [PATCH 63/82] added function renderApi() which renders the whole application docs into files. used via webinterface or commandline. changed RegExp: rhino needs global setting as second param in constructor --- DocApplication/functions.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/DocApplication/functions.js b/DocApplication/functions.js index aa586d6e..14393695 100644 --- a/DocApplication/functions.js +++ b/DocApplication/functions.js @@ -31,6 +31,27 @@ function getDir (dir, obj) { } } +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 Date: Tue, 6 Jan 2004 15:51:12 +0000 Subject: [PATCH 64/82] supress security checks if accessed from commandline - setting via res.data.noWeb --- Global/functions.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Global/functions.js b/Global/functions.js index 86db57d5..4d3740bb 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -107,6 +107,9 @@ function sortProps(a,b) { * @arg appObj application object to check against (if adminUsername etc are set in app.properties) */ function checkAuth(appObj) { + if (res && res.data.noWeb==true) { + return true; + } var ok = false; // check against root @@ -142,6 +145,9 @@ function checkAuth(appObj) { * check access to the manage-app by ip-addresses */ function checkAddress() { + if (res && res.data.noWeb==true) { + return true; + } // if allowadmin value in server.properties has changed, // re-construct the addressFilter if (app.data.addressString != root.getProperty ("allowadmin")){ From e8e2c7098a88bd79c8f7e018a1344e7a0f492252 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 6 Jan 2004 15:55:39 +0000 Subject: [PATCH 65/82] added function renderApi(appName) which can be used from commandline --- Root/functions.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Root/functions.js b/Root/functions.js index 342e79ea..b5c26f9e 100644 --- a/Root/functions.js +++ b/Root/functions.js @@ -1,10 +1,26 @@ /** - * of no use, just to avoid error message + * renders the api of a given application. used from commandline. */ -function onRequest () { +function renderApi(appName) { + + // supress security checks when accessing actions + res.data.noWeb = true; + + // start the application + this.startApplication(appName); + var appObj = this.getApp(appName); + var docApp = appObj.getChildElement("api"); + + // now render the api + var ct = docApp.renderApi(); + writeln("rendered " + ct + " files"); + + // cleanup + this.stopApplication(appName); } + /** * lists all applications in appdir. * for active apps use this.getApplications() = helma.main.Server.getApplications() From 265fc2bf77a2ba1360bd0f6de0b8a9a1b9ea6a28 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 13 Apr 2004 08:35:15 +0000 Subject: [PATCH 66/82] don't encode type.properties content to avoid double blank lines --- DocPrototype/typeproperties.skin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DocPrototype/typeproperties.skin b/DocPrototype/typeproperties.skin index 4eead93f..2a0ffd32 100644 --- a/DocPrototype/typeproperties.skin +++ b/DocPrototype/typeproperties.skin @@ -3,7 +3,7 @@
    type.properties
    <% param.content encoding="html" %>
    <% param.content %>
    From 2c907f75c86085fb9cad15aba211ecae677b7c95 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 13 Apr 2004 08:37:02 +0000 Subject: [PATCH 67/82] removed space between functionname and params --- Global/renderFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js index 7381c031..ad6862f5 100644 --- a/Global/renderFunctions.js +++ b/Global/renderFunctions.js @@ -15,7 +15,7 @@ function renderLink (docEl, param) { text += str.substring (0, str.length-6); } } else if (docEl.getType () == docEl.FUNCTION) { - var text = docEl.getName () + " ("; + var text = docEl.getName () + "("; var arr = docEl.listParameters (); for (var i=0; i Date: Tue, 13 Apr 2004 08:37:38 +0000 Subject: [PATCH 68/82] changed macro sourcecode to work with regexp and added more syntax highlighting --- DocFunction/macros.js | 71 ++++++++++++++++++++++++++----------------- DocFunction/main.skin | 2 +- 2 files changed, 44 insertions(+), 29 deletions(-) diff --git a/DocFunction/macros.js b/DocFunction/macros.js index 2f674bec..ed2c1354 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -87,35 +87,50 @@ function type_macro (param) { * macro returning nicely formatted sourcecode of this method. * code is encoded, >% %<-tags are colorcoded, line numbers are added */ -function source_macro(par) { - var str = this.getContent (); - var arr = str.split("<%"); - var str2 = ""; - for ( var i=0; i<%'); + + r = new RegExp("%>","gim"); + sourcecode = sourcecode.replace(r, '%>'); + + // highlight js-comments + r = new RegExp("^([ \\t]*//.*)", "gm"); + sourcecode = sourcecode.replace(r, '$1'); + + // highlight quotation marks, but not for skins + if (this.getTypeName() != "Skin") { + r = new RegExp("(".*?")", "gm"); + sourcecode = sourcecode.replace(r, '$1'); + r = new RegExp("(\'[\']*\')", "gm"); + sourcecode = sourcecode.replace(r, '$1'); + } + + // remove all CR and LF, just
    remains + var r = new RegExp("[\\r\\n]","gm"); + sourcecode = sourcecode.replace(r, ""); + + var arr = sourcecode.split("
    "); + for (var i=0; i' + (i+1) + ': '); + if (i<99) { + res.write(' '); + } + if (i<9) { + res.write(' '); + } + res.write(arr[i] + "\n"); + } + + } else { + res.write(sourcecode); } - var arr = str2.split("%>"); - var str3 = ""; - for ( var i=0; i"); - var str4 = ""; - for ( var i=0; i ' - if (i<99) str4+=' '; - if (i<9) str4+=' '; - // Hack: remove leading returns/line feeds in each line - while (arr[i].length>0 && - (arr[i][0] == '\n' || arr[i][0] == '\r')) - arr[i] = arr[i].substring(1); - str4 += arr[i] + "
    "; - } - return ( str4 ); } diff --git a/DocFunction/main.skin b/DocFunction/main.skin index f9546829..da43ed06 100644 --- a/DocFunction/main.skin +++ b/DocFunction/main.skin @@ -24,7 +24,7 @@ From af52a36f3da8083c2669c55b7d7de56d603474a9 Mon Sep 17 00:00:00 2001 From: stefanp Date: Tue, 13 Apr 2004 15:40:27 +0000 Subject: [PATCH 69/82] check for prototype root or Root in hrefRoot_macro --- DocApplication/macros.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DocApplication/macros.js b/DocApplication/macros.js index daccf992..b93ee674 100644 --- a/DocApplication/macros.js +++ b/DocApplication/macros.js @@ -39,6 +39,9 @@ function headline_macro (param) { 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); From f1b50186fbc3ad6c8f86c2876423456e4e4c1f50 Mon Sep 17 00:00:00 2001 From: p3k Date: Wed, 28 Apr 2004 11:09:39 +0000 Subject: [PATCH 70/82] fixed bug that caused exception with wront access credentials --- Global/functions.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Global/functions.js b/Global/functions.js index 4d3740bb..6f506f3d 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -132,10 +132,9 @@ function checkAuth(appObj) { if (appObj!=null && appObj.isActive()) { // check against application - var appUsername = appObj.getProperty("adminusername"); - var appPassword = appObj.getProperty("adminpassword"); - if ( md5username==appUsername && md5password==appPassword ) - return true; + adminAccess = appObj.getProperty("adminAccess"); + if (md5key==adminAccess) + return true; } return forceAuth(); } From c632c8f8bd19721e0b77a7abe52e912d2d749bfd Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 30 Aug 2005 11:06:07 +0000 Subject: [PATCH 71/82] * Always render full file path because sources may be scattered in different repositories. --- Global/renderFunctions.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js index ad6862f5..2b7c4057 100644 --- a/Global/renderFunctions.js +++ b/Global/renderFunctions.js @@ -57,11 +57,8 @@ function renderLinkTag (param) { */ function renderLocation (docEl, param) { var f = docEl.getLocation (); - if (f.isDirectory ()) - return f.getName (); - else { - return f.getParentFile ().getName () + "/" + f.getName (); - } + // with repositories, always display full file path + return f.getAbsolutePath(); } From 437dfb94d3adab49d5176680d5998c5ef29de1e3 Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 31 Aug 2005 13:16:21 +0000 Subject: [PATCH 72/82] * Bring manage app up to date with current Helma. --- Application/actions.js | 67 +++++++ Application/functions.js | 25 ++- Application/macros.js | 176 +++++++++--------- Application/main.hac | 12 -- Application/main.skin | 4 +- Application/mrtg.hac | 42 ----- Application/redirectpublic.hac | 10 - DocApplication/actions.js | 88 ++++----- DocApplication/functions.js | 135 +++++++------- DocApplication/macros.js | 127 +++++++------ DocFunction/actions.js | 14 +- DocFunction/macros.js | 170 +++++++++-------- DocPrototype/actions.js | 28 +-- DocPrototype/asParentList.skin | 1 - DocPrototype/functions.js | 32 ++-- DocPrototype/list.skin | 1 - DocPrototype/macros.js | 225 ++++++++++++----------- DocPrototype/main.skin | 9 +- DocPrototype/typeproperties.skin | 2 +- Global/functions.js | 303 +++++++++++++++---------------- Global/macros.js | 12 +- Global/navig.skin | 4 +- Global/renderFunctions.js | 264 +++++++++++++-------------- Root/actions.js | 130 +++++++++++++ Root/functions.js | 39 ++-- Root/image.hac | 11 -- Root/macros.js | 273 ++++++++++++++-------------- Root/main.hac | 44 ----- Root/makekey.hac | 33 ---- Root/mrtg.hac | 37 ---- app.properties | 4 +- class.properties | 13 +- readme.txt | 2 +- 33 files changed, 1185 insertions(+), 1152 deletions(-) create mode 100644 Application/actions.js delete mode 100644 Application/main.hac delete mode 100644 Application/mrtg.hac delete mode 100644 Application/redirectpublic.hac create mode 100644 Root/actions.js delete mode 100644 Root/image.hac delete mode 100644 Root/main.hac delete mode 100644 Root/makekey.hac delete mode 100644 Root/mrtg.hac diff --git a/Application/actions.js b/Application/actions.js new file mode 100644 index 00000000..ddbedc75 --- /dev/null +++ b/Application/actions.js @@ -0,0 +1,67 @@ +/** +* renders AppManager +*/ +function main_action() { + if (checkAddress() == false) + return; + if (checkAuth(this) == false) + return; + + res.data.body = this.renderSkinAsString("main"); + renderSkin("global"); +} + + +/** +* prints session- and thread-stats for mrtg-tool +* doesn't check username or password, so that we don't have +* to write them cleartext in a mrtg-configfile but checks the +* remote address. +*/ +function mrtg_action() { + if (checkAddress() == false) + return; + + if (this.isActive() == false) { + res.write("0\n0\n0\n0\n"); + return; + } + + if (req.data.action == "sessions") { + + res.write(this.sessions.size()); + res.write("\n0\n0\n0\n"); + + } else if (req.data.action == "threads") { + + res.write(this.countActiveEvaluators() + "\n"); + res.write(this.countEvaluators() + "\n"); + res.write("0\n0\n"); + + } else if (req.data.action == "cache") { + + res.write(this.getCacheUsage() + "\n"); + res.write(this.getProperty("cachesize", "1000") + "\n"); + res.write("0\n0\n"); + + } else if (req.data.action == "requests") { + + // res.write ( + + } else { + res.write("0\n0\n0\n0\n"); + } + +} + +/** +* performs a redirect to the public site +* (workaround, we can't access application object from docapplication for some reason) +* @see application.url_macro +*/ +function redirectpublic_action() { + if (checkAddress() == false) return; + if (checkAuth(this) == false) return; + + res.redirect(this.url_macro()); +} diff --git a/Application/functions.js b/Application/functions.js index 63d7278f..cdf0af56 100644 --- a/Application/functions.js +++ b/Application/functions.js @@ -1,29 +1,28 @@ - /** - * construct an application object so that we can use - * skins for non-active applications too - * @arg name - */ -function constructor(name) { - this.name = name; +* construct an application object so that we can use +* skins for non-active applications too +* @arg name +*/ +function constructor(name) { + this.name = name; } /** * of no use, just to avoid error message */ -function onRequest () { +function onRequest() { } /** * return true/false to determine if application is running */ -function isActive() { - if ( root.getApplication(this.name)==null ) - return false; - else - return true; +function isActive() { + if (root.getApplication(this.name) == null) + return false; + else + return true; } diff --git a/Application/macros.js b/Application/macros.js index 219a2a86..22c32903 100644 --- a/Application/macros.js +++ b/Application/macros.js @@ -2,10 +2,10 @@ * macro rendering a skin * @param name name of skin */ -function skin_macro(par) { - if ( par && par.name ) { - this.renderSkin(par.name); - } +function skin_macro(par) { + if (par && par.name) { + this.renderSkin(par.name); + } } @@ -13,8 +13,8 @@ function skin_macro(par) { * macro-wrapper for href-function * @param action name of action to call on this prototype, default main */ -function href_macro(par) { - return this.href( (par&&par.action)?par.action:"main" ); +function href_macro(par) { + return this.href((par && par.action) ? par.action : "main"); } @@ -24,12 +24,12 @@ function href_macro(par) { * the application (which is using baseURI if set) */ function url_macro() { - var str = this.getProperty("absoluteuri"); - if ( str!=null && str!="" ) { - return str; - } else { - return this.getRootHref(); - } + var str = this.getProperty("absoluteuri"); + if (str != null && str != "") { + return str; + } else { + return this.getRootHref(); + } } @@ -37,8 +37,8 @@ function url_macro() { * Macro returning the title of an application */ function title_macro() { - var title = this.name; - return(title); + var title = this.name; + return(title); } @@ -49,25 +49,25 @@ function title_macro() { * @param Object Macro parameter object */ function description_macro(param) { - var str = ""; - var appHome = this.getAppDir(); - var f = new File(this.getAppDir().toString(), "description.txt"); - if (!f.exists()) - f = new File(this.getAppDir().toString(), "doc.html"); - if (f.exists()) { - str = f.readAll(); - if (str.length > 200) - str = str.substring(0, 200) + "..."; - } - return(str); + var str = ""; + var appHome = this.getAppDir(); + var f = new File(this.getAppDir().toString(), "description.txt"); + if (!f.exists()) + f = new File(this.getAppDir().toString(), "doc.html"); + if (f.exists()) { + str = f.readAll(); + if (str.length > 200) + str = str.substring(0, 200) + "..."; + } + return(str); } /** * Macro returning the server's uptime nicely formatted */ -function uptime_macro() { - return formatAge( (java.lang.System.currentTimeMillis()-this.starttime) / 1000 ); +function uptime_macro() { + return formatAge((java.lang.System.currentTimeMillis() - this.starttime) / 1000); } @@ -76,11 +76,11 @@ function uptime_macro() { * parameter used by global.formatCount * @see global.formatCount */ -function countSessions_macro(par) { - if ( this.isActive()==true ) - return this.sessions.size() + formatCount(this.sessions.size(),par); - else - return 0; +function countSessions_macro(par) { + if (this.isActive() == true) + return this.sessions.size() + formatCount(this.sessions.size(), par); + else + return 0; } @@ -91,12 +91,12 @@ function countSessions_macro(par) { * @see application.countUsers_macro * @see application.listUsers_macro */ -function users_macro(par) { - if ( req.data.showusers=="true" ) { - this.listUsers_macro(par); - } else { - this.countUsers_macro(par); - } +function users_macro(par) { + if (req.data.showusers == "true") { + this.listUsers_macro(par); + } else { + this.countUsers_macro(par); + } } @@ -106,11 +106,11 @@ function users_macro(par) { * parameter used by global.formatCount * @see global.formatCount */ -function countUsers_macro(par) { - if ( this.isActive()==true ) - return this.activeUsers.size() + formatCount(this.activeUsers.size(),par); - else - return 0; +function countUsers_macro(par) { + if (this.isActive() == true) + return this.activeUsers.size() + formatCount(this.activeUsers.size(), par); + else + return 0; } @@ -118,93 +118,93 @@ function countUsers_macro(par) { * Macro rendering the list of logged-in users if application is active * @param separator html-code written between elements */ -function listUsers_macro(par) { - var separator = (par && par.separator) ? par.separator : ", "; - if ( this.activeUsers.size()==0 ) - return ""; - var e = this.activeUsers.keys(); - while ( e.hasMoreElements() ) { - res.write ( e.nextElement() ); - if ( e.hasMoreElements() ) { - res.write ( separator ); - } - } +function listUsers_macro(par) { + var separator = (par && par.separator) ? par.separator : ", "; + if (this.activeUsers.size() == 0) + return ""; + var users = this.activeUsers.iterator(); + while (users.hasNext()) { + res.write(users.next().__name__); + if (users.hasNext()) { + res.write(separator); + } + } } /** * Macro returning the number of active evaluators (=threads) */ -function countActiveEvaluators_macro() { - return this.countActiveEvaluators(); +function countActiveEvaluators_macro() { + return this.countActiveEvaluators(); } /** * Macro returning the number of free evaluators (=threads) */ -function countFreeEvaluators_macro() { - return this.countFreeEvaluators(); +function countFreeEvaluators_macro() { + return this.countFreeEvaluators(); } /** * Macro returning the current number of objects in the cache */ -function cacheusage_macro (param) { - return this.getCacheUsage (); +function cacheusage_macro(param) { + return this.getCacheUsage(); } /** * Macro returning the number of objects allowed in the cache */ -function cachesize_macro (param) { - return this.getProperty ("cachesize", "1000"); +function cachesize_macro(param) { + return this.getProperty("cachesize", "1000"); } /** * Macro formatting the number of requests in the last 5 minutes */ -function requestCount_macro(par) { - if (app.data.stat==null || app.data.stat.get (this.name)==null) - return "not available"; - if (this.isActive()) { - var obj = app.data.stat.get (this.name); - return obj.requestCount + formatCount (obj.requestCount, par); - } else { - return 0 + formatCount (0,par); - } +function requestCount_macro(par) { + if (app.data.stat == null || app.data.stat[this.name] == null) + return "not available"; + if (this.isActive()) { + var obj = app.data.stat[this.name]; + return obj.requestCount + formatCount(obj.requestCount, par); + } else { + return 0 + formatCount(0, par); + } } /** * Macro formatting the number of errors in the last 5 minutes */ -function errorCount_macro(par) { - if (app.data.stat==null || app.data.stat.get (this.name)==null) - return "not available"; - if (this.isActive()) { - var obj = app.data.stat.get (this.name); - return obj.errorCount + formatCount (obj.errorCount, par); - } else { - return 0 + formatCount (0,par); - } +function errorCount_macro(par) { + if (app.data.stat == null || app.data.stat[this.name] == null) + return "not available"; + if (this.isActive()) { + var obj = app.data.stat[this.name]; + return obj.errorCount + formatCount(obj.errorCount, par); + } else { + return 0 + formatCount(0, par); + } } - - /** - * Macro formatting app.properties - */ -function properties_macro(par) { - formatProperties( this.getProperties(), par ); +* Macro formatting app.properties +*/ +function properties_macro(par) { + formatProperties(this.getProperties(), par); } -function appdir_macro (param) { - return this.getAppDir ().toString (); +function repositories_macro(param) { + var repos = this.getRepositories().iterator(); + while (repos.hasNext()) + res.writeln(repos.next().getName()); } diff --git a/Application/main.hac b/Application/main.hac deleted file mode 100644 index 7faa81af..00000000 --- a/Application/main.hac +++ /dev/null @@ -1,12 +0,0 @@ -/** - * renders AppManager - */ - -if (checkAddress()==false) - return; -if (checkAuth(this)==false) - return; - -res.data.body = this.renderSkinAsString("main"); -renderSkin ("global"); - diff --git a/Application/main.skin b/Application/main.skin index c689c6a9..455e77d2 100644 --- a/Application/main.skin +++ b/Application/main.skin @@ -47,9 +47,9 @@ - + - +
    Sourcecode in <% this.location %>: -
    <% this.source %>
    +
    <% this.source as="highlighted" %>
    <% this.uptime %>
    app directoryrepositories  <% this.appdir %><% this.repositories %>
    diff --git a/Application/mrtg.hac b/Application/mrtg.hac deleted file mode 100644 index b6129f21..00000000 --- a/Application/mrtg.hac +++ /dev/null @@ -1,42 +0,0 @@ - -/** - * prints session- and thread-stats for mrtg-tool - * doesn't check username or password, so that we don't have - * to write them cleartext in a mrtg-configfile but checks the - * remote address. - */ - -if ( checkAddress()==false ) - return; - -if ( this.isActive()==false ) { - res.write ( "0\n0\n0\n0\n"); - return; -} - -if (req.data.action=="sessions") { - - res.write (this.sessions.size()); - res.write ("\n0\n0\n0\n"); - -} else if (req.data.action=="threads") { - - res.write (this.countActiveEvaluators () + "\n"); - res.write (this.countEvaluators () + "\n"); - res.write ("0\n0\n"); - -} else if (req.data.action=="cache") { - - res.write (this.getCacheUsage () + "\n"); - res.write (this.getProperty ("cachesize", "1000") + "\n"); - res.write ("0\n0\n"); - -} else if (req.data.action=="requests") { - -// res.write ( - -} else { - res.write ( "0\n0\n0\n0\n"); -} - - diff --git a/Application/redirectpublic.hac b/Application/redirectpublic.hac deleted file mode 100644 index 7ead5169..00000000 --- a/Application/redirectpublic.hac +++ /dev/null @@ -1,10 +0,0 @@ -/** - * performs a redirect to the public site - * (workaround, we can't access application object from docapplication for some reason) - * @see application.url_macro - */ - -if ( checkAddress()==false ) return; -if ( checkAuth(this)==false ) return; - -res.redirect ( this.url_macro() ); diff --git a/DocApplication/actions.js b/DocApplication/actions.js index 573947a5..7c1efcfa 100644 --- a/DocApplication/actions.js +++ b/DocApplication/actions.js @@ -1,59 +1,59 @@ -function read_action () { - this.readApplication (); - res.redirect (this.href("main")); +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 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 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 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 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 = 'rendering API ...
    wrote ' + ct + ' files

    '; - res.data.body += 'back to manage console'; - res.data.title = "rendering helma api"; - res.data.head = renderSkinAsString("head"); - renderSkin ("basic"); +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 = 'rendering API ...
    wrote ' + ct + ' files

    '; + res.data.body += 'back to manage console'; + res.data.title = "rendering helma api"; + res.data.head = renderSkinAsString("head"); + renderSkin("basic"); } diff --git a/DocApplication/functions.js b/DocApplication/functions.js index 14393695..e3769a61 100644 --- a/DocApplication/functions.js +++ b/DocApplication/functions.js @@ -1,90 +1,89 @@ - /** - * 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 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); +function getPrototype(name) { + return this.getChildElement("prototype_" + name); } -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 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; iback to manage console'); - } +function linkToManage_macro(param) { + if (res.data.rendering != true) { + return ('back to manage console'); + } } -function headline_macro (param) { - res.write (this.getName ()); +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); - } +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); + } } @@ -54,15 +67,15 @@ function hrefRoot_macro (param) { * @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-1) - name = name.substring (0, name.length-6); - res.write (name); - res.write (" %>"); - } else if (this.getType () == this.SKIN) { - if (handler!="" && handler!="global") - res.write (handler + "/"); - res.write (this.getName ()); - res.write (".skin"); - } +function headline_macro(param) { + var p = this.getParentElement(); + var handler = (p != null) ? p.getName() : ""; + if (this.getType() == this.ACTION) { + res.write("/" + this.getName()); + } else if (this.getType() == this.FUNCTION) { + if (handler != "" && handler != "global") + res.write(handler + "."); + res.write(this.getName() + " ("); + var arr = this.listParameters(); + for (var i = 0; i < arr.length; i++) { + res.write(arr[i]); + if (i < arr.length - 1) { + res.write(", "); + } + } + res.write(")"); + } else if (this.getType() == this.MACRO) { + res.write("<% "); + if (handler != "" && handler != "global") + res.write(handler + "."); + var name = this.getName(); + if (name.indexOf("_macro") > -1) + name = name.substring(0, name.length - 6); + res.write(name); + res.write(" %>"); + } else if (this.getType() == this.SKIN) { + if (handler != "" && handler != "global") + res.write(handler + "/"); + res.write(this.getName()); + res.write(".skin"); + } else if (this.getType() == this.PROPERTIES) { + res.write(this.getName()); + } } -function skinparameters_macro (param) { - if (this.getType () == this.SKIN) { - this.parameters_macro (param); - } +function skinparameters_macro(param) { + if (this.getType() == this.SKIN) { + this.parameters_macro(param); + } } -function parameters_macro (param) { - var separator = (param.separator) ? param.separator : ", "; - var arr = this.listParameters (); - for (var i=0; i<%'); - r = new RegExp("%>","gim"); + r = new RegExp("%>", "gim"); sourcecode = sourcecode.replace(r, '%>'); // highlight js-comments @@ -113,24 +125,24 @@ function source_macro(param) { } // remove all CR and LF, just
    remains - var r = new RegExp("[\\r\\n]","gm"); + var r = new RegExp("[\\r\\n]", "gm"); sourcecode = sourcecode.replace(r, ""); - var arr = sourcecode.split("
    "); - for (var i=0; i' + (i+1) + ': '); - if (i<99) { - res.write(' '); - } - if (i<9) { - res.write(' '); - } - res.write(arr[i] + "\n"); - } + var arr = sourcecode.split("
    "); + for (var i = 0; i < arr.length; i++) { + res.write('' + (i + 1) + ': '); + if (i < 99) { + res.write(' '); + } + if (i < 9) { + res.write(' '); + } + res.write(arr[i] + "\n"); + } - } else { - res.write(sourcecode); - } + } else { + res.write(sourcecode); + } } diff --git a/DocPrototype/actions.js b/DocPrototype/actions.js index 853c8b66..a9b9c873 100644 --- a/DocPrototype/actions.js +++ b/DocPrototype/actions.js @@ -1,18 +1,18 @@ -function list_action () { - if (checkAddress()==false) - return; - if (checkAuth()==false) - return; - res.data.body = this.renderSkinAsString ("list"); - renderSkin ("api"); +function list_action() { + if (checkAddress() == false) + return; + if (checkAuth() == false) + return; + res.data.body = this.renderSkinAsString("list"); + renderSkin("api"); } -function main_action () { - if (checkAddress()==false) - return; - if (checkAuth()==false) - return; - res.data.body = this.renderSkinAsString ("main"); - renderSkin ("api"); +function main_action() { + if (checkAddress() == false) + return; + if (checkAuth() == false) + return; + res.data.body = this.renderSkinAsString("main"); + renderSkin("api"); } diff --git a/DocPrototype/asParentList.skin b/DocPrototype/asParentList.skin index cfdc8989..34208c8a 100644 --- a/DocPrototype/asParentList.skin +++ b/DocPrototype/asParentList.skin @@ -7,7 +7,6 @@ <% this.methods separator=", " filter="functions" skin="asParentListItem" prefix="Functions: " suffix="
    " %> <% this.methods separator=", " filter="macros" skin="asParentListItem" prefix="Macros: " suffix="
    " %> <% this.methods separator=", " filter="skins" skin="asParentListItem" prefix="Skins: " suffix="
    " %> -<% this.methods separator=", " filter="templates" skin="asParentListItem" prefix="Templates: " suffix="
    " %>
    Templates
    type.properties
     
    - + diff --git a/Global/functions.js b/Global/functions.js index 6f506f3d..7c40b5b7 100644 --- a/Global/functions.js +++ b/Global/functions.js @@ -1,11 +1,9 @@ - - /** - * scheduler function, runs global.appStat every minute - */ +* scheduler function, runs global.appStat every minute +*/ function scheduler() { - appStat(); - return 60000; + appStat(); + return 60000; } @@ -14,8 +12,8 @@ function scheduler() { * creates app.data.addressFilter */ function onStart() { - app.data.addressFilter = createAddressFilter(); - app.data.addressString = root.getProperty ("allowadmin"); + app.data.addressFilter = createAddressFilter(); + app.data.addressString = root.getProperty("allowadmin"); } /** @@ -23,80 +21,80 @@ function onStart() { * hostnames are converted, wildcards are only allowed in ip-addresses * (so, no network-names, sorry) */ -function createAddressFilter() { - var filter = new Packages.helma.util.InetAddressFilter(); - var str = root.getProperty("allowadmin"); - if ( str!=null && str!="" ) { - var arr = str.split(","); - for ( var i in arr ) { - var str = new java.lang.String(arr[i]); +function createAddressFilter() { + var filter = new Packages.helma.util.InetAddressFilter(); + var str = root.getProperty("allowadmin"); + if (str != null && str != "") { + var arr = str.split(","); + for (var i in arr) { + str = new java.lang.String(arr[i]); try { filter.addAddress(str.trim()); } catch (a) { try { - var str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); - filter.addAddress (str); + str = java.net.InetAddress.getByName(str.trim()).getHostAddress(); + filter.addAddress(str); } catch (b) { - app.log ("error using address " + arr[i] + ": " + b); + app.log("error using address " + arr[i] + ": " + b); } } - } - } else { - app.log("no addresses allowed for app manage, all access will be denied"); - } - return filter; + } + } else { + app.log("no addresses allowed for app manage, all access will be denied"); + } + return filter; } /** * updates the stats in app.data.stat every 5 minutes */ -function appStat () { - if (app.data.stat==null) - app.data.stat = new HopObject (); - if ((new Date()-300000) < app.data.stat.lastRun) - return; - var arr = root.getApplications (); - for (var i=0; i b.name) - return 1; - else if (a.name == b.name) - return 0; - else - return -1; +function sortByName(a, b) { + if (a.name > b.name) + return 1; + else if (a.name == b.name) + return 0; + else + return -1; } /** * utility function to sort property-arrays by key */ -function sortProps(a,b) { - if ( a>b ) - return 1; - else if ( a==b ) - return 0; - else - return -1; +function sortProps(a, b) { + if (a > b) + return 1; + else if (a == b) + return 0; + else + return -1; } /** @@ -106,62 +104,62 @@ function sortProps(a,b) { * object for http-auth and return false. * @arg appObj application object to check against (if adminUsername etc are set in app.properties) */ -function checkAuth(appObj) { - if (res && res.data.noWeb==true) { +function checkAuth(appObj) { + if (res && res.data.noWeb == true) { return true; } - var ok = false; + var ok = false; - // check against root - var adminAccess = root.getProperty("adminAccess"); + // check against root + var adminAccess = root.getProperty("adminAccess"); - if (adminAccess==null || adminAccess=="") { - res.redirect (root.href ("makekey")); - } + if (adminAccess == null || adminAccess == "") { + res.redirect(root.href("makekey")); + } - var uname = req.username; - var pwd = req.password; + var uname = req.username; + var pwd = req.password; - if ( uname==null || uname=="" || pwd==null || pwd=="" ) - return forceAuth(); + if (uname == null || uname == "" || pwd == null || pwd == "") + return forceAuth(); - var md5key = Packages.helma.util.MD5Encoder.encode(uname + "-" + pwd); + var md5key = Packages.helma.util.MD5Encoder.encode(uname + "-" + pwd); - if (md5key==adminAccess) - return true; + if (md5key == adminAccess) + return true; - if (appObj!=null && appObj.isActive()) { - // check against application - adminAccess = appObj.getProperty("adminAccess"); - if (md5key==adminAccess) - return true; - } - return forceAuth(); + if (appObj != null && appObj.isActive()) { + // check against application + adminAccess = appObj.getProperty("adminAccess"); + if (md5key == adminAccess) + return true; + } + return forceAuth(); } /** * check access to the manage-app by ip-addresses */ -function checkAddress() { - if (res && res.data.noWeb==true) { +function checkAddress() { + if (res && res.data.noWeb == true) { + return true; + } + // if allowadmin value in server.properties has changed, + // re-construct the addressFilter + if (app.data.addressString != root.getProperty("allowadmin")) { + app.data.addressFilter = createAddressFilter(); + app.data.addressString = root.getProperty("allowadmin"); + } + if (!app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost))) { + app.log("denied request from " + req.data.http_remotehost); + // forceStealth seems a bit like overkill here. + // display a message that the ip address must be added to server.properties + res.write("Access from address " + req.data.http_remotehost + " denied."); + return false; + } else { return true; } - // if allowadmin value in server.properties has changed, - // re-construct the addressFilter - if (app.data.addressString != root.getProperty ("allowadmin")){ - app.data.addressFilter = createAddressFilter(); - app.data.addressString = root.getProperty ("allowadmin"); - } - if ( !app.data.addressFilter.matches(java.net.InetAddress.getByName(req.data.http_remotehost)) ) { - app.log("denied request from " + req.data.http_remotehost ); - // forceStealth seems a bit like overkill here. - // display a message that the ip address must be added to server.properties - res.write ("Access from address "+req.data.http_remotehost+" denied."); - return false; - } else { - return true; - } } @@ -169,68 +167,67 @@ function checkAddress() { * response is reset to 401 / authorization required * @arg realm realm for http-auth */ -function forceAuth(realm) { - res.reset(); - res.status = 401; - res.realm = (realm!=null) ? realm : "helma"; - res.write ("Authorization Required. The server could not verify that you are authorized to access the requested page."); - return false; +function forceAuth(realm) { + res.reset(); + res.status = 401; + res.realm = (realm != null) ? realm : "helma"; + res.write("Authorization Required. The server could not verify that you are authorized to access the requested page."); + return false; } - /** - * macro-utility: formatting property lists - */ -function formatProperties(props,par) { - if ( props.size()==0 ) - return ""; - var e = props.keys(); - var arr = new Array(); - while ( e.hasMoreElements() ) { - arr[arr.length] = e.nextElement(); - } - arr.sort(sortProps); - for ( var i in arr ) { - // don't print the admin-password - if ( arr[i].toLowerCase()=="adminusername" || arr[i].toLowerCase()=="adminpassword" ) continue; - res.write ( par.itemprefix + arr[i] + par.separator + props.getProperty(arr[i]) + par.itemsuffix ); - } +* macro-utility: formatting property lists +*/ +function formatProperties(props, par) { + if (props.size() == 0) + return ""; + var e = props.keys(); + var arr = new Array(); + while (e.hasMoreElements()) { + arr[arr.length] = e.nextElement(); + } + arr.sort(sortProps); + for (var i in arr) { + // don't print the admin-password + if (arr[i].toLowerCase() == "adminusername" || arr[i].toLowerCase() == "adminpassword") continue; + res.write(par.itemprefix + arr[i] + par.separator + props.getProperty(arr[i]) + par.itemsuffix); + } } /** * macro-utility: formatting an integer value as human readable bytes */ -function formatBytes(bytes) { - if ( bytes > Math.pow(2,30) ) { - res.write( Math.round( 100*bytes/Math.pow(2,30) ) / 100 + "gb" ); - } else if ( bytes > Math.pow(2,20) ) { - res.write( Math.round( 100*bytes/Math.pow(2,20) ) / 100 + "mb" ); - } else { - res.write( Math.round( 100*bytes/Math.pow(2,10) ) / 100 + "kb" ); - } +function formatBytes(bytes) { + if (bytes > Math.pow(2, 30)) { + res.write(Math.round(100 * bytes / Math.pow(2, 30)) / 100 + "gb"); + } else if (bytes > Math.pow(2, 20)) { + res.write(Math.round(100 * bytes / Math.pow(2, 20)) / 100 + "mb"); + } else { + res.write(Math.round(100 * bytes / Math.pow(2, 10)) / 100 + "kb"); + } } /** * macro-utility: formatting time in millis as human readable age */ -function formatAge(age) { - var str = ""; - var days = Math.floor(age/86400); - var age = age - days * 86400; - var hours = Math.floor(age / 3600); - var age = age - hours * 3600; - var minutes = Math.floor(age / 60); - var seconds = Math.floor(age - minutes * 60); - if (days > 0) - str += (days + " days, "); - if (hours>0) - str += (hours + "h, "); - str += (minutes + "min"); - if (days == 0) str += (", " + seconds + "sec"); - return(str); +function formatAge(age) { + var str = ""; + var days = Math.floor(age / 86400); + age = age - days * 86400; + var hours = Math.floor(age / 3600); + age = age - hours * 3600; + var minutes = Math.floor(age / 60); + var seconds = Math.floor(age - minutes * 60); + if (days > 0) + str += (days + " days, "); + if (hours > 0) + str += (hours + "h, "); + str += (minutes + "min"); + if (days == 0) str += (", " + seconds + "sec"); + return(str); } @@ -241,23 +238,23 @@ function formatAge(age) { * @param singular string used for value==1 * @param plural string used for value!=1 */ -function formatCount(ct, par) { - if ( !par || !par.singular || !par.plural ) { - return ""; - } - if ( ct==1 ) - return par.singular; - else - return par.plural; +function formatCount(ct, par) { + if (!par || !par.singular || !par.plural) { + return ""; + } + if (ct == 1) + return par.singular; + else + return par.plural; } /** * tries to make out if this server is running linux from java's system properties */ -function isLinux () { - var str = java.lang.System.getProperty("os.name"); - return (str!=null && str.toLowerCase().indexOf("linux")!=-1); +function isLinux() { + var str = java.lang.System.getProperty("os.name"); + return (str != null && str.toLowerCase().indexOf("linux") != -1); } diff --git a/Global/macros.js b/Global/macros.js index 13408e7a..ee3fe97a 100644 --- a/Global/macros.js +++ b/Global/macros.js @@ -2,10 +2,10 @@ * macro rendering a skin * @param name name of skin */ -function skin_macro(par) { - if ( par && par.name ) { - renderSkin(par.name); - } +function skin_macro(par) { + if (par && par.name) { + renderSkin(par.name); + } } @@ -13,6 +13,6 @@ function skin_macro(par) { * Macro returning the actual date and time. */ function now_macro() { - var date = new Date(); - return(date.format("dd.MM.yyyy, HH:mm'h' zzz")); + var date = new Date(); + return(date.format("dd.MM.yyyy, HH:mm'h' zzz")); } diff --git a/Global/navig.skin b/Global/navig.skin index fecbbaf7..044e081d 100644 --- a/Global/navig.skin +++ b/Global/navig.skin @@ -11,7 +11,7 @@

    - and <% root.appCount filter="disabled" %> disabled apps: + disabled apps:
    <% root.appList filter="disabled" skin="navig_disabled" %> @@ -27,4 +27,4 @@

  • ">generate server password -

    \ No newline at end of file +

    diff --git a/Global/renderFunctions.js b/Global/renderFunctions.js index 2b7c4057..280c5168 100644 --- a/Global/renderFunctions.js +++ b/Global/renderFunctions.js @@ -1,95 +1,85 @@ - - -function renderLink (docEl, param) { - var text = ""; - if (docEl.getType () == docEl.APPLICATION || docEl.getType () == docEl.PROTOTYPE) { - text = docEl.getName (); - } else if (docEl.getType () == docEl.SKIN) { - text = docEl.getName () + ".skin"; - } else if (docEl.getType () == docEl.MACRO) { - if (param.handler!="false" && docEl.getParentElement () && docEl.getParentElement().getName()!="global") { - text = docEl.getParentElement ().getName () + "."; - } - var str = docEl.getName (); - if (str.indexOf("_macro")) { - text += str.substring (0, str.length-6); - } - } else if (docEl.getType () == docEl.FUNCTION) { - var text = docEl.getName () + "("; - var arr = docEl.listParameters (); - for (var i=0; i'; +function renderLink(docEl, param) { + var text = ""; + if (docEl.getType() == docEl.APPLICATION || docEl.getType() == docEl.PROTOTYPE) { + text = docEl.getName(); + } else if (docEl.getType() == docEl.SKIN) { + text = docEl.getName() + ".skin"; + } else if (docEl.getType() == docEl.MACRO) { + if (param.handler != "false" && docEl.getParentElement() && docEl.getParentElement().getName() != "global") { + text = docEl.getParentElement().getName() + "."; + } + var str = docEl.getName(); + if (str.indexOf("_macro")) { + text += str.substring(0, str.length - 6); + } + } else if (docEl.getType() == docEl.FUNCTION) { + text = docEl.getName() + "("; + var arr = docEl.listParameters(); + for (var i = 0; i < arr.length; i++) { + text += arr[i]; + if (i < arr.length - 1) + text += ", "; + } + text += ")"; + } else { + text = docEl.getName(); + } + param.href = docEl.href("main"); + if (!param.target) { + param.target = "main"; + } + return renderLinkTag(param) + text + ''; } - - -function renderLinkTag (param) { - var sb = new java.lang.StringBuffer (); - sb.append (''); - return sb.toString (); +function renderLinkTag(param) { + var sb = new java.lang.StringBuffer (); + sb.append(''); + return sb.toString(); } - /** - * renders the name of the location relative to the application - * root. - */ + * renders the name of the location of a doc element. + */ function renderLocation (docEl, param) { - var f = docEl.getLocation (); - // with repositories, always display full file path - return f.getAbsolutePath(); + return docEl.toString(); } - - /** - * renders tag list. - * @param param.skin skin to render on found DocTags - * @param param.separator String printed between tags - * @param param.type type string (param|return|author|version|see) to filter tags. - */ -function renderTags (docEl, param) { - var skinname = (param.skin) ? param.skin : "main"; - var type = param.type; - if (type=="params") - type = "param"; - else if (type=="returns") - type = "return"; - else if (type=="arg") +* renders tag list. +* @param param.skin skin to render on found DocTags +* @param param.separator String printed between tags +* @param param.type type string (param|return|author|version|see) to filter tags. +*/ +function renderTags(docEl, param) { + var skinname = (param.skin) ? param.skin : "main"; + var type = param.type; + if (type == "params") type = "param"; - var str = ""; - var arr = docEl.listTags (); - for (var i=0; i' + text + ''; - } else { - // make sure we only use the first item in the text so that unlinked comments - // can follow, store & split the that - var tok = new java.util.StringTokenizer (text); - var tmp = tok.nextToken (); - text = " " + text.substring (tmp.length + 1); - var parts = tmp.split("."); - // try to find the application object - var obj = docEl; - while (obj!=null) { - if (obj.getType () == Packages.helma.doc.DocElement.APPLICATION) { - var appObj = obj; - break; - } - obj = obj.getParentElement (); - } - var protoObj = appObj.getChildElement ("prototype_" + parts[0]); - if (protoObj==null) { - // prototype wasn't found, return the unlinked tag - return tmp + text; - } - if (parts.length==1) { - // no function specified, return the linked prototype - return '' + format (tmp) + '' + text; - } - // try to find a function object: - var arr = protoObj.listChildren (); - for (var i=0; i' + format(tmp) + '' + text; - } - } - // function not found: - return tmp + text; - } +function renderReference(docTagObj, docEl) { + // prepare the text: + var text = docTagObj.getText(); + text = new java.lang.String (text); + text = text.trim(); + if (text.indexOf("http://") == 0) { + // an url is a simple job + return '' + text + ''; + } else { + // make sure we only use the first item in the text so that unlinked comments + // can follow, store & split the that + var tok = new java.util.StringTokenizer (text); + var tmp = tok.nextToken(); + text = " " + text.substring(tmp.length + 1); + var parts = tmp.split("."); + // try to find the application object + var obj = docEl; + while (obj != null) { + if (obj.getType() == Packages.helma.doc.DocElement.APPLICATION) { + var appObj = obj; + break; + } + obj = obj.getParentElement(); + } + var protoObj = appObj.getChildElement("prototype_" + parts[0]); + if (protoObj == null) { + // prototype wasn't found, return the unlinked tag + return tmp + text; + } + if (parts.length == 1) { + // no function specified, return the linked prototype + return '' + format(tmp) + '' + text; + } + // try to find a function object: + var arr = protoObj.listChildren(); + for (var i = 0; i < arr.length; i++) { + if (arr[i].getName() == parts [1]) { + return '' + format(tmp) + '' + text; + } + } + // function not found: + return tmp + text; + } } - - /** - * function rendering a comment. - * @param param.length comment is shortened to the given length. - * @returns string - */ -function renderComment (docEl, param) { - var str = docEl.getComment (); - if (param.length) { - if (param.length < str.length) { - return str.substring (0, param.length) + " ..."; - } - } - return str; +* function rendering a comment. +* @param param.length comment is shortened to the given length. +* @returns string +*/ +function renderComment(docEl, param) { + var str = docEl.getComment(); + if (param.length) { + if (param.length < str.length) { + return str.substring(0, param.length) + " ..."; + } + } + return str; } diff --git a/Root/actions.js b/Root/actions.js new file mode 100644 index 00000000..aac54dc7 --- /dev/null +++ b/Root/actions.js @@ -0,0 +1,130 @@ +/** + * main action, show server-stats + * perform start, stop, restart and flush-action + * + */ +function main_action() { + + if (checkAddress() == false) return; + + if (req.data.app != null && req.data.app != "" && req.data.action != null && req.data.action != "") { + + var appObj = root.getApp(req.data.app); + // check access for application. md5-encoded uname/pwd can also be put in + // app.properties to limit access to a single app + if (checkAuth(appObj) == false) return; + + if (req.data.action == "start") { + this.startApplication(req.data.app); + res.redirect(appObj.href("main")); + + } else if (req.data.action == "stop") { + if (checkAuth() == false) return; + this.stopApplication(req.data.app); + res.redirect(root.href("main")); + + } else if (req.data.action == "restart") { + this.stopApplication(req.data.app); + this.startApplication(req.data.app); + res.redirect(appObj.href("main")); + + } else if (req.data.action == "flush") { + appObj.clearCache(); + res.redirect(appObj.href("main")); + + } + + } + + // output only to root + if (checkAuth() == false) return; + + res.data.title = "Helma Object Publisher - Serverinfo"; + res.data.body = this.renderSkinAsString("main"); + renderSkin("global"); +} + +/** +* return the helma object publisher logo, built into hop core +* to be independent of static html-paths +*/ +function image_action() { + if (checkAddress() == false) return; + + res.contentType = "image/gif"; + res.writeBinary(Packages.helma.util.Logo.hop); +} + +function makekey_action() { + + if (checkAddress() == false) + return; + + var obj = new Object(); + obj.msg = ""; + if (req.data.username != null && req.data.password != null) { + + // we have input from webform + if (req.data.username == "") + obj.msg += "username can't be left empty!
    "; + if (req.data.password == "") + obj.msg += "password can't be left empty!
    "; + if (obj.msg != "") { + obj.username = req.data.username; + res.reset(); + res.data.body = renderSkinAsString("pwdform", obj); + } else { + // render the md5-string: + obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
    \n"; + res.data.body = renderSkinAsString("pwdfeedback", obj); + } + + } else { + + // no input from webform, so print it + res.data.body = renderSkinAsString("pwdform", obj); + + } + + res.data.title = "username & password on " + root.hostname_macro(); + res.data.head = renderSkinAsString("head"); + renderSkin("basic"); +} + +/** +* prints server-stats for mrtg-tool. +* doesn't check username or password, so that we don't have +* to write them cleartext in a mrtg-configfile but checks the +* remote address. +*/ +function mrtg_action() { + + if (checkAddress() == false) + return; + + + if (req.data.action == "memory") { + + res.write(this.jvmTotalMemory_macro() + "\n"); + res.write(this.jvmFreeMemory_macro() + "\n"); + res.write("0\n0\n"); + + } else if (req.data.action == "netstat" && isLinux()) { + + var str = (new File("/proc/net/tcp")).readAll(); + var arr = str.split("\n"); + res.write(arr.length - 2 + "\n"); + res.write("0\n0\n0\n"); + + } else if (req.data.action == "loadavg" && isLinux()) { + + // load average of last 5 minutes: + var str = (new File("/proc/loadavg")).readAll(); + var arr = str.split(" "); + res.write(arr[1] * 100 + "\n"); + res.write("0\n0\n0\n"); + + } else { + res.write("0\n0\n0\n0\n"); + } +} \ No newline at end of file diff --git a/Root/functions.js b/Root/functions.js index b5c26f9e..dc6405f6 100644 --- a/Root/functions.js +++ b/Root/functions.js @@ -1,7 +1,6 @@ - /** - * renders the api of a given application. used from commandline. - */ +* renders the api of a given application. used from commandline. +*/ function renderApi(appName) { // supress security checks when accessing actions @@ -15,7 +14,7 @@ function renderApi(appName) { // now render the api var ct = docApp.renderApi(); writeln("rendered " + ct + " files"); - + // cleanup this.stopApplication(appName); } @@ -25,15 +24,15 @@ function renderApi(appName) { * lists all applications in appdir. * for active apps use this.getApplications() = helma.main.Server.getApplications() */ -function getAllApplications() { - var appsDir = this.getAppsHome(); - var dir = appsDir.list(); - var arr = new Array(); - for ( var i=0; i str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/'); - res.write ( arr[i].substring(pos+1) + ".jar" ); - if ( i < arr.length-1 ) res.write ( separator ); - } +function jvmJars_macro(par) { + var separator = (par && par.separator ) ? par.separator : ", "; + var str = java.lang.System.getProperty("java.class.path"); + var arr = str.split(".jar"); + for (var i in arr) { + var str = arr[i]; + var pos = ( str.lastIndexOf('\\') > str.lastIndexOf('/') ) ? str.lastIndexOf('\\') : str.lastIndexOf('/'); + res.write(arr[i].substring(pos + 1) + ".jar"); + if (i < arr.length - 1) res.write(separator); + } } /** * Macro that returns the name and version of the server's os */ -function os_macro() { - return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version"); +function os_macro() { + return java.lang.System.getProperty("os.name") + " " + java.lang.System.getProperty("os.arch") + " " + java.lang.System.getProperty("os.version"); } /** * Macro that returns anything from server.properties */ -function property_macro(par) { - if ( par && par.key ) { - return this.getProperty(key); - } else { - return ""; - } +function property_macro(par) { + if (par && par.key) { + return this.getProperty(key); + } else { + return ""; + } } /** * Macro formatting server.properties */ -function properties_macro(par) { - formatProperties(this.getProperties(),par); +function properties_macro(par) { + formatProperties(this.getProperties(), par); } /** * Macro that returns the timezone of this server */ -function timezone_macro(par) { - return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")"; +function timezone_macro(par) { + return java.util.TimeZone.getDefault().getDisplayName(false, java.util.TimeZone.LONG) + " (" + java.util.TimeZone.getDefault().getID() + ")"; } diff --git a/Root/main.hac b/Root/main.hac deleted file mode 100644 index f05009fa..00000000 --- a/Root/main.hac +++ /dev/null @@ -1,44 +0,0 @@ -/** - * main action, show server-stats - * perform start, stop, restart and flush-action - * - */ - - -if ( checkAddress()==false ) return; - -if ( req.data.app!=null && req.data.app!="" && req.data.action!=null && req.data.action!="" ) { - - var appObj = root.getApp(req.data.app); - // check access for application. md5-encoded uname/pwd can also be put in - // app.properties to limit access to a single app - if ( checkAuth(appObj)==false ) return; - - if ( req.data.action=="start" ) { - this.startApplication(req.data.app); - res.redirect ( appObj.href("main") ); - - } else if ( req.data.action=="stop" ) { - if ( checkAuth()==false ) return; - this.stopApplication(req.data.app); - res.redirect ( root.href("main") ); - - } else if ( req.data.action=="restart" ) { - this.stopApplication(req.data.app); - this.startApplication(req.data.app); - res.redirect ( appObj.href("main") ); - - } else if ( req.data.action=="flush" ) { - appObj.clearCache(); - res.redirect ( appObj.href("main") ); - - } - -} - -// output only to root -if ( checkAuth()==false ) return; - -res.data.title = "Helma Object Publisher - Serverinfo"; -res.data.body = this.renderSkinAsString("main"); -renderSkin("global"); diff --git a/Root/makekey.hac b/Root/makekey.hac deleted file mode 100644 index 6eb739fb..00000000 --- a/Root/makekey.hac +++ /dev/null @@ -1,33 +0,0 @@ - -if (checkAddress()==false) - return; - -var obj = new Object(); -obj.msg = ""; -if (req.data.username!=null && req.data.password!=null) { - - // we have input from webform - if ( req.data.username=="" ) - obj.msg += "username can't be left empty!
    "; - if ( req.data.password=="" ) - obj.msg += "password can't be left empty!
    "; - if ( obj.msg!="" ) { - obj.username = req.data.username; - res.reset(); - res.data.body = renderSkinAsString ("pwdform",obj); - } else { - // render the md5-string: - obj.propsString = "adminAccess=" + Packages.helma.util.MD5Encoder.encode(req.data.username + "-" + req.data.password) + "
    \n"; - res.data.body = renderSkinAsString ("pwdfeedback", obj); - } - -} else { - - // no input from webform, so print it - res.data.body = renderSkinAsString("pwdform",obj); - -} - -res.data.title = "username & password on " + root.hostname_macro(); -res.data.head = renderSkinAsString("head"); -renderSkin("basic"); diff --git a/Root/mrtg.hac b/Root/mrtg.hac deleted file mode 100644 index 44b672c8..00000000 --- a/Root/mrtg.hac +++ /dev/null @@ -1,37 +0,0 @@ - -/** - * prints server-stats for mrtg-tool. - * doesn't check username or password, so that we don't have - * to write them cleartext in a mrtg-configfile but checks the - * remote address. - */ - -if ( checkAddress()==false ) - return; - - -if (req.data.action=="memory") { - - res.write (this.jvmTotalMemory_macro () + "\n"); - res.write (this.jvmFreeMemory_macro () + "\n"); - res.write ("0\n0\n"); - -} else if (req.data.action=="netstat" && isLinux ()) { - - var str = (new File("/proc/net/tcp")).readAll(); - var arr = str.split("\n"); - res.write (arr.length-2 + "\n"); - res.write ("0\n0\n0\n"); - -} else if (req.data.action=="loadavg" && isLinux ()) { - - // load average of last 5 minutes: - var str = (new File("/proc/loadavg")).readAll(); - var arr = str.split(" "); - res.write (arr[1]*100 + "\n"); - res.write ("0\n0\n0\n"); - -} else { - res.write ( "0\n0\n0\n0\n"); -} - diff --git a/app.properties b/app.properties index d8232b4f..83e08c43 100644 --- a/app.properties +++ b/app.properties @@ -1,5 +1,5 @@ # Set baseURI for application generated URLs, if necessary. -#baseURI = /manage +# baseURI = /manage # A short description of what this application is about: _description = Helma's server management console. Start applications, introspection etc. @@ -8,3 +8,5 @@ _description = Helma's server management console. Start applications, introspect # might take more than one minute on a slow computer requestTimeout = 300 +# run scheduler function each minute +cron.scheduler.function = scheduler diff --git a/class.properties b/class.properties index 57808b22..6a51df81 100644 --- a/class.properties +++ b/class.properties @@ -1,4 +1,3 @@ - # # define the root class of this application # @@ -17,10 +16,10 @@ root.factory.method = getServer # and, yes, map the root class again. # -helma.main.Server = root -helma.framework.core.Application = application -helma.doc.DocApplication = docapplication -helma.doc.DocPrototype = docprototype -helma.doc.DocFunction = docfunction -helma.doc.DocTag = doctag +helma.main.Server = Root +helma.framework.core.Application = Application +helma.doc.DocApplication = DocApplication +helma.doc.DocPrototype = DocPrototype +helma.doc.DocFunction = DocFunction +helma.doc.DocTag = DocTag diff --git a/readme.txt b/readme.txt index 180a849d..8e271c95 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ To get the manage-application to work you must: - add it to the apps.properties file with the following line: manage - - use helma distribution 1.2-RC1 or later. + - use helma distribution 1.5 or later. - add the following properties to server.properties: From c9463fe57a00323b2e2feb67eb8d46f5c9a53a10 Mon Sep 17 00:00:00 2001 From: p3k Date: Tue, 6 Jun 2006 17:18:03 +0000 Subject: [PATCH 73/82] fix bug causing an exception when there's no app directory at all --- Root/functions.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Root/functions.js b/Root/functions.js index dc6405f6..f7043f15 100644 --- a/Root/functions.js +++ b/Root/functions.js @@ -28,6 +28,8 @@ function getAllApplications() { var appsDir = this.getAppsHome(); var dir = appsDir.list(); var arr = new Array(); + if (!dir) + return arr; for (var i = 0; i < dir.length; i++) { if (dir[i].toLowerCase() != "cvs" && dir[i].indexOf(".") == -1) arr[arr.length] = this.getApp(dir[i]); From 694139d897437a172a77894eb8a4a85afd2b7731 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 20 Nov 2006 11:05:24 +0000 Subject: [PATCH 74/82] * Do not rely on Java classes to implement IPathElement. Implement all necessary features such as href() and getChildElement() ourselves instead. * Add missing classes to class.properties. * Display actual line numbers in function source macro. --- Application/functions.js | 23 +++++++++++++++-------- DocApplication/functions.js | 15 +++++++++++---- DocFunction/macros.js | 3 ++- DocPrototype/functions.js | 24 +++++++++++------------- Root/functions.js | 6 ++++++ class.properties | 2 ++ 6 files changed, 47 insertions(+), 26 deletions(-) diff --git a/Application/functions.js b/Application/functions.js index cdf0af56..a42865d0 100644 --- a/Application/functions.js +++ b/Application/functions.js @@ -7,14 +7,6 @@ function constructor(name) { this.name = name; } - -/** - * of no use, just to avoid error message - */ -function onRequest() { -} - - /** * return true/false to determine if application is running */ @@ -25,4 +17,19 @@ function isActive() { return true; } +/** + * Method used by Helma for URL composition. + */ +function href(action) { + var base = root.href() + this.name + "/"; + return action ? base + action : base; +} +/** + * Method used by Helma request path resolution. + */ +function getChildElement(name) { + if (name == "api") + return this.getDoc(); + return null; +} diff --git a/DocApplication/functions.js b/DocApplication/functions.js index e3769a61..dec28856 100644 --- a/DocApplication/functions.js +++ b/DocApplication/functions.js @@ -1,6 +1,6 @@ /** -* get the prototype of any doc-object (either a prototype, a function or a tag) -*/ + * 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) { @@ -11,12 +11,19 @@ function getDocPrototype(obj) { /** - * get a prototype of this docapplication, ie get on of the children of this object - */ + * 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(); diff --git a/DocFunction/macros.js b/DocFunction/macros.js index 9bc3d9ee..9443f0eb 100644 --- a/DocFunction/macros.js +++ b/DocFunction/macros.js @@ -129,8 +129,9 @@ function source_macro(param) { sourcecode = sourcecode.replace(r, ""); var arr = sourcecode.split("
    "); + var line = this.getStartLine ? this.getStartLine() : 1; for (var i = 0; i < arr.length; i++) { - res.write('' + (i + 1) + ': '); + res.write('' + (line++) + ': '); if (i < 99) { res.write(' '); } diff --git a/DocPrototype/functions.js b/DocPrototype/functions.js index b418b24b..ad9ef068 100644 --- a/DocPrototype/functions.js +++ b/DocPrototype/functions.js @@ -1,14 +1,3 @@ -///** -// * utility function for head_macro, rendering link to app and to prototype -// */ -//function getPath() { -// var appObj = this.getParentElement (); -// var str = appObj.getPath(); -// str += '/' + this.name + ''; -// return( str ); -//} - - function translateType(filter) { if (filter == "actions") return Packages.helma.doc.DocElement.ACTION; @@ -24,9 +13,18 @@ function translateType(filter) { return -1; } - +/** + * Get the application we're part of. + */ function getApplication() { return this.getParentElement(); } - +/** + * Method used by Helma for URL composition. + */ +function href(action) { + var base = this.getParentElement().href() + + this.getElementName() + "/"; + return action ? base + action : base; +} diff --git a/Root/functions.js b/Root/functions.js index f7043f15..60c9a9b6 100644 --- a/Root/functions.js +++ b/Root/functions.js @@ -55,5 +55,11 @@ function getApp(name) { return appObj; } +/** + * Method used by Helma path resolution. + */ +function getChildElement(name) { + return this.getApp(name); +} diff --git a/class.properties b/class.properties index 6a51df81..4f48d3cc 100644 --- a/class.properties +++ b/class.properties @@ -21,5 +21,7 @@ helma.framework.core.Application = Application helma.doc.DocApplication = DocApplication helma.doc.DocPrototype = DocPrototype helma.doc.DocFunction = DocFunction +helma.doc.DocProperties = DocFunction +helma.doc.DocSkin = DocFunction helma.doc.DocTag = DocTag From 68db756b0ed4b7f1cd7ed1936b2c2742db238c28 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 20 Nov 2006 13:34:15 +0000 Subject: [PATCH 75/82] * Do not rely on Java classes to implement IPathElement. Implement all necessary features such as href() and getChildElement() ourselves instead. --- DocFunction/functions.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 DocFunction/functions.js diff --git a/DocFunction/functions.js b/DocFunction/functions.js new file mode 100644 index 00000000..eafd288c --- /dev/null +++ b/DocFunction/functions.js @@ -0,0 +1,10 @@ +/** + * Method used by Helma for URL composition. + */ +function href(action) { + var base = this.getParentElement().href() + + this.getElementName() + "/"; + return action ? base + action : base; +} + + From db03770c72355c174b52fd0d5f77ceda137c55b7 Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 20 Nov 2006 14:05:28 +0000 Subject: [PATCH 76/82] * Minor reformat of Jsdoc comment. --- Application/functions.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Application/functions.js b/Application/functions.js index a42865d0..52567b08 100644 --- a/Application/functions.js +++ b/Application/functions.js @@ -1,8 +1,8 @@ /** -* construct an application object so that we can use -* skins for non-active applications too -* @arg name -*/ + * construct an application object so that we can use + * skins for non-active applications too + * @arg name + */ function constructor(name) { this.name = name; } From dd20db9815f67438d456efd141bde2493ccafa2b Mon Sep 17 00:00:00 2001 From: hns Date: Thu, 15 Mar 2007 16:48:00 +0000 Subject: [PATCH 77/82] * Close quotes for suffix attribute. --- DocPrototype/list.skin | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DocPrototype/list.skin b/DocPrototype/list.skin index 55620dac..0225a667 100644 --- a/DocPrototype/list.skin +++ b/DocPrototype/list.skin @@ -3,8 +3,8 @@ <% this.inheritance deep="true" hopobject="true" action="main" target="main" onClick="parent.changePrototypeList(this);" separator=", " prefix="extends: " suffix="
    " %>
    -<% this.methods filter="actions" skin="asListItem" prefix="

    Actions:
    " suffix="

    %> -<% this.methods filter="functions" skin="asListItem" prefix="

    Functions:
    " suffix="

    %> -<% this.methods filter="macros" skin="asListItem" prefix="

    Macros:
    " suffix="

    %> -<% this.methods filter="skins" skin="asListItem" prefix="

    Skins:
    " suffix="

    %> +<% this.methods filter="actions" skin="asListItem" prefix="

    Actions:
    " suffix="

    " %> +<% this.methods filter="functions" skin="asListItem" prefix="

    Functions:
    " suffix="

    " %> +<% this.methods filter="macros" skin="asListItem" prefix="

    Macros:
    " suffix="

    " %> +<% this.methods filter="skins" skin="asListItem" prefix="

    Skins:
    " suffix="

    " %> From ba09754f4869ed860e4339b3bd2b507805a4dd2a Mon Sep 17 00:00:00 2001 From: hns Date: Mon, 19 Mar 2007 16:21:40 +0000 Subject: [PATCH 78/82] * Add missing closing quotes to this.methods suffix attribute. --- DocPrototype/main.skin | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DocPrototype/main.skin b/DocPrototype/main.skin index afaf2ab8..0542d1d2 100644 --- a/DocPrototype/main.skin +++ b/DocPrototype/main.skin @@ -36,35 +36,35 @@ filter="actions" skin="asLargeListItem" prefix="
  • " - suffix=" + suffix="" %> <% this.methods separator="" filter="functions" skin="asLargeListItem" prefix="" - suffix=" + suffix="" %> <% this.methods separator="" filter="macros" skin="asLargeListItem" prefix="" - suffix=" + suffix="" %> <% this.methods separator="" filter="skins" skin="asLargeListItemSkin" prefix="" - suffix=" + suffix="" %> <% this.methods separator="" filter="properties" skin="asLargeListItemSkin" prefix="" - suffix=" + suffix="" %> <% this.parentPrototype skin="asParentList" %> From ce30c5aac4bdd55edd8485309828af1acd7d4773 Mon Sep 17 00:00:00 2001 From: hns Date: Tue, 1 Apr 2008 09:51:07 +0000 Subject: [PATCH 80/82] * Implement Application.getParentElement(). --- Application/functions.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Application/functions.js b/Application/functions.js index 52567b08..248fb68a 100644 --- a/Application/functions.js +++ b/Application/functions.js @@ -25,6 +25,13 @@ function href(action) { return action ? base + action : base; } +/** + * Method used by Helma for URL composition. + */ +function getParentElement() { + return root; +} + /** * Method used by Helma request path resolution. */ From dc887342945f3d1203bf5e12b9de7908baf999de Mon Sep 17 00:00:00 2001 From: hns Date: Fri, 4 Apr 2008 11:48:15 +0000 Subject: [PATCH 81/82] * Make Root.getAllApplications() include the apps defined in apps.properties. Requires a fresh Helma snapshot (1.6.2+). Fixes bug 520 --- Root/functions.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/Root/functions.js b/Root/functions.js index 60c9a9b6..9e8ead34 100644 --- a/Root/functions.js +++ b/Root/functions.js @@ -26,13 +26,24 @@ function renderApi(appName) { */ function getAllApplications() { var appsDir = this.getAppsHome(); - var dir = appsDir.list(); + var dir = appsDir.listFiles(); var arr = new Array(); - if (!dir) - return arr; - for (var i = 0; i < dir.length; i++) { - if (dir[i].toLowerCase() != "cvs" && dir[i].indexOf(".") == -1) - arr[arr.length] = this.getApp(dir[i]); + var seen = {}; + // first check apps directory for apps directories + if (dir) { + for (var i = 0; i < dir.length; i++) { + if (dir[i].isDirectory() && dir[i].name.toLowerCase() != "cvs") { + arr[arr.length] = this.getApp(dir[i].name); + seen[dir[i].name] = true; + } + } + } + // then check entries in apps.properties for apps not currently running + var props = wrapJavaMap(root.getAppsProperties(null)); + for (var i in props) { + if (i.indexOf(".") < 0 && !seen[i] && !root.getApplication(i)) { + arr[arr.length] = this.getApp(i); + } } return arr; } From c15785a22d2b84721befda99c234feef28a00926 Mon Sep 17 00:00:00 2001 From: zumbrunn Date: Tue, 12 Aug 2008 20:40:53 +0000 Subject: [PATCH 82/82] updated mailing list and source repository links --- Global/navig.skin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Global/navig.skin b/Global/navig.skin index 044e081d..b7d93776 100644 --- a/Global/navig.skin +++ b/Global/navig.skin @@ -20,8 +20,8 @@

    Information on helma.org:

  • reference
    -
  • mailinglist
    -
  • cvs
    +
  • mailinglist
    +
  • svn
  • download

  • type.propertiestype.properties in <% param.source %>
    <% param.content %>
    Actions
     
     
    Functions
     
     
    Macros
     
     
    Skins
     
     
    type.properties