Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Commit

Permalink
set asynchronous JS template as default and pushed version to 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Gernot committed Mar 18, 2013
1 parent 28ce2ef commit e829bc2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -29,6 +29,7 @@ This middleware *should* be thread safe. Although my experience in such areas is

## Change Log

* 0.2.0 Use asynchronous JS tracking code by default
* 0.1.0 Initial Release


Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.1.3
0.2.0
2 changes: 1 addition & 1 deletion lib/rack/piwik.rb
Expand Up @@ -27,7 +27,7 @@ def _call(env)
def html?; @headers['Content-Type'] =~ /html/; end

def inject(response)
file = 'sync'
file = 'async'
@template ||= ::ERB.new ::File.read ::File.expand_path("../templates/#{file}.erb",__FILE__)
response.gsub(%r{</body>}, @template.result(binding) + "</body>")
end
Expand Down
3 changes: 1 addition & 2 deletions lib/rack/templates/async.erb
Expand Up @@ -20,9 +20,8 @@
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->

<!-- Piwik Image Tracker -->
<!-- Image Tracker -->
<noscript>
<%# TODO set protocol (HTTP or HTTPS) based on the current protocol according to rack logic %>
<img src="http://<%= @options[:piwik_url] %>/piwik.php?idsite=<%= @options[:piwik_id] %>&amp;rec=1" style="border:0" alt="" />
Expand Down
9 changes: 7 additions & 2 deletions lib/rack/templates/sync.erb
Expand Up @@ -17,5 +17,10 @@ try {
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script>
<noscript><img src="http://<%= @options[:piwik_url]%>/piwik.php?idsite=<%= @options[:piwik_id]%>" alt="" /></noscript>
<!-- End Piwik Code -->

<!-- Image Tracker -->
<noscript>
<%# TODO set protocol (HTTP or HTTPS) based on the current protocol according to rack logic %>
<img src="http://<%= @options[:piwik_url] %>/piwik.php?idsite=<%= @options[:piwik_id] %>&amp;rec=1" style="border:0" alt="" />
</noscript>
<!-- End Piwik -->
2 changes: 1 addition & 1 deletion rack-piwik.gemspec
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.email = ["maxwell@joindiaspora.com"]
s.homepage = "https://github.com/maxwell/rack-piwik"
s.summary = "Rack middleware to inject the Piwik tracking code into outgoing responses. Adapted from rack-google-analytics"
s.description = "Simple Rack middleware for implementing piwik Analytics racking in your Ruby-Rack based project."
s.description = "Simple Rack middleware for implementing Piwik Analytics tracking in your Ruby-Rack based project."

s.files = Dir.glob("lib/**/*") + %w(README.md LICENSE)
s.require_path = 'lib'
Expand Down

0 comments on commit e829bc2

Please sign in to comment.