appoxy_rails 0.0.23 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sessions/application_controller.rb +19 -6
- data/lib/sessions/sessions_controller.rb +3 -3
- data/lib/ui/application_helper.rb +19 -11
- metadata +13 -13
@@ -13,6 +13,8 @@ module Appoxy
|
|
13
13
|
base.before_filter :clear_sdb_stats
|
14
14
|
|
15
15
|
base.helper_method :facebook_oauth_url
|
16
|
+
base.helper_method :is_mobile_device?
|
17
|
+
base.helper_method :is_device?
|
16
18
|
|
17
19
|
end
|
18
20
|
|
@@ -29,7 +31,7 @@ module Appoxy
|
|
29
31
|
|
30
32
|
|
31
33
|
def logout_keeping_session!
|
32
|
-
@current_user
|
34
|
+
@current_user = nil # not logged in, and don't do it for me
|
33
35
|
session[:user_id] = nil # keeps the session but kill our variable
|
34
36
|
end
|
35
37
|
|
@@ -59,15 +61,26 @@ module Appoxy
|
|
59
61
|
|
60
62
|
def login_from_session
|
61
63
|
#puts 'Login from session=' + session[:user_id].inspect
|
62
|
-
|
64
|
+
user = nil
|
63
65
|
if session[:user_id]
|
64
66
|
begin
|
65
|
-
|
67
|
+
user = ::User.find(session[:user_id])
|
66
68
|
rescue => ex
|
67
69
|
puts 'User not found: ' + ex.message
|
68
70
|
end
|
69
71
|
end
|
70
|
-
|
72
|
+
unless user
|
73
|
+
# else try with cookie
|
74
|
+
if cookies[:auth_token]
|
75
|
+
# todo: should this also check a user_id cookie too?
|
76
|
+
user = ::User.find_by_remember_token(cookies[:auth_token])
|
77
|
+
end
|
78
|
+
if user && !user.remember_token_expires.nil? && Time.now < user.remember_token_expires
|
79
|
+
@current_user = user
|
80
|
+
session[:user_id] = user.id
|
81
|
+
end
|
82
|
+
end
|
83
|
+
user
|
71
84
|
end
|
72
85
|
|
73
86
|
def current_url
|
@@ -90,14 +103,14 @@ module Appoxy
|
|
90
103
|
|
91
104
|
def authenticate
|
92
105
|
if !logged_in?
|
93
|
-
flash[:warning]
|
106
|
+
flash[:warning] = "You need to login to access this page."
|
94
107
|
session[:return_to] = request.request_uri # return to after logging in
|
95
108
|
puts "ac=" + params[:ac].inspect
|
96
109
|
if params[:user_id] && params[:ac]
|
97
110
|
# todo: should we store ac in cookie? Make it easier to pass around
|
98
111
|
cookies[:ac] = params[:ac]
|
99
112
|
# then from an invite
|
100
|
-
user
|
113
|
+
user = ::User.find(params[:user_id])
|
101
114
|
if user && user.password.blank? # is this the best way to decide of user has not logged in? Could also check status.
|
102
115
|
redirect_to :controller=>"users", :action=>"new", :email=>user.email, :ac=>params[:ac]
|
103
116
|
return
|
@@ -438,7 +438,7 @@ module Appoxy
|
|
438
438
|
return false
|
439
439
|
else
|
440
440
|
set_user_cookies(user)
|
441
|
-
after_create
|
441
|
+
# after_create
|
442
442
|
return user
|
443
443
|
end
|
444
444
|
end
|
@@ -469,8 +469,8 @@ module Appoxy
|
|
469
469
|
|
470
470
|
def set_user_cookies(user)
|
471
471
|
set_current_user(user)
|
472
|
-
response.set_cookie('user_id', :value => user.id, :expires => user.remember_expires)
|
473
|
-
response.set_cookie('rme', :value=>user.
|
472
|
+
response.set_cookie('user_id', :value => user.id, :expires => user.remember_expires.to_time)
|
473
|
+
response.set_cookie('rme', :value=>user.remember_token, :expires => user.remember_expires.to_time)
|
474
474
|
end
|
475
475
|
|
476
476
|
|
@@ -81,7 +81,7 @@ module Appoxy
|
|
81
81
|
def date_format(date, options={})
|
82
82
|
format = options[:format] || :long
|
83
83
|
# puts 'date_format on ' + date.class.name + " --- " + date.inspect
|
84
|
-
user
|
84
|
+
user ||= @current_user
|
85
85
|
return '' if date.nil?
|
86
86
|
date = Time.parse(date) if date.is_a?(String)
|
87
87
|
if date.is_a?(Date) && !date.is_a?(DateTime) && !date.is_a?(Time)
|
@@ -90,17 +90,25 @@ module Appoxy
|
|
90
90
|
return date.to_local_s(user, :format=>format)
|
91
91
|
end
|
92
92
|
|
93
|
-
def flash_messages
|
93
|
+
def flash_messages(options={})
|
94
94
|
if flash.size > 0
|
95
|
-
s
|
95
|
+
s = "<div class=\"flash_messages_container\">"
|
96
96
|
s2 = ""
|
97
97
|
flash.each_pair do |type, msg|
|
98
|
+
clazz = "flash #{type}"
|
99
|
+
if options[:theme] == :jquery
|
100
|
+
if type == "error"
|
101
|
+
clazz << " ui-state-error"
|
102
|
+
elsif type == "highlight"
|
103
|
+
clazz << " ui-state-highlight"
|
104
|
+
end
|
105
|
+
end
|
98
106
|
if msg.is_a?(Array)
|
99
107
|
msg.each do |m|
|
100
|
-
s2 << content_tag(:div, m, :class =>
|
108
|
+
s2 << content_tag(:div, m, :class =>clazz)
|
101
109
|
end
|
102
110
|
else
|
103
|
-
s2 << content_tag(:div, msg, :class =>
|
111
|
+
s2 << content_tag(:div, msg, :class =>clazz)
|
104
112
|
end
|
105
113
|
end
|
106
114
|
s << s2
|
@@ -109,10 +117,10 @@ module Appoxy
|
|
109
117
|
end
|
110
118
|
end
|
111
119
|
|
112
|
-
def error_messages_for(ob)
|
120
|
+
def error_messages_for(ob, options={})
|
113
121
|
return '' if ob.nil?
|
114
122
|
if ob.errors.size > 0
|
115
|
-
s
|
123
|
+
s = "<div class=\"error_message_for_container\">"
|
116
124
|
s2 = ""
|
117
125
|
ob.errors.full_messages.each do |msg|
|
118
126
|
s2 << content_tag(:div, msg, :class => "error_message_for")
|
@@ -130,9 +138,9 @@ module Appoxy
|
|
130
138
|
def appoxy_geo_finder(options={})
|
131
139
|
# ret = File.read('_geo_location_finder.html.erb')
|
132
140
|
options.merge!({:current_user=>current_user})
|
133
|
-
options
|
141
|
+
options = Appoxy::UI::BindingHack.new(options)
|
134
142
|
template = ERB.new(File.read(File.join(File.dirname(__FILE__), '_geo_location_finder.html.erb')))
|
135
|
-
ret
|
143
|
+
ret = template.result(options.get_binding)
|
136
144
|
ret.html_safe
|
137
145
|
end
|
138
146
|
|
@@ -141,7 +149,7 @@ module Appoxy
|
|
141
149
|
# :div_id => default is "news_feed"
|
142
150
|
def latest_news(feed_url, options={})
|
143
151
|
div_id = options[:div_id] || "news_feed"
|
144
|
-
|
152
|
+
s = <<-EOF
|
145
153
|
<div id="#{div_id}"></div>
|
146
154
|
|
147
155
|
<script type="text/javascript">
|
@@ -166,7 +174,7 @@ module Appoxy
|
|
166
174
|
}
|
167
175
|
google.setOnLoadCallback(#{div_id}_init);
|
168
176
|
</script>
|
169
|
-
EOF
|
177
|
+
EOF
|
170
178
|
s.html_safe
|
171
179
|
end
|
172
180
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appoxy_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ default_executable:
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-client
|
17
|
-
requirement: &
|
17
|
+
requirement: &22818252 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *22818252
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: oauth
|
28
|
-
requirement: &
|
28
|
+
requirement: &22817964 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *22817964
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: ruby-openid
|
39
|
-
requirement: &
|
39
|
+
requirement: &22817676 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :runtime
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *22817676
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: appoxy_api
|
50
|
-
requirement: &
|
50
|
+
requirement: &22817388 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *22817388
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: mini_fb
|
61
|
-
requirement: &
|
61
|
+
requirement: &22817100 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *22817100
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: simple_record
|
72
|
-
requirement: &
|
72
|
+
requirement: &22816812 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :runtime
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *22816812
|
81
81
|
description: Appoxy API Helper gem description...
|
82
82
|
email: travis@appoxy.com
|
83
83
|
executables: []
|