@mjhls/mjh-framework 1.0.893-ris-v1 → 1.0.893-ris-v2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/View.js CHANGED
@@ -29,13 +29,13 @@ var styleInject_es = require('./style-inject.es-dcee06b6.js');
29
29
  require('./index-eadd5035.js');
30
30
  var disqusReact = require('disqus-react');
31
31
  var Schema = require('./Schema.js');
32
+ var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
32
33
  var keys = require('./keys-e982b3fa.js');
33
34
  var index_es = require('./index.es-f3e47207.js');
34
35
  var index = require('./index-fc2f1ca2.js');
35
36
  var getRelatedArticle = require('./getRelatedArticle.js');
36
37
  var getQuery = require('./getQuery.js');
37
38
  var getSeriesDetail = require('./getSeriesDetail.js');
38
- require('./_commonjsHelpers-06173234.js');
39
39
  require('./core.get-iterator-method-5643aa10.js');
40
40
  require('./web.dom.iterable-d98303e0.js');
41
41
  require('./_library-dd23b178.js');
@@ -446,6 +446,12 @@ var getSocialShareDisableFlag = function getSocialShareDisableFlag(article) {
446
446
  return showSocialShare;
447
447
  };
448
448
 
449
+ var FileSaver_min = _commonjsHelpers.createCommonjsModule(function (module, exports) {
450
+ (function(a,b){b();})(_commonjsHelpers.commonjsGlobal,function(){function b(a,b){return "undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c);},d.onerror=function(){console.error("could not download file");},d.send();}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send();}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"));}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b);}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof _commonjsHelpers.commonjsGlobal&&_commonjsHelpers.commonjsGlobal.global===_commonjsHelpers.commonjsGlobal?_commonjsHelpers.commonjsGlobal:void 0,a=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href);},4E4),setTimeout(function(){e(j);},0));}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else {var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i);});}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null;},k.readAsDataURL(b);}else {var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m);},4E4);}});f.saveAs=g.saveAs=g,(module.exports=g);});
451
+
452
+
453
+ });
454
+
449
455
  var Article = React.forwardRef(function (props, ref) {
450
456
  var onVote = function () {
451
457
  var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee(nodeKey, selectedChoice) {
@@ -652,26 +658,44 @@ var Article = React.forwardRef(function (props, ref) {
652
658
  }
653
659
  return null;
654
660
  };
655
- var downloadRIS = function downloadRIS(filename) {
661
+ var generateRIS = function generateRIS() {
656
662
  var fileContent = 'TY - JOUR\n';
663
+ if (article.title) fileContent += 'TI - ' + article.title + '\n'; //Title - TI
664
+ if (article.summary) fileContent += 'N2 - ' + article.summary + '\n'; //Abstract - N2
657
665
  if (issue) {
658
- if (issue.year) fileContent += 'PY - ' + issue.year + '\n';
659
- if (issue.month) {
660
- fileContent += 'DA - ' + moment.moment().month(issue.month).format('MMMM') + '\n';
666
+ if (issue.number) fileContent += 'IS - ' + issue.number + '\n'; //Issue Number - IS
667
+ if (issue.publication && issue.publication.name) {
668
+ fileContent += 'JF - ' + issue.publication.name + '\n'; //Journal Name - JF
669
+ fileContent += 'JO - ' + issue.publication.name + '\n'; //Journal Name - JO
670
+ fileContent += 'T2 - ' + issue.publication.name + '\n'; //Secondary Title - T2
671
+ }
672
+ fileContent += 'PB - MJH Life Sciences\n'; //Publisher - PB
673
+ if (issue.year) fileContent += 'PY - ' + issue.year + '\n'; //Published Year - PY
674
+ if (issue.volume) fileContent += 'VL - ' + issue.volume + '\n'; //Volume - VL
675
+ if (issue.url) fileContent += 'L1 - ' + issue.url + '\n'; //Link to PDF - L1
676
+ }
677
+ if (pageNumber) {
678
+ if (pageNumber.includes('-')) {
679
+ fileContent += 'SP - ' + pageNumber.split('-')[0] + '\n'; //Start Page - SP
680
+ fileContent += 'EP - ' + pageNumber.split('-')[1] + '\n'; //End Page - EP
681
+ } else {
682
+ fileContent += 'SP - ' + pageNumber + '\n';
661
683
  }
662
- if (issue.publication && issue.publication.name) fileContent += 'TI - ' + issue.publication.name + '\n';
663
- if (issue.name) fileContent += 'T2 - ' + issue.name + '\n';
664
- if (issue.volume) fileContent += 'IS - ' + issue.volume + '\n';
665
- if (issue.number) fileContent += 'IS - ' + issue.number + '\n';
666
684
  }
667
- fileContent += 'ER -';
668
- var element = document.createElement('a');
669
- element.setAttribute('href', 'data:application/x-research-info-systems;charset=utf-8,' + encodeURIComponent(fileContent));
670
- element.setAttribute('download', filename);
671
- element.style.display = 'none';
672
- document.body.appendChild(element);
673
- element.click();
674
- document.body.removeChild(element);
685
+ if (shareOptions && shareOptions.shareBaseUrl) {
686
+ fileContent += 'L2 - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Link to Full-text - L2
687
+ fileContent += 'UR - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Doc URL - UR
688
+ }
689
+ if (props.Website) fileContent += 'LK - https://' + props.Website.liveDomain + '\n'; //Website Link - LK
690
+ if (article.published) fileContent += 'Y1 - ' + moment.moment(published).format('DD-MMMM-YYYY') + '\n'; //Primary Date - Y1
691
+ fileContent += 'Y2 - ' + moment.moment().format('DD-MMMM-YYYY') + '\n'; //Access Date - Y2
692
+ fileContent += 'ER -\n'; //End of Record
693
+ return fileContent;
694
+ };
695
+ var downloadRIS = function downloadRIS() {
696
+ var fileContent = generateRIS();
697
+ var file = new File([fileContent], 'citation-' + url + '.ris', { type: 'application/x-research-info-systems;charset=utf-8' });
698
+ FileSaver_min.saveAs(file, 'citation-' + url + '.ris');
675
699
  };
676
700
 
677
701
  var RelevantTopics = function RelevantTopics() {
@@ -1016,7 +1040,7 @@ var Article = React.forwardRef(function (props, ref) {
1016
1040
  var shareTitle = article.title;
1017
1041
  var shareSummary = article.summary;
1018
1042
  var shareImage = thumbnail && thumbnail.asset ? urlFor({ client: props.client, source: thumbnail.asset }) : shareImageDefault;
1019
- var siteName = props.website && props.website.title ? props.website.title : '';
1043
+ var siteName = props.Website && props.Website.title ? props.Website.title : '';
1020
1044
  var shareKeywords = getKeywords(props.article).join(',');
1021
1045
 
1022
1046
  var meta = {
@@ -1270,10 +1294,10 @@ var Article = React.forwardRef(function (props, ref) {
1270
1294
  'Download Issue : ',
1271
1295
  issue.name
1272
1296
  ),
1273
- React__default['default'].createElement(
1297
+ issue && React__default['default'].createElement(
1274
1298
  Button__default['default'],
1275
- { onClick: function onClick(req) {
1276
- return downloadRIS('citation-' + url + '.ris');
1299
+ { onClick: function onClick() {
1300
+ return downloadRIS();
1277
1301
  } },
1278
1302
  'Download RIS'
1279
1303
  )
package/dist/esm/View.js CHANGED
@@ -27,13 +27,13 @@ import { s as styleInject } from './style-inject.es-1f59c1d0.js';
27
27
  import './index-755f2cc2.js';
28
28
  import { DiscussionEmbed } from 'disqus-react';
29
29
  import Schema from './Schema.js';
30
+ import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers-0c4b6f40.js';
30
31
  import { _ as _Object$keys } from './keys-31dcdb31.js';
31
32
  import { I as InfiniteScroll } from './index.es-a6137319.js';
32
33
  import { l as lib_3 } from './index-f0fc23eb.js';
33
34
  import getRelatedArticle from './getRelatedArticle.js';
34
35
  import getQuery from './getQuery.js';
35
36
  import getSeriesDetail from './getSeriesDetail.js';
36
- import './_commonjsHelpers-0c4b6f40.js';
37
37
  import './core.get-iterator-method-ea258bb1.js';
38
38
  import './web.dom.iterable-ab4dea5c.js';
39
39
  import './_library-528f1934.js';
@@ -436,6 +436,12 @@ var getSocialShareDisableFlag = function getSocialShareDisableFlag(article) {
436
436
  return showSocialShare;
437
437
  };
438
438
 
439
+ var FileSaver_min = createCommonjsModule(function (module, exports) {
440
+ (function(a,b){b();})(commonjsGlobal,function(){function b(a,b){return "undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c);},d.onerror=function(){console.error("could not download file");},d.send();}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send();}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"));}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b);}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof commonjsGlobal&&commonjsGlobal.global===commonjsGlobal?commonjsGlobal:void 0,a=f.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href);},4E4),setTimeout(function(){e(j);},0));}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else {var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i);});}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null;},k.readAsDataURL(b);}else {var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m);},4E4);}});f.saveAs=g.saveAs=g,(module.exports=g);});
441
+
442
+
443
+ });
444
+
439
445
  var Article = forwardRef(function (props, ref) {
440
446
  var onVote = function () {
441
447
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(nodeKey, selectedChoice) {
@@ -642,26 +648,44 @@ var Article = forwardRef(function (props, ref) {
642
648
  }
643
649
  return null;
644
650
  };
645
- var downloadRIS = function downloadRIS(filename) {
651
+ var generateRIS = function generateRIS() {
646
652
  var fileContent = 'TY - JOUR\n';
653
+ if (article.title) fileContent += 'TI - ' + article.title + '\n'; //Title - TI
654
+ if (article.summary) fileContent += 'N2 - ' + article.summary + '\n'; //Abstract - N2
647
655
  if (issue) {
648
- if (issue.year) fileContent += 'PY - ' + issue.year + '\n';
649
- if (issue.month) {
650
- fileContent += 'DA - ' + moment().month(issue.month).format('MMMM') + '\n';
656
+ if (issue.number) fileContent += 'IS - ' + issue.number + '\n'; //Issue Number - IS
657
+ if (issue.publication && issue.publication.name) {
658
+ fileContent += 'JF - ' + issue.publication.name + '\n'; //Journal Name - JF
659
+ fileContent += 'JO - ' + issue.publication.name + '\n'; //Journal Name - JO
660
+ fileContent += 'T2 - ' + issue.publication.name + '\n'; //Secondary Title - T2
661
+ }
662
+ fileContent += 'PB - MJH Life Sciences\n'; //Publisher - PB
663
+ if (issue.year) fileContent += 'PY - ' + issue.year + '\n'; //Published Year - PY
664
+ if (issue.volume) fileContent += 'VL - ' + issue.volume + '\n'; //Volume - VL
665
+ if (issue.url) fileContent += 'L1 - ' + issue.url + '\n'; //Link to PDF - L1
666
+ }
667
+ if (pageNumber) {
668
+ if (pageNumber.includes('-')) {
669
+ fileContent += 'SP - ' + pageNumber.split('-')[0] + '\n'; //Start Page - SP
670
+ fileContent += 'EP - ' + pageNumber.split('-')[1] + '\n'; //End Page - EP
671
+ } else {
672
+ fileContent += 'SP - ' + pageNumber + '\n';
651
673
  }
652
- if (issue.publication && issue.publication.name) fileContent += 'TI - ' + issue.publication.name + '\n';
653
- if (issue.name) fileContent += 'T2 - ' + issue.name + '\n';
654
- if (issue.volume) fileContent += 'IS - ' + issue.volume + '\n';
655
- if (issue.number) fileContent += 'IS - ' + issue.number + '\n';
656
674
  }
657
- fileContent += 'ER -';
658
- var element = document.createElement('a');
659
- element.setAttribute('href', 'data:application/x-research-info-systems;charset=utf-8,' + encodeURIComponent(fileContent));
660
- element.setAttribute('download', filename);
661
- element.style.display = 'none';
662
- document.body.appendChild(element);
663
- element.click();
664
- document.body.removeChild(element);
675
+ if (shareOptions && shareOptions.shareBaseUrl) {
676
+ fileContent += 'L2 - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Link to Full-text - L2
677
+ fileContent += 'UR - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Doc URL - UR
678
+ }
679
+ if (props.Website) fileContent += 'LK - https://' + props.Website.liveDomain + '\n'; //Website Link - LK
680
+ if (article.published) fileContent += 'Y1 - ' + moment(published).format('DD-MMMM-YYYY') + '\n'; //Primary Date - Y1
681
+ fileContent += 'Y2 - ' + moment().format('DD-MMMM-YYYY') + '\n'; //Access Date - Y2
682
+ fileContent += 'ER -\n'; //End of Record
683
+ return fileContent;
684
+ };
685
+ var downloadRIS = function downloadRIS() {
686
+ var fileContent = generateRIS();
687
+ var file = new File([fileContent], 'citation-' + url + '.ris', { type: 'application/x-research-info-systems;charset=utf-8' });
688
+ FileSaver_min.saveAs(file, 'citation-' + url + '.ris');
665
689
  };
666
690
 
667
691
  var RelevantTopics = function RelevantTopics() {
@@ -1006,7 +1030,7 @@ var Article = forwardRef(function (props, ref) {
1006
1030
  var shareTitle = article.title;
1007
1031
  var shareSummary = article.summary;
1008
1032
  var shareImage = thumbnail && thumbnail.asset ? urlFor({ client: props.client, source: thumbnail.asset }) : shareImageDefault;
1009
- var siteName = props.website && props.website.title ? props.website.title : '';
1033
+ var siteName = props.Website && props.Website.title ? props.Website.title : '';
1010
1034
  var shareKeywords = getKeywords(props.article).join(',');
1011
1035
 
1012
1036
  var meta = {
@@ -1260,10 +1284,10 @@ var Article = forwardRef(function (props, ref) {
1260
1284
  'Download Issue : ',
1261
1285
  issue.name
1262
1286
  ),
1263
- React__default.createElement(
1287
+ issue && React__default.createElement(
1264
1288
  Button,
1265
- { onClick: function onClick(req) {
1266
- return downloadRIS('citation-' + url + '.ris');
1289
+ { onClick: function onClick() {
1290
+ return downloadRIS();
1267
1291
  } },
1268
1292
  'Download RIS'
1269
1293
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.893-ris-v1",
3
+ "version": "1.0.893-ris-v2",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",
@@ -56,6 +56,7 @@
56
56
  "eslint-plugin-react": "^7.10.0",
57
57
  "eslint-plugin-react-hooks": "^2.3.0",
58
58
  "eslint-plugin-standard": "^3.1.0",
59
+ "file-saver": "^2.0.5",
59
60
  "get-youtube-id": "^1.0.1",
60
61
  "gh-pages": "^1.2.0",
61
62
  "lodash": "^4.17.15",