sugar 0.0.34 → 0.0.35

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.34
1
+ 0.0.35
@@ -1,10 +1,12 @@
1
1
  require 'sugar/actionview/forms'
2
2
  require 'sugar/actionview/structure'
3
+ require 'sugar/actionview/stats'
3
4
 
4
5
  module Sugar
5
6
  module Actionview
6
7
  include Sugar::Actionview::Structure
7
8
  include Sugar::Actionview::Forms
9
+ include Sugar::Actionview::Stats
8
10
 
9
11
  def human(*args)
10
12
  if args.size == 2
@@ -0,0 +1,55 @@
1
+ module Sugar
2
+ module Actionview
3
+ module Stats
4
+ def online_stats(options = {})
5
+ static_includes = []
6
+ dynamic_includes = ''
7
+ noscript_includes = []
8
+ initializers = []
9
+
10
+ if options[:piwik]
11
+ static_includes << "//#{options[:piwik][:site]}/piwik.js"
12
+ initializers <<-END_PIWIK
13
+ var piwikTracker = Piwik.getTracker("#{options[:piwik][:site]}/piwik.php", #{options[:piwik][:id]});
14
+ piwikTracker.trackPageView();
15
+ piwikTracker.enableLinkTracking();
16
+ END_PIWIK
17
+ noscript_includes << %(<img src="//#{options[:piwik][:site]}/piwik.php?idsite=#{options[:piwik][:id]}" alt="" style="border:0" />)
18
+ end
19
+
20
+ if options[:metrika]
21
+ static_includes << '//mc.yandex.ru/resource/watch.js'
22
+ initializers << "var yaCounter#{options[:metrika]} = new Ya.Metrika(#{options[:metrika]});"
23
+ noscript_includes << %(<img src="//mc.yandex.ru/watch/#{options[:metrika]}" alt="" />)
24
+ end
25
+
26
+ if options[:analytics]
27
+ dynamic_includes << 'var gaJsHost=("https:"==document.location.protocol)?"https://ssl.":"http://www.";'
28
+ dynamic_includes << 'document.write(unescape("%3Cscript src=\'"+gaJsHost+"google-analytics.com/ga.js"\' type=\'text/javascript\'%3E%3C/script%3E));'
29
+ initializers << "var pageTracker = _gat._getTracker('#{options}'); pageTracker._trackPageview();"
30
+ end
31
+
32
+ returning '' do |result|
33
+ unless dynamic_includes.empty?
34
+ result << javascript_tag(dynamic_includes)
35
+ end
36
+ result << javascript_include_tag(static_includes) unless static_includes.empty?
37
+ unless initializers.empty?
38
+ result << javascript_tag do
39
+ initializers.collect do |initializer|
40
+ "try {#{initializer}} catch(e) {}\n"
41
+ end
42
+ end
43
+ end
44
+ unless noscript_includes.empty?
45
+ result << content_tag(:noscript,
46
+ content_tag(:div,
47
+ noscript_includes.join,
48
+ :style => 'position: absolute'))
49
+ end
50
+ end
51
+ end
52
+
53
+ end
54
+ end
55
+ end
data/sugar.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sugar}
8
- s.version = "0.0.34"
8
+ s.version = "0.0.35"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexander Semyonov"]
12
- s.date = %q{2009-10-14}
12
+ s.date = %q{2009-11-12}
13
13
  s.email = %q{rotuka@tokak.ru}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "lib/sugar/actioncontroller.rb",
28
28
  "lib/sugar/actionview.rb",
29
29
  "lib/sugar/actionview/forms.rb",
30
+ "lib/sugar/actionview/stats.rb",
30
31
  "lib/sugar/actionview/structure.rb",
31
32
  "lib/sugar/activerecord.rb",
32
33
  "lib/sugar/locales/de.yml",
@@ -56,3 +57,4 @@ Gem::Specification.new do |s|
56
57
  else
57
58
  end
58
59
  end
60
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sugar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.34
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Semyonov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-14 00:00:00 +04:00
12
+ date: 2009-11-12 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -34,6 +34,7 @@ files:
34
34
  - lib/sugar/actioncontroller.rb
35
35
  - lib/sugar/actionview.rb
36
36
  - lib/sugar/actionview/forms.rb
37
+ - lib/sugar/actionview/stats.rb
37
38
  - lib/sugar/actionview/structure.rb
38
39
  - lib/sugar/activerecord.rb
39
40
  - lib/sugar/locales/de.yml