golf 0.5.0 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/lib/golf/compiler.rb +7 -2
- data/lib/golf/version.rb +1 -1
- data/resources/jquery.golf.js +16 -144
- data/test/test_compiler.rb +5 -5
- metadata +1 -1
data/Gemfile.lock
CHANGED
data/lib/golf/compiler.rb
CHANGED
@@ -10,6 +10,10 @@ module Golf
|
|
10
10
|
self.golfpath = "#{golfpath}/golfapp"
|
11
11
|
puts "golf #{Golf::VERSION}: starting compiler in #{@golfpath}..."
|
12
12
|
puts "golf #{Golf::VERSION}: is valid golfapp?: #{Golf::Compiler.valid?(@golfpath)}"
|
13
|
+
puts "golf #{Golf::VERSION}: loading filters in #{golfpath}/filters"
|
14
|
+
Dir["#{golfpath}/filters/*.rb"].each do |path|
|
15
|
+
require path
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def self.valid?(dir)
|
@@ -140,8 +144,9 @@ module Golf
|
|
140
144
|
filter = element.attributes["filter"]
|
141
145
|
filter_name = filter.capitalize.to_sym
|
142
146
|
if Golf::Filter.constants.include?(filter_name)
|
143
|
-
element.
|
144
|
-
|
147
|
+
element.remove_attribute('filter')
|
148
|
+
res = Golf::Filter.const_get(filter_name).transform(element.to_s)
|
149
|
+
element.swap(res)
|
145
150
|
end
|
146
151
|
end
|
147
152
|
return doc.to_s
|
data/lib/golf/version.rb
CHANGED
data/resources/jquery.golf.js
CHANGED
@@ -417,160 +417,32 @@ window.d = Debug("GOLF");
|
|
417
417
|
window.Debug = Debug;
|
418
418
|
window.Component = Component;
|
419
419
|
|
420
|
-
//
|
421
|
-
|
422
|
-
if (serverside) {
|
423
|
-
|
424
|
-
if (!window.forcebot) {
|
425
|
-
$.fx.off = true;
|
426
|
-
|
427
|
-
$.fn.fadeIn = $.fn.slideDown = function(speed, callback) {
|
428
|
-
return $.fn.show.call(this, 0, callback);
|
429
|
-
};
|
430
|
-
|
431
|
-
$.fn.fadeOut = $.fn.slideUp = function(speed, callback) {
|
432
|
-
return $.fn.hide.call(this, 0, callback);
|
433
|
-
};
|
434
|
-
|
435
|
-
// this is problematic because the js css manipulations are not carried
|
436
|
-
// over in proxy mode; needs to be in a style tag maybe
|
437
|
-
//(function(fadeTo) {
|
438
|
-
// jQuery.fn.fadeTo = function(speed, opacity, callback) {
|
439
|
-
// return fadeTo.call(this, 0, opacity, callback);
|
440
|
-
// };
|
441
|
-
//})(jQuery.fn.fadeTo);
|
442
|
-
|
443
|
-
$.fn.slideToggle = function(speed, callback) {
|
444
|
-
return $.fn.toggle.call(this, 0, callback);
|
445
|
-
};
|
446
|
-
|
447
|
-
$.fn.show = (function(show) {
|
448
|
-
return function(speed, callback) {
|
449
|
-
return show.call(this, 0, callback);
|
450
|
-
};
|
451
|
-
})($.fn.show);
|
420
|
+
// install overrides on jQ DOM manipulation methods to accomodate components
|
452
421
|
|
453
|
-
|
454
|
-
return function(speed, callback) {
|
455
|
-
return hide.call(this, 0, callback);
|
456
|
-
};
|
457
|
-
})($.fn.hide);
|
422
|
+
(function() {
|
458
423
|
|
424
|
+
// this is to prevent accidentally reloading the page
|
459
425
|
$.fn.bind = (function(bind) {
|
460
426
|
var lastId = 0;
|
461
427
|
return function(name, fn) {
|
462
|
-
var jself
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
"/"+_href.replace(/^(http:\/\/)?([^\/]\/?)*\/\//g, ""));
|
476
|
-
else if (jself.attr("href"))
|
477
|
-
jself.data("_golf_oldhref", _href.replace(/^#/, ""));
|
478
|
-
|
479
|
-
jself.attr({
|
480
|
-
rel: "nofollow",
|
481
|
-
href: "?target="+lastId+"&event=onclick"
|
482
|
-
});
|
483
|
-
fn = function() {
|
484
|
-
var argv = Array.prototype.slice.call(arguments);
|
485
|
-
if ($(this).data("_golf_oldfn").apply(jss, argv) !== false) {
|
486
|
-
$(this).attr("href", servletUrl+$(this).data("_golf_oldhref"));
|
487
|
-
$.golf.location($(this).data("_golf_oldhref"));
|
488
|
-
}
|
489
|
-
};
|
490
|
-
} else {
|
491
|
-
var a = "<a rel='nofollow' href='?target="+lastId+
|
492
|
-
"&event=onclick'></a>";
|
493
|
-
jself.wrap(a);
|
494
|
-
jself._golf_addClass("golfproxylink");
|
495
|
-
}
|
496
|
-
} else if (name == "submit") {
|
497
|
-
if (!_golfid) {
|
498
|
-
++lastId;
|
499
|
-
jself.attr("golfid", lastId);
|
500
|
-
jself.append(
|
501
|
-
"<input type='hidden' name='event' value='onsubmit'/>");
|
502
|
-
jself.append(
|
503
|
-
"<input type='hidden' name='target' value='"+lastId+"'/>");
|
504
|
-
if (!$.golf.events[lastId])
|
505
|
-
$.golf.events[lastId] = [];
|
506
|
-
}
|
507
|
-
$.golf.events[jself.attr("golfid")].push(fn);
|
428
|
+
var jself = $(this);
|
429
|
+
if (name == "submit") {
|
430
|
+
var oldfn = fn;
|
431
|
+
fn = function() {
|
432
|
+
var argv = Array.prototype.slice.call(arguments);
|
433
|
+
try {
|
434
|
+
oldfn.apply(this, argv);
|
435
|
+
} catch(e) {
|
436
|
+
d(e.stack);
|
437
|
+
$.golf.errorPage("Oops!", "<code>"+e.toString()+"</code>");
|
438
|
+
}
|
439
|
+
return false;
|
440
|
+
};
|
508
441
|
}
|
509
442
|
return bind.call(jself, name, fn);
|
510
443
|
};
|
511
444
|
})($.fn.bind);
|
512
445
|
|
513
|
-
$.fn.trigger = (function(trigger) {
|
514
|
-
return function(type, data) {
|
515
|
-
var jself = $(this);
|
516
|
-
// FIXME: this is here because hunit stops firing js submit events
|
517
|
-
if (type == "submit") {
|
518
|
-
var tmp = $.golf.events[jself.attr("golfid")];
|
519
|
-
return $.each(tmp, function(){
|
520
|
-
this.call(jself, type, data);
|
521
|
-
});
|
522
|
-
} else {
|
523
|
-
return trigger.call($(this), type, data);
|
524
|
-
}
|
525
|
-
};
|
526
|
-
})($.fn.trigger);
|
527
|
-
}
|
528
|
-
|
529
|
-
$.fn.val = (function(val) {
|
530
|
-
return function(newVal) {
|
531
|
-
if (arguments.length == 0)
|
532
|
-
return $.trim(val.call($(this)));
|
533
|
-
else
|
534
|
-
return val.call($(this), newVal);
|
535
|
-
};
|
536
|
-
})($.fn.val);
|
537
|
-
|
538
|
-
$.ajax = (function(ajax) {
|
539
|
-
return function(options) {
|
540
|
-
options.async = false;
|
541
|
-
return ajax(options);
|
542
|
-
};
|
543
|
-
})($.ajax);
|
544
|
-
|
545
|
-
} else {
|
546
|
-
|
547
|
-
$.fn.bind = (function(bind) {
|
548
|
-
var lastId = 0;
|
549
|
-
return function(name, fn) {
|
550
|
-
var jself = $(this);
|
551
|
-
if (name == "submit") {
|
552
|
-
var oldfn = fn;
|
553
|
-
fn = function() {
|
554
|
-
var argv = Array.prototype.slice.call(arguments);
|
555
|
-
try {
|
556
|
-
oldfn.apply(this, argv);
|
557
|
-
} catch(e) {
|
558
|
-
d(e.stack);
|
559
|
-
$.golf.errorPage("Oops!", "<code>"+e.toString()+"</code>");
|
560
|
-
}
|
561
|
-
return false;
|
562
|
-
};
|
563
|
-
}
|
564
|
-
return bind.call(jself, name, fn);
|
565
|
-
};
|
566
|
-
})($.fn.bind);
|
567
|
-
|
568
|
-
}
|
569
|
-
|
570
|
-
// install overrides on jQ DOM manipulation methods to accomodate components
|
571
|
-
|
572
|
-
(function() {
|
573
|
-
|
574
446
|
$.each(
|
575
447
|
[
|
576
448
|
"append",
|
data/test/test_compiler.rb
CHANGED
@@ -30,11 +30,11 @@ class CompilerTest < Test::Unit::TestCase
|
|
30
30
|
b = JSON.parse @compiler.component_json
|
31
31
|
assert_equal a.keys.sort,b.keys.sort
|
32
32
|
assert_equal a,b
|
33
|
-
puts a["HelloWorld"]["html"]
|
34
|
-
puts b["HelloWorld"]["html"]
|
35
|
-
a.keys.each do |key|
|
36
|
-
|
37
|
-
end
|
33
|
+
#puts a["HelloWorld"]["html"]
|
34
|
+
#puts b["HelloWorld"]["html"]
|
35
|
+
#a.keys.each do |key|
|
36
|
+
# puts "#{key} should be #{a[key].hash}, but was #{b[key].hash}"
|
37
|
+
#end
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_res_generation
|