# HG changeset patch # User k0s # Date 1269807958 14400 # Node ID 9869cf47fcf8a8aa4ad633e7ae71882fa8971524 initial commit of Firefox addon template diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/firefoxaddon/__init__.py Sun Mar 28 16:25:58 2010 -0400 @@ -0,0 +1,22 @@ +from paste.script import templates + +var = templates.var + +class FirefoxAddon(templates.Template): + _template_dir = 'template' + summary = 'template for a firefox addon' + vars = [ + var('description', 'One-line description of the package'), + var('author', 'Author name'), + var('url', 'URL of homepage'), + ] + + def pre(self, command, output_dir, vars): + """ + called before the template is applied + """ + + def post(self, command, output_dir, vars): + """ + called after the template is applied + """ diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/template/README.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/firefoxaddon/template/README.txt Sun Mar 28 16:25:58 2010 -0400 @@ -0,0 +1,1 @@ +FirefoxAddon: template for a firefox addon diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/template/build.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/firefoxaddon/template/build.sh Sun Mar 28 16:25:58 2010 -0400 @@ -0,0 +1,128 @@ +#!/bin/bash +# build.sh -- builds JAR and XPI files for mozilla extensions +# by Nickolay Ponomarev +# (original version based on Nathan Yergler's build script) +# Most recent version is at + +# This script assumes the following directory structure: +# ./ +# chrome.manifest (optional - for newer extensions) +# install.rdf +# (other files listed in $ROOT_FILES) +# +# content/ | +# locale/ |} these can be named arbitrary and listed in $CHROME_PROVIDERS +# skin/ | +# +# defaults/ | +# components/ |} these must be listed in $ROOT_DIRS in order to be packaged +# ... | +# +# It uses a temporary directory ./build when building; don't use that! +# Script's output is: +# ./$APP_NAME.xpi +# ./$APP_NAME.jar (only if $KEEP_JAR=1) +# ./files -- the list of packaged files +# +# Note: It modifies chrome.manifest when packaging so that it points to +# chrome/$APP_NAME.jar!/* + +# +# default configuration file is ./config_build.sh, unless another file is +# specified in command-line. Available config variables: +APP_NAME= # short-name, jar and xpi files name. Must be lowercase with no spaces +CHROME_PROVIDERS= # which chrome providers we have (space-separated list) +CLEAN_UP= # delete the jar / "files" when done? (1/0) +ROOT_FILES= # put these files in root of xpi (space separated list of leaf filenames) +ROOT_DIRS= # ...and these directories (space separated list) +BEFORE_BUILD= # run this before building (bash command) +AFTER_BUILD= # ...and this after the build (bash command) + +if [ -z $1 ]; then + . ./config_build.sh +else + . $1 +fi + +if [ -z $APP_NAME ]; then + echo "You need to create build config file first!" + echo "Read comments at the beginning of this script for more info." + exit; +fi + +ROOT_DIR=`pwd` +TMP_DIR=build + +#uncomment to debug +#set -x + +# remove any left-over files from previous build +rm -f $APP_NAME.jar $APP_NAME.xpi files +rm -rf $TMP_DIR + +$BEFORE_BUILD + +mkdir --parents --verbose $TMP_DIR/chrome + +# generate the JAR file, excluding CVS and temporary files +JAR_FILE=$TMP_DIR/chrome/$APP_NAME.jar +echo "Generating $JAR_FILE..." +for CHROME_SUBDIR in $CHROME_PROVIDERS; do + find $CHROME_SUBDIR -path '*CVS*' -prune -o -type f -print | grep -v \~ >> files +done + +zip -0 -r $JAR_FILE `cat files` +# The following statement should be used instead if you don't wish to use the JAR file +#cp --verbose --parents `cat files` $TMP_DIR/chrome + +# prepare components and defaults +echo "Copying various files to $TMP_DIR folder..." +for DIR in $ROOT_DIRS; do + mkdir $TMP_DIR/$DIR + FILES="`find $DIR -path '*CVS*' -prune -o -type f -print | grep -v \~`" + echo $FILES >> files + cp --verbose --parents $FILES $TMP_DIR +done + +# Copy other files to the root of future XPI. +for ROOT_FILE in $ROOT_FILES install.rdf chrome.manifest; do + cp --verbose $ROOT_FILE $TMP_DIR + if [ -f $ROOT_FILE ]; then + echo $ROOT_FILE >> files + fi +done + +cd $TMP_DIR + +if [ -f "chrome.manifest" ]; then + echo "Preprocessing chrome.manifest..." + # You think this is scary? + #s/^(content\s+\S*\s+)(\S*\/)$/\1jar:chrome\/$APP_NAME\.jar!\/\2/ + #s/^(skin|locale)(\s+\S*\s+\S*\s+)(.*\/)$/\1\2jar:chrome\/$APP_NAME\.jar!\/\3/ + # + # Then try this! (Same, but with characters escaped for bash :) + sed -i -r s/^\(content\\s+\\S*\\s+\)\(\\S*\\/\)$/\\1jar:chrome\\/$APP_NAME\\.jar!\\/\\2/ chrome.manifest + sed -i -r s/^\(skin\|locale\)\(\\s+\\S*\\s+\\S*\\s+\)\(.*\\/\)$/\\1\\2jar:chrome\\/$APP_NAME\\.jar!\\/\\3/ chrome.manifest + + # (it simply adds jar:chrome/whatever.jar!/ at appropriate positions of chrome.manifest) +fi + +# generate the XPI file +echo "Generating $APP_NAME.xpi..." +zip -r ../$APP_NAME.xpi * + +cd "$ROOT_DIR" + +echo "Cleanup..." +if [ $CLEAN_UP = 0 ]; then + # save the jar file + mv $TMP_DIR/chrome/$APP_NAME.jar . +else + rm ./files +fi + +# remove the working files +rm -rf $TMP_DIR +echo "Done!" + +$AFTER_BUILD diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/template/chrome.manifest_tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/firefoxaddon/template/chrome.manifest_tmpl Sun Mar 28 16:25:58 2010 -0400 @@ -0,0 +1,5 @@ +content ${package} content/ +locale ${package} en-US locale/en-US/ +skin ${package} classic/1.0 skin/ +overlay chrome://browser/content/browser.xul chrome://${package}/content/firefoxOverlay.xul +style chrome://global/content/customizeToolbar.xul chrome://${package}/skin/overlay.css diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/template/config_build.sh_tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/firefoxaddon/template/config_build.sh_tmpl Sun Mar 28 16:25:58 2010 -0400 @@ -0,0 +1,9 @@ +#!/bin/bash +# Build config for build.sh +APP_NAME=${package} +CHROME_PROVIDERS="content locale skin" +CLEAN_UP=1 +ROOT_FILES= +ROOT_DIRS="defaults" +BEFORE_BUILD= +AFTER_BUILD= diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/template/content/++package++.jpg Binary file firefoxaddon/template/content/++package++.jpg has changed diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/template/content/about.xul_tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/firefoxaddon/template/content/about.xul_tmpl Sun Mar 28 16:25:58 2010 -0400 @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r 9869cf47fcf8 firefoxaddon/template/content/firefoxOverlay.xul_tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/firefoxaddon/template/content/firefoxOverlay.xul_tmpl Sun Mar 28 16:25:58 2010 -0400 @@ -0,0 +1,28 @@ + + + + +