Skip to content

Commit

Permalink
Merge branch 'bzr/golem' of /Users/distler/Sites/code/instiki
Browse files Browse the repository at this point in the history
  • Loading branch information
distler committed Feb 27, 2010
2 parents 529a91f + 519f81a commit 57fe0b9
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 300 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG
Expand Up @@ -4,6 +4,27 @@ N.B.: You *must* run

after installing the new software, to enjoy the benefits of this new version.

------------------------------------------------------------------------------
* 0.19

New Features:

* WYSIWYG SVG editing (via SVG-edit)
* One-click S5 templates

Bugs Fixed:

* Allow special characters ('.', '/', etc) in page names.
* Fix BlahTeX/PNG path, so equations render in diff and
previous revision pages.
* Fix HTML Export feature so that o uploaded files are
included, stylesheets load, etc.
* Uploaded files inclided in Markup Export.
* Fix Print View, so that uploaded images work.
* Fix some more Ruby 1.9 isues.
* Prevent page from being renamed to null.
* Fix Migration to work under PostgreSQL (from J. Zellman).

------------------------------------------------------------------------------
* 0.18.1

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Expand Up @@ -270,10 +270,10 @@ def charset=(encoding)
module Instiki
module VERSION #:nodoc:
MAJOR = 0
MINOR = 18
TINY = 1
MINOR = 19
TINY = 0
SUFFIX = '(MML+)'
PRERELEASE = false
PRERELEASE = 'pre'
if PRERELEASE
STRING = [MAJOR, MINOR].join('.') + PRERELEASE + SUFFIX
else
Expand Down
2 changes: 2 additions & 0 deletions public/javascripts/page_helper.js
Expand Up @@ -91,6 +91,7 @@ function setupSVGedit(path){
window.close();
}
});
editor.svgCanvas.randomizeIds();
editor.svgCanvas.setSvgString(selected);
}, true);
} else {
Expand All @@ -101,6 +102,7 @@ function setupSVGedit(path){
window.close();
}
});
editor.svgCanvas.randomizeIds();
}, true);
}
SVGeditButton.disabled = true;
Expand Down
18 changes: 16 additions & 2 deletions public/svg-edit/editor/extensions/ext-arrows.js
Expand Up @@ -13,9 +13,11 @@ $(function() {
var svgcontent = S.svgcontent,
addElem = S.addSvgElementFromJson,
nonce = S.nonce,
randomize_ids = S.randomize_ids,
selElems;

svgCanvas.bind('setarrownonce', setArrowNonce);
svgCanvas.bind('unsetsetarrownonce', unsetArrowNonce);

var lang_list = {
"en":[
Expand All @@ -27,16 +29,28 @@ $(function() {
};

var prefix = 'se_arrow_';
var arrowprefix = prefix + nonce + '_';
if (randomize_ids) {
var arrowprefix = prefix + nonce + '_';
} else {
var arrowprefix = prefix;
}

var pathdata = {
fw: {d:"m0,0l10,5l-10,5l5,-5l-5,-5z", refx:8, id: arrowprefix + 'fw'},
bk: {d:"m10,0l-10,5l10,5l-5,-5l5,-5z", refx:2, id: arrowprefix + 'bk'}
}

function setArrowNonce(window, n) {
randomize_ids = true;
arrowprefix = prefix + n + '_';
pathdata.fw.id = arrowprefix + 'fw';
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
}

function unsetArrowNonce(window) {
randomize_ids = false;
arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
}

Expand Down
321 changes: 31 additions & 290 deletions public/svg-edit/editor/images/logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions public/svg-edit/editor/svg-editor.html
Expand Up @@ -156,6 +156,12 @@ <h3 id="layersLabel">Layers</h3>
<div class="push_button" id="tool_topath" title="Convert to Path"></div>
<div class="push_button" id="tool_reorient" title="Reorient path"></div>
<div class="tool_sep"></div>
<!--
<label>
<span>id:</span>
<input id="elem_id" class="attr_changer" data-attr="id" size="10" type="text" title="Identify the element"/>
</label>
-->
</div>
<div class="toolset" id="tool_opacity">
<label>
Expand Down
14 changes: 13 additions & 1 deletion public/svg-edit/editor/svg-editor.js
Expand Up @@ -665,6 +665,7 @@ function svg_edit_setup() {
};

// updates the toolbar (colors, opacity, etc) based on the selected element
// This function also updates the opacity and id elements that are in the context panel
var updateToolbar = function() {
if (selectedElement != null &&
selectedElement.tagName != "image" &&
Expand Down Expand Up @@ -727,6 +728,7 @@ function svg_edit_setup() {
var opac_perc = ((selectedElement.getAttribute("opacity")||1.0)*100);
$('#group_opacity').val(opac_perc);
$('#opac_slider').slider('option', 'value', opac_perc);
$('#elem_id').val(selectedElement.id);
}

updateToolButtonState();
Expand Down Expand Up @@ -1034,7 +1036,17 @@ function svg_edit_setup() {
this.value = selectedElement.getAttribute(attr);
return false;
}
// if the user is changing the id, then de-select the element first
// change the ID, then re-select it with the new ID
if (attr == "id") {
var elem = selectedElement;
svgCanvas.clearSelection();
elem.id = val;
svgCanvas.addToSelection([elem],true);
}
else {
svgCanvas.changeSelectedAttribute(attr, val);
}
});

// Prevent selection of elements when shift-clicking
Expand Down Expand Up @@ -2778,7 +2790,7 @@ function svg_edit_setup() {
updateCanvas(true);
});

// var revnums = "svg-editor.js ($Rev: 1430 $) ";
// var revnums = "svg-editor.js ($Rev: 1433 $) ";
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute("title", revnums);
return svgCanvas;
Expand Down
56 changes: 52 additions & 4 deletions public/svg-edit/editor/svgcanvas.js
Expand Up @@ -945,6 +945,7 @@ function BatchCommand(text) {

//nonce to uniquify id's
var nonce = Math.floor(Math.random()*100001);
var randomize_ids = false;

// map namespace URIs to prefixes
var nsMap = {};
Expand Down Expand Up @@ -986,9 +987,9 @@ function BatchCommand(text) {
overflow: 'visible',
xmlns: svgns,
"xmlns:se": se_ns,
"se:nonce": nonce,
"xmlns:xlink": xlinkns
}).appendTo(svgroot);
if (randomize_ids) svgContent.setAttributeNS(se_ns, nonce);

var convertToNum, convertToUnit, setUnitAttr;

Expand Down Expand Up @@ -1071,6 +1072,20 @@ function BatchCommand(text) {
if(re.test(val)) valid = true;
});
}
} else if (attr == "id") {
// if we're trying to change the id, make sure it's not already present in the doc
// and the id value is valid.

var result = false;
// because getElem() can throw an exception in the case of an invalid id
// (according to http://www.w3.org/TR/xml-id/ IDs must be a NCName)
// we wrap it in an exception and only return true if the ID was valid and
// not already present
try {
var elem = getElem(val);
result = (elem == null);
} catch(e) {}
return result;
} else valid = true;

return valid;
Expand Down Expand Up @@ -1289,7 +1304,11 @@ function BatchCommand(text) {
// private functions
var getId = function() {
if (events["getid"]) return call("getid", obj_num);
return idprefix + nonce +'_' + obj_num;
if (randomize_ids) {
return idprefix + nonce +'_' + obj_num;
} else {
return idprefix + obj_num;
}
};

var getNextId = function() {
Expand Down Expand Up @@ -5525,6 +5544,27 @@ function BatchCommand(text) {
return svgCanvasToString();
};

//function randomizeIds
// This function determines whether to add a nonce to the prefix, when
// generating IDs in SVG-Edit
//
// Parameters:
// an opional boolean, which, if true, adds a nonce to the prefix. Thus
// svgCanvas.randomizeIds() <==> svgCanvas.randomizeIds(true)
//
// if you're controlling SVG-Edit externally, and want randomized IDs, call
// this BEFORE calling svgCanvas.setSvgString
//
this.randomizeIds = function() {
if (arguments.length > 0 && arguments[0] == false) {
randomize_ids = false;
if (extensions["Arrows"]) call("unsetarrownonce") ;
} else {
randomize_ids = true;
}
}

//
// Function: setSvgString
// This function sets the current drawing as the input SVG XML.
//
Expand All @@ -5551,11 +5591,13 @@ function BatchCommand(text) {
// retrieve or set the nonce
n = svgcontent.getAttributeNS(se_ns, 'nonce');
if (n) {
randomize_ids = true;
nonce = n;
if (extensions["Arrows"]) call("setarrownonce", n) ;
} else {
} else if (randomize_ids) {
svgcontent.setAttributeNS(xmlnsns, 'xml:se', se_ns);
svgcontent.setAttributeNS(se_ns, 'se:nonce', nonce);
if (extensions["Arrows"]) call("setarrownonce", nonce) ;
}
// change image href vals if possible
$(svgcontent).find('image').each(function() {
Expand Down Expand Up @@ -5650,6 +5692,11 @@ function BatchCommand(text) {
// Returns:
// This function returns false if the import was unsuccessful, true otherwise.

// TODO: properly handle if namespace is introduced by imported content (must add to svgcontent
// and update all prefixes in the imported node)
// TODO: properly handle recalculating dimensions, recalculateDimensions() doesn't handle
// arbitrary transform lists, but makes some assumptions about how the transform list
// was obtained
// TODO: import should happen in top-left of current zoomed viewport
// TODO: create a new layer for the imported SVG
this.importSvgString = function(xmlString) {
Expand Down Expand Up @@ -7908,7 +7955,7 @@ function BatchCommand(text) {
// Function: getVersion
// Returns a string which describes the revision number of SvgCanvas.
this.getVersion = function() {
return "svgcanvas.js ($Rev: 1431 $)";
return "svgcanvas.js ($Rev: 1433 $)";
};

this.setUiStrings = function(strs) {
Expand Down Expand Up @@ -8200,4 +8247,5 @@ var Utils = {
catch(e){ throw new Error("Error parsing XML string"); };
return out;
}

};

0 comments on commit 57fe0b9

Please sign in to comment.