appoxy_rails 0.0.17 → 0.0.18
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/lib/sessions/oauth_token.rb +12 -12
- data/lib/sessions/sessions_controller.rb +1 -1
- data/lib/ui/binding_hack.rb +13 -13
- data/lib/ui/test.rb +7 -7
- data/lib/ui/visualizations.rb +127 -49
- metadata +3 -3
data/lib/sessions/oauth_token.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
class OauthToken < SimpleRecord::Base
|
2
|
-
|
3
|
-
belongs_to :user
|
4
|
-
|
5
|
-
has_strings :type, # request or access
|
6
|
-
:site,
|
7
|
-
:token,
|
8
|
-
:secret
|
9
|
-
|
10
|
-
# has_clobs :access_token
|
11
|
-
|
12
|
-
end
|
1
|
+
class OauthToken < SimpleRecord::Base
|
2
|
+
|
3
|
+
belongs_to :user
|
4
|
+
|
5
|
+
has_strings :type, # request or access
|
6
|
+
:site,
|
7
|
+
:token,
|
8
|
+
:secret
|
9
|
+
|
10
|
+
# has_clobs :access_token
|
11
|
+
|
12
|
+
end
|
data/lib/ui/binding_hack.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
module Appoxy
|
2
|
-
module UI
|
3
|
-
class BindingHack
|
4
|
-
|
5
|
-
def initialize(hash)
|
6
|
-
@options = hash
|
7
|
-
end
|
8
|
-
|
9
|
-
def get_binding
|
10
|
-
binding
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module Appoxy
|
2
|
+
module UI
|
3
|
+
class BindingHack
|
4
|
+
|
5
|
+
def initialize(hash)
|
6
|
+
@options = hash
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_binding
|
10
|
+
binding
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|
data/lib/ui/test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require_relative 'binding_hack'
|
3
|
-
|
4
|
-
options = Appoxy::UI::BindingHack.new(:x=>"hi")
|
5
|
-
template = ERB.new(File.read(File.join(File.dirname(__FILE__), '_geo_location_finder.html.erb')))
|
6
|
-
ret = template.result(options.get_binding)
|
7
|
-
p ret
|
1
|
+
require 'erb'
|
2
|
+
require_relative 'binding_hack'
|
3
|
+
|
4
|
+
options = Appoxy::UI::BindingHack.new(:x=>"hi")
|
5
|
+
template = ERB.new(File.read(File.join(File.dirname(__FILE__), '_geo_location_finder.html.erb')))
|
6
|
+
ret = template.result(options.get_binding)
|
7
|
+
p ret
|
data/lib/ui/visualizations.rb
CHANGED
@@ -2,24 +2,28 @@ module Appoxy
|
|
2
2
|
module UI
|
3
3
|
class Visualizations
|
4
4
|
|
5
|
+
|
6
|
+
def add_tooltip
|
7
|
+
"
|
8
|
+
tooltip: {
|
9
|
+
formatter: function() {
|
10
|
+
return '<b>'+ this.point.name +'</b>: '+ this.y;
|
11
|
+
}
|
12
|
+
},
|
13
|
+
"
|
14
|
+
end
|
15
|
+
|
5
16
|
def pie(options={})
|
6
17
|
|
7
|
-
|
8
|
-
width = options[:width] || "100%"
|
9
|
-
height = options[:height] || nil
|
10
|
-
s = <<-EOF
|
11
|
-
<div id="#{div_id}" style="width:#{200}; #{height ? 'height:' + height : ""}"></div>
|
18
|
+
@type = 'pie'
|
12
19
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
plotBorderWidth: null,
|
21
|
-
plotShadow: false
|
22
|
-
},
|
20
|
+
@options = options
|
21
|
+
common_values(options)
|
22
|
+
|
23
|
+
s = ""
|
24
|
+
s << add_div()
|
25
|
+
s << add_chart_start()
|
26
|
+
s << "
|
23
27
|
plotOptions: {
|
24
28
|
pie: {
|
25
29
|
allowPointSelect: true,
|
@@ -35,49 +39,123 @@ module Appoxy
|
|
35
39
|
showInLegend: true
|
36
40
|
}
|
37
41
|
},
|
38
|
-
|
39
|
-
|
40
|
-
s << "title: {
|
41
|
-
text: '#{options[:title]}'
|
42
|
-
},"
|
43
|
-
end
|
42
|
+
"
|
43
|
+
s << add_title
|
44
44
|
|
45
|
-
s <<
|
46
|
-
tooltip: {
|
47
|
-
formatter: function() {
|
48
|
-
return '<b>'+ this.point.name +'</b>: '+ this.y;
|
49
|
-
}
|
50
|
-
},
|
51
|
-
"
|
45
|
+
s << add_tooltip()
|
52
46
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
data: [
|
58
|
-
"
|
59
|
-
data = options[:data]
|
60
|
-
data.each_with_index do |d, i|
|
61
|
-
# todo: should check for hash and allow like:
|
62
|
-
# {
|
63
|
-
# name: 'Chrome',
|
64
|
-
# y: 12.8,
|
65
|
-
# sliced: true,
|
66
|
-
# selected: true
|
67
|
-
# },
|
68
|
-
s << "['#{d[0]}', #{d[1]}]"
|
69
|
-
if i < data.size - 1
|
70
|
-
s << ",\n"
|
71
|
-
end
|
47
|
+
unless @options[:series]
|
48
|
+
# make the default series
|
49
|
+
serieses = [{:name=>options[:title, :data=>options[:data]]}]
|
50
|
+
@options[:series] = serieses
|
72
51
|
end
|
73
|
-
|
74
|
-
|
52
|
+
|
53
|
+
if @options[:series]
|
54
|
+
s << add_series
|
55
|
+
else
|
56
|
+
# todo: DELETE THIS SECTION
|
57
|
+
# Single set of data
|
58
|
+
# s << "
|
59
|
+
# series: [{
|
60
|
+
# type: '#{@type}',
|
61
|
+
# name: '#{options[:title]}',
|
62
|
+
# data: [
|
63
|
+
# "
|
64
|
+
# s << add_data
|
65
|
+
# s << "]
|
66
|
+
# }]"
|
67
|
+
end
|
68
|
+
s << "
|
75
69
|
});
|
76
70
|
});
|
77
71
|
</script>\n"
|
78
72
|
s.html_safe
|
79
73
|
|
80
74
|
end
|
75
|
+
|
76
|
+
def add_series
|
77
|
+
s = "series: [
|
78
|
+
"
|
79
|
+
series = @options[:series]
|
80
|
+
series.each_with_index do |ser, i|
|
81
|
+
# each series is a hash
|
82
|
+
s << "{
|
83
|
+
type: '#{@type}',
|
84
|
+
name: '#{ser[:name]}',
|
85
|
+
data: ["
|
86
|
+
s << add_data(ser[:data])
|
87
|
+
s << "
|
88
|
+
}
|
89
|
+
"
|
90
|
+
if i < series.size - 1
|
91
|
+
s << ",\n"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
s
|
95
|
+
end
|
96
|
+
|
97
|
+
def add_data(data)
|
98
|
+
s = ""
|
99
|
+
# data ||= @options[:data]
|
100
|
+
if data.is_a?(Array)
|
101
|
+
data.each_with_index do |d, i|
|
102
|
+
if d.is_a?(Array)
|
103
|
+
s << "['#{d[0]}', #{d[1]}]"
|
104
|
+
elsif d.is_a?(Hash)
|
105
|
+
s << "
|
106
|
+
{
|
107
|
+
name: '#{d[:name]}',
|
108
|
+
y: #{d[:y]}
|
109
|
+
// sliced: #{d[:sliced]},
|
110
|
+
// selected: #{d[:selected]}
|
111
|
+
}"
|
112
|
+
else
|
113
|
+
raise "Expected array or hash for data series elements."
|
114
|
+
end
|
115
|
+
if i < data.size - 1
|
116
|
+
s << ",\n"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
s
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
def add_div
|
125
|
+
"<div id=\"#{@div_id}\" style=\"width:#{@width}; #{@height ? 'height:' + @height : ""}\"></div>"
|
126
|
+
end
|
127
|
+
|
128
|
+
def add_chart_start
|
129
|
+
"<script type=\"text/javascript\">
|
130
|
+
var #{@id}_chart;
|
131
|
+
$(document).ready(function() {
|
132
|
+
#{@id}_chart = new Highcharts.Chart({
|
133
|
+
chart: {
|
134
|
+
renderTo: '#{@div_id}',
|
135
|
+
plotBackgroundColor: null,
|
136
|
+
plotBorderWidth: null,
|
137
|
+
plotShadow: false,
|
138
|
+
defaultSeriesType: '#{@type}'
|
139
|
+
},
|
140
|
+
"
|
141
|
+
end
|
142
|
+
|
143
|
+
def add_title
|
144
|
+
s= ""
|
145
|
+
if @options[:title]
|
146
|
+
s << "title: {
|
147
|
+
text: '#{@options[:title]}'
|
148
|
+
},"
|
149
|
+
end
|
150
|
+
""
|
151
|
+
end
|
152
|
+
|
153
|
+
def common_values(options)
|
154
|
+
@id = options[:title].underscore
|
155
|
+
@div_id = "#{@id}_div" || "#{@type}_div"
|
156
|
+
@width = options[:width] || "100%"
|
157
|
+
@height = options[:height] || nil
|
158
|
+
end
|
81
159
|
end
|
82
160
|
|
83
161
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 18
|
9
|
+
version: 0.0.18
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Reeder
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-02-
|
17
|
+
date: 2011-02-07 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|