bradgessler-owidget 0.0.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/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :minor: 0
3
+ :patch: 0
4
+ :major: 0
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), '../owidget')
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+ module OWidget
6
+ class Consumer
7
+ def initialize(content='', links=[])
8
+ @content, @links = content, links
9
+ end
10
+
11
+ def links(force=false)
12
+ if @links.empty? or force
13
+ doc = Nokogiri::HTML(@content)
14
+ @links = (doc/'html head link[rel="owidget"]').map{ |link| link['href'] }
15
+ end
16
+ return @links
17
+ end
18
+
19
+ def widgets
20
+ links.map do |href|
21
+ open(href).read
22
+ end
23
+ end
24
+ end
25
+ end
data/lib/owidget.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+
3
+ module OWidget
4
+ end
@@ -0,0 +1,133 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <meta content='text/html;charset=UTF-8' http-equiv='content-type' />
5
+ <title>
6
+ Simple Text Message Polling
7
+ | Poll Everywhere
8
+ </title>
9
+ <link href="/stylesheets/application.css?1240373923" media="screen" rel="stylesheet" type="text/css" />
10
+ <link href="/stylesheets/structural.css?1240373923" media="screen" rel="stylesheet" type="text/css" />
11
+ <link href="/stylesheets/domain.css" media="screen" rel="stylesheet" type="text/css" />
12
+ <!--[if IE 6]>
13
+ <link href="/stylesheets/ie6_hacks.css?1240373923" media="screen" rel="stylesheet" type="text/css" />
14
+ <![endif]-->
15
+ <!--[if IE 7]>
16
+ <link href="/stylesheets/ie7_hacks.css?1240373923" media="screen" rel="stylesheet" type="text/css" />
17
+ <![endif]-->
18
+ <style type='text/css'>
19
+ .show #content .wrapper.inner {width:100%;}
20
+ </style>
21
+ <script src="/javascripts/prototype.js?1240373923" type="text/javascript"></script>
22
+ <script src="/javascripts/effects.js?1240373923" type="text/javascript"></script>
23
+ <script src="/javascripts/dragdrop.js?1240373923" type="text/javascript"></script>
24
+ <script src="/javascripts/controls.js?1240373923" type="text/javascript"></script>
25
+ <script src="/javascripts/swfobject.js?1240373923" type="text/javascript"></script>
26
+ <script src="/javascripts/widgets/tooltip.js?1240373923" type="text/javascript"></script>
27
+ <script src="/javascripts/application.js?1240373923" type="text/javascript"></script>
28
+ <link rel="alternate" type="application/json+oembed" href="http://www.polleverywhere.com/services/oembed?format=json&amp;url=http%3A%2F%2Fwww.polleverywhere.com%2Fmultiple_choice_polls%2FMzkwNzM1MzEw" title="What is your favorite color?" />
29
+ <link rel="alternate" type="application/xml+oembed" href="http://www.polleverywhere.com/services/oembed?format=xml&amp;url=http%3A%2F%2Fwww.polleverywhere.com%2Fmultiple_choice_polls%2FMzkwNzM1MzEw" title="What is your favorite color?" />
30
+ <link href='/favicon.ico' rel='shortcut icon' type='image/x-type' />
31
+ <link rel="owidget" href="http://www.polleverywhere.com/multiple_choice_polls/MzkwNzM1MzEw.owidget" />
32
+ </head>
33
+ <body class='multiple_choice_polls show'>
34
+ <script src="/javascripts/tooltips/wz_tooltip.js?1240373923" type="text/javascript"></script>
35
+ <script src="/javascripts/widgets/tooltip.js?1240373923" type="text/javascript"></script>
36
+ <a name='top'></a>
37
+ <div class='outter wrapper'>
38
+ <div id='header'>
39
+ <div class='inner wrapper'>
40
+ <a href='/' id='logo' title='Poll Everywhere - Simple SMS Voting'> </a>
41
+ <ul class='horizontal menu' id='main_menu'>
42
+ <li>
43
+ <a href="/plans/retail">Our Plans &amp; Pricing</a>
44
+ </li>
45
+ <li>
46
+ <a href="/faq">FAQ</a>
47
+ </li>
48
+ <li>
49
+ <a href="http://blog.polleverywhere.com/">Blog</a>
50
+ </li>
51
+ <li>
52
+ <a href="/login">Log In</a>
53
+ </li>
54
+ </ul>
55
+ </div>
56
+ <div class='clear'></div>
57
+ </div>
58
+ <div id='content'>
59
+ <div class='inner wrapper'>
60
+
61
+ <div id="swf">
62
+ <div style='width: 100%, height: 550px; background: #FFF; border: 1px solid #CCC'>
63
+ <div style='padding: 220px 20px; text-align: center; color: #F00;'>
64
+ <strong>You do not have flash installed or javascript may be disabled. Please</strong>
65
+ <a href="http://www.adobe.com/go/getflashplayer">install the latest version of Flash</a>
66
+ to view the chart.
67
+ </div>
68
+ </div>
69
+
70
+ </div>
71
+ <script type="text/javascript">
72
+ var so_swf = new SWFObject("/multiple_choice_polls/MzkwNzM1MzEw.swf", "swf", "100%", "500", "9.0.45", "#000");
73
+ so_swf.addVariable("remembertoken", "");
74
+ so_swf.addVariable("ispollowner", "false");
75
+ so_swf.addParam("allowfullscreen", "true");
76
+ so_swf.useExpressInstall("/flash/expressInstall.swf");
77
+ so_swf.write("swf");
78
+ </script>
79
+ </div>
80
+ <div class='clear'></div>
81
+ </div>
82
+ <div id='footer'>
83
+ <div class='inner wrapper'>
84
+ <div class='two columns'>
85
+ <div class='left column'>
86
+ <h3>
87
+ Talk to us:
88
+ +1 (800) 388-2039
89
+ </h3>
90
+ <small>
91
+ International:
92
+ +1 (773) 382-0377
93
+ </small>
94
+ <p>
95
+ <script type="text/javascript">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%71%75%65%73%74%69%6f%6e%73%40%70%6f%6c%6c%65%76%65%72%79%77%68%65%72%65%2e%63%6f%6d%3f%73%75%62%6a%65%63%74%3d%50%6f%6c%6c%25%32%30%45%76%65%72%79%77%68%65%72%65%25%32%30%51%75%65%73%74%69%6f%6e%73%22%3e%71%75%65%73%74%69%6f%6e%73%40%70%6f%6c%6c%65%76%65%72%79%77%68%65%72%65%2e%63%6f%6d%3c%2f%61%3e%27%29%3b'))</script>
96
+ </p>
97
+ </div>
98
+ <div class='right column'>
99
+ <h3>
100
+ Designed by
101
+ <a href="http://conden.se/">Condense</a>
102
+ </h3>
103
+ <p>
104
+ <a href="/polls">Browse Public Polls</a>,
105
+ <a href="/terms">Terms of Service</a>,
106
+ <a href="/privacy-policy">Privacy Policy</a>,
107
+ <a href="/refund-policy">Refund Policy</a>
108
+ </p>
109
+ </div>
110
+ </div>
111
+ <div class='clear'></div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ <!-- Start Google Site Statistics -->
116
+ <script type="text/javascript">
117
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
118
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
119
+ </script>
120
+ <script type="text/javascript">
121
+ try {
122
+ var pageTracker = _gat._getTracker("UA-2204221-1");
123
+ pageTracker._setDomainName("polleverywhere.com"); // Catch pe.com and www.pe.com
124
+ pageTracker._addIgnoredRef("blog.polleverywhere.com"); // Treat blog as direct trafic
125
+ pageTracker._initData();
126
+ pageTracker._trackPageview();
127
+
128
+ } catch(err) {}
129
+ </script>
130
+ <!-- End Google Site Statistics -->
131
+
132
+ </body>
133
+ </html>
@@ -0,0 +1,26 @@
1
+ <div class='outter wrapper'>
2
+ <div id='header'>
3
+ <div class='inner wrapper'></div>
4
+ </div>
5
+ <div id='content' style='height: 375px;'>
6
+ <div class='inner wrapper'>
7
+ <div class='opened vote'>
8
+ <h1>What is your favorite color?</h1>
9
+ <ol class='accumulators'>
10
+ <li class='accumulator'>
11
+ <a href="http://www.polleverywhere.com/vote.hapi?height=400&amp;poll=MzkwNzM1MzEw&amp;response=GReen13&amp;width=300" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;">GREEN</a>
12
+ </li>
13
+ <li class='accumulator'>
14
+ <a href="http://www.polleverywhere.com/vote.hapi?height=400&amp;poll=MzkwNzM1MzEw&amp;response=red12&amp;width=300" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;">RED</a>
15
+ </li>
16
+ <li class='accumulator'>
17
+ <a href="http://www.polleverywhere.com/vote.hapi?height=400&amp;poll=MzkwNzM1MzEw&amp;response=blue12&amp;width=300" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;">BLUE</a>
18
+ </li>
19
+ <li class='accumulator'>
20
+ <a href="http://www.polleverywhere.com/vote.hapi?height=400&amp;poll=MzkwNzM1MzEw&amp;response=YELLOW12&amp;width=300" onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;f.submit();return false;">Yellow</a>
21
+ </li>
22
+ </ol>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ </div>
@@ -0,0 +1,24 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe OWidget::Consumer do
4
+ before(:each) do
5
+ @consumer = OWidget::Consumer.new(content('polleverywhere.html'))
6
+ end
7
+
8
+ it "should have links" do
9
+ @consumer.should respond_to(:links)
10
+ end
11
+
12
+ it "should find links in a page with <link rel='owidget' />" do
13
+ @consumer.should have(1).links
14
+ end
15
+
16
+ it "should have widgets" do
17
+ @consumer.should respond_to(:widgets)
18
+ end
19
+
20
+ it "should request widgets" do
21
+ @consumer.should_receive(:open).with('http://www.polleverywhere.com/multiple_choice_polls/MzkwNzM1MzEw.owidget').and_return(io('polleverywhere.owidget'))
22
+ @consumer.widgets
23
+ end
24
+ end
@@ -0,0 +1,11 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+ require File.join(File.dirname(__FILE__), '../lib/consumer/consumer')
4
+
5
+ def io(file)
6
+ File.open(File.join(File.dirname(__FILE__), 'fixtures', file))
7
+ end
8
+
9
+ def content(file)
10
+ io(file).read
11
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bradgessler-owidget
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Brad Gessler
8
+ - Garry Tan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-04-22 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Embed oWidget resources into static content
18
+ email: everybody@owidget.org
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files: []
24
+
25
+ files:
26
+ - VERSION.yml
27
+ - lib/consumer
28
+ - lib/consumer/consumer.rb
29
+ - lib/owidget.rb
30
+ - spec/fixtures
31
+ - spec/fixtures/polleverywhere.html
32
+ - spec/fixtures/polleverywhere.owidget
33
+ - spec/owidget
34
+ - spec/owidget/consumer_spec.rb
35
+ - spec/spec_helper.rb
36
+ has_rdoc: true
37
+ homepage: http://www.owidget.org
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --inline-source
41
+ - --charset=UTF-8
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.2.0
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: the oWidget gem makes it easy to embed content into static HTML
63
+ test_files: []
64
+