[Antville-dev] Mozilla context menu extension

Franz Philipp Moser philipp.moser at chello.at
Tue Jul 20 12:54:31 CEST 2004


Hi list,

Here is the mozilla context menu extension. Hope everything works fine!
Don't forget to upgrade the antvilleLib, because of the fileSeperator bug.

No extra files are needed in static. Everything is generated from skins 
and stored in the sites static dir. So it gets only generated once. 
Maybe there is a bug if the site.alias has "-" or "." in it, but as 
before haven't tested it.

All files go to the Site object.

Point Browser to http://yourhost.yourdomain:yourport/yoursite/blog2.xpi

This only works with mozilla :), maybe firefox to, but I haven't tested it.

Hope it's useful and will become part of antville.

cu Philipp
-- 
XML is the ASCII for the new millenium
(Cocoon Documentation)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://grazia.helma.org/pipermail/antville-dev/attachments/20040720/1a1630fb/xpi_blog2.dtd.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xpi_action.js
Type: application/x-javascript
Size: 4375 bytes
Desc: not available
Url : http://grazia.helma.org/pipermail/antville-dev/attachments/20040720/1a1630fb/xpi_action.js
-------------- next part --------------
/*
 *
 * Copyright (c) 2004 Franz Philipp Moser
 *
 * Based on original code Copyright (c) 2001-2002  Ted Mielczarek
 * and Copyright (c) 2003 Phil Ringnalda
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

var blog2MenuItems<% site.alias %> = new Array("blog2-sep-<% this.alias %>", "blog2-<% this.alias %>");

var Blog2<% site.alias %> = {
    init: function() {
        //get Context menu
        var menu = document.getElementById("contentAreaContextMenu");
        menu.addEventListener("popupshowing", this.showHide, false);
    },

    showHide: function() {
        for(var i = 0; i < blog2MenuItems<% site.alias %>.length; i++) {
            var menuitem = document.getElementById(blog2MenuItems<% site.alias %>[i]);
            menuitem.hidden = false;
        }
    },

    blogThis: function(e) {
        var target = window.content.document;
        this.antvilleBlog(gContextMenu.searchSelected(), target.location.href, target.title);
    },

    antvilleBlog: function(selectedText, href, title) {
        //create link
        var link = escape('<a href="' + href + '">' + title + "</a>: " + selectedText);

        //make redirect to weblog
        var antvilleURL = "<% site.url %>stories/create?content_text=" + link;
        
        //open window with new blog url
        window.open(antvilleURL, "_blank", "");
    }
}

// do the init on load
window.addEventListener("load", Blog2<% site.alias %>.init, false); 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: xpi_blog2Overlay.xul.skin
Type: text/xml
Size: 2417 bytes
Desc: not available
Url : http://grazia.helma.org/pipermail/antville-dev/attachments/20040720/1a1630fb/xpi_blog2Overlay.xul.xml
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xpi_content_contents.rdf.skin
Type: text/xml
Size: 1101 bytes
Desc: not available
Url : http://grazia.helma.org/pipermail/antville-dev/attachments/20040720/1a1630fb/xpi_content_contents.rdf.xml
-------------- next part --------------
const APP_DISPLAY_NAME = "Blog2<% this.alias%>";
const APP_NAME = "blog2<% this.alias%>";
const APP_PACKAGE = "/Franz Philipp Moser/blog2<% this.alias%>";
const APP_VERSION = "0.9";

const APP_JAR_FILE = "blog2<% this.alias%>.jar";
const APP_CONTENT_FOLDER = "content/blog2<% this.alias%>/";
const APP_LOCALE_FOLDER  = "locale/en-US/blog2<% this.alias%>/";

const APP_SUCCESS_MESSAGE = "\nRight-click Blog2<% this.alias%> is yours.\n\n";


initInstall(APP_NAME, APP_PACKAGE, APP_VERSION);

var chromef;

if(confirm("Install this into the application directory?  (Cancel will install into your profile directory)"))
  chromef = getFolder("Chrome");
else
  chromef = getFolder("Profile", "chrome");

var err = addFile(APP_PACKAGE, APP_VERSION, APP_JAR_FILE, chromef, null)
if(err == SUCCESS) { 
	var jar = getFolder(chromef, APP_JAR_FILE);
	registerChrome(CONTENT | DELAYED_CHROME, jar, APP_CONTENT_FOLDER);
	registerChrome(LOCALE  | DELAYED_CHROME, jar, APP_LOCALE_FOLDER);
	err = performInstall();
	if(err == SUCCESS || err == REBOOT_NEEDED) {
		alert(APP_NAME + " " + APP_VERSION + " has been succesfully installed.\n"
			+APP_SUCCESS_MESSAGE
			+"Please restart your browser before continuing.");
	} else { 
		alert("Install failed. Error code:" + err);
		cancelInstall(err);
	}
} else { 
	alert("Failed to create " +APP_JAR_FILE +"\n"
		+"You probably don't have appropriate permissions \n"
		+"(write access to phoenix/chrome directory). \n"
		+"_____________________________\nError code:" + err);
	cancelInstall(err);
}

-------------- next part --------------
A non-text attachment was scrubbed...
Name: xpi_locale_contents.rdf.skin
Type: text/xml
Size: 740 bytes
Desc: not available
Url : http://grazia.helma.org/pipermail/antville-dev/attachments/20040720/1a1630fb/xpi_locale_contents.rdf.xml


More information about the Antville-dev mailing list