" + settings.get("message") + "
" @staticmethod def wtforms(field, settings): @@ -3092,7 +3099,7 @@ class MultiCheckboxBuilder(WTFormsBuilder): @staticmethod def match(field): return field.get("input") == "checkbox" and \ - (len(field.get("options", [])) > 0 or field.get("options_fn") is not None) + (len(field.get("options", [])) > 0 or field.get("options_fn") is not None) @staticmethod def wtform(formulaic_context, field, wtfargs): diff --git a/portality/lib/analytics.py b/portality/lib/analytics.py deleted file mode 100644 index c2a1a69896..0000000000 --- a/portality/lib/analytics.py +++ /dev/null @@ -1,172 +0,0 @@ -# ~~ GoogleAnalytics:ExternalService~~ -import logging -import os -from functools import wraps - -# Logger specific to analytics -logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - -# The global tracker object -tracker = None - - -class GAException(Exception): - pass - - -def create_tracker(ga_id, domain): - global tracker - if ga_id: - #tracker = UniversalAnalytics.Tracker.create(ga_id, client_id=domain) - raise GAException("GA is not running because universal-analytics is broken in Python 3") - else: - raise GAException("Invalid GA ID supplied, no tracker created.") - - -def create_logfile(log_dir=None): - filepath = __name__ + '.log' - if log_dir is not None: - if not os.path.exists(log_dir): - os.makedirs(log_dir) - filepath = os.path.join(log_dir, filepath) - fh = logging.FileHandler(filepath) - fh.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')) - logger.addHandler(fh) - - -class GAEvent(object): - category = None - action = None - label = None - value = None - fieldsobject = None - - def __init__(self, category, action, label='', value=None, fieldsobject=None): - self.category = category - self.action = action - self.label = label - self.value = value - self.fieldsobject=fieldsobject - - def submit(self): - ga_send_event(self.category, self.action, self.label, self.value, self.fieldsobject) - - -def ga_send_event(category, action, label='', value=None, fieldsobject=None): - """ - Send event data to Google Analytics. - (supposedly supporting other analytics providers as well, - check https://github.com/analytics-pros/universal-analytics-python ) - - See https://support.google.com/analytics/answer/1033068?hl=en for - guidance on how to use the various event properties this decorator - takes. - - One thing to note is that event_value must be an integer. We - don't really use that, it's for things like "total downloads" or - "number of times video played". - - The others are strings and can be anything we like. They must - take into account what previous strings we've sent so that events - can be aggregated correctly. Changing the strings you use for - categories, actions and labels to describe the same event will - split your analytics reports into two: before and after the - change of the event strings you use. - - :param category: Typically the object that was interacted with (e.g. 'Video') - :param action: The type of interaction (e.g. 'play') - :param label: Useful for categorizing events (e.g. 'Fall Campaign') - :param value: A non-negative numeric value associated with the event (e.g. 42) - :param fieldsobject: Key, value pairs which don't fit into the above categories - """ - - # Write event to file even if there's no tracker configured. - analytics_args = [category, action] - - if label != '': - analytics_args.append(label) - if value is not None: - analytics_args.append(value) - if fieldsobject is not None: - analytics_args.append(fieldsobject) - - logger.debug("Event Send %s", analytics_args) - - # Send the event to GA via the tracker - if tracker is not None: - tracker.send('event', *analytics_args) - else: - # logger.error("Google Analytics tracker is not configured.") - pass # we now know it's broken, stop spamming this in our logs. - - -def sends_ga_event(event_category, event_action, event_label='', - event_value=0, record_value_of_which_arg=''): - """ - Decorator for Flask view functions, sending event data to Google - Analytics. - - :param event_category: - :param event_action: - :param event_label: - :param event_value: - - :param record_value_of_which_arg: The name of one argument that - the view function takes. During tracking, the value of that - argument will be extracted and sent as the Event Label to the - analytics servers. NOTE! If you pass both event_label and - record_value_of_which_arg to this decorator, event_label will be - ignored and overwritten by the action that - record_value_of_which_arg causes. - - For example: - @sends_ga_event('API Hit', 'Search applications', - record_value_of_which_arg='search_query') - def search_applications(search_query): - # ... - - Then we get a hit, with search_query being set to 'computer shadows'. - This will result in an event with category "API Hit", action "Search - applications" and label "computer shadows". - - A different example: - @sends_ga_event('API Hit', 'Retrieve application', - record_value_of_which_arg='application_id') - def retrieve_application(application_id): - # ... - - Then we get a hit asking for application with id '12345'. - This will result in an event with category "API Hit", action "Retrieve - application" and label "12345". - - Clashing arguments: - @sends_ga_event('API Hit', 'Retrieve application', - event_label='Special interest action', - record_value_of_which_arg='application_id') - def retrieve_application(application_id): - # ... - - Then we get a hit asking for application with id '12345' again. - This will result in an event with category "API Hit", action "Retrieve - application" and label "12345". I.e. the event_label passed in will - be ignored, because we also passed in record_value_of_which_arg which - overrides the event label sent to the analytics servers. - - On testing: this has been tested manually on DOAJ with Google - Analytics by @emanuil-tolev & @Steven-Eardley. - """ - - def decorator(fn): - @wraps(fn) - def decorated_view(*args, **kwargs): - el = event_label - if record_value_of_which_arg in kwargs: - el = kwargs[record_value_of_which_arg] - - ga_send_event(event_category, event_action, el, event_value) - - return fn(*args, **kwargs) - - return decorated_view - return decorator diff --git a/portality/settings.py b/portality/settings.py index 3ca81bb4fa..55e57ab140 100644 --- a/portality/settings.py +++ b/portality/settings.py @@ -9,7 +9,7 @@ # Application Version information # ~~->API:Feature~~ -DOAJ_VERSION = "6.5.0" +DOAJ_VERSION = "6.5.3" API_VERSION = "3.0.1" ###################################### @@ -1218,48 +1218,51 @@ ###################################################### -# Google Analytics configuration -# specify in environment .cfg file - avoids sending live analytics -# events from test and dev environments -# ~~->GoogleAnalytics:ExternalService~~ +# Analytics configuration +# specify in environment .cfg file - avoids sending live analytics events from test and dev environments -GOOGLE_ANALYTICS_ID = '' - -# Where to put the google analytics logs -GOOGLE_ANALTYICS_LOG_DIR = None +# ~~->PlausibleAnalytics:ExternalService~~ +# Plausible analytics +# root url of plausible +PLAUSIBLE_URL = "https://plausible.io" +PLAUSIBLE_JS_URL = PLAUSIBLE_URL + "/js/script.outbound-links.file-downloads.js" +PLAUSIBLE_API_URL = PLAUSIBLE_URL + "/api/event" +# site name / domain name that used to register in plausible +PLAUSIBLE_SITE_NAME = BASE_DOMAIN +PLAUSIBLE_LOG_DIR = None -# Google Analytics custom dimensions. These are configured in the GA interface. -GA_DIMENSIONS = { - 'oai_res_id': 'dimension1', # In GA as OAI:Record +# Analytics custom dimensions. These are configured in the interface. #fixme: are these still configured since the move from GA? +ANALYTICS_DIMENSIONS = { + 'oai_res_id': 'dimension1', # In analytics as OAI:Record } -# GA for OAI-PMH +# Plausible for OAI-PMH # ~~-> OAIPMH:Feature~~ -GA_CATEGORY_OAI = 'OAI-PMH' +ANALYTICS_CATEGORY_OAI = 'OAI-PMH' -# GA for Atom +# Plausible for Atom # ~~-> Atom:Feature~~ -GA_CATEGORY_ATOM = 'Atom' -GA_ACTION_ACTION = 'Feed request' +ANALYTICS_CATEGORY_ATOM = 'Atom' +ANALYTICS_ACTION_ACTION = 'Feed request' -# GA for JournalCSV +# Plausible for JournalCSV # ~~-> JournalCSV:Feature~~ -GA_CATEGORY_JOURNALCSV = 'JournalCSV' -GA_ACTION_JOURNALCSV = 'Download' +ANALYTICS_CATEGORY_JOURNALCSV = 'JournalCSV' +ANALYTICS_ACTION_JOURNALCSV = 'Download' -# GA for OpenURL +# Plausible for OpenURL # ~~->OpenURL:Feature~~ -GA_CATEGORY_OPENURL = 'OpenURL' +ANALYTICS_CATEGORY_OPENURL = 'OpenURL' -# GA for PublicDataDump +# Plausible for PublicDataDump # ~~->PublicDataDump:Feature~~ -GA_CATEGORY_PUBLICDATADUMP = 'PublicDataDump' -GA_ACTION_PUBLICDATADUMP = 'Download' +ANALYTICS_CATEGORY_PUBLICDATADUMP = 'PublicDataDump' +ANALYTICS_ACTION_PUBLICDATADUMP = 'Download' -# GA for API +# Plausible for API # ~~-> API:Feature~~ -GA_CATEGORY_API = 'API Hit' -GA_ACTIONS_API = { +ANALYTICS_CATEGORY_API = 'API Hit' +ANALYTICS_ACTIONS_API = { 'search_applications': 'Search applications', 'search_journals': 'Search journals', 'search_articles': 'Search articles', @@ -1279,10 +1282,10 @@ } -# GA for fixed query widget +# Plausible for fixed query widget # ~~->FixedQueryWidget:Feature~~ -GA_CATEGORY_FQW = 'FQW' -GA_ACTION_FQW = 'Hit' +ANALYTICS_CATEGORY_FQW = 'FQW' +ANALYTICS_ACTION_FQW = 'Hit' ##################################################### # Anonymised data export (for dev) configuration @@ -1380,15 +1383,6 @@ # Editorial Dashboard - set to-do list size TODO_LIST_SIZE = 48 -####################################################### -# Plausible analytics -# root url of plausible -PLAUSIBLE_URL = "https://plausible.io" -PLAUSIBLE_JS_URL = PLAUSIBLE_URL + "/js/script.outbound-links.file-downloads.js" -PLAUSIBLE_API_URL = PLAUSIBLE_URL + "/api/event" -# site name / domain name that used to register in plausible -PLAUSIBLE_SITE_NAME = BASE_DOMAIN -PLAUSIBLE_LOG_DIR = None ######################################################### # Background tasks --- monitor_bgjobs diff --git a/portality/static/js/application_form.js b/portality/static/js/application_form.js index 178aef09c4..3944845669 100644 --- a/portality/static/js/application_form.js +++ b/portality/static/js/application_form.js @@ -844,8 +844,8 @@ window.Parsley.addValidator("optionalIf", { }); window.Parsley.addValidator("differentTo", { - validateString : function(value, requirement) { - return (!value || ($("[name = " + requirement + "]")).val() !== value); + validateString : function(value, requirement, message) { + return (!value || ($("[name = " + requirement + "]")).val().toLowerCase() !== value.toLowerCase()); }, messages: { en: 'Value of this field and %s field must be different' diff --git a/portality/static/js/notifications.js b/portality/static/js/notifications.js index c564aff81e..9492402824 100644 --- a/portality/static/js/notifications.js +++ b/portality/static/js/notifications.js @@ -58,7 +58,7 @@ doaj.notifications.notificationsReceived = function(data) { } $(".notification_action_link").on("click", doaj.notifications.notificationClicked); - $(".dropdown--notifications").hoverIntent(doaj.notifications.showDropdown, doaj.notifications.hideDropdown); + $("#notifications_nav").hoverIntent(doaj.notifications.showDropdown, doaj.notifications.hideDropdown); } doaj.notifications.showDropdown = function(e) { diff --git a/portality/static/js/tourist.js b/portality/static/js/tourist.js index cc0f375f0a..b2931f6dcf 100644 --- a/portality/static/js/tourist.js +++ b/portality/static/js/tourist.js @@ -15,6 +15,17 @@ doaj.tourist.init = function(params) { if (first) { doaj.tourist.start(first); } + + $("#dropdown--tour_nav").hoverIntent(doaj.tourist.showDropdown, doaj.tourist.hideDropdown); +} + +doaj.tourist.showDropdown = function(e) { + console.log("showDropdown` called") + $("#feature_tours").show(); +} +doaj.tourist.hideDropdown = function() { + console.log("showDropdown` called") + $("#feature_tours").hide(); } doaj.tourist.findNextTour = function() { diff --git a/portality/templates/_js_includes.html b/portality/templates/_js_includes.html index 50f3abdeff..d18034e523 100644 --- a/portality/templates/_js_includes.html +++ b/portality/templates/_js_includes.html @@ -14,15 +14,6 @@ - - - - {%- endif -%} {# FIXME: do we need these any more? #} diff --git a/portality/templates/account/view.html b/portality/templates/account/view.html index ab4c8c0de6..dd1c2aa4a2 100644 --- a/portality/templates/account/view.html +++ b/portality/templates/account/view.html @@ -90,7 +90,9 @@{{ account.api_key }}
+ {{ account.api_key }}
+ Copy value
+