You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by cd...@apache.org on 2007/03/23 16:48:04 UTC
svn commit: r521779 - in /forrest/trunk/tools/forrestbar/xpi:
chrome/content/contents.rdf chrome/content/forrestbarOverlay.js
chrome/content/forrestbarOverlay.xul chrome/content/forrestbarSettings.xul
install.rdf
Author: cdupoirieux
Date: Fri Mar 23 08:48:03 2007
New Revision: 521779
URL: http://svn.apache.org/viewvc?view=rev&rev=521779
Log:
FOR-962 - Add an options window to set the localhost and the port.
These are saved in user preferences.
Added:
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul (with props)
Modified:
forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js
forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul
forrest/trunk/tools/forrestbar/xpi/install.rdf
Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf
URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf (original)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf Fri Mar 23 08:48:03 2007
@@ -17,14 +17,15 @@
-->
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
+ xmlns:chrome="http://www.mozilla.org/rdf/chrome#"
+ chrome:settingsURL="chrome://forrestbar/content/forrestbarSettings.xul">
<RDF:Seq about="urn:mozilla:package:root">
<RDF:li resource="urn:mozilla:package:forrestbar"/>
</RDF:Seq>
<RDF:Description about="urn:mozilla:package:forrestbar"
- chrome:extension="true" chrome:name="forrestbar" chrome:displayName="ForrestBar 0.7"/>
+ chrome:extension="true" chrome:name="forrestbar" chrome:displayName="ForrestBar 0.8"/>
<RDF:Seq about="urn:mozilla:overlays">
<RDF:li resource="chrome://browser/content/browser.xul"/>
Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js
URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js (original)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js Fri Mar 23 08:48:03 2007
@@ -28,6 +28,12 @@
{
removeEventListener ("load",startforrestbar, true); // Keep the event from firing a hundred more times.
}
+ setLocalHostMenuItemLabel();
+}
+
+function setLocalHostMenuItemLabel()
+{
+ document.getElementById("forrest.run.menuitem").label="Local Forrest (" + getLocalWebServer() + ")";
}
addEventListener("load", startforrestbar, true); // Run the startup function when the window loads
@@ -96,8 +102,11 @@
function contract(subUrl,searchID)
{
- var searchItem = document.getElementById(searchID);
- navigate('http://localhost:8888/'+subUrl + searchItem.value);
+ if( isLocalUrlOrWarnMe() )
+ {
+ var searchItem = document.getElementById(searchID);
+ navigate(getLocalWebServerUrl() + subUrl + searchItem.value);
+ }
}
function navProject(searchID) {
@@ -108,12 +117,10 @@
function viewXML(xmltype)
{
var href = gBrowser.currentURI.spec;
- if( ! isLocalUrl())
+ if( isLocalUrlOrWarnMe() )
{
- alert("This action is only available on Local Forrest (jetty) site...");
- return(false);
+ (dispatcherCall)?navigate(getLocalWebServerUrl()+xmltype+href.substring(getLocalWebServerUrl().length, href.lastIndexOf('.') )):navigate(href.substring(0, href.lastIndexOf('.') ) + xmltype);
}
- (dispatcherCall)?navigate("http://localhost:8888/"+xmltype+href.substring(href.lastIndexOf('8888/')+5, href.lastIndexOf('.') )):navigate(href.substring(0, href.lastIndexOf('.') ) + xmltype);
}
function isLocalUrl ()
@@ -122,11 +129,114 @@
return( (typeof(href) != 'undefined') &&
(href.substr) &&
- (startsWith(href, 'http://127.0.0.1:8888/') || startsWith(href, 'http://localhost:8888/'))
+ (startsWith(href, getLocalWebServerUrl() ))
);
}
+function isLocalUrlOrWarnMe()
+{
+ var isIt = isLocalUrl();
+ if( ! isIt )
+ {
+ alert("This action is only available on Local Forrest (jetty) site...");
+ }
+ return isIt;
+}
+
function startsWith(st, pref)
{
return( (pref.length > 0) && (st.substring(0, pref.length) == pref) );
}
+
+/* ----------- */
+/* Forrest Run */
+/* ----------- */
+function navigateForrestRun() {
+ navigate( getLocalWebServerUrl() );
+}
+
+function getLocalWebServer() {
+ var localhost= getForrestRunHost() + ":" + getForrestRunPort() ;
+ return localhost;
+}
+
+function getLocalWebServerUrl() {
+ var Url= "http://" + getLocalWebServer() + "/" ;
+ return Url;
+}
+
+/* ----------------- */
+/* Options functions */
+/* ----------------- */
+
+/* Getting preferences */
+function getForrestRunHost()
+{
+ var prefservice = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
+ var prefs = prefservice.getBranch("");
+
+ var forrestHost = null;
+ if (prefs.getPrefType("forrestbar.run.host") == prefs.PREF_STRING)
+ {
+ forrestHost = prefs.getCharPref("forrestbar.run.host");
+ }
+ if ((forrestHost == null) || (forrestHost.length = 0))
+ {
+ forrestHost='localhost';
+ }
+ return forrestHost;
+}
+
+function getForrestRunPort()
+{
+ var prefservice = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
+ var prefs = prefservice.getBranch("");
+
+ var forrestPort = null;
+ if (prefs.getPrefType("forrestbar.run.port") == prefs.PREF_STRING)
+ {
+ forrestPort = prefs.getCharPref("forrestbar.run.port");
+ }
+ if ((forrestPort == null) || (forrestPort.length = 0))
+ {
+ forrestPort='8888';
+ }
+ return forrestPort;
+}
+
+/* Initialising Options Panel */
+function initForrestBarOptions()
+{
+ document.getElementById('forrestbar.run.host').value = getForrestRunHost();
+ document.getElementById('forrestbar.run.port').value = getForrestRunPort();
+}
+
+/* recording Options in prefs */
+function setForrestBarOptions()
+{
+ var prefService = Components.classes["@mozilla.org/preferences-service;1"]
+ .getService(Components.interfaces.nsIPrefService);
+ var prefs = prefService.getBranch("");
+
+ var oldHost=getForrestRunHost();
+ var oldPort=getForrestRunPort();
+ var newHost=document.getElementById('forrestbar.run.host').value;
+ var newPort=document.getElementById('forrestbar.run.port').value;
+ var change=false;
+
+ if( oldHost != newHost )
+ {
+ change=true;
+ prefs.setCharPref("forrestbar.run.host", newHost);
+ }
+ if( oldPort != newPort )
+ {
+ change=true;
+ prefs.setCharPref("forrestbar.run.port", newPort);
+ }
+ if( change )
+ alert("Warning! the label of the Local Forrest item will be refreshed at the next start of your browser...");
+
+ window.close();
+}
+
Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul
URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul (original)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul Fri Mar 23 08:48:03 2007
@@ -35,10 +35,7 @@
<menuitem label="Docs for development version" onclick="navigate('http://forrest.apache.org/docs/dev/');" />
<menuitem label="Testing Zone" onclick="navigate('http://forrest.zones.apache.org/');" />
<menuseparator />
- <menuitem label="Local Forrest (localhost:8888)" onclick="navigate('http://localhost:8888/');" hidden="false" />
- <menuitem label="Local Forrest (127.0.0.1:8888)" onclick="navigate('http://127.0.0.1:8888/');" hidden="false" />
- <menuseparator />
- <menuitem label="Local Forrest (127.0.0.1:8080)" onclick="navigate('http://127.0.0.1:8080/');" hidden="false" />
+ <menuitem label="Local Forrest (localhost:8888)" onclick="navigateForrestRun();" hidden="false" id="forrest.run.menuitem"/>
</menupopup>
</toolbarbutton>
Added: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul?view=auto&rev=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul (added)
+++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul Fri Mar 23 08:48:03 2007
@@ -0,0 +1,65 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- FIXME - should be forrestbar.css ... -->
+<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
+
+<dialog xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ onload="initForrestBarOptions();"
+ ondialogaccept="setForrestBarOptions();"
+ title="Forrest Bar Options">
+
+ <html:script language="javascript" src="chrome://forrestbar/content/forrestbarOverlay.js" />
+
+ <tabbox>
+ <tabs>
+ <tab label="Forrest Run Options"/>
+ </tabs>
+
+ <tabpanels>
+ <tabpanel>
+ <vbox>
+ <groupbox>
+ <caption label="Host"/>
+ <description>Indicate here the name of the host runing Forrest Run.</description>
+ <hbox align="center">
+ <label control="forresthost" value="Host"/>
+ <menulist id="forrestbar.run.host">
+ <menupopup>
+ <menuitem label="localhost" value="localhost"/>
+ <menuitem label="127.0.0.1" value="127.0.0.1"/>
+ </menupopup>
+ </menulist>
+ </hbox>
+ <hbox align="center">
+ <label control="forrestport" value="Port"/>
+ <textbox id="forrestbar.run.port"
+ pref="true"
+ preftype="string"
+ prefstring="forrestbar.run.port"
+ size="15"
+ />
+ </hbox>
+ </groupbox>
+ </vbox>
+ </tabpanel>
+ </tabpanels>
+ </tabbox>
+</dialog>
+
Propchange: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
------------------------------------------------------------------------------
svn:eol-style = native
Modified: forrest/trunk/tools/forrestbar/xpi/install.rdf
URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/install.rdf?view=diff&rev=521779&r1=521778&r2=521779
==============================================================================
--- forrest/trunk/tools/forrestbar/xpi/install.rdf (original)
+++ forrest/trunk/tools/forrestbar/xpi/install.rdf Fri Mar 23 08:48:03 2007
@@ -22,6 +22,12 @@
<Description about="urn:mozilla:install-manifest">
<em:id>{057e51a0-7e81-4749-ad58-d5e32a6084a9}</em:id> <!-- need guid for 1.0 -->
<em:version>0.8-dev</em:version>
+ <em:contributor>Nicola Ken Barozzi</em:contributor>
+ <em:contributor>Dave Brondsema</em:contributor>
+ <em:contributor>David Crossley</em:contributor>
+ <em:contributor>Cyriaque Dupoirieux</em:contributor>
+ <em:contributor>Ross Gardler</em:contributor>
+ <em:contributor>Thorsten Scherler</em:contributor>
<!-- <em:type>2</em:type> only used in 1.5 and not needed for extensions. -->
<!-- Target Applications with minimum and maximum supported versions. -->
@@ -58,7 +64,7 @@
<em:description>Navigation and developer assistance for Apache Forrest-related documentation frameworks</em:description>
<em:creator>Apache Forrest community</em:creator>
<em:homepageURL>http://www.forrest.apache.org/</em:homepageURL>
-
+ <em:optionsURL>chrome://forrestbar/content/forrestbarSettings.xul</em:optionsURL>
<!-- Need this for 1.0 compatibility -->
<em:file>
<Description about="urn:mozilla:extension:file:forrestbar.jar">
Re: svn commit: r521779 - in /forrest/trunk/tools/forrestbar/xpi:
chrome/content/contents.rdf chrome/content/forrestbarOverlay.js chrome/content/forrestbarOverlay.xul
chrome/content/forrestbarSettings.xul install.rdf
Posted by Ross Gardler <rg...@apache.org>.
Cyriaque Dupoirieux wrote:
> Do you want I rollback my commit ?
No please do not roll it back.
Thanks for your time on this, I think we can create a better solution
and only intended to record how this could be done. As things stand,
your solution is better than the one I've committed ;-)
Ross
Re: svn commit: r521779 - in /forrest/trunk/tools/forrestbar/xpi:
chrome/content/contents.rdf chrome/content/forrestbarOverlay.js chrome/content/forrestbarOverlay.xul
chrome/content/forrestbarSettings.xul install.rdf
Posted by Cyriaque Dupoirieux <Cy...@pcotech.fr>.
Ross,
Do you want I rollback my commit ?
In that case, can you explain me the problem you have (I mean, when does
the forrest bar loose the port ?)
Salutations,
Cyriaque,
le 26/03/2007 12:13 Ross Gardler a écrit :
> Cyriaque Dupoirieux wrote:
>> le 25/03/2007 01:26 Ross Gardler a écrit :
>>> Cyriaque Dupoirieux wrote:
>>>> Ross,
>>>>
>>>> If you think this commit correct the FOR-962 -
>>>> https://issues.apache.org/jira/browse/FOR-962 -, just tell me and
>>>> I'll close it.
>>>
>>> I've not tested it, but it looks like an OK workaround.
>> You are cruel with me to say I have just made a workaround ;-) .
>>>
>>> However, I wonder if we need to set a property for this. The port
>>> number is in the URL of the currently viewed page, can't we just
>>> extract it?
>> Ok, my concerns are :
>>
>> * What can be the first access to "Forrest run" if we don't have
>> properties to define the host and the port ?
>
> The first access will almost never be a request for one of the
> internal dispatcher files, if it is we can simply throw up a box
> asking for the port (or just an error saying go to the index page first).
>
>
>> * How to be sure the current Url is a "forrest run" Url. You may
>> have several local ports which are not for forrest.
>
> That is not a problem introduced by this requirement. The URL for
> dispatcher menu stuff is already derived from the browser URL, e.g.
> click on "dispatcher-dev -> structurer".
>
> Ross
>
>
Re: svn commit: r521779 - in /forrest/trunk/tools/forrestbar/xpi:
chrome/content/contents.rdf chrome/content/forrestbarOverlay.js chrome/content/forrestbarOverlay.xul
chrome/content/forrestbarSettings.xul install.rdf
Posted by Ross Gardler <rg...@apache.org>.
Cyriaque Dupoirieux wrote:
> le 25/03/2007 01:26 Ross Gardler a écrit :
>> Cyriaque Dupoirieux wrote:
>>> Ross,
>>>
>>> If you think this commit correct the FOR-962 -
>>> https://issues.apache.org/jira/browse/FOR-962 -, just tell me and
>>> I'll close it.
>>
>> I've not tested it, but it looks like an OK workaround.
> You are cruel with me to say I have just made a workaround ;-) .
>>
>> However, I wonder if we need to set a property for this. The port
>> number is in the URL of the currently viewed page, can't we just
>> extract it?
> Ok, my concerns are :
>
> * What can be the first access to "Forrest run" if we don't have
> properties to define the host and the port ?
The first access will almost never be a request for one of the internal
dispatcher files, if it is we can simply throw up a box asking for the
port (or just an error saying go to the index page first).
> * How to be sure the current Url is a "forrest run" Url. You may
> have several local ports which are not for forrest.
That is not a problem introduced by this requirement. The URL for
dispatcher menu stuff is already derived from the browser URL, e.g.
click on "dispatcher-dev -> structurer".
Ross
Re: svn commit: r521779 - in /forrest/trunk/tools/forrestbar/xpi:
chrome/content/contents.rdf chrome/content/forrestbarOverlay.js chrome/content/forrestbarOverlay.xul
chrome/content/forrestbarSettings.xul install.rdf
Posted by Cyriaque Dupoirieux <Cy...@pcotech.fr>.
le 25/03/2007 01:26 Ross Gardler a écrit :
> Cyriaque Dupoirieux wrote:
>> Ross,
>>
>> If you think this commit correct the FOR-962 -
>> https://issues.apache.org/jira/browse/FOR-962 -, just tell me and
>> I'll close it.
>
> I've not tested it, but it looks like an OK workaround.
You are cruel with me to say I have just made a workaround ;-) .
>
> However, I wonder if we need to set a property for this. The port
> number is in the URL of the currently viewed page, can't we just
> extract it?
Ok, my concerns are :
* What can be the first access to "Forrest run" if we don't have
properties to define the host and the port ?
* How to be sure the current Url is a "forrest run" Url. You may
have several local ports which are not for forrest.
o Several options in Dev. menu make a test to check the action
is available (display the toc, the body of the current page...)
Salutations,
Cyriaque,
>
> Ross
>
>
Re: svn commit: r521779 - in /forrest/trunk/tools/forrestbar/xpi:
chrome/content/contents.rdf chrome/content/forrestbarOverlay.js chrome/content/forrestbarOverlay.xul
chrome/content/forrestbarSettings.xul install.rdf
Posted by Ross Gardler <rg...@apache.org>.
Cyriaque Dupoirieux wrote:
> Ross,
>
> If you think this commit correct the FOR-962 -
> https://issues.apache.org/jira/browse/FOR-962 -, just tell me and I'll
> close it.
I've not tested it, but it looks like an OK workaround.
However, I wonder if we need to set a property for this. The port number
is in the URL of the currently viewed page, can't we just extract it?
Ross
Re: svn commit: r521779 - in /forrest/trunk/tools/forrestbar/xpi:
chrome/content/contents.rdf chrome/content/forrestbarOverlay.js chrome/content/forrestbarOverlay.xul
chrome/content/forrestbarSettings.xul install.rdf
Posted by Cyriaque Dupoirieux <Cy...@pcotech.fr>.
Ross,
If you think this commit correct the FOR-962 -
https://issues.apache.org/jira/browse/FOR-962 -, just tell me and I'll
close it.
Thanks,
Salutations,
Cyriaque,
le 23/03/2007 16:48 cdupoirieux@apache.org a écrit :
> Author: cdupoirieux
> Date: Fri Mar 23 08:48:03 2007
> New Revision: 521779
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=521779
> Log:
> FOR-962 - Add an options window to set the localhost and the port.
> These are saved in user preferences.
>
> Added:
> forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul (with props)
> Modified:
> forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf
> forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js
> forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul
> forrest/trunk/tools/forrestbar/xpi/install.rdf
>
> Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf
> URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf?view=diff&rev=521779&r1=521778&r2=521779
> ==============================================================================
> --- forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf (original)
> +++ forrest/trunk/tools/forrestbar/xpi/chrome/content/contents.rdf Fri Mar 23 08:48:03 2007
> @@ -17,14 +17,15 @@
> -->
>
> <RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> - xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
> + xmlns:chrome="http://www.mozilla.org/rdf/chrome#"
> + chrome:settingsURL="chrome://forrestbar/content/forrestbarSettings.xul">
>
> <RDF:Seq about="urn:mozilla:package:root">
> <RDF:li resource="urn:mozilla:package:forrestbar"/>
> </RDF:Seq>
>
> <RDF:Description about="urn:mozilla:package:forrestbar"
> - chrome:extension="true" chrome:name="forrestbar" chrome:displayName="ForrestBar 0.7"/>
> + chrome:extension="true" chrome:name="forrestbar" chrome:displayName="ForrestBar 0.8"/>
>
> <RDF:Seq about="urn:mozilla:overlays">
> <RDF:li resource="chrome://browser/content/browser.xul"/>
>
> Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js
> URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js?view=diff&rev=521779&r1=521778&r2=521779
> ==============================================================================
> --- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js (original)
> +++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.js Fri Mar 23 08:48:03 2007
> @@ -28,6 +28,12 @@
> {
> removeEventListener ("load",startforrestbar, true); // Keep the event from firing a hundred more times.
> }
> + setLocalHostMenuItemLabel();
> +}
> +
> +function setLocalHostMenuItemLabel()
> +{
> + document.getElementById("forrest.run.menuitem").label="Local Forrest (" + getLocalWebServer() + ")";
> }
>
> addEventListener("load", startforrestbar, true); // Run the startup function when the window loads
> @@ -96,8 +102,11 @@
>
> function contract(subUrl,searchID)
> {
> - var searchItem = document.getElementById(searchID);
> - navigate('http://localhost:8888/'+subUrl + searchItem.value);
> + if( isLocalUrlOrWarnMe() )
> + {
> + var searchItem = document.getElementById(searchID);
> + navigate(getLocalWebServerUrl() + subUrl + searchItem.value);
> + }
> }
>
> function navProject(searchID) {
> @@ -108,12 +117,10 @@
> function viewXML(xmltype)
> {
> var href = gBrowser.currentURI.spec;
> - if( ! isLocalUrl())
> + if( isLocalUrlOrWarnMe() )
> {
> - alert("This action is only available on Local Forrest (jetty) site...");
> - return(false);
> + (dispatcherCall)?navigate(getLocalWebServerUrl()+xmltype+href.substring(getLocalWebServerUrl().length, href.lastIndexOf('.') )):navigate(href.substring(0, href.lastIndexOf('.') ) + xmltype);
> }
> - (dispatcherCall)?navigate("http://localhost:8888/"+xmltype+href.substring(href.lastIndexOf('8888/')+5, href.lastIndexOf('.') )):navigate(href.substring(0, href.lastIndexOf('.') ) + xmltype);
> }
>
> function isLocalUrl ()
> @@ -122,11 +129,114 @@
>
> return( (typeof(href) != 'undefined') &&
> (href.substr) &&
> - (startsWith(href, 'http://127.0.0.1:8888/') || startsWith(href, 'http://localhost:8888/'))
> + (startsWith(href, getLocalWebServerUrl() ))
> );
> }
>
> +function isLocalUrlOrWarnMe()
> +{
> + var isIt = isLocalUrl();
> + if( ! isIt )
> + {
> + alert("This action is only available on Local Forrest (jetty) site...");
> + }
> + return isIt;
> +}
> +
> function startsWith(st, pref)
> {
> return( (pref.length > 0) && (st.substring(0, pref.length) == pref) );
> }
> +
> +/* ----------- */
> +/* Forrest Run */
> +/* ----------- */
> +function navigateForrestRun() {
> + navigate( getLocalWebServerUrl() );
> +}
> +
> +function getLocalWebServer() {
> + var localhost= getForrestRunHost() + ":" + getForrestRunPort() ;
> + return localhost;
> +}
> +
> +function getLocalWebServerUrl() {
> + var Url= "http://" + getLocalWebServer() + "/" ;
> + return Url;
> +}
> +
> +/* ----------------- */
> +/* Options functions */
> +/* ----------------- */
> +
> +/* Getting preferences */
> +function getForrestRunHost()
> +{
> + var prefservice = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
> + var prefs = prefservice.getBranch("");
> +
> + var forrestHost = null;
> + if (prefs.getPrefType("forrestbar.run.host") == prefs.PREF_STRING)
> + {
> + forrestHost = prefs.getCharPref("forrestbar.run.host");
> + }
> + if ((forrestHost == null) || (forrestHost.length = 0))
> + {
> + forrestHost='localhost';
> + }
> + return forrestHost;
> +}
> +
> +function getForrestRunPort()
> +{
> + var prefservice = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
> + var prefs = prefservice.getBranch("");
> +
> + var forrestPort = null;
> + if (prefs.getPrefType("forrestbar.run.port") == prefs.PREF_STRING)
> + {
> + forrestPort = prefs.getCharPref("forrestbar.run.port");
> + }
> + if ((forrestPort == null) || (forrestPort.length = 0))
> + {
> + forrestPort='8888';
> + }
> + return forrestPort;
> +}
> +
> +/* Initialising Options Panel */
> +function initForrestBarOptions()
> +{
> + document.getElementById('forrestbar.run.host').value = getForrestRunHost();
> + document.getElementById('forrestbar.run.port').value = getForrestRunPort();
> +}
> +
> +/* recording Options in prefs */
> +function setForrestBarOptions()
> +{
> + var prefService = Components.classes["@mozilla.org/preferences-service;1"]
> + .getService(Components.interfaces.nsIPrefService);
> + var prefs = prefService.getBranch("");
> +
> + var oldHost=getForrestRunHost();
> + var oldPort=getForrestRunPort();
> + var newHost=document.getElementById('forrestbar.run.host').value;
> + var newPort=document.getElementById('forrestbar.run.port').value;
> + var change=false;
> +
> + if( oldHost != newHost )
> + {
> + change=true;
> + prefs.setCharPref("forrestbar.run.host", newHost);
> + }
> + if( oldPort != newPort )
> + {
> + change=true;
> + prefs.setCharPref("forrestbar.run.port", newPort);
> + }
> + if( change )
> + alert("Warning! the label of the Local Forrest item will be refreshed at the next start of your browser...");
> +
> + window.close();
> +}
> +
>
> Modified: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul
> URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul?view=diff&rev=521779&r1=521778&r2=521779
> ==============================================================================
> --- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul (original)
> +++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarOverlay.xul Fri Mar 23 08:48:03 2007
> @@ -35,10 +35,7 @@
> <menuitem label="Docs for development version" onclick="navigate('http://forrest.apache.org/docs/dev/');" />
> <menuitem label="Testing Zone" onclick="navigate('http://forrest.zones.apache.org/');" />
> <menuseparator />
> - <menuitem label="Local Forrest (localhost:8888)" onclick="navigate('http://localhost:8888/');" hidden="false" />
> - <menuitem label="Local Forrest (127.0.0.1:8888)" onclick="navigate('http://127.0.0.1:8888/');" hidden="false" />
> - <menuseparator />
> - <menuitem label="Local Forrest (127.0.0.1:8080)" onclick="navigate('http://127.0.0.1:8080/');" hidden="false" />
> + <menuitem label="Local Forrest (localhost:8888)" onclick="navigateForrestRun();" hidden="false" id="forrest.run.menuitem"/>
> </menupopup>
> </toolbarbutton>
>
>
> Added: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
> URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul?view=auto&rev=521779
> ==============================================================================
> --- forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul (added)
> +++ forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul Fri Mar 23 08:48:03 2007
> @@ -0,0 +1,65 @@
> +<?xml version="1.0"?>
> +<!--
> + Licensed to the Apache Software Foundation (ASF) under one or more
> + contributor license agreements. See the NOTICE file distributed with
> + this work for additional information regarding copyright ownership.
> + The ASF licenses this file to You under the Apache License, Version 2.0
> + (the "License"); you may not use this file except in compliance with
> + the License. You may obtain a copy of the License at
> +
> + http://www.apache.org/licenses/LICENSE-2.0
> +
> + Unless required by applicable law or agreed to in writing, software
> + distributed under the License is distributed on an "AS IS" BASIS,
> + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + See the License for the specific language governing permissions and
> + limitations under the License.
> +-->
> +<!-- FIXME - should be forrestbar.css ... -->
> +<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
> +
> +<dialog xmlns:html="http://www.w3.org/1999/xhtml"
> + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
> + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
> + onload="initForrestBarOptions();"
> + ondialogaccept="setForrestBarOptions();"
> + title="Forrest Bar Options">
> +
> + <html:script language="javascript" src="chrome://forrestbar/content/forrestbarOverlay.js" />
> +
> + <tabbox>
> + <tabs>
> + <tab label="Forrest Run Options"/>
> + </tabs>
> +
> + <tabpanels>
> + <tabpanel>
> + <vbox>
> + <groupbox>
> + <caption label="Host"/>
> + <description>Indicate here the name of the host runing Forrest Run.</description>
> + <hbox align="center">
> + <label control="forresthost" value="Host"/>
> + <menulist id="forrestbar.run.host">
> + <menupopup>
> + <menuitem label="localhost" value="localhost"/>
> + <menuitem label="127.0.0.1" value="127.0.0.1"/>
> + </menupopup>
> + </menulist>
> + </hbox>
> + <hbox align="center">
> + <label control="forrestport" value="Port"/>
> + <textbox id="forrestbar.run.port"
> + pref="true"
> + preftype="string"
> + prefstring="forrestbar.run.port"
> + size="15"
> + />
> + </hbox>
> + </groupbox>
> + </vbox>
> + </tabpanel>
> + </tabpanels>
> + </tabbox>
> +</dialog>
> +
>
> Propchange: forrest/trunk/tools/forrestbar/xpi/chrome/content/forrestbarSettings.xul
> ------------------------------------------------------------------------------
> svn:eol-style = native
>
> Modified: forrest/trunk/tools/forrestbar/xpi/install.rdf
> URL: http://svn.apache.org/viewvc/forrest/trunk/tools/forrestbar/xpi/install.rdf?view=diff&rev=521779&r1=521778&r2=521779
> ==============================================================================
> --- forrest/trunk/tools/forrestbar/xpi/install.rdf (original)
> +++ forrest/trunk/tools/forrestbar/xpi/install.rdf Fri Mar 23 08:48:03 2007
> @@ -22,6 +22,12 @@
> <Description about="urn:mozilla:install-manifest">
> <em:id>{057e51a0-7e81-4749-ad58-d5e32a6084a9}</em:id> <!-- need guid for 1.0 -->
> <em:version>0.8-dev</em:version>
> + <em:contributor>Nicola Ken Barozzi</em:contributor>
> + <em:contributor>Dave Brondsema</em:contributor>
> + <em:contributor>David Crossley</em:contributor>
> + <em:contributor>Cyriaque Dupoirieux</em:contributor>
> + <em:contributor>Ross Gardler</em:contributor>
> + <em:contributor>Thorsten Scherler</em:contributor>
> <!-- <em:type>2</em:type> only used in 1.5 and not needed for extensions. -->
>
> <!-- Target Applications with minimum and maximum supported versions. -->
> @@ -58,7 +64,7 @@
> <em:description>Navigation and developer assistance for Apache Forrest-related documentation frameworks</em:description>
> <em:creator>Apache Forrest community</em:creator>
> <em:homepageURL>http://www.forrest.apache.org/</em:homepageURL>
> -
> + <em:optionsURL>chrome://forrestbar/content/forrestbarSettings.xul</em:optionsURL>
> <!-- Need this for 1.0 compatibility -->
> <em:file>
> <Description about="urn:mozilla:extension:file:forrestbar.jar">
>
>
>
>