Skip to content

Commit

Permalink
NBBIB-463 Complete contributor citation implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
camilocodes committed Aug 22, 2024
1 parent 5ff75ed commit 99c3b69
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 8 deletions.
41 changes: 37 additions & 4 deletions configuration/views.view.nb_bibliography_contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,12 @@ display:
contextual_filters_or: false
relationships: { }
header: { }
footer: { }
footer:
area_text_custom:
id: area_text_custom
table: views
field: area_text_custom
plugin_id: text_custom
display_extenders: { }
cache_metadata:
max-age: -1
Expand Down Expand Up @@ -1175,8 +1180,8 @@ display:
label: ''
exclude: true
alter:
alter_text: false
text: ''
alter_text: true
text: "{% if name__value|slice(-1, 1) == \".\" %}\r\n{{ name__value[:-1] }}\r\n{% endif %}\r\n{% if name__value|slice(-1, 1) != \".\" %}\r\n{{ name__value }}\r\n{% endif %}\r\n"
make_link: false
path: ''
absolute: false
Expand Down Expand Up @@ -1292,7 +1297,7 @@ display:
exclude: false
alter:
alter_text: true
text: "\"{{ name }}.\" <em>Tide & Time: A New Brunswick Bibliography</em>, UNB Libraries, {{ view_yabrm_contributor }}, Accessed on {{ drupal_token('date:custom:d') }} {{ drupal_token('date:custom:F') }} {{ drupal_token('date:custom:Y') }}."
text: "\"{{ name|trim }}.\" <em>{{ 'Tide & Time: A New Brunswick Bibliography' }}</em>, UNB Libraries, {{ view_yabrm_contributor }}, accessed on {{ drupal_token('date:custom:d') }} {{ drupal_token('date:custom:F') }} {{ drupal_token('date:custom:Y') }}."
make_link: false
path: ''
absolute: false
Expand Down Expand Up @@ -1336,6 +1341,7 @@ display:
cache:
type: none
options: { }
empty: { }
sorts: { }
arguments:
id:
Expand Down Expand Up @@ -1379,6 +1385,7 @@ display:
operator: AND
groups: { }
defaults:
empty: false
cache: false
title: false
use_ajax: false
Expand All @@ -1388,8 +1395,34 @@ display:
arguments: false
filters: false
filter_groups: false
header: false
footer: false
use_ajax: true
display_description: ''
header:
area_text_custom:
id: area_text_custom
table: views
field: area_text_custom
relationship: none
group_type: group
admin_label: ''
plugin_id: text_custom
empty: false
content: "<div id=\"cite-success\" class=\"messages messages--status visually-hidden\" role=\"status\">Copied the citation to clipboard.</div>\r\n<div id =\"cite-error\" class=\"messages messages--error visually-hidden\" role=\"status\">Copied the citation to clipboard.</div>"
tokenize: false
footer:
area_text_custom:
id: area_text_custom
table: views
field: area_text_custom
relationship: none
group_type: group
admin_label: ''
plugin_id: text_custom
empty: false
content: "<b>Note:</b>\r\n<p>This citation uses a modified MLA (Modern Language Association) style.</p>\r\n<a href=\"#\" id=\"cite\" class=\"btn btn-secondary fw-normal lh-lg float-end\">Copy citation<i class=\"fa fa-paperclip\"></a></button>"
tokenize: false
display_extenders: { }
path: cite/contributor/%id
cache_metadata:
Expand Down
3 changes: 2 additions & 1 deletion custom/modules/nbbib_core/js/cite_copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
// Transcription copy button.
$('#cite').click(function() {
// Copy html, convert to string,remove tags, replace breaks with spaces.
navigator.clipboard.writeText($('.views-field-bibliographic-citation > .field-content')
navigator.clipboard.writeText($('#drupal-modal .views-field > .field-content')
.html()
.toString()
.replace(/<\/?[^>]+>/gi, '')
.replace(/\n/g, ' ')
.replace(/\s+/g, ' ')
.replace('&amp;', '&')
.trim()).then(
function() {
// Clipboard successfully set.
Expand Down
7 changes: 6 additions & 1 deletion custom/modules/nbbib_core/nbbib_core.module
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,12 @@ function reindex_collection_refs($cid) {
* Implements hook_views_pre_render().
*/
function nbbib_core_views_pre_render($view) {
if (isset($view) && $view->id() == 'nb_bibliography_citations') {
$cite_views = [
'nb_bibliography_citations',
'nb_bibliography_contributors',
];

if (isset($view) and in_array($view->id(), $cite_views)) {
// Attach citation button library.
$view->element['#attached']['library'][] = 'nbbib_core/cite-copy';
// Include current facets in view title.
Expand Down
7 changes: 5 additions & 2 deletions custom/themes/bs5_nbbib_lib_unb_ca/src/scss/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ html {
svg {
display: none;
}
.search-result {
.view-content {
margin: 1rem 0 2rem 0;
.views-field-bibliographic-citation {
li {
margin: 0 !important;
}
.views-field {
padding-left: 1rem;
border-left: 1px solid $base-200;
}
Expand Down

0 comments on commit 99c3b69

Please sign in to comment.