appoxy_rails 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -94,6 +94,14 @@ Includes:
94
94
  - Some debug stuff if in development environment.
95
95
  - Timezone script to get user timezone.
96
96
 
97
+ ### appoxy_geo_finder
98
+
99
+ Finds user's geolocation and sets on User object.
100
+
101
+ ### latest_news(feed_url)
102
+
103
+ Will display a feed of the specific url.
104
+
97
105
  ## Authentication
98
106
 
99
107
  Any controllers that require authentication to view, use:
@@ -63,7 +63,7 @@ module Appoxy
63
63
  ret += '<div style="clear:both; margin-top:15px;"
64
64
  class="instance_info_div">' + INSTANCE_INFO["instance_id"] + ':
65
65
  Revision ' + RELEASE_INFO["scm"]["revision"][0..5] + ' built on ' +
66
- RELEASE_INFO["deploy_date"] + '</div>'
66
+ RELEASE_INFO["deploy_date"] + '</div>'
67
67
  end
68
68
 
69
69
  if Rails.env == "development"
@@ -128,12 +128,46 @@ module Appoxy
128
128
  def appoxy_geo_finder(options={})
129
129
  # ret = File.read('_geo_location_finder.html.erb')
130
130
  options.merge!({:current_user=>current_user})
131
- options = Appoxy::UI::BindingHack.new(options)
131
+ options = Appoxy::UI::BindingHack.new(options)
132
132
  template = ERB.new(File.read(File.join(File.dirname(__FILE__), '_geo_location_finder.html.erb')))
133
133
  ret = template.result(options.get_binding)
134
134
  ret.html_safe
135
135
  end
136
136
 
137
+ # feed_url: url to atom or rss feed
138
+ # options:
139
+ # :div_id => default is "news_feed"
140
+ def latest_news(feed_url, options={})
141
+ div_id = options[:div_id] || "news_feed"
142
+ s = <<-EOF
143
+ <div id="#{div_id}"></div>
144
+
145
+ <script type="text/javascript">
146
+
147
+ google.load("feeds", "1");
148
+
149
+ function #{div_id}_init() {
150
+ var feed = new google.feeds.Feed("#{feed_url}");
151
+ feed.setNumEntries(3)
152
+ feed.load(function(result) {
153
+ if (!result.error) {
154
+ var container = $("##{div_id}");
155
+ for (var i = 0; i < result.feed.entries.length; i++) {
156
+ var entry = result.feed.entries[i];
157
+ container.append('<div><div class="blog_title"><a href="' + entry.link + '">' + entry.title + '</a></div>'
158
+ + '<div class="blog_body">' + entry.contentSnippet + '</div>'
159
+ + '<div class="blog_date">' + entry.publishedDate + '</div>'
160
+ + '</div>');
161
+ }
162
+ }
163
+ });
164
+ }
165
+ google.setOnLoadCallback(#{div_id}_init);
166
+ </script>
167
+ EOF
168
+ s.html_safe
169
+ end
170
+
137
171
 
138
172
  end
139
173
 
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 14
9
- version: 0.0.14
8
+ - 15
9
+ version: 0.0.15
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-29 00:00:00 -08:00
17
+ date: 2011-01-30 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency