add show_downloads config option
This commit is contained in:
parent
8c0e9c2072
commit
5a1150f4c7
|
@ -21,6 +21,7 @@ Installation
|
||||||
googleanalytics.id = UA-1010101-1
|
googleanalytics.id = UA-1010101-1
|
||||||
googleanalytics.username = googleaccount@gmail.com
|
googleanalytics.username = googleaccount@gmail.com
|
||||||
googleanalytics.password = googlepassword
|
googleanalytics.password = googlepassword
|
||||||
|
googleanalytics.show_downloads = true
|
||||||
# the following *must* match profile name in GA dashboard
|
# the following *must* match profile name in GA dashboard
|
||||||
googleanalytics.profile_name = mydomain.com
|
googleanalytics.profile_name = mydomain.com
|
||||||
|
|
||||||
|
@ -33,6 +34,13 @@ from the analytics home page to see the profile name. Sometimes your
|
||||||
profile name might have a trailing slash; you need to include that,
|
profile name might have a trailing slash; you need to include that,
|
||||||
too, if so.
|
too, if so.
|
||||||
|
|
||||||
|
Note also that your password will probably be readable by other
|
||||||
|
people; so you may want to set up a new gmail account specifically
|
||||||
|
for accessing your gmail profile.
|
||||||
|
|
||||||
|
If ``show_downloads`` is set, a download count for resources will be
|
||||||
|
displayed on individual package pages.
|
||||||
|
|
||||||
3. Wait a day or so for some stats to be recorded in Google
|
3. Wait a day or so for some stats to be recorded in Google
|
||||||
|
|
||||||
4. Import Google stats by running the following command from
|
4. Import Google stats by running the following command from
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import urllib
|
import urllib
|
||||||
import os
|
import os
|
||||||
|
from paste.deploy.converters import asbool
|
||||||
from genshi.filters import Transformer
|
from genshi.filters import Transformer
|
||||||
from genshi import HTML
|
from genshi import HTML
|
||||||
from genshi.core import START, TEXT, END
|
from genshi.core import START, TEXT, END
|
||||||
|
@ -40,6 +41,8 @@ class GoogleAnalyticsPlugin(SingletonPlugin):
|
||||||
stream = stream | Transformer('head').append(code)
|
stream = stream | Transformer('head').append(code)
|
||||||
resource_url = config.get('googleanalytics.resource_prefix',
|
resource_url = config.get('googleanalytics.resource_prefix',
|
||||||
DEFAULT_RESOURCE_URL_TAG)
|
DEFAULT_RESOURCE_URL_TAG)
|
||||||
|
show_downloads = asbool(config.get('googleanalytics.show_downloads',
|
||||||
|
False))
|
||||||
|
|
||||||
# add download tracking link
|
# add download tracking link
|
||||||
def js_attr(name, event):
|
def js_attr(name, event):
|
||||||
|
@ -69,8 +72,11 @@ class GoogleAnalyticsPlugin(SingletonPlugin):
|
||||||
# perform the stream transform
|
# perform the stream transform
|
||||||
stream = stream | Transformer(
|
stream = stream | Transformer(
|
||||||
'//div[@id="package"]//td/a')\
|
'//div[@id="package"]//td/a')\
|
||||||
.apply(download_adder).attr('onclick', js_attr)
|
.attr('onclick', js_attr)
|
||||||
|
if show_downloads:
|
||||||
|
stream = stream | Transformer(
|
||||||
|
'//div[@id="package"]//td/a')\
|
||||||
|
.apply(download_adder)
|
||||||
return stream
|
return stream
|
||||||
|
|
||||||
def after_map(self, map):
|
def after_map(self, map):
|
||||||
|
|
|
@ -51,6 +51,8 @@ class TestLoadCommand:
|
||||||
= 'borf'
|
= 'borf'
|
||||||
config.local_conf['googleanalytics.profile_name'] \
|
config.local_conf['googleanalytics.profile_name'] \
|
||||||
= 'borf'
|
= 'borf'
|
||||||
|
config.local_conf['googleanalytics.show_downloads'] \
|
||||||
|
= 'true'
|
||||||
cls.config = config.local_conf
|
cls.config = config.local_conf
|
||||||
wsgiapp = make_app(config.global_conf, **config.local_conf)
|
wsgiapp = make_app(config.global_conf, **config.local_conf)
|
||||||
env = {'HTTP_ACCEPT': ('text/html;q=0.9,text/plain;'
|
env = {'HTTP_ACCEPT': ('text/html;q=0.9,text/plain;'
|
||||||
|
|
Loading…
Reference in New Issue