Author: hannes
Date: 2008-12-18 15:58:33 +0100 (Thu, 18 Dec 2008)
New Revision: 9446
Added:
apps/gobi/trunk/code/Global/Config.js
apps/gobi/trunk/extensions/search/Global/Config.js
Removed:
apps/gobi/trunk/code/gobi.conf
Modified:
apps/gobi/trunk/code/Global/Startup.js
apps/gobi/trunk/extensions/search/README.txt
Log:
Change xml-based gobi.conf with an in-application Javascript-based config, making it easier for extensions to register services and create pages.
Details at http://dev.helma.org/trac/helma/changeset/9446
Added: apps/gobi/trunk/code/Global/Config.js
Modified: apps/gobi/trunk/code/Global/Startup.js
===================================================================
--- apps/gobi/trunk/code/Global/Startup.js 2008-12-18 13:57:31 UTC (rev 9445)
+++ apps/gobi/trunk/code/Global/Startup.js 2008-12-18 14:58:33 UTC (rev 9446)
@@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
/**
* Application onStart script. this is called when the application is started.
* It reads a file called gobi.conf in the application directory and uses
@@ -40,18 +40,14 @@
app.logger.error("Caught in convertAttachments: " + x);
}
- try {
- // check our service nodes are set up as defined in gobi.conf
- var conf = Xml.get("file:///"+app.appDir+"/gobi.conf");
-
- register(root, conf);
-
- } catch (x) {
- app.log("Error reading gobi.conf: "+x);
- if (x.javaException)
- x.javaException.printStackTrace();
+ for (var i = 0; i < gobi.pages.length; i++) {
+ registerPage(root, gobi.pages[i]);
}
-
+
+ for (var i = 0; i < gobi.services.length; i++) {
+ registerService(root, gobi.services[i]);
+ }
+
// register forms for prototypes
registerForm("Page");
@@ -61,26 +57,10 @@
}
}
-function register(base, conf) {
- if (conf.page) {
- var pages = conf.page.list();
- for (var i in pages) {
- registerPage(base, pages[i]);
- }
- }
-
- if (conf.service) {
- var services = conf.service.list();
- for (var i in services) {
- registerService(base, services[i]);
- }
- }
-}
-
function registerPage(base, conf) {
app.log("Registering page " + conf.path);
if (!conf.path) {
- app.log("Illegal page definition in in gobi.conf: "+
+ app.log("Illegal page definition in in gobi.conf: " +
"path=" + conf.path);
return null;
}
@@ -94,27 +74,23 @@
function applyPageConfig(page, conf) {
page.childtype = conf.childtype;
-
- register(page, conf);
-
- if (conf.property) {
- var props = conf.property.list();
- for (var i in props) {
- page[props[i].name] = props[i].value;
+ if (conf.properties) {
+ for (var i in conf.properties) {
+ page[i] = conf.properties[i];
}
}
}
function registerService(base, conf) {
- app.log("Registering service "+conf.name);
+ app.log("Registering service " + conf.name);
if (!conf.name) {
app.log("Illegal service definition in in gobi.conf: "+
- "name="+conf.name);
+ "name=" + conf.name);
return null;
}
// check if service page exists
- var srvLinkName = "system:service:"+conf.name;
+ var srvLinkName = "system:service:" + conf.name;
var links = root.getLinks(srvLinkName, "out");
var page = links.length > 0 ? links[0].target : null;
@@ -122,9 +98,9 @@
try {
page = registerPage(base, conf);
root.addLink(srvLinkName, "out", page);
- app.log("Created service instance for "+conf.name+": "+page.name);
+ app.log("Created service instance for " + conf.name + ": " + page.name);
} catch (error) {
- app.log("Error creating service for "+conf.name+": "+error);
+ app.log("Error creating service for " + conf.name + ": " + error);
}
} else {
applyPageConfig(page, conf);
Deleted: apps/gobi/trunk/code/gobi.conf
Added: apps/gobi/trunk/extensions/search/Global/Config.js
Modified: apps/gobi/trunk/extensions/search/README.txt
===================================================================
--- apps/gobi/trunk/extensions/search/README.txt 2008-12-18 13:57:31 UTC (rev 9445)
+++ apps/gobi/trunk/extensions/search/README.txt 2008-12-18 14:58:33 UTC (rev 9446)
@@ -9,14 +9,7 @@
## INSTALLATION ##
##################
-You need to install the Helma modules in your Helma installation directory. To
-create the search service add the following lines to gobi.conf:
-
- <service name="search"
- path="search"
- type="Search"/>
-
-Then, add the extension directory itself to the list of repositories in
+To install, add the extension directory itself to the list of repositories in
apps.properties (example):
gobi.repository.1 = ./apps/gobi/extensions/search/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.