e9_tags 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/e9_tags/rack/tags_js.rb +10 -2
- data/lib/e9_tags/version.rb +1 -1
- metadata +1 -1
data/lib/e9_tags/rack/tags_js.rb
CHANGED
@@ -2,8 +2,16 @@ module E9Tags::Rack
|
|
2
2
|
class TagsJs
|
3
3
|
def self.call(env)
|
4
4
|
if env["PATH_INFO"] =~ /^\/js\/tags/
|
5
|
-
|
6
|
-
|
5
|
+
rel = ::Tagging
|
6
|
+
.joins(:tag)
|
7
|
+
.order('tags.name')
|
8
|
+
.select('distinct taggings.context, tags.name')
|
9
|
+
|
10
|
+
retv = ::Tagging.connection
|
11
|
+
.select_rows(rel.to_sql, 'Tags JS')
|
12
|
+
.inject({}) {|h, row| (h[row.first] ||= []) << row.last; h }
|
13
|
+
|
14
|
+
js = "window.e9=window.e9||{};window.e9.tags=#{retv.to_json};"
|
7
15
|
|
8
16
|
[200, {"Content-Type" => "text/javascript", "Cache-Control" => "max-age=3600, must-revalidate"}, [js]]
|
9
17
|
else
|
data/lib/e9_tags/version.rb
CHANGED