From 224967c777b2c75bfb99584788fd974f48049f9e Mon Sep 17 00:00:00 2001 From: katepechekhonova Date: Mon, 20 Apr 2020 01:05:20 -0400 Subject: [PATCH 1/4] use topic not call number to form browse by category --- source/js/book.js | 112 ---------------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 source/js/book.js diff --git a/source/js/book.js b/source/js/book.js deleted file mode 100644 index 9b8d16c..0000000 --- a/source/js/book.js +++ /dev/null @@ -1,112 +0,0 @@ -YUI().use( - 'node', 'anim', 'crossframe', 'router', 'event-resize', 'querystring-parse', - function (Y) { - 'use strict'; - - var params = { 'lang' : 'en' }; - - if (window.location.search.length){ - params = Y.QueryString.parse(window.location.search.replace(/\?/i, '')) - } - - var body = Y.one('body'), - widget = Y.one('.widget.book'), - appRoot = body.getAttribute("data-appRoot"); - body.addClass('io-loading'); - function calculateAvailableHeight() { - var siblings = widget.siblings(), - viewport = Y.DOM.viewportRegion(), - availableHeight = viewport.height; - // Push the iframe down 5px to make up for the 5 pixels - // space created by the curved corners of the browser? - // Not elegant but to consider. - // availableHeight += 5; - siblings.each(function(node) { - availableHeight = availableHeight - node.get('offsetHeight'); - }); - if (body.hasClass('io-loading')) { - var loadingAnimation = Y.one('.bubblingG'), - loaderHeight = loadingAnimation.get('offsetHeight'); - availableHeight = availableHeight + loaderHeight; - } - return availableHeight; - } - function resizeBookView() { - widget.setStyles({ - height: calculateAvailableHeight() - }); - } - function hideSiblings() { - widget.siblings().each(function(node) { - node.addClass('hiddenSiblings'); - }); - resizeBookView(); - } - function showSiblings() { - widget.siblings().each(function(node) { - node.removeClass('hiddenSiblings'); - }); - resizeBookView(); - } - function requestReplaceLoadBook(request) { - var src = widget.getAttribute('data-sourceUrl'), - bookTheme = widget.getAttribute('data-bookTheme'), - identifier = request.params.identifier, - page = (request.params.page) ? request.params.page : 1; - widget.setAttribute('data-identifier', identifier); - if (request.src === 'replace') { - src = src + '/books/' + request.params.identifier + '/' + page + '?embed=1&lang=' + params.lang; - widget.set('src', src); - } - } - - var router = new Y.Router({ root: appRoot, routes: [{ path: '/book/:identifier/:page', callbacks: requestReplaceLoadBook }, { path: '/book/:identifier', callbacks: requestReplaceLoadBook }]}); - - Y.on('windowresize', resizeBookView); - - Y.on('button:button-fullscreen:on', hideSiblings); - - Y.on('button:button-fullscreen:off', showSiblings); - - Y.on('openlayers:change', function(data) { - router.save('/book/' + widget.getAttribute('data-identifier') + '/' + data.sequence); - }); - - Y.on('change:option:multivolume', function(data) { - var parts = data.url.split('/'); - if (parts[3]) { - var route = '/book/' + parts[3] + '/1'; - router.replace(route); - } - }); - - // DLTS Viewer fires a crossframe:message when the - // metadata pane in the book page is updated. We - // listen for this event and use it to update - // [HTML element] with the title of the book. - // [WCAG2.0AA compliance](https://www.w3.org/WAI/WCAG21/Understanding/page-titled.html) - Y.on('display:load', function(data) { - document.title = data.title + ': ' + Y.one('meta[property="og:site_name"]').get('content'); - }); - - Y.Global.on("crossframe:message", function(o, data) { - var message = JSON.parse(data.message); - Y.fire(message.fire, message.data); - }); - - widget.on('load', function() { - var anim = new Y.Anim({ - node: this, - to: { - opacity: 1 - }, - duration: 0.3 - }); - resizeBookView(); - anim.run(); - body.removeClass('io-loading'); - }); - resizeBookView(); - // initial request - router.replace(router.getPath()); -}); From bc04ad2622dc8b85f6d1826177d7fbae6d10816f Mon Sep 17 00:00:00 2001 From: katepechekhonova <ekate@nyu.edu> Date: Mon, 20 Apr 2020 02:56:57 -0400 Subject: [PATCH 2/4] Modifications for curl and browsebycategory --- source/json/curl.js | 4 ++-- source/json/pages/browsebycategory.js | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/json/curl.js b/source/json/curl.js index 49c75a5..5cc09b5 100644 --- a/source/json/curl.js +++ b/source/json/curl.js @@ -16,11 +16,11 @@ module.exports = exports = { "dest" : "source/json/datasources/subjectCount.json" }, "categoryQueryEn" : { - "src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&q=sm_collection_code:aco&fq=sm_topic:*&facet=true&rows=0&facet.query=%7B!key=%22General%20Works%22%7Dss_call_number:A*&facet.query=%7B!key=%22Philosophy.%20Psychology.%20Religion%22%7Dss_call_number:B*&facet.query=%7B!key=%22Auxiliary%20Sciences%20of%20History%22%7Dss_call_number:C*&facet.query=%7B!key=%22World%20History%20and%20History%20of%20Europe,%20Asia,%20Africa,%20Australia,%20New%20Zealand,%20etc..%22%7Dss_call_number:D*&facet.query=%7B!key=%22History%20of%20the%20Americas%22%7Dss_call_number:(E*%20OR%20F*)&facet.query=%7B!key=%22Geography.%20Anthropology.%20Recreation%22%7Dss_call_number:G*&facet.query=%7B!key=%22Social%20Sciences%22%7Dss_call_number:H*&facet.query=%7B!key=%22Political%20Science%22%7Dss_call_number:J*&facet.query=%7B!key=%22Law%22%7Dss_call_number:K*&facet.query=%7B!key=%22Education%22%7Dss_call_number:L*&facet.query=%7B!key=%22Music%20and%20Books%20on%20Music%22%7Dss_call_number:M*&facet.query=%7B!key=%22Fine%20Arts%22%7Dss_call_number:N*&facet.query=%7B!key=%22Language%20and%20Literature%22%7Dss_call_number:P*&facet.query=%7B!key=%22Science%22%7Dss_call_number:Q*&facet.query=%7B!key=%22Medicine%22%7Dss_call_number:R*&facet.query=%7B!key=%22Agriculture%22%7Dss_call_number:S*&facet.query=%7B!key=%22Technology%22%7Dss_call_number:T*&facet.query=%7B!key=%22Military%20Science%22%7Dss_call_number:U*&facet.query=%7B!key=%22Naval%20Science%22%7Dss_call_number:V*&facet.query=%7B!key=%22Bibliography.%20Library%20Science,%20Information%20Resources%20(General)%22%7Dss_call_number:Z*`, + "src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&q=sm_collection_code:aco&fq=sm_topic:*&facet=true&rows=0&facet.field=sm_topic`, "dest" : "source/json/datasources/categoryQueryEn.json" }, "categoryQueryAr" : { - "src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&wt=json&json.nl=arrmap&q=sm_ar_topic:*&facet=true&rows=0&facet.query=%7B!key=%22%D8%A7%D9%84%D9%85%D8%B9%D8%A7%D8%B1%D9%81%20%D8%A7%D9%84%D8%B9%D8%A7%D9%85%D8%A9%22%7Dss_call_number:A*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%81%D9%84%D8%B3%D9%81%D8%A9%20%D9%88%D8%B9%D9%84%D9%85%20%D8%A7%D9%84%D9%86%D9%81%D8%B3%20%D9%88%D8%A7%D9%84%D8%AF%D9%8A%D9%86%22%7Dss_call_number:B*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D9%81%D8%B1%D8%B9%D9%8A%D8%A9%20%D9%84%D9%84%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%22%7Dss_call_number:C*&facet.query=%7B!key=%22%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%20%D8%A7%D9%84%D8%B9%D8%A7%D9%84%D9%85%20%D9%88%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%20%D8%A3%D9%88%D8%B1%D9%88%D8%A8%D8%A7%20%D9%88%D8%A2%D8%B3%D9%8A%D8%A7%20%D9%88%D8%A3%D9%81%D8%B1%D9%8A%D9%82%D9%8A%D8%A7%22%7Dss_call_number:D*&facet.query=%7B!key=%22%D8%AA%D8%A7%D8%B1%D9%8A%D8%AE%20%D8%A3%D9%85%D8%B1%D9%8A%D9%83%D8%A7%22%7Dss_call_number:(E*%20OR%20F*)&facet.query=%7B!key=%22%D8%A7%D9%84%D8%AC%D8%BA%D8%B1%D8%A7%D9%81%D9%8A%D8%A7%20%D9%88%D8%A7%D9%84%D8%A3%D9%86%D8%AB%D8%B1%D8%A8%D9%88%D9%84%D9%88%D8%AC%D9%8A%D8%A7%20%D9%88%D8%A7%D9%84%D8%AA%D8%B1%D9%81%D9%8A%D9%87%22%7Dss_call_number:G*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%A7%D8%AC%D8%AA%D9%85%D8%A7%D8%B9%D9%8A%D8%A9%22%7Dss_call_number:H*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%B3%D9%8A%D8%A7%D8%B3%D9%8A%D8%A9%22%7Dss_call_number:J*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%82%D8%A7%D9%86%D9%88%D9%86%22%7Dss_call_number:K*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%AA%D8%B9%D9%84%D9%8A%D9%85%22%7Dss_call_number:L*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%85%D9%88%D8%B3%D9%8A%D9%82%D9%89%22%7Dss_call_number:M*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%81%D9%86%D9%88%D9%86%20%D8%A7%D9%84%D8%AC%D9%85%D9%8A%D9%84%D8%A9%22%7Dss_call_number:N*&facet.query=%7B!key=%22%D8%A7%D9%84%D9%84%D8%BA%D8%A7%D8%AA%20%D9%88%D8%A7%D9%84%D8%A2%D8%AF%D8%A7%D8%A8%22%7Dss_call_number:P*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%22%7Dss_call_number:Q*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B7%D8%A8%22%7Dss_call_number:R*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B2%D8%B1%D8%A7%D8%B9%D8%A9%22%7Dss_call_number:S*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%AA%D9%83%D9%86%D9%88%D9%84%D9%88%D8%AC%D9%8A%D8%A7%22%7Dss_call_number:T*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%B9%D8%B3%D9%83%D8%B1%D9%8A%D8%A9%22%7Dss_call_number:U*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D8%A8%D8%AD%D8%B1%D9%8A%D8%A9%22%7Dss_call_number:V*&facet.query=%7B!key=%22%D8%A7%D9%84%D8%A8%D8%A8%D9%84%D9%8A%D9%88%D8%BA%D8%B1%D8%A7%D9%81%D9%8A%D8%A7%20%D8%8C%20%D9%88%D8%B9%D9%84%D9%88%D9%85%20%D8%A7%D9%84%D9%85%D9%83%D8%AA%D8%A8%D8%A7%D8%AA%20%D8%8C%20%D9%88%D8%A7%D9%84%D9%85%D8%B9%D9%84%D9%88%D9%85%D8%A7%D8%AA%20%D8%A7%D9%84%D8%B9%D8%A7%D9%85%D8%A9%22%7Dss_call_number:Z*`, + "src" : `${discoveryCore}/select?wt=json&json.nl=arrmap&q=sm_collection_code:aco&fq=sm_ar_topic:*&facet=true&rows=0&facet.field=sm_ar_topic`, "dest" : "source/json/datasources/categoryQueryAr.json" } } diff --git a/source/json/pages/browsebycategory.js b/source/json/pages/browsebycategory.js index 31e2aa8..45a6b14 100644 --- a/source/json/pages/browsebycategory.js +++ b/source/json/pages/browsebycategory.js @@ -48,13 +48,16 @@ module.exports = async function browsebycategory () { if (grunt.file.isFile(datasourcesFilepath)) { const data = await grunt.file.readJSON(datasourcesFilepath); // Get Object keys and organize the data in a more meaningful way - return Object.keys(data.facet_counts.facet_queries).map(category => { + var fd = ( language === 'En') ? Object.values(data.facet_counts.facet_fields.sm_topic) : Object.values(data.facet_counts.facet_fields.sm_ar_topic); + console.log(fd); + + return fd.map(category => { return { - category: category, + category: Object.keys(category), // build link - uri: encodeURI(`${appUrl}/search?category=${category}&scope=matches`), + uri: encodeURI(`${appUrl}/search?category=${Object.keys(category)}&scope=matches`), // format count number e.g., 1,000 instead of 1000. - count: toNumberWithCommas(data.facet_counts.facet_queries[category]), + count: toNumberWithCommas(Object.values(category)), // label (en/ar) used to prefix the books count prefixLabel: prefixLabel[language], }; @@ -62,6 +65,7 @@ module.exports = async function browsebycategory () { } } catch (error) { + console.log("here 1"); grunt.fail.warn(error); } } @@ -69,8 +73,10 @@ module.exports = async function browsebycategory () { try { const frontCount = await frontCountFromCache(); let categoriesEn = await categoriesFromCache('En'); + //console.log(categoriesEn); categoriesEn.unshift({ category: 'All', count: frontCount, uri: `${appUrl}/browse`}); let categoriesAr = await categoriesFromCache('Ar'); + console.log(categoriesAr); categoriesAr.unshift({ category: 'الجميع', count: frontCount, uri: `${appUrl}/browse`}); return { From 70c552e3a8adaed3e188bc17985f5954d275eee1 Mon Sep 17 00:00:00 2001 From: katepechekhonova <ekate@nyu.edu> Date: Mon, 20 Apr 2020 03:14:22 -0400 Subject: [PATCH 3/4] fixed error with book.js --- source/js/book.js | 112 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 source/js/book.js diff --git a/source/js/book.js b/source/js/book.js new file mode 100644 index 0000000..9b8d16c --- /dev/null +++ b/source/js/book.js @@ -0,0 +1,112 @@ +YUI().use( + 'node', 'anim', 'crossframe', 'router', 'event-resize', 'querystring-parse', + function (Y) { + 'use strict'; + + var params = { 'lang' : 'en' }; + + if (window.location.search.length){ + params = Y.QueryString.parse(window.location.search.replace(/\?/i, '')) + } + + var body = Y.one('body'), + widget = Y.one('.widget.book'), + appRoot = body.getAttribute("data-appRoot"); + body.addClass('io-loading'); + function calculateAvailableHeight() { + var siblings = widget.siblings(), + viewport = Y.DOM.viewportRegion(), + availableHeight = viewport.height; + // Push the iframe down 5px to make up for the 5 pixels + // space created by the curved corners of the browser? + // Not elegant but to consider. + // availableHeight += 5; + siblings.each(function(node) { + availableHeight = availableHeight - node.get('offsetHeight'); + }); + if (body.hasClass('io-loading')) { + var loadingAnimation = Y.one('.bubblingG'), + loaderHeight = loadingAnimation.get('offsetHeight'); + availableHeight = availableHeight + loaderHeight; + } + return availableHeight; + } + function resizeBookView() { + widget.setStyles({ + height: calculateAvailableHeight() + }); + } + function hideSiblings() { + widget.siblings().each(function(node) { + node.addClass('hiddenSiblings'); + }); + resizeBookView(); + } + function showSiblings() { + widget.siblings().each(function(node) { + node.removeClass('hiddenSiblings'); + }); + resizeBookView(); + } + function requestReplaceLoadBook(request) { + var src = widget.getAttribute('data-sourceUrl'), + bookTheme = widget.getAttribute('data-bookTheme'), + identifier = request.params.identifier, + page = (request.params.page) ? request.params.page : 1; + widget.setAttribute('data-identifier', identifier); + if (request.src === 'replace') { + src = src + '/books/' + request.params.identifier + '/' + page + '?embed=1&lang=' + params.lang; + widget.set('src', src); + } + } + + var router = new Y.Router({ root: appRoot, routes: [{ path: '/book/:identifier/:page', callbacks: requestReplaceLoadBook }, { path: '/book/:identifier', callbacks: requestReplaceLoadBook }]}); + + Y.on('windowresize', resizeBookView); + + Y.on('button:button-fullscreen:on', hideSiblings); + + Y.on('button:button-fullscreen:off', showSiblings); + + Y.on('openlayers:change', function(data) { + router.save('/book/' + widget.getAttribute('data-identifier') + '/' + data.sequence); + }); + + Y.on('change:option:multivolume', function(data) { + var parts = data.url.split('/'); + if (parts[3]) { + var route = '/book/' + parts[3] + '/1'; + router.replace(route); + } + }); + + // DLTS Viewer fires a crossframe:message when the + // metadata pane in the book page is updated. We + // listen for this event and use it to update + // <title> [HTML element] with the title of the book. + // [WCAG2.0AA compliance](https://www.w3.org/WAI/WCAG21/Understanding/page-titled.html) + Y.on('display:load', function(data) { + document.title = data.title + ': ' + Y.one('meta[property="og:site_name"]').get('content'); + }); + + Y.Global.on("crossframe:message", function(o, data) { + var message = JSON.parse(data.message); + Y.fire(message.fire, message.data); + }); + + widget.on('load', function() { + var anim = new Y.Anim({ + node: this, + to: { + opacity: 1 + }, + duration: 0.3 + }); + resizeBookView(); + anim.run(); + body.removeClass('io-loading'); + }); + resizeBookView(); + // initial request + router.replace(router.getPath()); +}); From d73e95d457c64b07b91be140d3d769b10326cf64 Mon Sep 17 00:00:00 2001 From: katepechekhonova <ekate@nyu.edu> Date: Wed, 29 Apr 2020 10:20:10 -0400 Subject: [PATCH 4/4] Added comment to browsebycatgory.js --- source/json/pages/browsebycategory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/json/pages/browsebycategory.js b/source/json/pages/browsebycategory.js index 45a6b14..a14d3da 100644 --- a/source/json/pages/browsebycategory.js +++ b/source/json/pages/browsebycategory.js @@ -47,7 +47,7 @@ module.exports = async function browsebycategory () { // check if datasource file exists if (grunt.file.isFile(datasourcesFilepath)) { const data = await grunt.file.readJSON(datasourcesFilepath); - // Get Object keys and organize the data in a more meaningful way + // Get Object keys and organize the data in a more meaningful way. TODO: add checks for malformed response var fd = ( language === 'En') ? Object.values(data.facet_counts.facet_fields.sm_topic) : Object.values(data.facet_counts.facet_fields.sm_ar_topic); console.log(fd);