appoxy_rails 0.0.15 → 0.0.16

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.
@@ -22,7 +22,7 @@ module Appoxy
22
22
  end
23
23
 
24
24
  def create
25
- before_create
25
+ return if before_create == false
26
26
 
27
27
  # recaptchas should be optional
28
28
  # unless verify_recaptcha
@@ -34,41 +34,52 @@ module Appoxy
34
34
  logout_keeping_session!
35
35
 
36
36
  @email = params[:email]
37
+ if @email.blank?
38
+ flash[:error] = "You must enter a valid email address."
39
+ render :action=>"new"
40
+ return
41
+ end
42
+
37
43
  @has_password = params[:has_password]
38
44
  #puts 'has_pass? ' + @has_password.inspect
45
+ @az_style = params[:az_style]
39
46
 
40
- if params[:has_password].blank?
41
- flash[:error] = "Please click the radio button to let us know if you have a password or not."
42
- render :action=>"new"
43
- return
47
+ if @az_style
48
+ if params[:has_password].blank?
49
+ flash[:error] = "Please click the radio button to let us know if you have a password or not."
50
+ render :action=>"new"
51
+ return
52
+ end
53
+ if @has_password == "true"
54
+
55
+ else
56
+ # new user
57
+ redirect_to (new_user_path + "?email=#{@email}")
58
+ end
44
59
  end
45
60
 
46
- if @has_password == "true"
47
- user = ::User.find_by_email(@email)
61
+ user = ::User.find_by_email(@email)
48
62
  # user = User.authenticate(@email, params[:password])
49
- if user && user.authenticate(params[:password])
50
- self.current_user = user
51
- flash[:info] = "Logged in successfully."
52
- orig_url = session[:return_to]
53
- puts 'orig_url = ' + orig_url.to_s
54
- session[:return_to] = nil
55
- if !orig_url.nil?
56
- redirect_to orig_url # if entered via a different url
57
- else
58
- after_create
59
- end
60
- user.last_login = Time.now
61
- user.save(:dirty=>true)
63
+ if user && user.authenticate(params[:password])
64
+ self.current_user = user
65
+ flash[:info] = "Logged in successfully."
66
+ orig_url = session[:return_to]
67
+ puts 'orig_url = ' + orig_url.to_s
68
+ session[:return_to] = nil
69
+ if !orig_url.nil?
70
+ redirect_to orig_url # if entered via a different url
62
71
  else
63
- flash[:info] = "Invalid email or password. Please try again."
64
- render :action => 'new'
72
+ after_create
65
73
  end
74
+ user.last_login = Time.now
75
+ user.save(:dirty=>true)
66
76
  else
67
- # new user
68
- redirect_to (new_user_path + "?email=#{@email}")
77
+ flash[:error] = "Invalid email or password. Please try again."
78
+ render :action => 'new'
69
79
  end
70
80
  end
71
81
 
82
+ # Return false to stop before creating.
72
83
  def before_create
73
84
 
74
85
  end
@@ -1,4 +1,6 @@
1
1
  require_relative 'binding_hack'
2
+ require_relative 'visualizations'
3
+
2
4
 
3
5
  module Appoxy
4
6
 
@@ -25,12 +27,13 @@ module Appoxy
25
27
  r
26
28
  end
27
29
 
30
+
31
+ # todo: add themes support http://www.stemkoski.com/jquery-ui-1-7-2-themes-list-at-google-code/
28
32
  def appoxy_javascripts
29
- ' <script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAhes0f80sBcwL-h5xCNkkgxQBmiBpQeSpIciQPfZ5Ss-a60KXIRQOVvqzsNpqzhmG9tjky_5rOuaeow"></script>
33
+ '<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAAAhes0f80sBcwL-h5xCNkkgxQBmiBpQeSpIciQPfZ5Ss-a60KXIRQOVvqzsNpqzhmG9tjky_5rOuaeow"></script>
30
34
  <script type="text/javascript">
31
35
  google.load("jquery", "1");
32
36
  google.load("jqueryui", "1");
33
-
34
37
  </script>
35
38
  '.html_safe
36
39
  end
@@ -95,10 +98,10 @@ module Appoxy
95
98
  flash.each_pair do |type, msg|
96
99
  if msg.is_a?(Array)
97
100
  msg.each do |m|
98
- s2 << content_tag(:div, m, :class => type)
101
+ s2 << content_tag(:div, m, :class => "flash #{type}")
99
102
  end
100
103
  else
101
- s2 << content_tag(:div, msg, :class => type)
104
+ s2 << content_tag(:div, msg, :class => "flash #{type}")
102
105
  end
103
106
  end
104
107
  s << s2
@@ -168,6 +171,9 @@ EOF
168
171
  s.html_safe
169
172
  end
170
173
 
174
+ def visualizations
175
+ Visualizations.new
176
+ end
171
177
 
172
178
  end
173
179
 
@@ -0,0 +1,86 @@
1
+ module Appoxy
2
+ module UI
3
+ class Visualizations
4
+
5
+ def pie(options={})
6
+
7
+ div_id = options[:title].underscore || "pie_div"
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>
12
+
13
+ <script type="text/javascript">
14
+ var age_pie_chart;
15
+ $(document).ready(function() {
16
+ age_pie_chart = new Highcharts.Chart({
17
+ chart: {
18
+ renderTo: '#{div_id}',
19
+ plotBackgroundColor: null,
20
+ plotBorderWidth: null,
21
+ plotShadow: false
22
+ },
23
+ plotOptions: {
24
+ pie: {
25
+ allowPointSelect: true,
26
+ cursor: 'pointer',
27
+ dataLabels: {
28
+ enabled: false,
29
+ color: '#000000',
30
+ connectorColor: '#000000',
31
+ formatter: function() {
32
+ return '<b>'+ this.point.name +'</b>: '+ this.y +' %';
33
+ }
34
+ },
35
+ showInLegend: true
36
+ }
37
+ },
38
+ EOF
39
+ if options[:title]
40
+ s << "title: {
41
+ text: '#{options[:title]}'
42
+ },"
43
+ end
44
+
45
+ s << "
46
+ tooltip: {
47
+ formatter: function() {
48
+ return '<b>'+ this.point.name +'</b>: '+ this.y;
49
+ }
50
+ },
51
+ "
52
+
53
+ s << "
54
+ series: [{
55
+ type: 'pie',
56
+ name: '#{options[:title]}',
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
72
+ end
73
+ s << "]
74
+ }]
75
+ });
76
+ });
77
+ </script>\n"
78
+ s.html_safe
79
+
80
+ end
81
+ end
82
+
83
+ end
84
+
85
+
86
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 15
9
- version: 0.0.15
8
+ - 16
9
+ version: 0.0.16
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-01-30 00:00:00 -08:00
17
+ date: 2011-02-01 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -110,6 +110,7 @@ files:
110
110
  - lib/ui/binding_hack.rb
111
111
  - lib/ui/test.rb
112
112
  - lib/ui/time_zoner.rb
113
+ - lib/ui/visualizations.rb
113
114
  - README.markdown
114
115
  has_rdoc: true
115
116
  homepage: http://www.appoxy.com