dolores-cml 0.5.2 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.4
data/cml.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{cml}
5
- s.version = "0.5.2"
5
+ s.version = "0.5.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chris Van Pelt"]
9
- s.date = %q{2009-09-07}
9
+ s.date = %q{2009-09-08}
10
10
  s.description = %q{CML let's you easily create form elements and custom interfaces for the CrowdFlower Croud Labor platform}
11
11
  s.email = %q{vanpelt@doloreslabs.com}
12
12
  s.extra_rdoc_files = [
data/lib/cml/parser.rb CHANGED
@@ -5,7 +5,7 @@ module CML
5
5
  def initialize(content, opts = {})
6
6
  @opts = opts
7
7
  #Because nokogiri is munging my CDATA sections, we parse it out ahead of time
8
- @cdata = content.scan(/(<(script|style)[^>]*>)(.+?)(<\/\2)/m)
8
+ @cdata = content.scan(/(<(script|style)[^>]*?>)(.+?)(<\/\2)/m)
9
9
  @doc = Parser.parse(content)
10
10
  @cftags = @doc.xpath("//cml:*[not(ancestor::cml:*)]")
11
11
  normalize if opts[:normalize]
@@ -17,7 +17,7 @@ module CML
17
17
  def self.parse(content)
18
18
  #This sucks, we remove scripts, styles, and close non self closed tags
19
19
  #We could potentially add CDATA clauses to them, but this is "easier"
20
- xhtml = content.gsub(/(<(script|style)[^>]*>)(.+?)(<\/\2)/m, "\\1\\4").gsub(/(<(input|link|img|br|hr).*?)>/,'\1/>') #base, basefont, area, meta
20
+ xhtml = content.gsub(/(<(script|style)[^>]*?>)(.+?)(<\/\2)/m, "\\1\\4").gsub(/(<(input|link|img|br|hr).*?)>/,'\1/>') #base, basefont, area, meta
21
21
  Nokogiri::XML("<root xmlns:cml=\"http://crowdflower.com\">#{xhtml}</root>")
22
22
  end
23
23
 
@@ -96,8 +96,8 @@ module CML
96
96
  end
97
97
 
98
98
  def wrap(content)
99
- #This has to happen if we are outputing html, can go away if we use xhtml
100
- #content = content.gsub(/%7B%7B/,'{{').gsub(/%7D%7D/,'}}')
99
+ #This happens when variables are inside of href's
100
+ content = content.gsub(/%7B%7B/,'{{').gsub(/%7D%7D/,'}}')
101
101
  @opts[:no_wrap] ? content : "<div class=\"cml#{" "+@opts[:class] if @opts[:class]}\" id=\"#{@opts[:prefix]}\">#{content}</div>"
102
102
  end
103
103
 
data/spec/complex_spec.rb CHANGED
@@ -85,6 +85,11 @@ describe "CML Complex" do
85
85
  }
86
86
  </style>
87
87
  <script type="text/javascript" charset="utf-8">
88
+ // query1 = 'compare'
89
+ // query2 = 'base'
90
+ if (1 < 1) {
91
+ var x = 0;
92
+ }
88
93
  var ranking = [null]
89
94
  //Some really long comment that doesn't get borked by libxml... don't you dare insert a new line.
90
95
  //Why are my && disapearing?
@@ -20,65 +20,15 @@
20
20
  <script type="text/javascript" charset="utf-8">
21
21
  // query1 = 'compare'
22
22
  // query2 = 'base'
23
- document.addEvent('domready', function() {
24
-
25
- var inFrame = ($$('body.in_frame').length > 0);
26
- var onWarningPage = ($$('div.missed', 'h3.tainted').length > 0);
27
-
28
- var results = $('u{{_unit_id}}_div').getElements('.searchresult');
29
- var rand = Math.floor(Math.random()*2);
30
- var inputValues = ['compare_is_much_better', 'compare_is_a_little_better', 'base_is_a_little_better', 'base_is_much_better']
31
- var htmlValues = [
32
- 'The <b>top</b> result is <b>much better</b> than the bottom one',
33
- 'The <b>top</b> result is <b>a little better</b> than the bottom one',
34
- 'The <b>bottom</b> result is <b>a little better</b> than the top one',
35
- 'The <b>bottom</b> result is <b>much better</b> than the top one',
36
- '<b>Both</b> results are <b>not relevant</b> to the search terms <b>at all</b>'
37
- ];
38
-
39
- if (inFrame && !onWarningPage) {
40
- if (rand == 0) {
41
- // Put base on top
42
- results[0].inject(results[1], 'after');
43
- inputValues.reverse();
44
- }
45
- } else {
46
- // Fix the text a bit
47
- $$('div.missed span').each(function(el) {
48
- el.set('text', el.get('text').replace('Compare', 'The top result'));
49
- el.set('text', el.get('text').replace('Base', 'The bottom result'));
50
- el.set('text', el.get('text').replace(' compare', ' or the top result'));
51
- el.set('text', el.get('text').replace(' base', ' or the bottom result'));
52
- });
53
- }
54
-
55
- // Fix the input values and labels
56
- if ($('u{{_unit_id}}')) {
57
- $('u{{_unit_id}}').getElements('input.result_is_better').each(function(input, i) {
58
- if (i < inputValues.length) input.set('value', inputValues[i]);
59
- input.inject(input.getParent().set('html', htmlValues[i]), 'top');
60
- });
61
- }
62
-
63
- $('u{{_unit_id}}_div').getElements('table.srchresult').each(function(el, i) {
64
- // Fix a weird bug that got introduced in some circumstances way back in the scraping process
65
- var bid_buy = el.getElement('td.bid_buy');
66
- if (bid_buy.getChildren().length < 1) {
67
- var numBids = Math.floor(Math.random()*15);
68
- new Element('p', {'text': numBids+' bids'}).inject(bid_buy);
69
- }
70
- });
71
-
72
- // Show the input form
73
- $('u{{_unit_id}}_div').setStyle('display', 'block');
74
- });
75
-
23
+ if (1 < 1) {
24
+ var x = 0;
25
+ }
76
26
  var ranking = [null]
77
27
  //Some really long comment that doesn't get borked by libxml... don't you dare insert a new line.
78
28
  //Why are my && disapearing?
79
- if (ranking && !onSomeWarningpage) {
80
- //Preserve my curlies
81
- var unit_id = {{_unit_id}};
82
- var rad = "even inside strings {{awesome}}"
29
+ if(ranking && !false) {
30
+ //Preserve my curlies
31
+ var unit_id = {{_unit_id}};
32
+ var rad = "even inside strings {{awesome}}"
83
33
  }
84
34
  </script>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dolores-cml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Van Pelt
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-07 00:00:00 -07:00
12
+ date: 2009-09-08 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -100,6 +100,7 @@ files:
100
100
  - spec/validation_spec.rb
101
101
  has_rdoc: false
102
102
  homepage: http://github.com/dolores/cml
103
+ licenses:
103
104
  post_install_message:
104
105
  rdoc_options:
105
106
  - --charset=UTF-8
@@ -120,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
121
  requirements: []
121
122
 
122
123
  rubyforge_project:
123
- rubygems_version: 1.2.0
124
+ rubygems_version: 1.3.5
124
125
  signing_key:
125
126
  specification_version: 3
126
127
  summary: CML is CrowdFlower Markup Language