Changes to Makefile so things build better. Start on a python script for releasing the HTML file

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1929 eee81c28-f429-11dd-99c0-75d572ba1ddd
master
Jeff Schiller 2011-01-17 22:11:35 +00:00
parent 97071abd0e
commit af0599d632
5 changed files with 161 additions and 88 deletions

View File

@ -3,48 +3,57 @@ VERSION=2.6
PACKAGE=$(NAME)-$(VERSION)
MAKEDOCS=naturaldocs/NaturalDocs
CLOSURE=build/tools/closure-compiler.jar
YUICOMPRESS=build/tools/yuicompressor.jar
ZIP=zip
# All files that will be compiled by the Closure compiler.
JS_FILES=\
browser.js \
svgtransformlist.js \
math.js \
units.js \
svgutils.js \
sanitize.js \
history.js \
select.js \
draw.js \
svgcanvas.js \
svg-editor.js \
locale/locale.js
JS_INPUT_FILES=$(addprefix editor/, $(JS_FILES))
JS_BUILD_FILES=$(addprefix build/$(PACKAGE)/, $(JS_FILES))
CLOSURE_JS_ARGS=$(addprefix --js , $(JS_INPUT_FILES))
COMPILED_JS=editor/svgedit.compiled.js
all: release firefox opera
build/$(PACKAGE):
# The build directory relies on the JS being compiled.
build/$(PACKAGE): $(COMPILED_JS)
rm -rf config
mkdir config
if [ -x $(MAKEDOCS) ] ; then $(MAKEDOCS) -i editor/ -o html docs/ -p config/ -oft -r ; fi
# Make build directory and copy all editor contents into it
mkdir -p build/$(PACKAGE)
cp -r editor/* build/$(PACKAGE)
-find build/$(PACKAGE) -name .svn -type d -exec rm -rf {} \;
# minify spin button
java -jar $(YUICOMPRESS) build/$(PACKAGE)/spinbtn/JQuerySpinBtn.js > build/$(PACKAGE)/spinbtn/JQuerySpinBtn.min.js
# minify SVG-edit files
java -jar $(YUICOMPRESS) build/$(PACKAGE)/svg-editor.js > build/$(PACKAGE)/svg-editor.min.js
java -jar $(YUICOMPRESS) build/$(PACKAGE)/svgcanvas.js > build/$(PACKAGE)/svgcanvas.min.js
# Remove all hidden .svn directories
-find build/$(PACKAGE) -name .svn -type d | xargs rm -rf {} \;
# Remove all JS files that were compiled
rm $(JS_BUILD_FILES)
# codedread: NOTE: Some files are not ready for the Closure compiler: (jquery)
$(COMPILED_JS):
java -jar $(CLOSURE) \
--js browser.js \
--js svgtransformlist.js \
--js math.js \
--js units.js \
--js svgutils.js \
--js sanitize.js \
--js history.js \
--js select.js \
--js draw.js \
--js svgcanvas.js \
--js svg-editor.js \
--js locale/locale.js \
--js_output_file svgedit.compiled.js
# CSS files do not work remotely
# java -jar $(YUICOMPRESS) build/$(PACKAGE)/spinbtn/JQuerySpinBtn.css > build/$(PACKAGE)/spinbtn/JQuerySpinBtn.min.css
# java -jar $(YUICOMPRESS) build/$(PACKAGE)/svg-editor.css > build/$(PACKAGE)/svg-editor.min.css
--compilation_level WHITESPACE_ONLY \
$(CLOSURE_JS_ARGS) \
--js_output_file $(COMPILED_JS)
release: build/$(PACKAGE)
cd build ; $(ZIP) $(PACKAGE).zip -r $(PACKAGE) ; cd ..
tar -z -c -f build/$(PACKAGE)-src.tar.gz \
--exclude-vcs \
--exclude='\.svn' \
--exclude='build/*' \
.
@ -66,3 +75,4 @@ clean:
rm -rf build/$(PACKAGE)
rm -rf build/firefox
rm -rf build/opera
rm -rf $(COMPILED_JS)

62
build/tools/ship.py Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ship.py
#
# Licensed under the Apache 2 License as is the rest of the project
#
# Copyright (c) 2011 Jeff Schiller
#
# This script takes the following inputs:
#
# * a HTML file
# * a series of flag names
#
# It parses, the HTML file, enables/disables sections of the makrup based
# on conditional comments and flag values, then outputs a new HTML file.
#
# Example:
#
# in.html:
# <!--{if foo}>
# FOO!
# <!{else}-->
# BAR!
# <!--{endif}-->
#
# $ ship.py --i in.html --o test-out.html --enable foo
#
# out.html:
# <!--{if foo}-->
# FOO!
# <!--{else}>
# BAR!
# <!{endif}-->
#
# Only if-else-endif are currently supported. All conditional comment expressions must
# be on one line with no other non-whitespace characters.
import optparse
_options_parser = optparse.OptionParser(
usage="%prog --i input.svg --o output.svg [--enable flag1]",
description=("Hello world!"))
_options_parser.add_option("--i",
action="store", dest="input_html_file", help="Input HTML filename")
_options_parser.add_option("--o",
action="store", dest="output_html_file", help="Output HTML filename")
_options_parser.add_option("--on",
action="append", type="string", dest="enabled_flags",
help="name of flag to enable")
def parse_args(args=None):
options, rargs = _options_parser.parse_args(args)
print options
if rargs:
_options_parser.error("Additional arguments not handled: %r, see --help" % rargs)
return options, (None, None)
if __name__ == '__main__':
options, (input, output) = parse_args()

View File

@ -8,6 +8,11 @@
*
*/
// Dependencies
// 1) jQuery
// 2) svgcanvas.js
// 3) svg-editor.js
var svgEditor = (function($, Editor) {
var lang_param;
@ -47,7 +52,6 @@ var svgEditor = (function($, Editor) {
}
}
Editor.readLang = function(langData) {
var more = Editor.canvas.runExtensions("addlangData", lang_param, true);
$.each(more, function(i, m) {
@ -133,9 +137,7 @@ var svgEditor = (function($, Editor) {
svginfo_grid_settings: config.grid,
svginfo_snap_onoff: config.snapping_onoff,
svginfo_snap_step: config.snapping_stepsize,
svginfo_snap_step: config.snapping_stepsize
}, true);
// Shape categories

View File

@ -9,38 +9,39 @@
<link rel="stylesheet" href="jgraduate/css/jgraduate.css" type="text/css"/>
<link rel="stylesheet" href="svg-editor.css" type="text/css"/>
<link rel="stylesheet" href="spinbtn/JQuerySpinBtn.css" type="text/css"/>
<!-- Development version of script tags: -->
<script type="text/javascript" src="jquery.js"></script>
<!--script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js"></script-->
<script type="text/javascript" src="js-hotkeys/jquery.hotkeys.min.js"></script>
<script type="text/javascript" src="jgraduate/jquery.jgraduate.js"></script>
<script type="text/javascript" src="svgicons/jquery.svgicons.js"></script>
<script type="text/javascript" src="jquerybbq/jquery.bbq.min.js"></script>
<script type="text/javascript" src="spinbtn/JQuerySpinBtn.js"></script>
<script type="text/javascript" src="contextmenu/jquery.contextMenu.js"></script>
<script type="text/javascript" src="browser.js"></script>
<script type="text/javascript" src="svgtransformlist.js"></script>
<script type="text/javascript" src="math.js"></script>
<script type="text/javascript" src="units.js"></script>
<script type="text/javascript" src="svgutils.js"></script>
<script type="text/javascript" src="sanitize.js"></script>
<script type="text/javascript" src="history.js"></script>
<script type="text/javascript" src="select.js"></script>
<script type="text/javascript" src="draw.js"></script>
<script type="text/javascript" src="svgcanvas.js"></script>
<script type="text/javascript" src="svg-editor.js"></script>
<script type="text/javascript" src="locale/locale.js"></script>
<!-- you can load extensions here -->
<!-- <script type="text/javascript" src="extensions/ext-helloworld.js"></script> -->
<!-- Release version of script tags: >
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="js-hotkeys/jquery.hotkeys-0.7.9.js"></script>
<!--{if jquery_release}>
<script type="text/javascript" src="jquery.js"></script>
<!{else}-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.js"></script>
<!--{endif}-->
<script type="text/javascript" src="js-hotkeys/jquery.hotkeys.min.js"></script>
<script type="text/javascript" src="jquerybbq/jquery.bbq.min.js"></script>
<script type="text/javascript" src="svgicons/jquery.svgicons.js"></script>
<script type="text/javascript" src="jgraduate/jquery.jgraduate.min.js"></script>
<script type="text/javascript" src="spinbtn/JQuerySpinBtn.min.js"></script>
<script type="text/javascript" src="svgedit.compiled.js"></script>
-->
<script type="text/javascript" src="contextmenu/jquery.contextMenu.min.js"></script>
<!--{if svg_edit_release}>
<script type="text/javascript" src="svgedit.compiled.js"></script>
<{else}-->
<script type="text/javascript" src="browser.js"></script>
<script type="text/javascript" src="svgtransformlist.js"></script>
<script type="text/javascript" src="math.js"></script>
<script type="text/javascript" src="units.js"></script>
<script type="text/javascript" src="svgutils.js"></script>
<script type="text/javascript" src="sanitize.js"></script>
<script type="text/javascript" src="history.js"></script>
<script type="text/javascript" src="select.js"></script>
<script type="text/javascript" src="draw.js"></script>
<script type="text/javascript" src="svgcanvas.js"></script>
<script type="text/javascript" src="svg-editor.js"></script>
<script type="text/javascript" src="locale/locale.js"></script>
<!--{endif}-->
<!-- you can load extensions here -->
<!-- <script type="text/javascript" src="extensions/ext-helloworld.js"></script> -->
<!-- always minified scripts -->
<script type="text/javascript" src="jquery-ui/jquery-ui-1.8.custom.min.js"></script>

View File

@ -262,7 +262,7 @@ if (svgedit.browser.supportsSelectors()) {
};
}
canvas.getElem = getElem;
// Function: assignAttributes
// Assigns multiple attributes to an element.
//
@ -2827,9 +2827,6 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
// in this function we do not record any state changes yet (but we do update
// any elements that are still being created, moved or resized on the canvas)
// TODO: svgcanvas should just retain a reference to the image being dragged instead
// of the getId() and getElementById() funkiness - this will help us customize the ids
// a little bit for squares and paths
var mouseMove = function(evt)
{
if (!started) return;
@ -2839,7 +2836,6 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
mouse_x = pt.x * current_zoom,
mouse_y = pt.y * current_zoom,
shape = getElem(getId());
// IE9 gives the wrong root_sctm
// TODO: Use non-browser sniffing way to make this work
if($.browser.msie) {
@ -3567,8 +3563,10 @@ var getMouseTarget = this.getMouseTarget = function(evt) {
return false;
};
$(container).mousedown(mouseDown).mousemove(mouseMove).click(handleLinkInCanvas).dblclick(dblClick);
$(window).mouseup(mouseUp);
// Added mouseup to the container here.
// TODO(codedread): Figure out why after the Closure compiler, the window mouseup is ignored.
$(container).mousedown(mouseDown).mousemove(mouseMove).click(handleLinkInCanvas).dblclick(dblClick).mouseup(mouseUp);
// $(window).mouseup(mouseUp);
$(container).bind("mousewheel DOMMouseScroll", function(e){
if(!e.shiftKey) return;
@ -7016,7 +7014,7 @@ this.cloneLayer = function(name) {
// Deletes the current layer from the drawing and then clears the selection. This function
// then calls the 'changed' handler. This is an undoable action.
this.deleteCurrentLayer = function() {
if (current_layer && current_drawing.all_layers.length > 1) {
if (current_layer && current_drawing.getNumLayers() > 1) {
var batchCmd = new BatchCommand("Delete Layer");
// actually delete from the DOM and store in our Undo History
var parent = current_layer.parentNode;
@ -7026,7 +7024,7 @@ this.deleteCurrentLayer = function() {
addCommandToHistory(batchCmd);
clearSelection();
identifyLayers();
canvas.setCurrentLayer(current_drawing.all_layers[current_drawing.all_layers.length-1][0]);
canvas.setCurrentLayer(current_drawing.getLayer(current_drawing.getNumLayers()));
call("changed", [svgcontent]);
return true;
}
@ -7042,7 +7040,7 @@ this.deleteCurrentLayer = function() {
this.getCurrentLayer = function() {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (current_drawing.all_layers[i][1] == current_layer) {
return current_drawing.all_layers[i][0];
return current_drawing.getLayer(i);
}
}
return "";
@ -7059,8 +7057,8 @@ this.getCurrentLayer = function() {
// true if the current layer was switched, otherwise false
this.setCurrentLayer = function(name) {
name = svgedit.utilities.toXml(name);
for (var i = 0; i < current_drawing.all_layers.length; ++i) {
if (name == current_drawing.all_layers[i][0]) {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (name == current_drawing.getLayer(i)) {
if (current_layer != current_drawing.all_layers[i][1]) {
clearSelection();
current_layer.setAttribute("style", "pointer-events:none");
@ -7090,10 +7088,10 @@ this.renameCurrentLayer = function(newname) {
if (!canvas.setCurrentLayer(newname)) {
var batchCmd = new BatchCommand("Rename Layer");
// find the index of the layer
for (var i = 0; i < current_drawing.all_layers.length; ++i) {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (current_drawing.all_layers[i][1] == oldLayer) break;
}
var oldname = current_drawing.all_layers[i][0];
var oldname = current_drawing.getLayer(i);
current_drawing.all_layers[i][0] = svgedit.utilities.toXml(newname);
// now change the underlying title element contents
@ -7130,19 +7128,19 @@ this.renameCurrentLayer = function(newname) {
// Returns:
// true if the current layer position was changed, false otherwise.
this.setCurrentLayerPosition = function(newpos) {
if (current_layer && newpos >= 0 && newpos < current_drawing.all_layers.length) {
for (var oldpos = 0; oldpos < current_drawing.all_layers.length; ++oldpos) {
if (current_layer && newpos >= 0 && newpos < current_drawing.getNumLayers()) {
for (var oldpos = 0; oldpos < current_drawing.getNumLayers(); ++oldpos) {
if (current_drawing.all_layers[oldpos][1] == current_layer) break;
}
// some unknown error condition (current_layer not in all_layers)
if (oldpos == current_drawing.all_layers.length) { return false; }
if (oldpos == current_drawing.getNumLayers()) { return false; }
if (oldpos != newpos) {
// if our new position is below us, we need to insert before the node after newpos
var refLayer = null;
var oldNextSibling = current_layer.nextSibling;
if (newpos > oldpos ) {
if (newpos < current_drawing.all_layers.length-1) {
if (newpos < current_drawing.getNumLayers()-1) {
refLayer = current_drawing.all_layers[newpos+1][1];
}
}
@ -7154,7 +7152,7 @@ this.setCurrentLayerPosition = function(newpos) {
addCommandToHistory(new MoveElementCommand(current_layer, oldNextSibling, svgcontent));
identifyLayers();
canvas.setCurrentLayer(current_drawing.all_layers[newpos][0]);
canvas.setCurrentLayer(current_drawing.getLayer(newpos));
return true;
}
@ -7175,8 +7173,8 @@ this.setCurrentLayerPosition = function(newpos) {
this.getLayerVisibility = function(layername) {
// find the layer
var layer = null;
for (var i = 0; i < current_drawing.all_layers.length; ++i) {
if (current_drawing.all_layers[i][0] == layername) {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (current_drawing.getLayer(i) == layername) {
layer = current_drawing.all_layers[i][1];
break;
}
@ -7198,8 +7196,8 @@ this.getLayerVisibility = function(layername) {
this.setLayerVisibility = function(layername, bVisible) {
// find the layer
var layer = null;
for (var i = 0; i < current_drawing.all_layers.length; ++i) {
if (current_drawing.all_layers[i][0] == layername) {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (current_drawing.getLayer(i) == layername) {
layer = current_drawing.all_layers[i][1];
break;
}
@ -7232,8 +7230,8 @@ this.setLayerVisibility = function(layername, bVisible) {
this.moveSelectedToLayer = function(layername) {
// find the layer
var layer = null;
for (var i = 0; i < current_drawing.all_layers.length; ++i) {
if (current_drawing.all_layers[i][0] == layername) {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (current_drawing.getLayer(i) == layername) {
layer = current_drawing.all_layers[i][1];
break;
}
@ -7300,7 +7298,7 @@ this.mergeLayer = function(skipHistory) {
this.mergeAllLayers = function() {
var batchCmd = new BatchCommand("Merge all Layers");
current_layer = current_drawing.all_layers[current_drawing.all_layers.length-1][1];
current_layer = current_drawing.all_layers[current_drawing.getNumLayers()-1][1];
while($(svgcontent).children('g').length > 1) {
batchCmd.addSubCommand(canvas.mergeLayer(true));
}
@ -7321,8 +7319,8 @@ this.mergeAllLayers = function() {
// The opacity value of the given layer. This will be a value between 0.0 and 1.0, or null
// if layername is not a valid layer
this.getLayerOpacity = function(layername) {
for (var i = 0; i < current_drawing.all_layers.length; ++i) {
if (current_drawing.all_layers[i][0] == layername) {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (current_drawing.getLayer(i) == layername) {
var g = current_drawing.all_layers[i][1];
var opacity = g.getAttribute("opacity");
if (!opacity) {
@ -7347,8 +7345,8 @@ this.getLayerOpacity = function(layername) {
// opacity - a float value in the range 0.0-1.0
this.setLayerOpacity = function(layername, opacity) {
if (opacity < 0.0 || opacity > 1.0) return;
for (var i = 0; i < current_drawing.all_layers.length; ++i) {
if (current_drawing.all_layers[i][0] == layername) {
for (var i = 0; i < current_drawing.getNumLayers(); ++i) {
if (current_drawing.getLayer(i) == layername) {
var g = current_drawing.all_layers[i][1];
g.setAttribute("opacity", opacity);
break;