From a8f7c08f4ba5fb5665f196c29d92f55468783e80 Mon Sep 17 00:00:00 2001
From: Richard Jones
Date: Fri, 10 Nov 2023 16:31:18 +0000
Subject: [PATCH] comment out all the bitly integration
---
portality/settings.py | 4 +-
portality/static/js/doaj.fieldrender.edges.js | 14 +-
portality/static/js/doaj.js | 46 +-
.../static/js/edges/public.article.edge.js | 2 +-
.../static/js/edges/public.journal.edge.js | 2 +-
.../widget/fq_widget_depends_compiled.js | 843 ++++++++++++++----
portality/view/doajservices.py | 82 +-
7 files changed, 725 insertions(+), 268 deletions(-)
diff --git a/portality/settings.py b/portality/settings.py
index 48149cc5ef..6293861cb4 100644
--- a/portality/settings.py
+++ b/portality/settings.py
@@ -1069,11 +1069,11 @@
# ~~->Bitly:ExternalService~~
# bit,ly api shortening service
-BITLY_SHORTENING_API_URL = "https://api-ssl.bitly.com/v4/shorten"
+#BITLY_SHORTENING_API_URL = "https://api-ssl.bitly.com/v4/shorten"
# bitly oauth token
# ENTER YOUR OWN TOKEN IN APPROPRIATE .cfg FILE
-BITLY_OAUTH_TOKEN = ""
+#BITLY_OAUTH_TOKEN = ""
###############################################
# Date handling
diff --git a/portality/static/js/doaj.fieldrender.edges.js b/portality/static/js/doaj.fieldrender.edges.js
index 49faf4b543..fc39fb42de 100644
--- a/portality/static/js/doaj.fieldrender.edges.js
+++ b/portality/static/js/doaj.fieldrender.edges.js
@@ -1302,15 +1302,15 @@ $.extend(true, doaj, {
var comp = this.component;
- var shareButtonFrag = "";
var shareButtonClass = edges.css_classes(this.namespace, "toggle-share", this);
var modalId = edges.css_id(this.namespace, "modal", this);
- shareButtonFrag = '' + this.shareLinkText + ' ';
+ let shareButtonFrag = '' + this.shareLinkText + ' ';
- var shorten = "";
+ let shorten = "";
if (this.component.urlShortener) {
var shortenClass = edges.css_classes(this.namespace, "shorten", this);
- shorten = 'Share a link to this search
'
+ var shortenButtonClass = edges.css_classes(this.namespace, "shorten-url", this)
+ shorten = 'shorten url
';
}
var embed = "";
if (this.component.embedSnippet) {
@@ -1320,11 +1320,11 @@ $.extend(true, doaj, {
}
var shareBoxClass = edges.css_classes(this.namespace, "share", this);
var shareUrlClass = edges.css_classes(this.namespace, "share-url", this);
- var shortenButtonClass = edges.css_classes(this.namespace, "shorten-url", this);
+
var shareFrag = '\
- ' + shorten + '\
+
Share a link to this search
\
\
-
shorten url
\
+ ' + shorten + '\
' + embed + '\
';
diff --git a/portality/static/js/doaj.js b/portality/static/js/doaj.js
index 0e8d479614..0636e9d6aa 100644
--- a/portality/static/js/doaj.js
+++ b/portality/static/js/doaj.js
@@ -69,29 +69,29 @@ var doaj = {
doaj.bindMiniSearch();
},
- bitlyShortener : function(query, success_callback, error_callback) {
- // ~~-> Bitly:ExternalService ~~
- function callbackWrapper(data) {
- success_callback(data.url);
- }
-
- function errorHandler() {
- alert("Sorry, we're unable to generate short urls at this time");
- error_callback();
- }
-
- var page = window.location.protocol + '//' + window.location.host + window.location.pathname;
-
- $.ajax({
- type: "POST",
- contentType: "application/json",
- dataType: "jsonp",
- url: "/service/shorten",
- data : JSON.stringify({page: page, query: query}),
- success: callbackWrapper,
- error: errorHandler
- });
- },
+ // bitlyShortener : function(query, success_callback, error_callback) {
+ // // ~~-> Bitly:ExternalService ~~
+ // function callbackWrapper(data) {
+ // success_callback(data.url);
+ // }
+ //
+ // function errorHandler() {
+ // alert("Sorry, we're unable to generate short urls at this time");
+ // error_callback();
+ // }
+ //
+ // var page = window.location.protocol + '//' + window.location.host + window.location.pathname;
+ //
+ // $.ajax({
+ // type: "POST",
+ // contentType: "application/json",
+ // dataType: "jsonp",
+ // url: "/service/shorten",
+ // data : JSON.stringify({page: page, query: query}),
+ // success: callbackWrapper,
+ // error: errorHandler
+ // });
+ // },
journal_toc_id : function(journal) {
// if e-issn is available, use that
diff --git a/portality/static/js/edges/public.article.edge.js b/portality/static/js/edges/public.article.edge.js
index f4595e9227..b520a5c474 100644
--- a/portality/static/js/edges/public.article.edge.js
+++ b/portality/static/js/edges/public.article.edge.js
@@ -139,7 +139,7 @@ $.extend(true, doaj, {
edges.newFullSearchController({
id: "share_embed",
category: "controller",
- urlShortener : doaj.bitlyShortener,
+ // urlShortener : doaj.bitlyShortener,
embedSnippet : doaj.publicSearch.embedSnippet,
renderer: doaj.renderers.newShareEmbedRenderer({
shareLinkText: ' Share or embed'
diff --git a/portality/static/js/edges/public.journal.edge.js b/portality/static/js/edges/public.journal.edge.js
index f4494d8c4d..8904e50dfb 100644
--- a/portality/static/js/edges/public.journal.edge.js
+++ b/portality/static/js/edges/public.journal.edge.js
@@ -224,7 +224,7 @@ $.extend(true, doaj, {
edges.newFullSearchController({
id: "share_embed",
category: "controller",
- urlShortener : doaj.bitlyShortener,
+ // urlShortener : doaj.bitlyShortener,
embedSnippet : doaj.publicSearch.embedSnippet,
renderer: doaj.renderers.newShareEmbedRenderer({
shareLinkText: ' Share or embed'
diff --git a/portality/static/widget/fq_widget_depends_compiled.js b/portality/static/widget/fq_widget_depends_compiled.js
index a913236580..5bbbc208a4 100644
--- a/portality/static/widget/fq_widget_depends_compiled.js
+++ b/portality/static/widget/fq_widget_depends_compiled.js
@@ -1,5 +1,7 @@
/** base namespace for all DOAJ-specific functions */
+// ~~ DOAJ:Library ~~
var doaj = {
+ scrollPosition: 100,
init : function() {
// Use Feather icons
feather.replace();
@@ -8,50 +10,48 @@ var doaj = {
var openMenu = document.querySelector(".secondary-nav__menu-toggle");
var nav = document.querySelector(".secondary-nav__menu");
- openMenu.addEventListener('click', function() {
- nav.classList.toggle("secondary-nav__menu-toggle--active");
- }, false);
+ if (openMenu) {
+ openMenu.addEventListener('click', function () {
+ nav.classList.toggle("secondary-nav__menu-toggle--active");
+ }, false);
+ }
- // Display back-to-top button on scroll
- var topBtn = document.getElementById("top");
+ // On scroll, display back-to-top button & add class to header primary menu
+ var topBtn = document.getElementById("top"),
+ topNav = document.querySelector(".primary-nav");
- function displayTopBtn() {
- if (topBtn) {
- if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
+ function displayOnScroll() {
+ if (topBtn && topNav) {
+ if (document.body.scrollTop > doaj.scrollPosition || document.documentElement.scrollTop > doaj.scrollPosition) {
topBtn.style.display = "flex";
+ topNav.classList.add("primary-nav--scrolled");
} else {
topBtn.style.display = "none";
+ topNav.classList.remove("primary-nav--scrolled");
}
}
}
- // Hide header menu on down scroll; display on scroll up
- var prevScrollPos = window.pageYOffset,
- topNav = document.querySelector(".primary-nav");
-
- function hideNav() {
- var currentScrollPos = window.pageYOffset;
-
- if (prevScrollPos > currentScrollPos) {
- topNav.classList.remove("primary-nav--scrolled");
- } else {
- topNav.classList.add("primary-nav--scrolled");
- }
- prevScrollPos = currentScrollPos;
- }
-
- window.onscroll = function() {
- displayTopBtn();
- hideNav();
- };
+ window.addEventListener("scroll", function() {
+ displayOnScroll();
+ });
// Tabs
jQuery (function($) {
$("[role='tab']").click(function(e) {
e.preventDefault();
- $(this).attr("aria-selected", "true");
- $(this).parent().siblings().children().attr("aria-selected", "false");
- var tabpanelShow = $(this).attr("href");
+ let el = $(this);
+
+ el.attr("aria-selected", "true");
+ el.siblings().children().attr("aria-selected", "false");
+
+ let tabpanelShow = el.attr("href");
+ if (!tabpanelShow) {
+ let innerLink = el.find("a");
+ innerLink.attr("aria-selected", "true");
+ tabpanelShow = innerLink.attr("href")
+ }
+
$(tabpanelShow).attr("aria-hidden", "false");
$(tabpanelShow).siblings().attr("aria-hidden", "true");
});
@@ -69,29 +69,29 @@ var doaj = {
doaj.bindMiniSearch();
},
- bitlyShortener : function(query, success_callback, error_callback) {
-
- function callbackWrapper(data) {
- success_callback(data.url);
- }
-
- function errorHandler() {
- alert("Sorry, we're unable to generate short urls at this time");
- error_callback();
- }
-
- var page = window.location.protocol + '//' + window.location.host + window.location.pathname;
-
- $.ajax({
- type: "POST",
- contentType: "application/json",
- dataType: "jsonp",
- url: "/service/shorten",
- data : JSON.stringify({page: page, query: query}),
- success: callbackWrapper,
- error: errorHandler
- });
- },
+ // bitlyShortener : function(query, success_callback, error_callback) {
+ // // ~~-> Bitly:ExternalService ~~
+ // function callbackWrapper(data) {
+ // success_callback(data.url);
+ // }
+ //
+ // function errorHandler() {
+ // alert("Sorry, we're unable to generate short urls at this time");
+ // error_callback();
+ // }
+ //
+ // var page = window.location.protocol + '//' + window.location.host + window.location.pathname;
+ //
+ // $.ajax({
+ // type: "POST",
+ // contentType: "application/json",
+ // dataType: "jsonp",
+ // url: "/service/shorten",
+ // data : JSON.stringify({page: page, query: query}),
+ // success: callbackWrapper,
+ // error: errorHandler
+ // });
+ // },
journal_toc_id : function(journal) {
// if e-issn is available, use that
@@ -244,6 +244,59 @@ var doaj = {
} else {
doaj.scroller.doScroll = true;
}
+ },
+
+ searchQuerySource : function (params) {
+ // ~~-> Edges:Technology ~~
+ // ~~-> Elasticsearch:Technology ~~
+ // ~~-> Edges:Query ~~
+ let terms = params.terms;
+ let term = params.term;
+ let queryString = params.queryString;
+ let sort = params.sort;
+
+ let musts = [];
+ if (terms) {
+ for (let term of terms) {
+ musts.push({"terms" : term})
+ }
+ }
+
+ if (term) {
+ for (let t of term) {
+ musts.push({"term" : t});
+ }
+ }
+
+ if (queryString) {
+ musts.push({
+ "query_string" : {
+ "default_operator" : "AND",
+ "query" : queryString
+ }
+ })
+ }
+
+ let query = {"match_all": {}}
+ if (musts.length > 0) {
+ query = {
+ "bool" : {
+ "must" : musts
+ }
+ }
+ }
+
+ let obj = {"query": query}
+ if (sort) {
+ if (Array.isArray(sort)) {
+ obj["sort"] = sort;
+ } else {
+ obj["sort"] = [sort];
+ }
+ }
+
+ let source = JSON.stringify(obj)
+ return encodeURIComponent(source)
}
};
@@ -4494,6 +4547,24 @@ $.extend(edges, {
});
$.extend(true, doaj, {
+ filters : {
+ noCharges : function() {
+ return {
+ id: "no_charges",
+ display: "Without fees",
+ must: [
+ es.newTermFilter({
+ field: "bibjson.apc.has_apc",
+ value: false
+ }),
+ es.newTermFilter({
+ field: "bibjson.other_charges.has_other_charges",
+ value: false
+ })
+ ]
+ }
+ }
+ },
facets : {
inDOAJ : function() {
return edges.newRefiningANDTermSelector({
@@ -4503,8 +4574,18 @@ $.extend(true, doaj, {
display: "In DOAJ?",
deactivateThreshold: 1,
valueMap : {
- 1 : "True",
- 0 : "False"
+ 1 : "Yes",
+ 0 : "No",
+ true: "Yes",
+ false: "No"
+ },
+ parseSelectedValueString: function(val) {
+ // this is needed because ES7 doesn't understand "1" or `1` to be `true`, so
+ // we convert the string value of the aggregation back to a boolean
+ return val === "1"
+ },
+ filterToAggValue : function(val) {
+ return val === true ? 1 : 0;
},
renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
controls: true,
@@ -4514,6 +4595,223 @@ $.extend(true, doaj, {
hideInactive: true
})
})
+ },
+
+ openOrClosed: function() {
+ return edges.newRefiningANDTermSelector({
+ id: "application_type",
+ category: "facet",
+ field: "index.application_type.exact",
+ display: "Open or closed?",
+ deactivateThreshold : 1,
+ orderDir: "asc",
+ valueMap : {
+ "finished application/update": "Closed",
+ "update request": "Open",
+ "new application": "Open"
+ },
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+
+ applicationStatus : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "application_status",
+ category: "facet",
+ field: "admin.application_status.exact",
+ display: "Status",
+ deactivateThreshold: 1,
+ valueFunction: doaj.valueMaps.adminStatusMap,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ hasEditorGroup : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "has_editor_group",
+ category: "facet",
+ field: "index.has_editor_group.exact",
+ display: "Has editor group?",
+ deactivateThreshold : 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ hasEditor : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "has_editor",
+ category: "facet",
+ field: "index.has_editor.exact",
+ display: "Has Associate Editor?",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ editorGroup : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "editor_group",
+ category: "facet",
+ field: "admin.editor_group.exact",
+ display: "Editor group",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ editor : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "editor",
+ category: "facet",
+ field: "admin.editor.exact",
+ display: "Editor",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ hasAPC : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "author_pays",
+ category: "facet",
+ field: "index.has_apc.exact",
+ display: "Publication charges?",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ classification : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "classification",
+ category: "facet",
+ field: "index.classification.exact",
+ display: "Classification",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ language : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "language",
+ category: "facet",
+ field: "index.language.exact",
+ display: "Journal language",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ countryPublisher : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "country_publisher",
+ category: "facet",
+ field: "index.country.exact",
+ display: "Country of publisher",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ subject : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "subject",
+ category: "facet",
+ field: "index.subject.exact",
+ display: "Subject",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ publisher : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "publisher",
+ category: "facet",
+ field: "bibjson.publisher.name.exact",
+ display: "Publisher",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
+ },
+ journalLicence : function() {
+ return edges.newRefiningANDTermSelector({
+ id: "journal_license",
+ category: "facet",
+ field: "index.license.exact",
+ display: "Journal license",
+ deactivateThreshold: 1,
+ renderer: edges.bs3.newRefiningANDTermSelectorRenderer({
+ controls: true,
+ open: false,
+ togglable: true,
+ countFormat: doaj.valueMaps.countFormat,
+ hideInactive: true
+ })
+ })
}
},
@@ -4531,6 +4829,13 @@ $.extend(true, doaj, {
'accepted' : 'Accepted'
},
+ adminStatusMap: function(value) {
+ if (doaj.valueMaps.applicationStatus.hasOwnProperty(value)) {
+ return doaj.valueMaps.applicationStatus[value];
+ }
+ return value;
+ },
+
displayYearPeriod : function(params) {
var from = params.from;
var to = params.to;
@@ -4539,6 +4844,16 @@ $.extend(true, doaj, {
return {to: to, toType: "lt", from: from, fromType: "gte", display: display}
},
+ displayYearMonthPeriod : function(params) {
+ var from = params.from;
+ var to = params.to;
+ var field = params.field;
+
+ let d = new Date(parseInt(from))
+ let display = d.getUTCFullYear().toString() + "-" + doaj.valueMaps.monthPadding(d.getUTCMonth() + 1);
+ return {to: to, toType: "lt", from: from, fromType: "gte", display: display}
+ },
+
schemaCodeToNameClosure : function(tree) {
var nameMap = {};
function recurse(ctx) {
@@ -4564,10 +4879,36 @@ $.extend(true, doaj, {
countFormat : edges.numFormat({
thousandsSeparator: ","
+ }),
+
+ monthPadding: edges.numFormat({
+ zeroPadding: 2
})
},
-
components : {
+ pager : function(id, category) {
+ return edges.newPager({
+ id: id,
+ category: category,
+ renderer: edges.bs3.newPagerRenderer({
+ sizeOptions: [10, 25, 50, 100],
+ numberFormat: doaj.valueMaps.countFormat,
+ scroll: false
+ })
+ })
+ },
+
+ searchingNotification : function() {
+ return edges.newSearchingNotification({
+ id: "searching-notification",
+ category: "searching-notification",
+ finishedEvent: "edges:post-render",
+ renderer : doaj.renderers.newSearchingNotificationRenderer({
+ scrollOnSearch: true
+ })
+ })
+ },
+
subjectBrowser : function(params) {
var tree = params.tree;
var hideEmpty = edges.getParam(params.hideEmpty, false);
@@ -4618,7 +4959,7 @@ $.extend(true, doaj, {
showCounts: false
})
})
- },
+ }
},
templates : {
@@ -4651,7 +4992,7 @@ $.extend(true, doaj, {
\
\
\
-
\
+
\
\
\
Refine search results \
@@ -4659,10 +5000,16 @@ $.extend(true, doaj, {
\
+ \
+ Celebrating 20 years of DOAJ \
+ \
+ \
+ \
+ \
\
\
\
-
\
+
\
\
\
Display options \
@@ -4757,6 +5104,8 @@ $.extend(true, doaj, {
this.scrollTarget = edges.getParam(params.scrollTarget, "body");
+ this.scrollOnSearch = edges.getParam(params.scrollOnSearch, false);
+
// namespace to use in the page
this.namespace = "doaj-notification";
@@ -4774,8 +5123,11 @@ $.extend(true, doaj, {
Loading results…
`
this.component.edge.context.before(frag);
- let offset = $(this.scrollTarget).offset().top
- window.scrollTo(0, offset);
+
+ if (this.scrollOnSearch) {
+ let offset = $(this.scrollTarget).offset().top
+ window.scrollTo(0, offset);
+ }
} else {
let that = this;
let idSelector = edges.css_id_selector(this.namespace, "loading", this);
@@ -4841,13 +5193,13 @@ $.extend(true, doaj, {
toggle = '
';
}
var placeholder = 'Search ' + this.component.nodeCount + ' subjects';
- var frag = '
' + this.title + toggle + ' \
-
\
+ var frag = '
' + this.title + toggle + ' \
+
\
' + placeholder + ' \
\
\
\
-
';
+
';
// substitute in the component parts
frag = frag.replace(/{{FILTERS}}/g, treeFrag);
@@ -5131,8 +5483,7 @@ $.extend(true, doaj, {
sortOptions = '
\
\
- \
- Relevance ';
+ ';
for (var i = 0; i < comp.sortOptions.length; i++) {
var field = comp.sortOptions[i].field;
@@ -5140,7 +5491,8 @@ $.extend(true, doaj, {
sortOptions += '' + edges.escapeHtml(display) + ' ';
}
- sortOptions += '
';
+ sortOptions += '
Relevance \
+
';
}
// select box for fields to search on
@@ -5194,7 +5546,7 @@ $.extend(true, doaj, {
clearFrag = '
' + clearFrag + '
';
}
- var frag = searchBox + '
' + sortOptions + clearFrag + '
';
+ var frag = searchBox + '
' + sortOptions + clearFrag + '
';
comp.context.html(frag);
@@ -5274,13 +5626,14 @@ $.extend(true, doaj, {
};
this.setUISortField = function () {
+ let sb = this.component.sortBy
if (!this.component.sortBy) {
- return;
+ sb = "_score";
}
// get the selector we need
var sortSelector = edges.css_class_selector(this.namespace, "sortby", this);
var el = this.component.jq(sortSelector);
- el.val(this.component.sortBy);
+ el.val(sb);
};
this.setUISearchField = function () {
@@ -5497,15 +5850,15 @@ $.extend(true, doaj, {
var comp = this.component;
- var shareButtonFrag = "";
var shareButtonClass = edges.css_classes(this.namespace, "toggle-share", this);
var modalId = edges.css_id(this.namespace, "modal", this);
- shareButtonFrag = '
' + this.shareLinkText + ' ';
+ let shareButtonFrag = '
' + this.shareLinkText + ' ';
- var shorten = "";
+ let shorten = "";
if (this.component.urlShortener) {
var shortenClass = edges.css_classes(this.namespace, "shorten", this);
- shorten = '
Share a link to this search
'
+ var shortenButtonClass = edges.css_classes(this.namespace, "shorten-url", this)
+ shorten = '
shorten url
';
}
var embed = "";
if (this.component.embedSnippet) {
@@ -5515,11 +5868,11 @@ $.extend(true, doaj, {
}
var shareBoxClass = edges.css_classes(this.namespace, "share", this);
var shareUrlClass = edges.css_classes(this.namespace, "share-url", this);
- var shortenButtonClass = edges.css_classes(this.namespace, "shorten-url", this);
+
var shareFrag = '
\
- ' + shorten + '\
+
Share a link to this search
\
\
-
shorten url
\
+ ' + shorten + '\
' + embed + '\
';
@@ -5746,13 +6099,12 @@ $.extend(true, doaj, {
var textIdSelector = edges.css_id_selector(this.namespace, "text", this);
var text = this.component.jq(textIdSelector).val();
- if (text === "") {
- return;
- }
-
// if there is search text, then proceed to run the search
var val = this.component.jq(element).val();
this.component.setSearchField(val, false);
+ if (text === "") {
+ return;
+ }
this.component.setSearchText(text);
};
@@ -6028,10 +6380,10 @@ $.extend(true, doaj, {
if (this.togglable) {
toggle = '
';
}
- var frag = '
' + this.component.display + toggle + ' \
-
\
+ var frag = '
' + this.component.display + toggle + ' \
+
';
+
';
// substitute in the component parts
frag = frag.replace(/{{FILTERS}}/g, filterFrag + results);
@@ -6075,7 +6427,7 @@ $.extend(true, doaj, {
//var i = toggle.find("i");
//for (var j = 0; j < openBits.length; j++) {
// i.removeClass(openBits[j]);
- // }
+ // }
//for (var j = 0; j < closeBits.length; j++) {
// i.addClass(closeBits[j]);
//}
@@ -6087,9 +6439,9 @@ $.extend(true, doaj, {
//var i = toggle.find("i");
//for (var j = 0; j < closeBits.length; j++) {
// i.removeClass(closeBits[j]);
- // }
+ // }
//for (var j = 0; j < openBits.length; j++) {
- // i.addClass(openBits[j]);
+ // i.addClass(openBits[j]);
//}
//results.hide();
@@ -6135,6 +6487,7 @@ $.extend(true, doaj, {
// whether to hide or just disable the facet if not active
this.hideInactive = edges.getParam(params.hideInactive, false);
+ this.hideEmpty = edges.getParam(params.hideEmpty, false)
// whether the facet should be open or closed
// can be initialised and is then used to track internal state
@@ -6199,6 +6552,9 @@ $.extend(true, doaj, {
// render each value, if it is not also a filter that has been set
for (var i = 0; i < ts.values.length; i++) {
var val = ts.values[i];
+ if (val.count === 0 && this.hideEmpty) {
+ continue
+ }
if ($.inArray(val.display, filterTerms) === -1) {
var ltData = "";
@@ -6275,10 +6631,10 @@ $.extend(true, doaj, {
if (this.togglable) {
toggle = '
';
}
- var frag = '
' + this.component.display + toggle + ' \
-
\
+ var frag = '
' + this.component.display + toggle + ' \
+
';
+
';
// substitute in the component parts
frag = frag.replace(/{{FILTERS}}/g, filterFrag + results);
@@ -6333,7 +6689,7 @@ $.extend(true, doaj, {
//var i = toggle.find("i");
//for (var j = 0; j < openBits.length; j++) {
// i.removeClass(openBits[j]);
- // }
+ // }
//for (var j = 0; j < closeBits.length; j++) {
// i.addClass(closeBits[j]);
//}
@@ -6345,9 +6701,9 @@ $.extend(true, doaj, {
//var i = toggle.find("i");
//for (var j = 0; j < closeBits.length; j++) {
// i.removeClass(closeBits[j]);
- // }
+ // }
//for (var j = 0; j < openBits.length; j++) {
- // i.addClass(openBits[j]);
+ // i.addClass(openBits[j]);
//}
//results.hide();
@@ -6468,7 +6824,7 @@ $.extend(true, doaj, {
// the remove block looks different, depending on the kind of filter to remove
if (def.filter === "term" || def.filter === "terms") {
- filters += '
';
+ filters += ' ';
filters += def.display + valDisplay;
filters += ' ';
filters += " ";
@@ -6523,6 +6879,7 @@ $.extend(true, doaj, {
this.removeFilter = function (element) {
var el = this.component.jq(element);
+ var sf = this.component;
// if this is a compound filter, remove it by id
var compound = el.attr("data-compound");
@@ -6538,7 +6895,9 @@ $.extend(true, doaj, {
var value = false;
if (ft === "terms" || ft === "term") {
- value = el.attr("data-value");
+ let values = sf.mustFilters[field].values;
+ let idx = el.attr("data-value-idx")
+ value = values[idx].val
} else if (ft === "range") {
value = {};
@@ -6737,14 +7096,20 @@ $.extend(true, doaj, {
var seal = "";
if (edges.objVal("admin.seal", resultobj, false)) {
- seal = '
'
+ seal = ' '
if (this.widget){
- seal += ' '
+ seal += ' DOAJ Seal '
}
else {
- seal += '
'
+ seal += '
\
+ \
+ \
+ \
+ \
+ \
+
DOAJ Seal
\
+ ';
}
- seal += ' DOAJ Seal';
}
var issn = resultobj.bibjson.pissn;
if (!issn) {
@@ -6775,9 +7140,9 @@ $.extend(true, doaj, {
// add the subjects
var subjects = "";
if (edges.hasProp(resultobj, "index.classification_paths") && resultobj.index.classification_paths.length > 0) {
- subjects = '
Journal subjects ';
- subjects += "" + resultobj.index.classification_paths.join(", ") + " ";
- subjects += ' ';
+ subjects = '
Journal subjects ';
+ subjects += "" + resultobj.index.classification_paths.join(", ") + " ";
+ subjects += ' ';
}
var update_or_added = "";
@@ -6814,6 +7179,15 @@ $.extend(true, doaj, {
}
apcs += '';
+ var rights = "";
+ if (resultobj.bibjson.copyright) {
+ var copyright_url = resultobj.bibjson.copyright.url;
+ rights += '
';
+ rights += resultobj.bibjson.copyright.author_retains ? 'Author retains all rights' : 'Author doesn\'t retain all rights';
+ rights += ' ';
+ }
+
+
var licenses = "";
if (resultobj.bibjson.license && resultobj.bibjson.license.length > 0) {
var terms_url = resultobj.bibjson.ref.license_terms;
@@ -6821,7 +7195,7 @@ $.extend(true, doaj, {
var lic = resultobj.bibjson.license[i];
var license_url = lic.url || terms_url;
licenses += '
' + edges.escapeHtml(lic.type) + ' ';
- if (i != (resultobj.bibjson.license.length-1)) {
+ if (i !== (resultobj.bibjson.license.length-1)) {
licenses += ', ';
}
}
@@ -6835,15 +7209,26 @@ $.extend(true, doaj, {
}
var actions = "";
+ var modals = "";
if (this.actions.length > 0) {
actions = '
Actions ';
@@ -6853,7 +7238,6 @@ $.extend(true, doaj, {
\
\
\
\
+ ' + seal + '\
\
- ' + actions + '\
+ ' + actions + modals + '\
\
\
';
@@ -6960,9 +7348,9 @@ $.extend(true, doaj, {
var subjects = "";
if (edges.hasProp(resultobj, "index.classification_paths") && resultobj.index.classification_paths.length > 0) {
- subjects = '
Journal subjects ';
- subjects += "" + resultobj.index.classification_paths.join(", ") + " ";
- subjects += ' ';
+ subjects = '
Journal subjects ';
+ subjects += "" + resultobj.index.classification_paths.join(", ") + " ";
+ subjects += ' ';
}
var subjects_or_keywords = keywords === "" ? subjects : keywords;
@@ -7076,11 +7464,11 @@ $.extend(true, doaj, {
\
\
';
- /*
-
\
- ' + license + '\
- \
- */
+ /*
+
\
+ ' + license + '\
+ \
+ */
// close off the result and return
return frag;
};
@@ -7233,7 +7621,7 @@ $.extend(true, doaj, {
var deleteLinkUrl = deleteLinkTemplate.replace("__application_id__", resultobj.id);
var deleteClass = edges.css_classes(this.namespace, "delete", this);
if (resultobj.es_type === "draft_application" ||
- resultobj.admin.application_status === "update_request") {
+ resultobj.admin.application_status === "update_request") {
deleteLink = '
\
\
@@ -7370,20 +7758,7 @@ $.extend(true, doaj, {
}
var last_updated = "Last updated ";
- last_updated += doaj.humanDate(resultobj.last_updated);
-
- /*
- var icon = "edit-3";
- if (accessLink[1] === "View") {
- icon = "eye";
- }
- var viewOrEdit = '\
- \
- \
- ' + accessLink[1] + ' \
- \
- ';
- */
+ last_updated += doaj.humanDate(resultobj.last_manual_update);
var deleteLink = "";
var deleteLinkTemplate = doaj.publisherUpdatesSearchConfig.deleteLinkTemplate;
@@ -7483,9 +7858,9 @@ $.extend(true, doaj, {
this._renderPublicJournal = function(resultobj) {
var seal = "";
if (edges.objVal("admin.seal", resultobj, false)) {
- seal = ' \
- \
- DOAJ Seal\
+ seal = ' \
+ \
+ DOAJ Seal \
';
}
var issn = resultobj.bibjson.pissn;
@@ -7517,9 +7892,9 @@ $.extend(true, doaj, {
// add the subjects
var subjects = "";
if (edges.hasProp(resultobj, "index.classification_paths") && resultobj.index.classification_paths.length > 0) {
- subjects = 'Journal subjects ';
- subjects += "" + resultobj.index.classification_paths.join(", ") + " ";
- subjects += ' ';
+ subjects = 'Journal subjects ';
+ subjects += "" + resultobj.index.classification_paths.join(", ") + " ";
+ subjects += ' ';
}
var update_or_added = "";
@@ -7592,7 +7967,6 @@ $.extend(true, doaj, {
\
\
\
\
+ ' + seal + '\
\
\
' + update_or_added + '\
@@ -7673,8 +8048,7 @@ $.extend(true, doaj, {
sortOptions = label + '\
' + direction + ' \
- \
- Relevance ';
+ ';
for (var i = 0; i < comp.sortOptions.length; i++) {
var field = comp.sortOptions[i].field;
@@ -7783,7 +8157,7 @@ $.extend(true, doaj, {
fieldRender: {
titleField : function (val, resultobj, renderer) {
- var field = '';
+ var field = '';
if (resultobj.bibjson.title) {
if (resultobj.es_type === "journal") {
var display = edges.escapeHtml(resultobj.bibjson.title);
@@ -7794,45 +8168,57 @@ $.extend(true, doaj, {
} else {
field += edges.escapeHtml(resultobj.bibjson.title);
}
+ field += " ";
if (resultobj.admin && resultobj.admin.seal) {
- field += "
\
- \
- DOAJ Seal
";
- }
- return field + ""
+ field += '
';
+ }
+ return field + "
";
} else {
return false;
}
},
authorPays : function(val, resultobj, renderer) {
- var field = "";
- if (edges.hasProp(resultobj, "bibjson.apc.max") && resultobj.bibjson.apc.max.length > 0) {
- field += 'Has charges';
- } else if (edges.hasProp(resultobj, "bibjson.other_charges.has_other_charges") && resultobj.bibjson.other_charges.has_other_charges) {
- field += 'Has charges';
- }
- if (field === "") {
- field = 'No charges';
- }
+ if (resultobj.es_type === "journal") {
+ var field = "";
+ if (edges.hasProp(resultobj, "bibjson.apc.max") && resultobj.bibjson.apc.max.length > 0) {
+ field += 'Has charges';
+ } else if (edges.hasProp(resultobj, "bibjson.other_charges.has_other_charges") && resultobj.bibjson.other_charges.has_other_charges) {
+ field += 'Has charges';
+ }
+ if (field === "") {
+ field = 'No charges';
+ }
- var urls = [];
- if (edges.hasProp(resultobj, "bibjson.apc.url")) {
- urls.push(resultobj.bibjson.apc.url);
- }
- if (edges.hasProp(resultobj, "bibjson.has_other_charges.url")) {
- urls.push(resultobj.bibjson.has_other_charges.url)
- }
+ var urls = [];
+ if (edges.hasProp(resultobj, "bibjson.apc.url")) {
+ urls.push(resultobj.bibjson.apc.url);
+ }
+ if (edges.hasProp(resultobj, "bibjson.has_other_charges.url")) {
+ urls.push(resultobj.bibjson.has_other_charges.url)
+ }
- if (urls.length > 0) {
- field += ' (see ';
- for (var i = 0; i < urls.length; i++) {
- field += '' + urls[i] + ' ';
+ if (urls.length > 0) {
+ field += ' (see ';
+ for (var i = 0; i < urls.length; i++) {
+ field += '' + urls[i] + ' ';
+ }
+ field += ')';
}
- field += ')';
- }
- return field ? field : false;
+ return field ? field : false;
+ }
+ else {
+ return false;
+ }
},
abstract : function (val, resultobj, renderer) {
@@ -8006,20 +8392,25 @@ $.extend(true, doaj, {
if (resultobj.es_type === "application") {
// determine the link name
var linkName = "Review application";
- if (resultobj.admin.application_status === 'accepted' || resultobj.admin.application_status === 'rejected') {
- linkName = "View finished application";
- if (resultobj.admin.related_journal) {
- linkName = "View finished update";
+ if (resultobj.admin.application_type === "new_application") {
+ if (resultobj.admin.application_status === 'accepted' || resultobj.admin.application_status === 'rejected') {
+ linkName = "View application (finished)"
+ } else {
+ linkName = "Review application"
+ }
+ } else {
+ if (resultobj.admin.application_status === 'accepted' || resultobj.admin.application_status === 'rejected') {
+ linkName = "View update (finished)"
+ } else {
+ linkName = "Review update"
}
- } else if (resultobj.admin.current_journal) {
- linkName = "Review update";
}
var result = ' ' + linkName + '
';
+ result += ' style="margin-bottom: .75em;">' + linkName + '
';
return result;
}
return false;
@@ -8046,16 +8437,81 @@ $.extend(true, doaj, {
// if it's not a suggestion or an article .. (it's a
// journal!)
// we really need to expose _type ...
- var result = 'Edit this journal
';
+ result += ' style="margin-bottom: .75em;">Edit this journal';
return result;
}
return false;
}
},
+ },
+
+ bulk : {
+ applicationMultiFormBox : function(edge_instance, doaj_type) {
+ return doaj.multiFormBox.newMultiFormBox({
+ edge : edge_instance,
+ selector: "#admin-bulk-box",
+ bindings : {
+ editor_group : function(context) {
+ autocomplete($('#editor_group', context), 'name', 'editor_group', 1, false);
+ }
+ },
+ validators : {
+ application_status : function(context) {
+ var val = context.find("#application_status").val();
+ if (val === "") {
+ return {valid: false};
+ }
+ return {valid: true};
+ },
+ editor_group : function(context) {
+ var val = context.find("#editor_group").val();
+ if (val === "") {
+ return {valid: false};
+ }
+ return {valid: true};
+ },
+ note : function(context) {
+ var val = context.find("#note").val();
+ if (val === "") {
+ return {valid: false};
+ }
+ return {valid: true};
+ }
+ },
+ submit : {
+ note : {
+ data: function(context) {
+ return {
+ note: $('#note', context).val()
+ };
+ }
+ },
+ editor_group : {
+ data : function(context) {
+ return {
+ editor_group: $('#editor_group', context).val()
+ };
+ }
+ },
+ application_status : {
+ data : function(context) {
+ return {
+ application_status: $('#application_status', context).val()
+ };
+ }
+ }
+ },
+ urls : {
+ note : "/admin/" + doaj_type + "/bulk/add_note",
+ editor_group : "/admin/" + doaj_type + "/bulk/assign_editor_group",
+ application_status : "/admin/" + doaj_type + "/bulk/change_status"
+ }
+ });
+ }
}
});
@@ -8296,3 +8752,4 @@ $.extend(true, edges, {
}
}
});
+
diff --git a/portality/view/doajservices.py b/portality/view/doajservices.py
index 23466732d7..7d67cc03de 100644
--- a/portality/view/doajservices.py
+++ b/portality/view/doajservices.py
@@ -55,47 +55,47 @@ def unlocked():
return render_template("unlocked.html")
-@blueprint.route("/shorten", methods=["POST"])
-@jsonp
-def shorten():
- # Enable this if you are testing and you want to see the front end work, without working bit.ly credentials
- # return make_response(json.dumps({"url" : "testing url"}))
- try:
- # parse the json
- d = json.loads(request.data)
- p = d['page']
- q = d['query']
-
- # re-serialise the query, and url encode it
- source = urllib.parse.quote(json.dumps(q))
-
- # assemble the DOAJ url
- doajurl = p + "?source=" + source
-
- # assemble the bitly url. Note that we re-encode the doajurl to include in the
- # query arguments, so by this point it is double-encoded
- bitly = app.config.get("BITLY_SHORTENING_API_URL")
- bitly_oauth = app.config.get("BITLY_OAUTH_TOKEN")
-
- # Set an Auth Bearer token (Bitly 4.0)
- headers = {'Authorization': 'Bearer ' + bitly_oauth}
-
- # Add the long url as a payload
- payload = {'long_url': doajurl}
-
- # make the request
- resp = requests.post(bitly, headers=headers, data=json.dumps(payload))
- shorturl = resp.json().get('link')
-
- if not shorturl:
- abort(400)
-
- # make the response
- answer = make_response(json.dumps({"url": shorturl}))
- answer.mimetype = "application/json"
- return answer
- except:
- abort(400)
+# @blueprint.route("/shorten", methods=["POST"])
+# @jsonp
+# def shorten():
+# # Enable this if you are testing and you want to see the front end work, without working bit.ly credentials
+# # return make_response(json.dumps({"url" : "testing url"}))
+# try:
+# # parse the json
+# d = json.loads(request.data)
+# p = d['page']
+# q = d['query']
+#
+# # re-serialise the query, and url encode it
+# source = urllib.parse.quote(json.dumps(q))
+#
+# # assemble the DOAJ url
+# doajurl = p + "?source=" + source
+#
+# # assemble the bitly url. Note that we re-encode the doajurl to include in the
+# # query arguments, so by this point it is double-encoded
+# bitly = app.config.get("BITLY_SHORTENING_API_URL")
+# bitly_oauth = app.config.get("BITLY_OAUTH_TOKEN")
+#
+# # Set an Auth Bearer token (Bitly 4.0)
+# headers = {'Authorization': 'Bearer ' + bitly_oauth}
+#
+# # Add the long url as a payload
+# payload = {'long_url': doajurl}
+#
+# # make the request
+# resp = requests.post(bitly, headers=headers, data=json.dumps(payload))
+# shorturl = resp.json().get('link')
+#
+# if not shorturl:
+# abort(400)
+#
+# # make the response
+# answer = make_response(json.dumps({"url": shorturl}))
+# answer.mimetype = "application/json"
+# return answer
+# except:
+# abort(400)
@blueprint.route("/groupstatus/", methods=["GET"])