Skip to content

Commit

Permalink
Update README with Piwik ENV vars
Browse files Browse the repository at this point in the history
single quotes -> double
Have default_config use ENV instead of local_config
  • Loading branch information
Musee Ullah authored and nanaya committed Nov 20, 2014
1 parent 7cecf72 commit 19489ae
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -94,6 +94,8 @@ Configuration
See `config/local_config.rb.example`. Additionally, as I move to ENV-based configuration, here's the list of currently supported ENV variables:

- `MB_THREADS`: sets number of threads this application is running. Currently used to determine number of connection pool for `memcached`. Defaults to 1 if unset.
- `MB_PIWIK_HOST`: sets the host this application will attempt to contact a Piwik installation at. Defaults to false to not use Piwik if unset.
- `MB_PIWIK_ID`: sets the Site ID this application will send analytics data for.

Plans
-----
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/_piwik.html.erb
Expand Up @@ -4,9 +4,9 @@
_paq.push(["enableLinkTracking"]);

(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://<%= CONFIG['piwik_host'] -%>/";
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://<%= CONFIG["piwik_host"] -%>/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "<%= CONFIG['piwik_site_id'] -%>"]);
_paq.push(["setSiteId", "<%= CONFIG["piwik_site_id"] -%>"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Expand Up @@ -56,6 +56,6 @@
<% end %>
<%= yield(:post_cookie_javascripts) %>
<%= render 'layouts/ga' if CONFIG['ga-tracking-id'] -%>
<%= render 'layouts/piwik' if CONFIG['piwik_site_id'] and CONFIG['piwik_host'] -%>
<%= render 'layouts/piwik' if CONFIG["piwik_site_id"] and CONFIG["piwik_host"] -%>
</body>
</html>
3 changes: 3 additions & 0 deletions config/default_config.rb
Expand Up @@ -18,3 +18,6 @@
CONFIG["bgcolor"] ||= "gray"

CONFIG["threads"] ||= (ENV["MB_THREADS"] || 1).to_i

CONFIG["piwik_host"] ||= ENV["MB_PIWIK_HOST"]
CONFIG["piwik_site_id"] ||= ENV["MB_PIWIK_ID"]
4 changes: 2 additions & 2 deletions config/local_config.rb.example
Expand Up @@ -16,8 +16,8 @@ CONFIG["local_image_service"] = CONFIG["app_name"]
# CONFIG['ga-tracking-id'] = 'UA-XXXXX-X'

# Use this config to enable Piwik Analytics. Fill in the Site ID and FQDN (no protocol prefix)
CONFIG['piwik_host'] ||= ENV["MB_PIWIK_HOST"]
CONFIG['piwik_site_id'] ||= ENV["MB_PIWIK_ID"]
# CONFIG["piwik_host"] = "stats.moe.booru"
# CONFIG["piwik_site_id"] = 1

# Use this config to enable AddThis social sharing buttons. Fill in the Profile ID.
# CONFIG['addthis-id'] = 'ra-...'
Expand Down

0 comments on commit 19489ae

Please sign in to comment.