[Phoenix-commits] rev 14280 -
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content
andi at wyona.com
andi at wyona.com
Fri Jun 16 18:25:30 CEST 2006
Author: andi
Date: 2006-06-16 18:25:28 +0200 (Fri, 16 Jun 2006)
New Revision: 14280
Added:
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/neutron.js
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/neutronparser10.js
Removed:
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/cmsui.js
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/introspectionparser10.js
Modified:
public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.xul
Log:
Adjusted module names. Note though that the parser is not yet adapted to the latest specification changes, so it may break parsing new introspection files.
Deleted: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/cmsui.js
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/cmsui.js 2006-06-16 16:21:28 UTC (rev 14279)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/cmsui.js 2006-06-16 16:25:28 UTC (rev 14280)
@@ -1,252 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Copyright 2006 Wyona AG Zurich
- *
- * This file is part of Phoenix.
- *
- * Phoenix is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Phoenix is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Phoenix; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * ***** END LICENSE BLOCK *****
- */
-
-/**
- * @author Andreas Wuest
- *
- * This module contains the code to communicate with a CMS
- * supporting the Neutron specification (see
- * http://www.wyona.org/osr-101/osr-101.xhtml).
- */
-
-var Neutron = {
- /**
- * Fetch introspection file.
- *
- * @param {String} aURI URI of CMS to query for introspection file
- * @return {Capabilities} a Capabilities object
- */
- introspection: function (aURI, aBaseURI) {
- var xmlDocument = null;
- var success = null;
- var namespace = null;
- var introspection = null;
-
- /* DEBUG */ dump("neutron.js:Neutron.introspection(\"" + aURI + "\", \"" + aBaseURI + "\") invoked\n");
-
- try {
- xmlDocument = Components.classes["@mozilla.org/xml/xml-document;1"].createInstance(Components.interfaces.nsIDOMXMLDocument);
- xmlDocument.async = false;
-
- if (xmlDocument.load(aURI)) {
- // load successful
-
- /* DEBUG */ dump("neutron.js:Neutron.introspection: loading introspection file \"" + aURI + "\" succeeded\n");
-
- // Serialize document to string for local saving (DOMXMLDocument is also a DOMNode)
- var xmlSerializer = Components.classes["@mozilla.org/xmlextras/xmlserializer;1"].getService(Components.interfaces.nsIDOMSerializer);
- var serializedDoc = xmlSerializer.serializeToString(xmlDocument);
- /* DEBUG */ dump("neutron.js:Neutron.introspection: dump of loaded introspection document:\n" + serializedDoc + "\n");
-
- // instantiate the parser for this version and parse the file
- introspection = Neutron.introspectionParserFactory(xmlDocument, aBaseURI).parseIntrospection();
-
- introspection.introspectionDocument = serializedDoc;
- introspection.introspectionURI = aURI;
-
- /* DEBUG */ dump("neutron.js:Neutron.introspection: introspection = \n" + introspection.toString() + "\n");
- } else {
- // load failed
- throw new NeutronException("neutron.js:Neutron.introspection: loading introspection file \"" + aURI + "\" failed.");
- }
- } catch (exception) {
- if (!(exception instanceof NeutronException)) {
- /* DEBUG */ PhoenixDebug.dumpExceptionToConsole("neutron.js:Neutron.introspection", exception);
- Components.utils.reportError(exception);
-
- throw new NeutronException("neutron.js:Neutron.introspection: \"" + exception + "\".");
- } else {
- // rethrow
- throw exception;
- }
- }
-
- return introspection;
- },
-
- introspectionParserFactory: function (aDocument, aBaseURI) {
- var namespace = null;
- var introspectionParser = null;
-
- /* DEBUG */ dump("neutron.js:Neutron.introspectionParserFactory(\"" + aDocument + "\", \"" + aBaseURI + "\") invoked\n");
-
- // extract introspection version
- namespace = aDocument.evaluate('neutron10:introspection/attribute::xmlns', aDocument, Neutron.nsResolver, XPathResult.STRING_TYPE, null);
-
- /* DEBUG */ dump("neutron.js:Neutron.introspectionParserFactory: introspection namespace result type = \"" + namespace.resultType + "\"\n");
- /* DEBUG */ dump("neutron.js:Neutron.introspectionParserFactory: introspection namespace = \"" + namespace + "\"\n");
- /* DEBUG */ dump("neutron.js:Neutron.introspectionParserFactory: namespace node value = \"" + namespace.stringValue + "\"\n");
-
- return new NeutronParser10(aDocument, aBaseURI);
- },
-
- nsResolver: function (aPrefix) {
- var namespace = null;
-
- /* DEBUG */ dump("neutron.js:Neutron.nsResolver(\"" + aPrefix + "\") invoked\n");
-
- var namespace = {
- 'neutron10' : 'http://www.wyona.org/neutron/1.0'
- };
- return namespace[aPrefix] || null;
- },
-
- /**
- * Save an asset at the indicated path on the server.
- *
- * @param {Asset} aAsset the asset to save
- * @param {String} aPath the location on the CMS where the asset should be saved
- * @return {Undefined}
- * @throws {Error} NeutronTransactionException
- */
- save: function (aAsset, aPath) {
- // ...
- },
-
-};
-
-/**
- * Asset constructor. Instantiates a new object of type Asset.
- *
- * @constructor
- * @param {String} aContent an URI to the file where the content resides
- * @param {String} aAssetType the asset type of the asset
- * @return {Asset} a new Asset object
- */
-function Asset(aContent, aAssetType) {
- // private instance attributes
- content = aContent;
- assetType = aAssetType;
-
- // privileged instance methods
- /**
- * Return the content URI.
- *
- * @return {String} the content URI
- */
- this.getContent = function () {
- return content;
- };
-
- /**
- * Return the asset type.
- *
- * @return {String} the asset type
- */
- this.getAssetType = function () {
- return assetType;
- };
-}
-
-/**
- * Capabilities constructor. Instantiates a new object of type Capabilities.
- *
- * @constructor
- * @return {Capabilities} a new Capabilities object
- */
-function Introspection() {
- // ...
-}
-
-Introspection.prototype = {
- introspectionDocument: null,
- introspectionURI: null,
- edit: null,
- newAsset: null,
- navigation: null,
-
- getIntrospectionDocument: function () {
- return this.introspectionDocument;
- },
-
- getIntrospectionURI: function () {
- return this.introspectionURI;
- },
-
- // THE SPECIFICATION MUST FIRST BE WRITTEN FOR THIS PART
- queryCompatibility: function () {
- // return compatibility level
- },
-
- queryEditMIMEType: function () {
- // return capability status of operation Foo
- return this.edit.mimeType;
- },
-
- queryOpenURI: function () {
- // return capability status of operation Bar
- return this.edit.open.uri;
- },
-
- queryOpenMethod: function () {
- // return capability status of operation Bar
- return this.edit.open.method;
- },
-
- querySaveURI: function () {
- // return capability status of operation Bar
- return this.edit.save.uri;
- },
-
- querySaveMethod: function () {
- // return capability status of operation Bar
- return this.edit.save.method;
- },
-
- querySchemas: function () {
- return this.edit.schemas;
- },
-
- queryStyles: function () {
- return this.edit.styles;
- },
-
- toString: function () {
- var objString = null;
-
- objString = "Edit MIME-Type: " + this.edit.mimeType + "\n";
- objString += "Edit Open URI: " + this.edit.open.uri.spec + "\n";
- objString += "Edit Open method: " + this.edit.open.method + "\n";
- objString += "Edit Save URI: " + this.edit.save.uri.spec + "\n";
- objString += "Edit Save method: " + this.edit.save.method + "\n";
- objString += "Edit Schemas: " + this.edit.schemas + "\n";
- objString += "Edit Styles: " + this.edit.styles + "\n";
-
- return objString;
- }
-};
-
-/**
- * NeutronException constructor. Instantiates a new object of
- * type NeutronException.
- *
- * @constructor
- * @param {String} aMessage a descriptive error message
- * @return {NeutronException}
- */
-function NeutronException(aMessage) {
- this.message = aMessage;
- this.name = "NeutronException";
-}
-
-NeutronException.prototype.__proto__ = Error.prototype;
Deleted: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/introspectionparser10.js
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/introspectionparser10.js 2006-06-16 16:21:28 UTC (rev 14279)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/introspectionparser10.js 2006-06-16 16:25:28 UTC (rev 14280)
@@ -1,153 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- * Copyright 2006 Wyona AG Zurich
- *
- * This file is part of Phoenix.
- *
- * Phoenix is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Phoenix is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Phoenix; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * ***** END LICENSE BLOCK *****
- */
-
-/**
- * @author Andreas Wuest
- *
- * This module contains the code to parse files
- * based on the Neutron specification (see
- * http://www.wyona.org/osr-101/osr-101.xhtml).
- */
-
-function NeutronParser10(aDocument, aBaseURI) {
- /* DEBUG */ dump("neutronparser10.js:NeutronParser10(\"" + aDocument + "\", \"" + aBaseURI + "\") invoked\n");
-
- this.introspectionDocument = aDocument;
- this.baseURI = aBaseURI;
- this.ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
-}
-
-NeutronParser10.prototype = {
- introspectionDocument: null,
- baseURI : null,
- ioService : null,
-
- nsResolver: function (aPrefix) {
- var namespace = null;
-
- /* DEBUG */ dump("neutronparser10.js:NeutronParser10.nsResolver(\"" + aPrefix + "\") invoked\n");
-
- var namespace = {
- 'neutron10' : 'http://www.wyona.org/osr-101/1.0'
- };
- return namespace[aPrefix] || null;
- },
-
- /**
- * Parse introspection file.
- *
- * @return {Neutron10} a Neutron10 object
- */
- parseIntrospection: function () {
- var introspection = null;
- var elemNode = null;
-
- /* DEBUG */ dump("neutronparser10.js:NeutronParser10.parseIntrospection() invoked\n");
-
- introspection = new Neutron10();
-
- if (elemNode = this.introspectionDocument.evaluate('neutron10:introspection/neutron10:edit', this.introspectionDocument, this.nsResolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null).iterateNext()) {
- // edit element exists
- introspection.edit = this.parseEdit(this.introspectionDocument, elemNode);
- }
-
- if (elemNode = this.introspectionDocument.evaluate('neutron10:introspection/neutron10:new', this.introspectionDocument, this.nsResolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null).iterateNext()) {
- // new element exists
- introspection.newAsset = this.parseNew(this.introspectionDocument, elemNode);
- }
-
- if (elemNode = this.introspectionDocument.evaluate('neutron10:introspection/neutron10:navigation', this.introspectionDocument, this.nsResolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null).iterateNext()) {
- // navigation element exists
- introspection.navigation = this.parseNavigation(this.introspectionDocument, elemNode);
- }
-
- return introspection;
- },
-
- parseEdit: function (aDocument, aNode) {
- return {
- mimeType: aDocument.evaluate("attribute::mime-type", aNode, this.nsResolver, XPathResult.STRING_TYPE, null).stringValue,
- open: this.parseFileOperation(aDocument, aNode, "open"),
- save: this.parseFileOperation(aDocument, aNode, "save"),
- schemas: this.parseSchemas(aDocument, aNode),
- styles: this.parseStyles(aDocument, aNode),
- };
- },
-
- parseFileOperation: function (aDocument, aNode, aOperation) {
- return {
- uri: this.ioService.newURI(aDocument.evaluate("neutron10:" + aOperation + "/attribute::url", aNode, this.nsResolver, XPathResult.STRING_TYPE, null).stringValue, null, this.baseURI),
- method: aDocument.evaluate("neutron10:" + aOperation + "/attribute::method", aNode, this.nsResolver, XPathResult.STRING_TYPE, null).stringValue
- };
- },
-
- parseSchemas: function (aDocument, aNode) {
- var schemas = null;
- var schema = null;
- var schemaArray = new Array();
- var index = 0;
-
- schemas = aDocument.evaluate("neutron10:schema", aNode, this.nsResolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
-
- while (schema = schemas.iterateNext()) {
- schemaArray[index] = {
- href: aDocument.evaluate("attribute::href", schema, this.nsResolver, XPathResult.STRING_TYPE, null).stringValue,
- type: aDocument.evaluate("attribute::type", schema, this.nsResolver, XPathResult.STRING_TYPE, null).stringValue
- }
- }
-
- return (schemaArray.length > 0 ? schemaArray : null);
- },
-
- parseStyles: function (aDocument, aNode) {
- var styles = null;
- var style = null;
- var styleArray = new Array();
- var index = 0;
-
- styles = aDocument.evaluate("neutron10:style", aNode, this.nsResolver, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
-
- while (style = styles.iterateNext()) {
- styleArray[index] = {
- href: aDocument.evaluate("attribute::href", style, this.nsResolver, XPathResult.STRING_TYPE, null).stringValue
- }
- }
-
- return (styleArray.length > 0 ? styleArray : null);
- }
-};
-
-
-/**
- * Neutron10 constructor. Instantiates a new object of type Neutron10.
- *
- * @constructor
- * @return {Neutron10} a new Neutron10 object
- */
-function Neutron10() {
- // ...
-}
-
-Neutron10.prototype = {
- __proto__: Introspection.prototype
-};
Copied: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/neutron.js (from rev 14279, public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/cmsui.js)
Copied: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/neutronparser10.js (from rev 14279, public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/introspectionparser10.js)
Modified: public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.xul
===================================================================
--- public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.xul 2006-06-16 16:21:28 UTC (rev 14279)
+++ public/phoenix/trunk/phoenix/prototypes/prototype1/src/chrome/content/phoenix.xul 2006-06-16 16:25:28 UTC (rev 14280)
@@ -45,9 +45,9 @@
<script type="application/x-javascript"
src="chrome://phoenix/content/persistenceservice.js"/>
<script type="application/x-javascript"
- src="chrome://phoenix/content/cmsui.js"/>
+ src="chrome://phoenix/content/neutron.js"/>
<script type="application/x-javascript"
- src="chrome://phoenix/content/introspectionparser10.js"/>
+ src="chrome://phoenix/content/neutronparser10.js"/>
<toolbar id="nav-bar">
<stringbundle id="uiPhoenixOverlayStringbundle" src="chrome://phoenix/locale/phoenix.properties"/>
More information about the Phoenix-commits
mailing list