Skip to content

Commit

Permalink
Fixes #2313 Update Citation Style Configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
tadean committed Mar 30, 2023
1 parent 6e5c21d commit 1bcd62f
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 16 deletions.
8 changes: 3 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
],
"require": {
"php": ">=7.4",
"academicpuma/locales": "1.0.0",
"az-digital/arizona-bootstrap": "2.0.23",
"bower-asset/bootstrap-datepicker": "1.9.0",
"bower-asset/chosen": "1.8.7",
"citation-style-language/locales": "0.0.5",
"citation-style-language/styles": "0.0.199",
"composer/installers": "^1.9",
"cweagans/composer-patches": "^1.7",
"drupal/access_unpublished": "1.5.0",
Expand Down Expand Up @@ -113,7 +114,7 @@
"npm-asset/blazy": "1.8.2",
"npm-asset/jquery-ui-touch-punch": "0.2.3",
"npm-asset/slick-carousel": "1.8.0",
"seboettg/citeproc-php": "2.5.1"
"seboettg/citeproc-php": "2.6.0"
},
"require-dev": {
"az-digital/az-quickstart-dev": "~1"
Expand All @@ -123,9 +124,6 @@
"dev-main": "2.7.x-dev"
},
"patches": {
"seboettg/citeproc-php": {
"allow citeproc academicpuma scoping": "https://gist.githubusercontent.com/tadean/aa6b130f49882ba955321847f4fa6fc8/raw/a4e9ba97a9d7f9812a218b55018dfa4b02082379/citeproc_academicpuma_az_publication.patch"
},
"drupal/antibot": {
"drupalSettings not updated on rendering form in Ajax (3205217)": "https://www.drupal.org/files/issues/2021-03-24/3205217-1.patch"
},
Expand Down
19 changes: 18 additions & 1 deletion modules/custom/az_publication/az_publication.module
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use Drupal\Core\Link;
use Symfony\Component\HttpFoundation\Request;
use Drupal\node\NodeInterface;
use Drupal\az_publication\Plugin\views\argument\AZCitationStyleArgument;
use Seboettg\CiteProc\StyleSheet;
use Seboettg\CiteProc\Exception\CiteProcException;

/**
* Implements hook_entity_extra_field_info().
Expand Down Expand Up @@ -159,7 +161,22 @@ function az_publication_node_view(array &$build, EntityInterface $entity, Entity
$style = "az_publication.az_citation_style." . $style_context;
// Load style if available.
$config = \Drupal::config($style);
$style_info = $config->get('style');
$style_info = '';
$csl_style_name = $config->get('style');
$custom_style = $config->get('custom');
// Known styles from CSL package.
if (!empty($csl_style_name)) {
try {
$style_info = StyleSheet::loadStyleSheet($csl_style_name);
}
catch (CiteProcException $e) {
$style_info = '';
}
}
// Custom stylesheet.
if (!empty($custom_style)) {
$style_info = $custom_style;
}

if (!empty($style_info)) {
// Add cache tag based on citation mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ status: true
dependencies: { }
id: az_ama
label: 'American Medical Association Style (AMA)'
style: "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<style xmlns=\"http://purl.org/net/xbiblio/csl\" class=\"in-text\" version=\"1.0\" demote-non-dropping-particle=\"sort-only\" page-range-format=\"expanded\" initialize-with-hyphen=\"false\" default-locale=\"en-US\">\r\n <info>\r\n <title>American Medical Association 11th edition</title>\r\n <title-short>AMA (11th ed.)</title-short>\r\n <id>http://www.zotero.org/styles/american-medical-association</id>\r\n <link href=\"http://www.zotero.org/styles/american-medical-association\" rel=\"self\"/>\r\n <link href=\"http://www.zotero.org/styles/american-medical-association-10th-edition\" rel=\"template\"/>\r\n <link href=\"https://westlibrary.txwes.edu/sites/default/files/pdf/AMACitationStyle.pdf\" rel=\"documentation\"/>\r\n <link href=\"https://www.amamanualofstyle.com/fileasset/AMAMOS/aaaAMWA%20presentation%20Nov%202019%20FULL.pdf\" rel=\"documentation\"/>\r\n <author>\r\n <name>Julian Onions</name>\r\n <email>[email protected]</email>\r\n </author>\r\n <contributor>\r\n <name>Christian Pietsch</name>\r\n <uri>http://purl.org/net/pietsch</uri>\r\n </contributor>\r\n <contributor>\r\n <name>Daniel W Chan</name>\r\n <email>[email protected]</email>\r\n </contributor>\r\n <contributor>\r\n <name>Patrick O'Brien</name>\r\n <email>[email protected]</email>\r\n </contributor>\r\n <category citation-format=\"numeric\"/>\r\n <category field=\"medicine\"/>\r\n <summary>The American Medical Association style as used in JAMA. Version 11 as per November-2019.</summary>\r\n <updated>2022-03-17T08:48:24+00:00</updated>\r\n <rights license=\"http://creativecommons.org/licenses/by-sa/3.0/\">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>\r\n </info>\r\n <locale xml:lang=\"en\">\r\n <terms>\r\n <term name=\"page-range-delimiter\">-</term>\r\n <term name=\"presented at\">presented at</term>\r\n </terms>\r\n </locale>\r\n <macro name=\"editor\">\r\n <names variable=\"editor\">\r\n <name name-as-sort-order=\"all\" sort-separator=\" \" initialize-with=\"\" delimiter=\", \" delimiter-precedes-last=\"always\"/>\r\n <label form=\"short\" prefix=\", \"/>\r\n </names>\r\n </macro>\r\n <macro name=\"author\">\r\n <group suffix=\".\">\r\n <names variable=\"author\">\r\n <name name-as-sort-order=\"all\" sort-separator=\" \" initialize-with=\"\" delimiter=\", \" delimiter-precedes-last=\"always\"/>\r\n <label form=\"short\" prefix=\", \"/>\r\n <substitute>\r\n <names variable=\"editor\"/>\r\n <text macro=\"title\"/>\r\n </substitute>\r\n </names>\r\n </group>\r\n </macro>\r\n <macro name=\"access\">\r\n <choose>\r\n <if type=\"article-newspaper\" match=\"none\">\r\n <choose>\r\n <if variable=\"DOI\">\r\n <text value=\"doi:\"/>\r\n <text variable=\"DOI\"/>\r\n </if>\r\n <else-if variable=\"URL\">\r\n <group delimiter=\". \">\r\n <choose>\r\n <if type=\"webpage post post-weblog\" match=\"any\">\r\n <date variable=\"issued\" prefix=\"Published \" form=\"text\"/>\r\n </if>\r\n </choose>\r\n <group>\r\n <text term=\"accessed\" text-case=\"capitalize-first\" suffix=\" \"/>\r\n <date variable=\"accessed\">\r\n <date-part name=\"month\" suffix=\" \"/>\r\n <date-part name=\"day\" suffix=\", \"/>\r\n <date-part name=\"year\"/>\r\n </date>\r\n </group>\r\n <text variable=\"URL\"/>\r\n </group>\r\n </else-if>\r\n </choose>\r\n </if>\r\n </choose>\r\n </macro>\r\n <macro name=\"title\">\r\n <choose>\r\n <if type=\"bill book graphic legal_case legislation motion_picture report song thesis\" match=\"any\">\r\n <text variable=\"title\" font-style=\"italic\" text-case=\"title\"/>\r\n </if>\r\n <else>\r\n <text variable=\"title\"/>\r\n </else>\r\n </choose>\r\n </macro>\r\n <macro name=\"publisher\">\r\n <text variable=\"publisher\"/>\r\n </macro>\r\n <macro name=\"edition\">\r\n <choose>\r\n <if is-numeric=\"edition\">\r\n <group delimiter=\" \">\r\n <number variable=\"edition\" form=\"ordinal\"/>\r\n <text term=\"edition\" form=\"short\"/>\r\n </group>\r\n </if>\r\n <else>\r\n <text variable=\"edition\" suffix=\".\"/>\r\n </else>\r\n </choose>\r\n </macro>\r\n <citation collapse=\"citation-number\">\r\n <sort>\r\n <key variable=\"citation-number\"/>\r\n </sort>\r\n <layout delimiter=\",\" vertical-align=\"sup\">\r\n <text variable=\"citation-number\"/>\r\n <group prefix=\"(\" suffix=\")\">\r\n <label variable=\"locator\" form=\"short\" strip-periods=\"true\"/>\r\n <text variable=\"locator\"/>\r\n </group>\r\n </layout>\r\n </citation>\r\n <bibliography hanging-indent=\"false\" et-al-min=\"7\" et-al-use-first=\"3\" second-field-align=\"flush\">\r\n <layout>\r\n <text variable=\"citation-number\" suffix=\".\"/>\r\n <text macro=\"author\"/>\r\n <text macro=\"title\" prefix=\" \" suffix=\".\"/>\r\n <choose>\r\n <if type=\"bill book graphic legislation motion_picture report song\" match=\"any\">\r\n <group suffix=\".\" prefix=\" \" delimiter=\" \">\r\n <group delimiter=\" \">\r\n <text term=\"volume\" form=\"short\" text-case=\"capitalize-first\" strip-periods=\"true\"/>\r\n <text variable=\"volume\" suffix=\".\"/>\r\n </group>\r\n <text macro=\"edition\"/>\r\n <text macro=\"editor\" prefix=\"(\" suffix=\")\"/>\r\n </group>\r\n <text macro=\"publisher\" prefix=\" \"/>\r\n <group suffix=\".\" prefix=\"; \">\r\n <date variable=\"issued\">\r\n <date-part name=\"year\"/>\r\n </date>\r\n <text variable=\"page\" prefix=\":\"/>\r\n </group>\r\n </if>\r\n <else-if type=\"chapter paper-conference entry-dictionary entry-encyclopedia\" match=\"any\">\r\n <group prefix=\" \" delimiter=\" \">\r\n <text term=\"in\" text-case=\"capitalize-first\" suffix=\":\"/>\r\n <text macro=\"editor\"/>\r\n <text variable=\"container-title\" font-style=\"italic\" suffix=\".\" text-case=\"title\"/>\r\n <group delimiter=\" \">\r\n <text term=\"volume\" form=\"short\" text-case=\"capitalize-first\" strip-periods=\"true\"/>\r\n <text variable=\"volume\" suffix=\".\"/>\r\n </group>\r\n <text macro=\"edition\"/>\r\n <text variable=\"collection-title\" suffix=\".\"/>\r\n <group suffix=\".\">\r\n <text macro=\"publisher\"/>\r\n <group suffix=\".\" prefix=\"; \">\r\n <date variable=\"issued\">\r\n <date-part name=\"year\"/>\r\n </date>\r\n <text variable=\"page\" prefix=\":\"/>\r\n </group>\r\n </group>\r\n </group>\r\n </else-if>\r\n <else-if type=\"article-newspaper\">\r\n <text variable=\"container-title\" font-style=\"italic\" prefix=\" \" suffix=\". \"/>\r\n <choose>\r\n <if variable=\"URL\">\r\n <group delimiter=\". \" suffix=\".\">\r\n <text variable=\"URL\"/>\r\n <group prefix=\"Published \">\r\n <date variable=\"issued\">\r\n <date-part name=\"month\" suffix=\" \"/>\r\n <date-part name=\"day\" suffix=\", \"/>\r\n <date-part name=\"year\"/>\r\n </date>\r\n </group>\r\n <group>\r\n <text term=\"accessed\" text-case=\"capitalize-first\" suffix=\" \"/>\r\n <date variable=\"accessed\">\r\n <date-part name=\"month\" suffix=\" \"/>\r\n <date-part name=\"day\" suffix=\", \"/>\r\n <date-part name=\"year\"/>\r\n </date>\r\n </group>\r\n </group>\r\n </if>\r\n <else>\r\n <group delimiter=\":\" suffix=\".\">\r\n <group>\r\n <date variable=\"issued\">\r\n <date-part name=\"month\" suffix=\" \"/>\r\n <date-part name=\"day\" suffix=\", \"/>\r\n <date-part name=\"year\"/>\r\n </date>\r\n </group>\r\n <text variable=\"page\"/>\r\n </group>\r\n </else>\r\n </choose>\r\n </else-if>\r\n <else-if type=\"legal_case\">\r\n <group suffix=\",\" prefix=\" \" delimiter=\" \">\r\n <text macro=\"editor\" prefix=\"(\" suffix=\")\"/>\r\n </group>\r\n <group prefix=\" \" delimiter=\" \">\r\n <text variable=\"container-title\"/>\r\n <text variable=\"volume\"/>\r\n </group>\r\n <text variable=\"page\" prefix=\", \" suffix=\" \"/>\r\n <group prefix=\"(\" suffix=\").\" delimiter=\" \">\r\n <text variable=\"authority\"/>\r\n <date variable=\"issued\">\r\n <date-part name=\"year\"/>\r\n </date>\r\n </group>\r\n </else-if>\r\n <else-if type=\"webpage post post-weblog\" match=\"any\">\r\n <text variable=\"container-title\" prefix=\" \" suffix=\".\"/>\r\n </else-if>\r\n <else-if type=\"speech\">\r\n <group prefix=\" \" suffix=\":\">\r\n <choose>\r\n <if variable=\"genre\">\r\n <text variable=\"genre\" suffix=\" \"/>\r\n <text term=\"presented at\"/>\r\n </if>\r\n <else>\r\n <text term=\"presented at\" text-case=\"capitalize-first\"/>\r\n </else>\r\n </choose>\r\n </group>\r\n <group delimiter=\"; \" prefix=\" \" suffix=\".\">\r\n <text variable=\"event\"/>\r\n <group>\r\n <date delimiter=\" \" variable=\"issued\">\r\n <date-part name=\"month\"/>\r\n <date-part name=\"day\" suffix=\",\"/>\r\n <date-part name=\"year\"/>\r\n </date>\r\n </group>\r\n <text variable=\"event-place\"/>\r\n </group>\r\n </else-if>\r\n <else-if type=\"thesis\" match=\"any\">\r\n <group delimiter=\". \" prefix=\" \" suffix=\".\">\r\n <text variable=\"genre\"/>\r\n <group delimiter=\"; \">\r\n <text variable=\"publisher\"/>\r\n <date date-parts=\"year\" form=\"text\" variable=\"issued\"/>\r\n </group>\r\n </group>\r\n </else-if>\r\n <else>\r\n <text macro=\"editor\" prefix=\" \" suffix=\".\"/>\r\n <group prefix=\" \" suffix=\".\">\r\n <text variable=\"container-title\" font-style=\"italic\" form=\"short\" strip-periods=\"true\" suffix=\".\"/>\r\n <group delimiter=\";\" prefix=\" \">\r\n <choose>\r\n <if variable=\"issue volume\" match=\"any\">\r\n <date variable=\"issued\">\r\n <date-part name=\"year\"/>\r\n </date>\r\n </if>\r\n <else>\r\n <group delimiter=\" \">\r\n <text value=\"Published online\"/>\r\n <date form=\"text\" date-parts=\"year-month-day\" variable=\"issued\"/>\r\n </group>\r\n </else>\r\n </choose>\r\n <group>\r\n <text variable=\"volume\"/>\r\n <text variable=\"issue\" prefix=\"(\" suffix=\")\"/>\r\n </group>\r\n </group>\r\n <text variable=\"page\" prefix=\":\"/>\r\n </group>\r\n </else>\r\n </choose>\r\n <text prefix=\" \" macro=\"access\"/>\r\n </layout>\r\n </bibliography>\r\n</style>\r\n"
style: american-medical-association
custom: ''

Large diffs are not rendered by default.

Loading

0 comments on commit 1bcd62f

Please sign in to comment.