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

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,45 @@ 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() {
662
+ console.log(props);
656
663
  var fileContent = 'TY - JOUR\n';
664
+ if (article.title) fileContent += 'TI - ' + article.title + '\n'; //Title - TI
665
+ if (article.summary) fileContent += 'N2 - ' + article.summary + '\n'; //Abstract - N2
657
666
  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';
667
+ if (issue.issueNumber) fileContent += 'IS - ' + issue.issueNumber + '\n'; //Issue Number - IS
668
+ if (issue.publication && issue.publication.name) {
669
+ fileContent += 'JF - ' + issue.publication.name + '\n'; //Journal Name - JF
670
+ fileContent += 'JO - ' + issue.publication.name + '\n'; //Journal Name - JO
671
+ fileContent += 'T2 - ' + issue.publication.name + '\n'; //Secondary Title - T2
672
+ }
673
+ fileContent += 'PB - MJH Life Sciences\n'; //Publisher - PB
674
+ if (issue.year) fileContent += 'PY - ' + issue.year + '\n'; //Published Year - PY
675
+ if (issue.volume) fileContent += 'VL - ' + issue.volume + '\n'; //Volume - VL
676
+ if (issue.url) fileContent += 'L1 - ' + issue.url + '\n'; //Link to PDF - L1
677
+ }
678
+ if (pageNumber) {
679
+ if (pageNumber.includes('-')) {
680
+ fileContent += 'SP - ' + pageNumber.split('-')[0] + '\n'; //Start Page - SP
681
+ fileContent += 'EP - ' + pageNumber.split('-')[1] + '\n'; //End Page - EP
682
+ } else {
683
+ fileContent += 'SP - ' + pageNumber + '\n';
661
684
  }
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
685
  }
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);
686
+ if (shareOptions && shareOptions.shareBaseUrl) {
687
+ fileContent += 'L2 - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Link to Full-text - L2
688
+ fileContent += 'UR - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Doc URL - UR
689
+ }
690
+ if (props.Website) fileContent += 'LK - https://' + props.Website.liveDomain + '\n'; //Website Link - LK
691
+ if (article.published) fileContent += 'Y1 - ' + moment.moment(published).format('DD-MMMM-YYYY') + '\n'; //Primary Date - Y1
692
+ fileContent += 'Y2 - ' + moment.moment().format('DD-MMMM-YYYY') + '\n'; //Access Date - Y2
693
+ fileContent += 'ER -\n'; //End of Record
694
+ return fileContent;
695
+ };
696
+ var downloadRIS = function downloadRIS() {
697
+ var fileContent = generateRIS();
698
+ var file = new File([fileContent], 'citation-' + url + '.ris', { type: 'application/x-research-info-systems;charset=utf-8' });
699
+ FileSaver_min.saveAs(file, 'citation-' + url + '.ris');
675
700
  };
676
701
 
677
702
  var RelevantTopics = function RelevantTopics() {
@@ -1016,7 +1041,7 @@ var Article = React.forwardRef(function (props, ref) {
1016
1041
  var shareTitle = article.title;
1017
1042
  var shareSummary = article.summary;
1018
1043
  var shareImage = thumbnail && thumbnail.asset ? urlFor({ client: props.client, source: thumbnail.asset }) : shareImageDefault;
1019
- var siteName = props.website && props.website.title ? props.website.title : '';
1044
+ var siteName = props.Website && props.Website.title ? props.Website.title : '';
1020
1045
  var shareKeywords = getKeywords(props.article).join(',');
1021
1046
 
1022
1047
  var meta = {
@@ -1270,10 +1295,10 @@ var Article = React.forwardRef(function (props, ref) {
1270
1295
  'Download Issue : ',
1271
1296
  issue.name
1272
1297
  ),
1273
- React__default['default'].createElement(
1298
+ issue && React__default['default'].createElement(
1274
1299
  Button__default['default'],
1275
- { onClick: function onClick(req) {
1276
- return downloadRIS('citation-' + url + '.ris');
1300
+ { onClick: function onClick() {
1301
+ return downloadRIS();
1277
1302
  } },
1278
1303
  'Download RIS'
1279
1304
  )
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,45 @@ 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() {
652
+ console.log(props);
646
653
  var fileContent = 'TY - JOUR\n';
654
+ if (article.title) fileContent += 'TI - ' + article.title + '\n'; //Title - TI
655
+ if (article.summary) fileContent += 'N2 - ' + article.summary + '\n'; //Abstract - N2
647
656
  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';
657
+ if (issue.issueNumber) fileContent += 'IS - ' + issue.issueNumber + '\n'; //Issue Number - IS
658
+ if (issue.publication && issue.publication.name) {
659
+ fileContent += 'JF - ' + issue.publication.name + '\n'; //Journal Name - JF
660
+ fileContent += 'JO - ' + issue.publication.name + '\n'; //Journal Name - JO
661
+ fileContent += 'T2 - ' + issue.publication.name + '\n'; //Secondary Title - T2
662
+ }
663
+ fileContent += 'PB - MJH Life Sciences\n'; //Publisher - PB
664
+ if (issue.year) fileContent += 'PY - ' + issue.year + '\n'; //Published Year - PY
665
+ if (issue.volume) fileContent += 'VL - ' + issue.volume + '\n'; //Volume - VL
666
+ if (issue.url) fileContent += 'L1 - ' + issue.url + '\n'; //Link to PDF - L1
667
+ }
668
+ if (pageNumber) {
669
+ if (pageNumber.includes('-')) {
670
+ fileContent += 'SP - ' + pageNumber.split('-')[0] + '\n'; //Start Page - SP
671
+ fileContent += 'EP - ' + pageNumber.split('-')[1] + '\n'; //End Page - EP
672
+ } else {
673
+ fileContent += 'SP - ' + pageNumber + '\n';
651
674
  }
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
675
  }
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);
676
+ if (shareOptions && shareOptions.shareBaseUrl) {
677
+ fileContent += 'L2 - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Link to Full-text - L2
678
+ fileContent += 'UR - ' + (shareOptions.shareBaseUrl + url) + '\n'; //Doc URL - UR
679
+ }
680
+ if (props.Website) fileContent += 'LK - https://' + props.Website.liveDomain + '\n'; //Website Link - LK
681
+ if (article.published) fileContent += 'Y1 - ' + moment(published).format('DD-MMMM-YYYY') + '\n'; //Primary Date - Y1
682
+ fileContent += 'Y2 - ' + moment().format('DD-MMMM-YYYY') + '\n'; //Access Date - Y2
683
+ fileContent += 'ER -\n'; //End of Record
684
+ return fileContent;
685
+ };
686
+ var downloadRIS = function downloadRIS() {
687
+ var fileContent = generateRIS();
688
+ var file = new File([fileContent], 'citation-' + url + '.ris', { type: 'application/x-research-info-systems;charset=utf-8' });
689
+ FileSaver_min.saveAs(file, 'citation-' + url + '.ris');
665
690
  };
666
691
 
667
692
  var RelevantTopics = function RelevantTopics() {
@@ -1006,7 +1031,7 @@ var Article = forwardRef(function (props, ref) {
1006
1031
  var shareTitle = article.title;
1007
1032
  var shareSummary = article.summary;
1008
1033
  var shareImage = thumbnail && thumbnail.asset ? urlFor({ client: props.client, source: thumbnail.asset }) : shareImageDefault;
1009
- var siteName = props.website && props.website.title ? props.website.title : '';
1034
+ var siteName = props.Website && props.Website.title ? props.Website.title : '';
1010
1035
  var shareKeywords = getKeywords(props.article).join(',');
1011
1036
 
1012
1037
  var meta = {
@@ -1260,10 +1285,10 @@ var Article = forwardRef(function (props, ref) {
1260
1285
  'Download Issue : ',
1261
1286
  issue.name
1262
1287
  ),
1263
- React__default.createElement(
1288
+ issue && React__default.createElement(
1264
1289
  Button,
1265
- { onClick: function onClick(req) {
1266
- return downloadRIS('citation-' + url + '.ris');
1290
+ { onClick: function onClick() {
1291
+ return downloadRIS();
1267
1292
  } },
1268
1293
  'Download RIS'
1269
1294
  )
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-v3",
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",