databaseformalizer 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.project +18 -0
- data/README +256 -0
- data/README.md +2 -0
- data/Rakefile +21 -0
- data/app/controllers/databaseformalizer/attr_defs_controller.rb +98 -0
- data/app/controllers/databaseformalizer/attr_vals_controller.rb +85 -0
- data/app/controllers/databaseformalizer/dbformahome_controller.rb +7 -0
- data/app/controllers/databaseformalizer/entities_controller.rb +105 -0
- data/app/controllers/databaseformalizer/entity_defs_controller.rb +90 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/databaseformalizer/application_helper.rb +4 -0
- data/app/helpers/databaseformalizer/attr_defs_helper.rb +4 -0
- data/app/helpers/databaseformalizer/attr_vals_helper.rb +4 -0
- data/app/helpers/databaseformalizer/dbformahome_helper.rb +4 -0
- data/app/helpers/databaseformalizer/entities_helper.rb +160 -0
- data/app/helpers/databaseformalizer/entity_defs_helper.rb +68 -0
- data/app/models/databaseformalizer/attr_def.rb +48 -0
- data/app/models/databaseformalizer/attr_list_join_def.rb +17 -0
- data/app/models/databaseformalizer/attr_list_join_val.rb +18 -0
- data/app/models/databaseformalizer/attr_val.rb +36 -0
- data/app/models/databaseformalizer/attr_vals_entity.rb +18 -0
- data/app/models/databaseformalizer/entity.rb +27 -0
- data/app/models/databaseformalizer/entity_def.rb +24 -0
- data/app/models/databaseformalizer/entity_def_attr_def.rb +18 -0
- data/app/views/databaseformalizer/attr_defs/_form.html.erb +74 -0
- data/app/views/databaseformalizer/attr_defs/edit.html.erb +7 -0
- data/app/views/databaseformalizer/attr_defs/index.html.erb +38 -0
- data/app/views/databaseformalizer/attr_defs/new.html.erb +6 -0
- data/app/views/databaseformalizer/attr_defs/show.html.erb +50 -0
- data/app/views/databaseformalizer/attr_vals/_form.html.erb +29 -0
- data/app/views/databaseformalizer/attr_vals/edit.html.erb +7 -0
- data/app/views/databaseformalizer/attr_vals/index.html.erb +28 -0
- data/app/views/databaseformalizer/attr_vals/new.html.erb +6 -0
- data/app/views/databaseformalizer/attr_vals/show.html.erb +20 -0
- data/app/views/databaseformalizer/dbformahome/index.html.erb +19 -0
- data/app/views/databaseformalizer/entities/_attr_val_boolean_form.html.erb +7 -0
- data/app/views/databaseformalizer/entities/_attr_val_checkList_form.html.erb +22 -0
- data/app/views/databaseformalizer/entities/_attr_val_datetime_form.html.erb +15 -0
- data/app/views/databaseformalizer/entities/_attr_val_entityDef_form.html.erb +14 -0
- data/app/views/databaseformalizer/entities/_attr_val_form_all.html.erb +4 -0
- data/app/views/databaseformalizer/entities/_attr_val_form_one.html.erb +6 -0
- data/app/views/databaseformalizer/entities/_attr_val_integer_form.html.erb +10 -0
- data/app/views/databaseformalizer/entities/_attr_val_openList_element_form.html.erb +16 -0
- data/app/views/databaseformalizer/entities/_attr_val_openList_form.html.erb +12 -0
- data/app/views/databaseformalizer/entities/_attr_val_selectOneInList_form.html.erb +20 -0
- data/app/views/databaseformalizer/entities/_attr_val_string_form.html.erb +10 -0
- data/app/views/databaseformalizer/entities/_attr_val_text_form.html.erb +10 -0
- data/app/views/databaseformalizer/entities/_form.html.erb +54 -0
- data/app/views/databaseformalizer/entities/edit.html.erb +8 -0
- data/app/views/databaseformalizer/entities/index.html.erb +45 -0
- data/app/views/databaseformalizer/entities/new.html.erb +10 -0
- data/app/views/databaseformalizer/entities/new.js.erb +1 -0
- data/app/views/databaseformalizer/entities/show.html.erb +50 -0
- data/app/views/databaseformalizer/entity_defs/_form.html.erb +51 -0
- data/app/views/databaseformalizer/entity_defs/edit.html.erb +7 -0
- data/app/views/databaseformalizer/entity_defs/index.html.erb +57 -0
- data/app/views/databaseformalizer/entity_defs/new.html.erb +6 -0
- data/app/views/databaseformalizer/entity_defs/show.html.erb +30 -0
- data/app/views/databaseformalizer/layouts/application.html.erb +134 -0
- data/databaseformalizer.gemspec +34 -0
- data/lib/acts_as_entity/base.rb +101 -0
- data/lib/application_controller.rb +21 -0
- data/lib/application_helper.rb +3 -0
- data/lib/databaseformalizer.rb +27 -0
- data/lib/engine.rb +23 -0
- data/lib/generators/entity_def/USAGE +8 -0
- data/lib/generators/entity_def/entity_def_generator.rb +39 -0
- data/lib/generators/entity_def/templates/controller.rb +98 -0
- data/lib/generators/entity_def/templates/helper.rb +2 -0
- data/lib/generators/entity_def/templates/model.rb +3 -0
- data/lib/generators/entity_def/templates/view/_form.html.erb +35 -0
- data/lib/generators/entity_def/templates/view/edit.html.erb +6 -0
- data/lib/generators/entity_def/templates/view/index.html.erb +27 -0
- data/lib/generators/entity_def/templates/view/new.html.erb +5 -0
- data/lib/generators/entity_def/templates/view/show.html.erb +3 -0
- data/lib/rails/generators/databaseformalizer/databaseformalizer_generator.rb +52 -0
- data/lib/rails/generators/databaseformalizer/templates/initializer.rb +8 -0
- data/lib/rails/generators/databaseformalizer/templates/migration.rb +9 -0
- data/lib/rails/generators/databaseformalizer/templates/migration.rb.bak +9 -0
- data/lib/rails/generators/databaseformalizer/templates/schema.rb +84 -0
- data/lib/rails/railties/tasks.rake +8 -0
- data/public/bootstrap/css/bootstrap-fixed-header.css +15 -0
- data/public/bootstrap/css/bootstrap-responsive.css +808 -0
- data/public/bootstrap/css/bootstrap-responsive.min.css +9 -0
- data/public/bootstrap/css/bootstrap-toggle.css +242 -0
- data/public/bootstrap/css/cerulean/bootstrap.min.css +740 -0
- data/public/bootstrap/css/img/glyphicons-halflings-white.png +0 -0
- data/public/bootstrap/css/img/glyphicons-halflings.png +0 -0
- data/public/bootstrap/js/bootstrap-alert.js +90 -0
- data/public/bootstrap/js/bootstrap-collapse.js +157 -0
- data/public/bootstrap/js/bootstrap-dropdown.js +100 -0
- data/public/bootstrap/js/bootstrap-fixed-header.js +54 -0
- data/public/bootstrap/js/bootstrap-modal.js +218 -0
- data/public/bootstrap/js/bootstrap-popover.js +98 -0
- data/public/bootstrap/js/bootstrap-tab.js +135 -0
- data/public/bootstrap/js/bootstrap-toggle.js +104 -0
- data/public/bootstrap/js/bootstrap-tooltip.js +275 -0
- data/public/bootstrap/js/bootstrap-transition.js +61 -0
- data/public/bootstrap/js/bootstrap.js +1824 -0
- data/public/bootstrap/js/bootstrap.min.js +6 -0
- data/public/images/Thumbs.db +0 -0
- data/public/images/bootstrap/Thumbs.db +0 -0
- data/public/images/bootstrap/glyphicons-halflings.png +0 -0
- data/public/images/databaseformalizer.jpg +0 -0
- data/public/images/metamodel.png +0 -0
- data/public/images/model.png +0 -0
- data/public/javascripts/databaseformalizer.js +13 -0
- data/public/javascripts/jquery.js +9252 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
- data/public/jquery-ui/css/ui-lightness/jquery-ui-1.8.21.custom.css +565 -0
- data/public/jquery-ui/js/jquery-1.7.2.min.js +4 -0
- data/public/jquery-ui/js/jquery-ui-1.8.21.custom.min.js +125 -0
- data/public/jquery-validation/README.md +8 -0
- data/public/jquery-validation/additional-methods.js +300 -0
- data/public/jquery-validation/additional-methods.min.js +29 -0
- data/public/jquery-validation/changelog.txt +277 -0
- data/public/jquery-validation/jquery.validate.js +1188 -0
- data/public/jquery-validation/jquery.validate.min.js +51 -0
- data/public/jquery-validation/lib/jquery-1.3.2.js +4376 -0
- data/public/jquery-validation/lib/jquery-1.4.2.js +6240 -0
- data/public/jquery-validation/lib/jquery-1.4.4.js +7179 -0
- data/public/jquery-validation/lib/jquery-1.5.2.js +8374 -0
- data/public/jquery-validation/lib/jquery-1.6.1.js +8936 -0
- data/public/jquery-validation/lib/jquery.form.js +660 -0
- data/public/jquery-validation/lib/jquery.js +4376 -0
- data/public/jquery-validation/lib/jquery.metadata.js +122 -0
- data/public/jquery-validation/lib/jquery.mockjax.js +382 -0
- data/public/jquery-validation/localization/messages_ar.js +24 -0
- data/public/jquery-validation/localization/messages_bg.js +23 -0
- data/public/jquery-validation/localization/messages_ca.js +23 -0
- data/public/jquery-validation/localization/messages_cn.js +23 -0
- data/public/jquery-validation/localization/messages_cs.js +23 -0
- data/public/jquery-validation/localization/messages_da.js +20 -0
- data/public/jquery-validation/localization/messages_de.js +20 -0
- data/public/jquery-validation/localization/messages_el.js +24 -0
- data/public/jquery-validation/localization/messages_es.js +23 -0
- data/public/jquery-validation/localization/messages_eu.js +23 -0
- data/public/jquery-validation/localization/messages_fa.js +23 -0
- data/public/jquery-validation/localization/messages_fi.js +21 -0
- data/public/jquery-validation/localization/messages_fr.js +23 -0
- data/public/jquery-validation/localization/messages_ge.js +23 -0
- data/public/jquery-validation/localization/messages_he.js +23 -0
- data/public/jquery-validation/localization/messages_hu.js +20 -0
- data/public/jquery-validation/localization/messages_it.js +23 -0
- data/public/jquery-validation/localization/messages_ja.js +23 -0
- data/public/jquery-validation/localization/messages_kk.js +23 -0
- data/public/jquery-validation/localization/messages_lt.js +23 -0
- data/public/jquery-validation/localization/messages_lv.js +23 -0
- data/public/jquery-validation/localization/messages_nl.js +23 -0
- data/public/jquery-validation/localization/messages_no.js +23 -0
- data/public/jquery-validation/localization/messages_pl.js +23 -0
- data/public/jquery-validation/localization/messages_ptbr.js +23 -0
- data/public/jquery-validation/localization/messages_ptpt.js +23 -0
- data/public/jquery-validation/localization/messages_ro.js +23 -0
- data/public/jquery-validation/localization/messages_ru.js +23 -0
- data/public/jquery-validation/localization/messages_se.js +21 -0
- data/public/jquery-validation/localization/messages_si.js +23 -0
- data/public/jquery-validation/localization/messages_sk.js +20 -0
- data/public/jquery-validation/localization/messages_sl.js +23 -0
- data/public/jquery-validation/localization/messages_sr.js +23 -0
- data/public/jquery-validation/localization/messages_th.js +23 -0
- data/public/jquery-validation/localization/messages_tr.js +23 -0
- data/public/jquery-validation/localization/messages_tw.js +23 -0
- data/public/jquery-validation/localization/messages_ua.js +23 -0
- data/public/jquery-validation/localization/messages_vi.js +23 -0
- data/public/jquery-validation/localization/methods_de.js +12 -0
- data/public/jquery-validation/localization/methods_nl.js +9 -0
- data/public/jquery-validation/localization/methods_pt.js +9 -0
- data/public/jquery-validation/todo +172 -0
- data/public/jquery-validation/version.txt +1 -0
- data/public/stylesheets/databaseformalizer.css +64 -0
- data/public/stylesheets/scaffold.css +56 -0
- data/public/tablesorter/addons/.svn/all-wcprops +5 -0
- data/public/tablesorter/addons/.svn/entries +31 -0
- data/public/tablesorter/addons/pager/.svn/all-wcprops +17 -0
- data/public/tablesorter/addons/pager/.svn/entries +96 -0
- data/public/tablesorter/addons/pager/.svn/prop-base/jquery.tablesorter.pager.css.svn-base +5 -0
- data/public/tablesorter/addons/pager/.svn/prop-base/jquery.tablesorter.pager.js.svn-base +5 -0
- data/public/tablesorter/addons/pager/.svn/text-base/jquery.tablesorter.pager.css.svn-base +25 -0
- data/public/tablesorter/addons/pager/.svn/text-base/jquery.tablesorter.pager.js.svn-base +184 -0
- data/public/tablesorter/addons/pager/jquery.tablesorter.pager.css +25 -0
- data/public/tablesorter/addons/pager/jquery.tablesorter.pager.js +184 -0
- data/public/tablesorter/build/.svn/all-wcprops +47 -0
- data/public/tablesorter/build/.svn/entries +266 -0
- data/public/tablesorter/build/.svn/prop-base/ParseMaster.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/js.jar.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/jsmin.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/min.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/pack.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/packer.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/prop-base/writeFile.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/text-base/ParseMaster.js.svn-base +106 -0
- data/public/tablesorter/build/.svn/text-base/js.jar.svn-base +0 -0
- data/public/tablesorter/build/.svn/text-base/jsmin.js.svn-base +316 -0
- data/public/tablesorter/build/.svn/text-base/min.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/text-base/pack.js.svn-base +5 -0
- data/public/tablesorter/build/.svn/text-base/packer.js.svn-base +316 -0
- data/public/tablesorter/build/.svn/text-base/writeFile.js.svn-base +19 -0
- data/public/tablesorter/build/ParseMaster.js +106 -0
- data/public/tablesorter/build/js.jar +0 -0
- data/public/tablesorter/build/jsmin.js +316 -0
- data/public/tablesorter/build/min.js +5 -0
- data/public/tablesorter/build/pack.js +5 -0
- data/public/tablesorter/build/packer.js +316 -0
- data/public/tablesorter/build/writeFile.js +19 -0
- data/public/tablesorter/build.xml +26 -0
- data/public/tablesorter/changelog +41 -0
- data/public/tablesorter/jquery-latest.js +154 -0
- data/public/tablesorter/jquery.metadata.js +122 -0
- data/public/tablesorter/jquery.tablesorter.js +1031 -0
- data/public/tablesorter/jquery.tablesorter.min.js +4 -0
- data/public/tablesorter/jquery.tablesorter.widgets.js +433 -0
- data/public/tablesorter/jquery.ui.datepicker.js +1727 -0
- data/public/tablesorter/style.css +110 -0
- data/public/tablesorter/themes/.svn/all-wcprops +5 -0
- data/public/tablesorter/themes/.svn/entries +34 -0
- data/public/tablesorter/themes/blue/.svn/all-wcprops +35 -0
- data/public/tablesorter/themes/blue/.svn/entries +198 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/asc.gif.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/bg.gif.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/blue.zip.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/desc.gif.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/prop-base/style.css.svn-base +5 -0
- data/public/tablesorter/themes/blue/.svn/text-base/asc.gif.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/bg.gif.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/blue.zip.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/desc.gif.svn-base +0 -0
- data/public/tablesorter/themes/blue/.svn/text-base/style.css.svn-base +39 -0
- data/public/tablesorter/themes/blue/asc.gif +0 -0
- data/public/tablesorter/themes/blue/bg.gif +0 -0
- data/public/tablesorter/themes/blue/blue.zip +0 -0
- data/public/tablesorter/themes/blue/desc.gif +0 -0
- data/public/tablesorter/themes/blue/style.css +39 -0
- data/public/tablesorter/themes/green/.svn/all-wcprops +35 -0
- data/public/tablesorter/themes/green/.svn/entries +198 -0
- data/public/tablesorter/themes/green/.svn/prop-base/asc.png.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/bg.png.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/desc.png.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/green.zip.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/prop-base/style.css.svn-base +5 -0
- data/public/tablesorter/themes/green/.svn/text-base/asc.png.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/bg.png.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/desc.png.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/green.zip.svn-base +0 -0
- data/public/tablesorter/themes/green/.svn/text-base/style.css.svn-base +39 -0
- data/public/tablesorter/themes/green/asc.png +0 -0
- data/public/tablesorter/themes/green/bg.png +0 -0
- data/public/tablesorter/themes/green/desc.png +0 -0
- data/public/tablesorter/themes/green/green.zip +0 -0
- data/public/tablesorter/themes/green/style.css +39 -0
- data/test/database.yml +5 -0
- data/test/test_helper.rb +56 -0
- data/test/unit/databaseformalizer_test.rb +11 -0
- metadata +332 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/*
|
|
2
|
+
packer, version 2.0.2 (2005-08-19)
|
|
3
|
+
Copyright 2004-2005, Dean Edwards
|
|
4
|
+
License: http://creativecommons.org/licenses/LGPL/2.1/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
function pack(_script, _encoding, _fastDecode, _specialChars) {
|
|
8
|
+
// constants
|
|
9
|
+
var $IGNORE = "$1";
|
|
10
|
+
|
|
11
|
+
// validate parameters
|
|
12
|
+
_script += "\n";
|
|
13
|
+
_encoding = Math.min(parseInt(_encoding), 95);
|
|
14
|
+
|
|
15
|
+
// apply all parsing routines
|
|
16
|
+
function _pack($script) {
|
|
17
|
+
var i, $parse;
|
|
18
|
+
for (i = 0; ($parse = _parsers[i]); i++) {
|
|
19
|
+
$script = $parse($script);
|
|
20
|
+
}
|
|
21
|
+
return $script;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// unpacking function - this is the boot strap function
|
|
25
|
+
// data extracted from this packing routine is passed to
|
|
26
|
+
// this function when decoded in the target
|
|
27
|
+
var _unpack = function($packed, $ascii, $count, $keywords, $encode, $decode) {
|
|
28
|
+
while ($count--)
|
|
29
|
+
if ($keywords[$count])
|
|
30
|
+
$packed = $packed.replace(new RegExp('\\b' + $encode($count) + '\\b', 'g'), $keywords[$count]);
|
|
31
|
+
return $packed;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// code-snippet inserted into the unpacker to speed up decoding
|
|
35
|
+
var _decode = function() {
|
|
36
|
+
// does the browser support String.replace where the
|
|
37
|
+
// replacement value is a function?
|
|
38
|
+
if (!''.replace(/^/, String)) {
|
|
39
|
+
// decode all the values we need
|
|
40
|
+
while ($count--) $decode[$encode($count)] = $keywords[$count] || $encode($count);
|
|
41
|
+
// global replacement function
|
|
42
|
+
$keywords = [function($encoded){return $decode[$encoded]}];
|
|
43
|
+
// generic match
|
|
44
|
+
$encode = function(){return'\\w+'};
|
|
45
|
+
// reset the loop counter - we are now doing a global replace
|
|
46
|
+
$count = 1;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// keep a list of parsing functions, they'll be executed all at once
|
|
51
|
+
var _parsers = [];
|
|
52
|
+
function _addParser($parser) {
|
|
53
|
+
_parsers[_parsers.length] = $parser;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// zero encoding - just removal of white space and comments
|
|
57
|
+
function _basicCompression($script) {
|
|
58
|
+
var $parser = new ParseMaster;
|
|
59
|
+
// make safe
|
|
60
|
+
$parser.escapeChar = "\\";
|
|
61
|
+
// protect strings
|
|
62
|
+
$parser.add(/'[^'\n\r]*'/, $IGNORE);
|
|
63
|
+
$parser.add(/"[^"\n\r]*"/, $IGNORE);
|
|
64
|
+
// remove comments
|
|
65
|
+
$parser.add(/\/\/[^\n\r]*[\n\r]/, " ");
|
|
66
|
+
$parser.add(/\/\*[^*]*\*+([^\/][^*]*\*+)*\//, " ");
|
|
67
|
+
// protect regular expressions
|
|
68
|
+
$parser.add(/\s+(\/[^\/\n\r\*][^\/\n\r]*\/g?i?)/, "$2"); // IGNORE
|
|
69
|
+
$parser.add(/[^\w\x24\/'"*)\?:]\/[^\/\n\r\*][^\/\n\r]*\/g?i?/, $IGNORE);
|
|
70
|
+
// remove: ;;; doSomething();
|
|
71
|
+
if (_specialChars) $parser.add(/;;;[^\n\r]+[\n\r]/);
|
|
72
|
+
// remove redundant semi-colons
|
|
73
|
+
$parser.add(/\(;;\)/, $IGNORE); // protect for (;;) loops
|
|
74
|
+
$parser.add(/;+\s*([};])/, "$2");
|
|
75
|
+
// apply the above
|
|
76
|
+
$script = $parser.exec($script);
|
|
77
|
+
|
|
78
|
+
// remove white-space
|
|
79
|
+
$parser.add(/(\b|\x24)\s+(\b|\x24)/, "$2 $3");
|
|
80
|
+
$parser.add(/([+\-])\s+([+\-])/, "$2 $3");
|
|
81
|
+
$parser.add(/\s+/, "");
|
|
82
|
+
// done
|
|
83
|
+
return $parser.exec($script);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
function _encodeSpecialChars($script) {
|
|
87
|
+
var $parser = new ParseMaster;
|
|
88
|
+
// replace: $name -> n, $$name -> na
|
|
89
|
+
$parser.add(/((\x24+)([a-zA-Z$_]+))(\d*)/, function($match, $offset) {
|
|
90
|
+
var $length = $match[$offset + 2].length;
|
|
91
|
+
var $start = $length - Math.max($length - $match[$offset + 3].length, 0);
|
|
92
|
+
return $match[$offset + 1].substr($start, $length) + $match[$offset + 4];
|
|
93
|
+
});
|
|
94
|
+
// replace: _name -> _0, double-underscore (__name) is ignored
|
|
95
|
+
var $regexp = /\b_[A-Za-z\d]\w*/;
|
|
96
|
+
// build the word list
|
|
97
|
+
var $keywords = _analyze($script, _globalize($regexp), _encodePrivate);
|
|
98
|
+
// quick ref
|
|
99
|
+
var $encoded = $keywords.$encoded;
|
|
100
|
+
$parser.add($regexp, function($match, $offset) {
|
|
101
|
+
return $encoded[$match[$offset]];
|
|
102
|
+
});
|
|
103
|
+
return $parser.exec($script);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function _encodeKeywords($script) {
|
|
107
|
+
// escape high-ascii values already in the script (i.e. in strings)
|
|
108
|
+
if (_encoding > 62) $script = _escape95($script);
|
|
109
|
+
// create the parser
|
|
110
|
+
var $parser = new ParseMaster;
|
|
111
|
+
var $encode = _getEncoder(_encoding);
|
|
112
|
+
// for high-ascii, don't encode single character low-ascii
|
|
113
|
+
var $regexp = (_encoding > 62) ? /\w\w+/ : /\w+/;
|
|
114
|
+
// build the word list
|
|
115
|
+
$keywords = _analyze($script, _globalize($regexp), $encode);
|
|
116
|
+
var $encoded = $keywords.$encoded;
|
|
117
|
+
// encode
|
|
118
|
+
$parser.add($regexp, function($match, $offset) {
|
|
119
|
+
return $encoded[$match[$offset]];
|
|
120
|
+
});
|
|
121
|
+
// if encoded, wrap the script in a decoding function
|
|
122
|
+
return $script && _bootStrap($parser.exec($script), $keywords);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
function _analyze($script, $regexp, $encode) {
|
|
126
|
+
// analyse
|
|
127
|
+
// retreive all words in the script
|
|
128
|
+
var $all = $script.match($regexp);
|
|
129
|
+
var $$sorted = []; // list of words sorted by frequency
|
|
130
|
+
var $$encoded = {}; // dictionary of word->encoding
|
|
131
|
+
var $$protected = {}; // instances of "protected" words
|
|
132
|
+
if ($all) {
|
|
133
|
+
var $unsorted = []; // same list, not sorted
|
|
134
|
+
var $protected = {}; // "protected" words (dictionary of word->"word")
|
|
135
|
+
var $values = {}; // dictionary of charCode->encoding (eg. 256->ff)
|
|
136
|
+
var $count = {}; // word->count
|
|
137
|
+
var i = $all.length, j = 0, $word;
|
|
138
|
+
// count the occurrences - used for sorting later
|
|
139
|
+
do {
|
|
140
|
+
$word = "$" + $all[--i];
|
|
141
|
+
if (!$count[$word]) {
|
|
142
|
+
$count[$word] = 0;
|
|
143
|
+
$unsorted[j] = $word;
|
|
144
|
+
// make a dictionary of all of the protected words in this script
|
|
145
|
+
// these are words that might be mistaken for encoding
|
|
146
|
+
$protected["$" + ($values[j] = $encode(j))] = j++;
|
|
147
|
+
}
|
|
148
|
+
// increment the word counter
|
|
149
|
+
$count[$word]++;
|
|
150
|
+
} while (i);
|
|
151
|
+
// prepare to sort the word list, first we must protect
|
|
152
|
+
// words that are also used as codes. we assign them a code
|
|
153
|
+
// equivalent to the word itself.
|
|
154
|
+
// e.g. if "do" falls within our encoding range
|
|
155
|
+
// then we store keywords["do"] = "do";
|
|
156
|
+
// this avoids problems when decoding
|
|
157
|
+
i = $unsorted.length;
|
|
158
|
+
do {
|
|
159
|
+
$word = $unsorted[--i];
|
|
160
|
+
if ($protected[$word] != null) {
|
|
161
|
+
$$sorted[$protected[$word]] = $word.slice(1);
|
|
162
|
+
$$protected[$protected[$word]] = true;
|
|
163
|
+
$count[$word] = 0;
|
|
164
|
+
}
|
|
165
|
+
} while (i);
|
|
166
|
+
// sort the words by frequency
|
|
167
|
+
$unsorted.sort(function($match1, $match2) {
|
|
168
|
+
return $count[$match2] - $count[$match1];
|
|
169
|
+
});
|
|
170
|
+
j = 0;
|
|
171
|
+
// because there are "protected" words in the list
|
|
172
|
+
// we must add the sorted words around them
|
|
173
|
+
do {
|
|
174
|
+
if ($$sorted[i] == null) $$sorted[i] = $unsorted[j++].slice(1);
|
|
175
|
+
$$encoded[$$sorted[i]] = $values[i];
|
|
176
|
+
} while (++i < $unsorted.length);
|
|
177
|
+
}
|
|
178
|
+
return {$sorted: $$sorted, $encoded: $$encoded, $protected: $$protected};
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// build the boot function used for loading and decoding
|
|
182
|
+
function _bootStrap($packed, $keywords) {
|
|
183
|
+
var $ENCODE = _safeRegExp("$encode\\($count\\)", "g");
|
|
184
|
+
|
|
185
|
+
// $packed: the packed script
|
|
186
|
+
$packed = "'" + _escape($packed) + "'";
|
|
187
|
+
|
|
188
|
+
// $ascii: base for encoding
|
|
189
|
+
var $ascii = Math.min($keywords.$sorted.length, _encoding) || 1;
|
|
190
|
+
|
|
191
|
+
// $count: number of words contained in the script
|
|
192
|
+
var $count = $keywords.$sorted.length;
|
|
193
|
+
|
|
194
|
+
// $keywords: list of words contained in the script
|
|
195
|
+
for (var i in $keywords.$protected) $keywords.$sorted[i] = "";
|
|
196
|
+
// convert from a string to an array
|
|
197
|
+
$keywords = "'" + $keywords.$sorted.join("|") + "'.split('|')";
|
|
198
|
+
|
|
199
|
+
// $encode: encoding function (used for decoding the script)
|
|
200
|
+
var $encode = _encoding > 62 ? _encode95 : _getEncoder($ascii);
|
|
201
|
+
$encode = String($encode).replace(/_encoding/g, "$ascii").replace(/arguments\.callee/g, "$encode");
|
|
202
|
+
var $inline = "$count" + ($ascii > 10 ? ".toString($ascii)" : "");
|
|
203
|
+
|
|
204
|
+
// $decode: code snippet to speed up decoding
|
|
205
|
+
if (_fastDecode) {
|
|
206
|
+
// create the decoder
|
|
207
|
+
var $decode = _getFunctionBody(_decode);
|
|
208
|
+
if (_encoding > 62) $decode = $decode.replace(/\\\\w/g, "[\\xa1-\\xff]");
|
|
209
|
+
// perform the encoding inline for lower ascii values
|
|
210
|
+
else if ($ascii < 36) $decode = $decode.replace($ENCODE, $inline);
|
|
211
|
+
// special case: when $count==0 there are no keywords. I want to keep
|
|
212
|
+
// the basic shape of the unpacking funcion so i'll frig the code...
|
|
213
|
+
if (!$count) $decode = $decode.replace(_safeRegExp("($count)\\s*=\\s*1"), "$1=0");
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// boot function
|
|
217
|
+
var $unpack = String(_unpack);
|
|
218
|
+
if (_fastDecode) {
|
|
219
|
+
// insert the decoder
|
|
220
|
+
$unpack = $unpack.replace(/\{/, "{" + $decode + ";");
|
|
221
|
+
}
|
|
222
|
+
$unpack = $unpack.replace(/"/g, "'");
|
|
223
|
+
if (_encoding > 62) { // high-ascii
|
|
224
|
+
// get rid of the word-boundaries for regexp matches
|
|
225
|
+
$unpack = $unpack.replace(/'\\\\b'\s*\+|\+\s*'\\\\b'/g, "");
|
|
226
|
+
}
|
|
227
|
+
if ($ascii > 36 || _encoding > 62 || _fastDecode) {
|
|
228
|
+
// insert the encode function
|
|
229
|
+
$unpack = $unpack.replace(/\{/, "{$encode=" + $encode + ";");
|
|
230
|
+
} else {
|
|
231
|
+
// perform the encoding inline
|
|
232
|
+
$unpack = $unpack.replace($ENCODE, $inline);
|
|
233
|
+
}
|
|
234
|
+
// pack the boot function too
|
|
235
|
+
$unpack = pack($unpack, 0, false, true);
|
|
236
|
+
|
|
237
|
+
// arguments
|
|
238
|
+
var $params = [$packed, $ascii, $count, $keywords];
|
|
239
|
+
if (_fastDecode) {
|
|
240
|
+
// insert placeholders for the decoder
|
|
241
|
+
$params = $params.concat(0, "{}");
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// the whole thing
|
|
245
|
+
return "eval(" + $unpack + "(" + $params + "))\n";
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// mmm.. ..which one do i need ??
|
|
249
|
+
function _getEncoder($ascii) {
|
|
250
|
+
return $ascii > 10 ? $ascii > 36 ? $ascii > 62 ? _encode95 : _encode62 : _encode36 : _encode10;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// zero encoding
|
|
254
|
+
// characters: 0123456789
|
|
255
|
+
var _encode10 = function($charCode) {
|
|
256
|
+
return $charCode;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// inherent base36 support
|
|
260
|
+
// characters: 0123456789abcdefghijklmnopqrstuvwxyz
|
|
261
|
+
var _encode36 = function($charCode) {
|
|
262
|
+
return $charCode.toString(36);
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
// hitch a ride on base36 and add the upper case alpha characters
|
|
266
|
+
// characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
|
|
267
|
+
var _encode62 = function($charCode) {
|
|
268
|
+
return ($charCode < _encoding ? '' : arguments.callee(parseInt($charCode / _encoding))) +
|
|
269
|
+
(($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36));
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// use high-ascii values
|
|
273
|
+
var _encode95 = function($charCode) {
|
|
274
|
+
return ($charCode < _encoding ? '' : arguments.callee($charCode / _encoding)) +
|
|
275
|
+
String.fromCharCode($charCode % _encoding + 161);
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
// special _chars
|
|
279
|
+
var _encodePrivate = function($charCode) {
|
|
280
|
+
return "_" + $charCode;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// protect characters used by the parser
|
|
284
|
+
function _escape($script) {
|
|
285
|
+
return $script.replace(/([\\'])/g, "\\$1");
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// protect high-ascii characters already in the script
|
|
289
|
+
function _escape95($script) {
|
|
290
|
+
return $script.replace(/[\xa1-\xff]/g, function($match) {
|
|
291
|
+
return "\\x" + $match.charCodeAt(0).toString(16);
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
function _safeRegExp($string, $flags) {
|
|
296
|
+
return new RegExp($string.replace(/\$/g, "\\$"), $flags);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
// extract the body of a function
|
|
300
|
+
function _getFunctionBody($function) {
|
|
301
|
+
with (String($function)) return slice(indexOf("{") + 1, lastIndexOf("}"));
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
// set the global flag on a RegExp (you have to create a new one)
|
|
305
|
+
function _globalize($regexp) {
|
|
306
|
+
return new RegExp(String($regexp).slice(1, -1), "g");
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// build the parsing routine
|
|
310
|
+
_addParser(_basicCompression);
|
|
311
|
+
if (_specialChars) _addParser(_encodeSpecialChars);
|
|
312
|
+
if (_encoding) _addParser(_encodeKeywords);
|
|
313
|
+
|
|
314
|
+
// go!
|
|
315
|
+
return _pack(_script);
|
|
316
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
importPackage(java.io);
|
|
2
|
+
|
|
3
|
+
function writeFile( file, stream ) {
|
|
4
|
+
var buffer = new PrintWriter( new FileWriter( file ) );
|
|
5
|
+
buffer.print( stream );
|
|
6
|
+
buffer.close();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function read( file ) {
|
|
10
|
+
var jq = new File(file);
|
|
11
|
+
var reader = new BufferedReader(new FileReader(jq));
|
|
12
|
+
var line = null;
|
|
13
|
+
var buffer = new java.lang.StringBuffer(jq.length());
|
|
14
|
+
while( (line = reader.readLine()) != null) {
|
|
15
|
+
buffer.append(line);
|
|
16
|
+
buffer.append("\n");
|
|
17
|
+
}
|
|
18
|
+
return buffer.toString();
|
|
19
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
ParseMaster, version 1.0.2 (2005-08-19)
|
|
3
|
+
Copyright 2005, Dean Edwards
|
|
4
|
+
License: http://creativecommons.org/licenses/LGPL/2.1/
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/* a multi-pattern parser */
|
|
8
|
+
|
|
9
|
+
// KNOWN BUG: erroneous behavior when using escapeChar with a replacement value that is a function
|
|
10
|
+
|
|
11
|
+
function ParseMaster() {
|
|
12
|
+
// constants
|
|
13
|
+
var $EXPRESSION = 0, $REPLACEMENT = 1, $LENGTH = 2;
|
|
14
|
+
// used to determine nesting levels
|
|
15
|
+
var $GROUPS = /\(/g, $SUB_REPLACE = /\$\d/, $INDEXED = /^\$\d+$/,
|
|
16
|
+
$TRIM = /(['"])\1\+(.*)\+\1\1$/, $$ESCAPE = /\\./g, $QUOTE = /'/,
|
|
17
|
+
$$DELETED = /\x01[^\x01]*\x01/g;
|
|
18
|
+
var self = this;
|
|
19
|
+
// public
|
|
20
|
+
this.add = function($expression, $replacement) {
|
|
21
|
+
if (!$replacement) $replacement = "";
|
|
22
|
+
// count the number of sub-expressions
|
|
23
|
+
// - add one because each pattern is itself a sub-expression
|
|
24
|
+
var $length = (_internalEscape(String($expression)).match($GROUPS) || "").length + 1;
|
|
25
|
+
// does the pattern deal with sub-expressions?
|
|
26
|
+
if ($SUB_REPLACE.test($replacement)) {
|
|
27
|
+
// a simple lookup? (e.g. "$2")
|
|
28
|
+
if ($INDEXED.test($replacement)) {
|
|
29
|
+
// store the index (used for fast retrieval of matched strings)
|
|
30
|
+
$replacement = parseInt($replacement.slice(1)) - 1;
|
|
31
|
+
} else { // a complicated lookup (e.g. "Hello $2 $1")
|
|
32
|
+
// build a function to do the lookup
|
|
33
|
+
var i = $length;
|
|
34
|
+
var $quote = $QUOTE.test(_internalEscape($replacement)) ? '"' : "'";
|
|
35
|
+
while (i) $replacement = $replacement.split("$" + i--).join($quote + "+a[o+" + i + "]+" + $quote);
|
|
36
|
+
$replacement = new Function("a,o", "return" + $quote + $replacement.replace($TRIM, "$1") + $quote);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// pass the modified arguments
|
|
40
|
+
_add($expression || "/^$/", $replacement, $length);
|
|
41
|
+
};
|
|
42
|
+
// execute the global replacement
|
|
43
|
+
this.exec = function($string) {
|
|
44
|
+
_escaped.length = 0;
|
|
45
|
+
return _unescape(_escape($string, this.escapeChar).replace(
|
|
46
|
+
new RegExp(_patterns, this.ignoreCase ? "gi" : "g"), _replacement), this.escapeChar).replace($$DELETED, "");
|
|
47
|
+
};
|
|
48
|
+
// clear the patterns collection so that this object may be re-used
|
|
49
|
+
this.reset = function() {
|
|
50
|
+
_patterns.length = 0;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// private
|
|
54
|
+
var _escaped = []; // escaped characters
|
|
55
|
+
var _patterns = []; // patterns stored by index
|
|
56
|
+
var _toString = function(){return "(" + String(this[$EXPRESSION]).slice(1, -1) + ")"};
|
|
57
|
+
_patterns.toString = function(){return this.join("|")};
|
|
58
|
+
// create and add a new pattern to the patterns collection
|
|
59
|
+
function _add() {
|
|
60
|
+
arguments.toString = _toString;
|
|
61
|
+
// store the pattern - as an arguments object (i think this is quicker..?)
|
|
62
|
+
_patterns[_patterns.length] = arguments;
|
|
63
|
+
}
|
|
64
|
+
// this is the global replace function (it's quite complicated)
|
|
65
|
+
function _replacement() {
|
|
66
|
+
if (!arguments[0]) return "";
|
|
67
|
+
var i = 1, j = 0, $pattern;
|
|
68
|
+
// loop through the patterns
|
|
69
|
+
while ($pattern = _patterns[j++]) {
|
|
70
|
+
// do we have a result?
|
|
71
|
+
if (arguments[i]) {
|
|
72
|
+
var $replacement = $pattern[$REPLACEMENT];
|
|
73
|
+
switch (typeof $replacement) {
|
|
74
|
+
case "function": return $replacement(arguments, i);
|
|
75
|
+
case "number": return arguments[$replacement + i];
|
|
76
|
+
}
|
|
77
|
+
var $delete = (arguments[i].indexOf(self.escapeChar) == -1) ? "" :
|
|
78
|
+
"\x01" + arguments[i] + "\x01";
|
|
79
|
+
return $delete + $replacement;
|
|
80
|
+
// skip over references to sub-expressions
|
|
81
|
+
} else i += $pattern[$LENGTH];
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// encode escaped characters
|
|
85
|
+
function _escape($string, $escapeChar) {
|
|
86
|
+
return $escapeChar ? $string.replace(new RegExp("\\" + $escapeChar + "(.)", "g"), function($match, $char) {
|
|
87
|
+
_escaped[_escaped.length] = $char;
|
|
88
|
+
return $escapeChar;
|
|
89
|
+
}) : $string;
|
|
90
|
+
};
|
|
91
|
+
// decode escaped characters
|
|
92
|
+
function _unescape($string, $escapeChar) {
|
|
93
|
+
var i = 0;
|
|
94
|
+
return $escapeChar ? $string.replace(new RegExp("\\" + $escapeChar, "g"), function() {
|
|
95
|
+
return $escapeChar + (_escaped[i++] || "");
|
|
96
|
+
}) : $string;
|
|
97
|
+
};
|
|
98
|
+
function _internalEscape($string) {
|
|
99
|
+
return $string.replace($$ESCAPE, "");
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
ParseMaster.prototype = {
|
|
103
|
+
constructor: ParseMaster,
|
|
104
|
+
ignoreCase: false,
|
|
105
|
+
escapeChar: ""
|
|
106
|
+
};
|
|
Binary file
|