Skip to content

Instantly share code, notes, and snippets.

@HashNuke
Created February 17, 2010 06:20
Show Gist options
  • Save HashNuke/306363 to your computer and use it in GitHub Desktop.
Save HashNuke/306363 to your computer and use it in GitHub Desktop.
Script to generate a skeletal AIR application
#!/bin/sh
#Script to generate a skeletal HTML AIR application
#Copyright (C) 2010 Akash Manohar J (akashxav.com)
#
#Instructions:
#add <air_sdk>/bin to path (skip this if you did when you installed AIR SDK)
#save file as newairapp in the <air_sdk>/bin
#chmod+x <air_sdk>/bin/newairapp
#usage: newairapp <app_name>
#example: newairapp HelloAir
if [ -d $1 ] && [ ! $# -eq 0 ]
then
echo "The directory $1 already exists"
exit 0
fi
if [ $# -eq 1 ]
then
xml_desc_file="$1-app.xml"
main_html_file="$1.html"
current_dir_app_path=`pwd`"/$1"
mkdir $current_dir_app_path
echo "Created application dir: $current_dir_app_path"
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"\
"<application xmlns=\"http://ns.adobe.com/air/application/1.5\">\n"\
"\t <id>com.$USERNAME.$1</id>\n"\
"\t <version>0.1</version>\n"\
"\t <filename>$1</filename>\n"\
"\t <initialWindow>\n"\
"\t\t <content>$main_html_file</content>\n"\
"\t\t <visible>true</visible>\n"\
"\t\t <width>400</width>\n"\
"\t\t <height>200</height>\n"\
"\t </initialWindow>\n"\
"</application>" > $current_dir_app_path/$xml_desc_file
echo "Created application descriptor: $current_dir_app_path/$xml_desc_file"
echo "<html>\n"\
"\t<head>\n"\
"\t\t<script type=\"text/javascript\" src=\"AIRAliases.js\"></script>\n"\
"\t\t<script type=\"text/javascript\">\n"\
"\t\tfunction appLoad(){\n"\
"\t\t\t\tair.trace(\"Hello World\");\n"\
"\t\t}\n"\
"\t\t</script>\n"\
"\t\t<title>$1</title>\n"\
"\t</head>\n"\
"\t<body onLoad=\"appLoad()\">\n"\
"\t\t<h1>Hello World</h1>\n"\
"\t</body>\n"\
"</html>" > $current_dir_app_path/$main_html_file
echo "Created main view: "$main_html_file
current_dir=`pwd`
script_dir=$(dirname $0)
cd $script_dir
cp ../frameworks/libs/air/AIRAliases.js $current_dir_app_path"/"AIRAliases.js
exit 0
else
echo "Creates an AIR HTML application skeleton in the current directory"
echo "Usage: \n\tnewairapp <app_name>"
echo "Example: \n\tnewairapp HelloAIR"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment