diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 902a1647..d4783517 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -132,11 +132,14 @@ Rails/HasManyOrHasOneDependent: Exclude: - 'app/models/endpoint.rb' -# Offense count: 5 +# Offense count: 7 Rails/OutputSafety: Exclude: - 'app/forms/hyrax/forms/admin/appearance.rb' - 'app/helpers/blacklight/catalog_helper_behavior.rb' + - 'app/helpers/hyrax/citations_behaviors/formatters/apa_formatter.rb' + - 'app/helpers/hyrax/citations_behaviors/formatters/chicago_formatter.rb' + - 'app/helpers/hyrax/citations_behaviors/formatters/mla_formatter.rb' # Offense count: 1 # Cop supports --auto-correct. diff --git a/app/assets/images/atla-ir.png b/app/assets/images/atla-ir.png new file mode 100644 index 00000000..9d0ac89a Binary files /dev/null and b/app/assets/images/atla-ir.png differ diff --git a/app/assets/images/collection.png b/app/assets/images/collection.png new file mode 100755 index 00000000..95da3d3a Binary files /dev/null and b/app/assets/images/collection.png differ diff --git a/app/assets/images/default.png b/app/assets/images/default.png new file mode 100755 index 00000000..ef189573 Binary files /dev/null and b/app/assets/images/default.png differ diff --git a/app/assets/images/home-logos/ctschicago.png b/app/assets/images/home-logos/ctschicago.png new file mode 100644 index 00000000..d0daaa6d Binary files /dev/null and b/app/assets/images/home-logos/ctschicago.png differ diff --git a/app/assets/images/home-logos/ost.png b/app/assets/images/home-logos/ost.png new file mode 100644 index 00000000..a9c86a31 Binary files /dev/null and b/app/assets/images/home-logos/ost.png differ diff --git a/app/assets/images/home-logos/rim_atla-wider.png b/app/assets/images/home-logos/rim_atla-wider.png new file mode 100644 index 00000000..a8841617 Binary files /dev/null and b/app/assets/images/home-logos/rim_atla-wider.png differ diff --git a/app/assets/images/home-logos/rim_atla.png b/app/assets/images/home-logos/rim_atla.png new file mode 100644 index 00000000..a2dc5e95 Binary files /dev/null and b/app/assets/images/home-logos/rim_atla.png differ diff --git a/app/assets/images/work.png b/app/assets/images/work.png new file mode 100755 index 00000000..ef189573 Binary files /dev/null and b/app/assets/images/work.png differ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index c90e7eba..77605f43 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -18,4 +18,5 @@ *= require dataTables/bootstrap/3/jquery.dataTables.bootstrap *= require bootstrap-datepicker *= require_self + *= require atla-overrides */ diff --git a/app/assets/stylesheets/atla-overrides.scss b/app/assets/stylesheets/atla-overrides.scss new file mode 100644 index 00000000..65334831 --- /dev/null +++ b/app/assets/stylesheets/atla-overrides.scss @@ -0,0 +1,190 @@ +html, body.public-facing { + font-family: 'Muli', Helvetica, sans-serif; + font-size:1em; +} + +body {font-size:0.875em;} + +img {max-width:100%;} + +a#skip-to-content{padding:0;} + +/* LANDING PAGE for app */ +/*top nav bar*/ +body.splash-index.public-facing .navbar-inverse { + background-color: #fff; + border-color: #258FCE; +} +body.splash-index.public-facing .navbar-static-top {border-width: 3px 0 0;} + +body.splash-index.public-facing a,body.splash-index.public-facing .navbar-inverse .navbar-nav > li > a, body.splash-index.public-facing .navbar-inverse .navbar-text, body.splash-index.public-facing .navbar-inverse .navbar-brand { + color:#258FCE; + padding:1em; +} +body.splash-index.public-facing .home-logo-grid a {padding:0;} +body.splash-index.public-facing footer a {color:white;} +body.splash-index.public-facing footer.navbar.navbar-inverse.site-footer{ + border:0; + border-bottom:3px solid #258FCE; + background-color:#258FCE; +} + +body.splash-index span.institution_name { + display: none; +} + +body.splash-index .navbar-toggle {background-color:#258FCE;} +body.splash-index .navbar-inverse .navbar-toggle:hover {background-color:#fff;} +body.splash-index .navbar-inverse .navbar-toggle:hover .icon-bar {background-color:#258FCE;} + +/* in page content */ +body.splash-index .row {margin:0;} +body.splash-index #content-wrapper.container {padding-right:0px;padding-left:0px;} + +body.splash-index .home-logo { + margin-bottom:2em; +} + +body.splash-index .right-side{ + text-align:center; +} + +body.splash-index.public-facing h2{ + font-family: 'PT Serif'; + margin:4.5em 0 1em 0; + color:#4d4e4e; + font-size:1.5em; +} + +body.splash-index button.shared-search { + border: none; + color: white; + padding: 1em; + text-align: center; + text-decoration: none; + display: inline-block; + font-size: 1em; + /*font-weight:700;*/ + margin: 0 2px 1.25em 2px; + transition-duration: 0.4s; + cursor: pointer; + background-color:#E05C3F;/*#D43D1C*/ + box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.3); + border-radius:3px; +} + +body.splash-index button.shared-search:hover{ + background-color:#D43D1C; + border: 1px solid #E05C3F; +} + +body.splash-index .text-right p{color:#258FCE;} + +body.splash-index.public-facing a:hover, body.public-facing a:focus {color:#ffffff;text-decoration:underline;} + +/* across all tenants */ +.proprietor-accounts .btn-primary a:visited {color:white!important;} + +.public-facing .footer-link a, .public-facing .site-footer a {padding:1em;} +.public-facing .footer-link { + padding: 1em; +} + +footer.navbar.navbar-inverse.site-footer { + border:0; +} + +/* Work show metadata layout */ +.works-show p.work_description {margin-top:1em;} +.works-show dl.work-show {margin-top: 1em;} + +.work-show ul.tabular, .scholarly_show .work-show ul.tabular{padding-inline-start: 0px;} +.work-show dt {padding-bottom:0;} + +/* hide work type on work show pages */ +.works-show .work-type-tag {display:none;} + +.social-media{display:none;} + +/* Collection show layout */ + +.hyc-banner .hyc-title h1, .hyc-banner .hyc-bugs div{ + color:rgb(51, 51, 51); + text-shadow:none; +} + +.hyc-banner .hyc-title .label { + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; +} + +.hyc-banner {min-height:95px;} + +.hyc-bugs { + padding: 0 1em 0 2em; + text-align:right; +} + +.hyc-header {margin-bottom:0;} +.hyc-banner .hyc-title h1 {margin-bottom: 0.25em;} +.hyc-description h2 {font-size: 1.5em;} + +.hyc-bl-results {margin:0 0 1em 0;} +.hyc-blacklight.hyc-bl-title {padding: 0;} +.hyc-blacklight.hyc-bl-results {padding-left: 0;} +body.hyrax-collections .hyc-bl-search .col-sm-8 {float: right;} + +/* search resulsts */ +div.facets h3 {font-size: 1em;} + + +/* admin dashboard available works ETD all caps*/ +.dashboard label[for="input-Etd"] {text-transform: uppercase;} + +/* citations style */ +button.btn.btn-default.btn-block.citations-button.center-block {margin-top: 1em;} +.mla-citation, .apa-citation, .chicago-citation { + line-height: 1.25em; + display: inline-block; + width: 100%; + font-size:0.875em; +} +div#collapse-citations{text-align:left;overflow-wrap: break-word;} +div#collapse-citations h4 {font-size:1em;} +div#collapse-citations p {font-size:0.85em;} +button.btn.btn-default.btn-block.citations-button.center-block:hover, button.btn.btn-default.btn-block.citations-button.center-block:focus{ + background-color:#337ab7; + border-color: #204d75; + color:white; +} + + + +@media only screen and (min-width: 768px) { + .hyc-banner .hyc-title h1 {margin-bottom: 0em;} + + body.splash-index .row { + margin-right: -15px; + margin-left: -15px; +} +body.splash-index #content-wrapper.container {padding-right:15px;padding-left:15px;} + + body.splash-index .left-side { + padding-left: 0px; + padding-right: 50px; + } + body.splash-index .right-side { + padding-left: 50px; + padding-right: 10px; + } + body.splash-index button.shared-search {margin: 2em 2px 4px 2px;} + body.splash-index .col-xs-4.col-md-3.footer-link {width: 25%;} + + /* across all tenants * / + + /* banner area search bar */ + .navbar.navbar-static-top .input-group {margin-bottom:0;} + + +} diff --git a/app/assets/stylesheets/themes/shared_repository.scss b/app/assets/stylesheets/themes/shared_repository.scss new file mode 100644 index 00000000..840c29c5 --- /dev/null +++ b/app/assets/stylesheets/themes/shared_repository.scss @@ -0,0 +1,234 @@ +.shared_repository { + + &.public-facing, &.public-facing p {font-family: Muli, Helvetica, Arial, sans-serif!important;} + &.public-facing h1, h2, h3, h4, h5, h6 {font-family: 'PT Serif', serif;} + + img {max-width:100%;} + + &.public-facing a {color:#E05C3F;} + &.public-facing a:hover, &.public-facing a:focus{color:#D43D1C;} + h3.panel-title.facet-field-heading a {color:#333333;} + &.public-facing footer a {color:white;} + &.public-facing footer a:hover, &.public-facing footer a:focus {color:white;} + + div.facets h3 {font-size:1em;} + + .text-success, .facet-values li .selected {color:#E05C3F;} + + /*top admin nav bar*/ + &.public-facing .navbar-inverse { + background-color: #fff; + border-color: #258FCE; + } + + &.public-facing .navbar-static-top {border-width: 3px 0 0px} + + &.public-facing nav.navbar.navbar-default.navbar-static-top{ + border-width:0px; + margin-top:1em; + } + + &.public-facing .navbar-inverse .navbar-nav > li > a, &.public-facing .navbar-inverse .navbar-text, &.public-facing .navbar-inverse .navbar-brand {color:#258FCE;} + + &.public-facing .navbar-inverse .navbar-nav .open .dropdown-menu > li > a, .navbar-inverse .navbar-nav .open .twitter-typeahead .tt-menu > li > a, .twitter-typeahead .navbar-inverse .navbar-nav .open .tt-menu > li > a, &.public-facing .dropdown-header {color:#258FCE;} + + .navbar-inverse .navbar-collapse, .navbar-inverse #facet-panel-collapse, .navbar-inverse .navbar-form{border-color: #175E87;} + + ul#user_utility_links.nav.navbar-nav li {background-color:transparent;} + + /* hide globe icon on linked logo*/ + .image-masthead .glyphicon {display:none;} + + &.public-facing #masthead #logo img { + max-height:125px; + padding-top:.5em; + padding-left:.3em; + } + + &.public-facing .navbar{margin-bottom:0;} + + &.public-facing .navbar + .navbar, .navbar + .image-masthead {margin-top:0;} + + /* removing background banner image */ + .image-masthead .background-container, .container.site-title-container {display:none;} + .image-masthead .background-container-gradient {background:none;} + + /*hamburger menu*/ + &.public-facing button.navbar-toggle.collapsed,&.public-facing .navbar-inverse .navbar-toggle, &.public-facing .navbar-inverse .facets-toggle {background-color:#258FCE;} + + &.public-facing button.navbar-toggle.collapsed:hover{background-color:#175E87;} + + &.public-facing .navbar-inverse .navbar-toggle {border-color: #175E87;} + + &.public-facing .navbar-inverse .navbar-nav > .open > a, &.public-facing .navbar-inverse .navbar-nav > .open > a:hover, &.public-facing .navbar-inverse .navbar-nav > .open > a:focus{background-color: #258FCE;color:white;} + + .navbar-inverse .navbar-nav .open .dropdown-menu .divider, .navbar-inverse .navbar-nav .open .twitter-typeahead .tt-menu .divider, .twitter-typeahead .navbar-inverse .navbar-nav .open .tt-menu .divider{background-color: #175E87;} + + /* mobile stacked menu */ + .navbar-nav {margin:0} + + .image-masthead.row {margin-right:0;margin-left:0;} + + .image-masthead .navbar .navbar-nav {margin-left:0;} + + /* site nav bar on pages not catalog or login*/ + ul.nav.navbar-nav li {background-color:#258FCE;} + + &.public-facing .image-masthead .navbar .active > a, &.public-facing .image-masthead .navbar .active > a:hover, &.public-facing .image-masthead .navbar .active > a:focus {background-color:#175E87;} + &.public-facing .image-masthead .navbar {background-color: rgba(0, 0, 0, 0);} + + /* catalog/login nav bar */ + .navbar-default .navbar-nav li a {color:#eeeeee;text-transform: uppercase;} + .navbar-default {background-color:transparent;} + + &.catalog nav.navbar.navbar-default.navbar-static-top, &.devise-sessions nav.navbar.navbar-default.navbar-static-top{ + margin-bottom:2em; + border-bottom: 1px solid #e7e7e7; + } + + &.catalog .navbar-nav, &.devise-sessions .navbar-nav { + padding-left:1em; + margin-block-end: 0; + } + + &.devise-sessions .navbar-nav#user_utility_links {padding:0;} + + /* homepage page content */ + .container.homepage-container h2{ + font-family: 'PT Serif'; + margin:1.55em 0 0 0; + color:#4d4e4e;/*313133*/ + font-size:1.5em; + text-align:center; + } + + .container.homepage-container .row {margin:0;} + + /* search bar */ + &.hyrax-homepage #search-form-header{ + max-width:600px; + margin: 2em auto 0 auto; + } + /* search bar on other pages */ + .searchbar-right.navbar-right.col-sm-7 { + max-width: 600px; + } + + button.btn.btn-default.dropdown-toggle {display:none;} + + .form-horizontal .control-label, &.splash-index button.btn.btn-default.dropdown-toggle{display:none;} + + #search-field-header { + padding: 25px 12px 20px 12px; + border-top: 2px solid #E3E3E3 !important; + border-bottom: 2px solid #E3E3E3 !important; + border-left: 2px solid #E3E3E3 !important; + border-right: 0px solid transparent !important; + } + button#search-submit-header { + color: #575757; + background-color: #fff !important; + padding: 13px 12px 12px 12px; + border-top: 2px solid #E3E3E3 !important; + border-bottom: 2px solid #E3E3E3 !important; + border-right: 2px solid #E3E3E3 !important; + border-left: 0px solid transparent !important; + border-top-right-radius: 5px; + border-bottom-right-radius:5px; + } + + input::placeholder{font-size:1.5em;} + + .row.home-content {display:none;} + + /* limit width for text in pages for better usability */ + &.public-facing.hyrax-pages #content-wrapper, &.public-facing.hyrax-contact_form #content-wrapper {max-width:800px;} + /* adding space to text area for mobile view */ + &.public-facing.hyrax-pages div#content_block_page.row {margin-left:1em;margin-right:1em;} + + /* footer */ + &.public-facing footer.navbar.navbar-inverse.site-footer{ + border:0; + border-bottom:3px solid #258FCE; + background-color:#258FCE; + } + + /*contact page*/ + &.public-facing .alert-info{ + background-color:rgba(37,143,206, .3); + color:#333; + border-color:#258FCE; + } + &.public-facing .alert{margin-left:0;} + + &.public-facing .btn.btn-primary, &.public-facing .btn-primary.facets-toggle, &.public-facing .field-controls .facets-toggle.add, .field-controls &.public-facing .facets-toggle.add, &.public-facing .field-controls .btn.add, .field-controls &.public-facing .btn.add, &.public-facing .field-controls td.toggle input.add[type=submit], .field-controls td.toggle &.public-facing input.add[type=submit], &.public-facing td.toggle .field-controls input.add[type=submit], td.toggle .field-controls &.public-facing input.add[type=submit], &.public-facing td.toggle input.btn-primary[type=submit], td.toggle &.public-facing input.btn-primary[type=submit], &.public-facing td.toggle input[type=submit].active, td.toggle &.public-facing input[type=submit].active{ + background-color:#E05C3F; + border-color: #E05C3F; + } + + &.hyrax-contact_form .btn.btn-primary{box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.3);} + + /* splash */ + &.public-facing.hyrax-homepage #masthead.navbar {margin-bottom:20px;} + &.hyrax-homepage .navbar-header{display:none;} + + &.hyrax-homepage .home-logo { + margin-bottom:2em; + } + + &.hyrax-homepage .right-side{ + text-align:center; + } + &.hyrax-homepage h2{ + font-family: 'PT Serif'; + margin:3.5em 0 .5em 0; + color:#4d4e4e; + font-size:1.5em; + } + &.hyrax-homepage .splash-browse h2 {margin:2em 0 1em 0;} + &.hyrax-homepage #search-form-header {margin-top:1em;} + &.hyrax-homepage .text-right p{color:#258FCE;} + + @media screen and (min-width:768px){ + + .dropdown-menu .divider, .twitter-typeahead .tt-menu .divider{ + background-color: #e5e5e5;} + + /* site nav bar on pages not catalog or login*/ + .image-masthead .navbar-nav{ + padding-left:1em; + padding-top: 2em; + } + + .image-masthead.row {margin-right:-15px;margin-left:-15px;} + + /* catalog/login nav bar */ + &.catalog .navbar-nav, &.devise-sessions .navbar-nav { + padding-top:2em; + } + &.devise-sessions .navbar-nav#user_utility_links,&.catalog .navbar-nav#user_utility_links {padding:0;} + + #search-form-header{ + margin:0; + } + + /* removing extra space to text area for larger view on pages */ + &.public-facing.hyrax-pages div#content_block_page.row {margin-left:0em;margin-right:0em;} + + &.public-facing .alert{width:83%;} + + /* splash */ + &.hyrax-homepage .left-side { + padding-left: 0px; + padding-right: 50px; + } + &.hyrax-homepage .right-side { + padding-left: 50px; + padding-right: 10px; + } + + &.hyrax-homepage .splash-browse {padding-top:1em;} + + } + +} diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 6f31c1bf..a56f9d87 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -101,6 +101,7 @@ def self.modified_field config.add_index_field 'description_tesim', itemprop: 'description', helper_method: :index_filter config.add_index_field 'creator_tesim', itemprop: 'creator', link_to_search: 'creator_sim' config.add_index_field 'resource_type_tesim', label: 'Resource Type', link_to_search: 'resource_type_sim' + config.add_index_field 'institution_tesim', label: 'Institution', link_to_search: 'institution_sim' # solr fields to be displayed in the show (single result) view # The ordering of the field names is the order of the display @@ -147,7 +148,7 @@ def self.modified_field config.add_show_field 'event_date_tesim', label: 'Event date' config.add_show_field 'official_link_tesim', label: 'Official URL' config.add_show_field 'degree_tesim', label: 'Degree' - config.add_show_field 'level_tesim', label: 'Level' + # config.add_show_field 'level_tesim', label: 'Level' config.add_show_field 'discipline_tesim', label: 'Discipline' config.add_show_field 'degree_graning_institution_tesim', label: 'Degree Granting Institution' config.add_show_field 'advisor_tesim', label: 'Advisor' diff --git a/app/forms/hyrax/etd_form.rb b/app/forms/hyrax/etd_form.rb index 60f9cac5..f59b0180 100644 --- a/app/forms/hyrax/etd_form.rb +++ b/app/forms/hyrax/etd_form.rb @@ -12,7 +12,6 @@ class EtdForm < Hyrax::Forms::WorkForm resource_type institution degree - level discipline degree_granting_institution types @@ -26,7 +25,6 @@ class EtdForm < Hyrax::Forms::WorkForm bibliographic_citation format degree - level discipline degree_granting_institution advisor diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb index e1aaea70..077e246a 100644 --- a/app/helpers/accounts_helper.rb +++ b/app/helpers/accounts_helper.rb @@ -1,4 +1,14 @@ # frozen_string_literal: true module AccountsHelper + def host_for(sub_domain) + # rubocop:disable Style/FormatStringToken + default_host = ENV.fetch('HYKU_DEFAULT_HOST', "%{tenant}.#{Account.admin_host}") + default_host.gsub('%{tenant}', sub_domain) + # rubocop:enable Style/FormatStringToken + end + + def full_search_url + main_app.search_catalog_path + end end diff --git a/app/helpers/hyrax/citation_behaviors/common_behavior.rb b/app/helpers/hyrax/citation_behaviors/common_behavior.rb new file mode 100644 index 00000000..3c30e38e --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/common_behavior.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module CommonBehavior + def persistent_url(work); end + + def clean_end_punctuation(text) + return text[0, text.length - 1] if text && ([".", ",", ":", ";", "/"].include? text[-1, 1]) + text + end + end + end +end diff --git a/app/helpers/hyrax/citation_behaviors/formatters.rb b/app/helpers/hyrax/citation_behaviors/formatters.rb new file mode 100644 index 00000000..2c7130be --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/formatters.rb @@ -0,0 +1,30 @@ +# Hyrax Override: Improve Citations Format +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module Formatters + class BaseFormatter + include Hyrax::CitationsBehaviors::CommonBehavior + include Hyrax::CitationsBehaviors::NameBehavior + + attr_reader :view_context + + def initialize(view_context) + @view_context = view_context + end + + # Hyrax Override: Adds new functionality for citations + def add_link_to_original(work) + persistent_url(work).to_s + end + # end + end + + autoload :ApaFormatter, 'hyrax/citations_behaviors/formatters/apa_formatter' + autoload :ChicagoFormatter, 'hyrax/citations_behaviors/formatters/chicago_formatter' + autoload :MlaFormatter, 'hyrax/citations_behaviors/formatters/mla_formatter' + autoload :OpenUrlFormatter, 'hyrax/citations_behaviors/formatters/open_url_formatter' + end + end +end diff --git a/app/helpers/hyrax/citation_behaviors/formatters/apa_formatter.rb b/app/helpers/hyrax/citation_behaviors/formatters/apa_formatter.rb new file mode 100644 index 00000000..cb58a979 --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/formatters/apa_formatter.rb @@ -0,0 +1,94 @@ +# Hyrax Override: Improve Format of Citations +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module Formatters + class ApaFormatter < BaseFormatter + include Hyrax::CitationsBehaviors::PublicationBehavior + include Hyrax::CitationsBehaviors::TitleBehavior + + def format(work) + text = '' + text += authors_text_for(work) + text += pub_date_text_for(work) + text += add_title_text_for(work) + # Hyrax Override: adds addtl content for citation + text += " #{add_link_to_original(work)}" + # end + text.html_safe # rubocop:disable Rails/OutputSafety + end + + private + + def authors_text_for(work) + # setup formatted author list + authors_list = author_list(work).reject(&:blank?) + author_text = format_authors(authors_list) + if author_text.blank? + author_text + else + " " + end + end + + public + + def format_authors(authors_list = []) + return '' if authors_list.blank? + authors_list = Array.wrap(authors_list).collect(&:strip) + text = '' + text += convert_to_initials(authors_list.first) if authors_list.first + authors_list[1..-1].each do |author| + text += if author == authors_list.last + ", & #{convert_to_initials(author)}" + else + ", #{convert_to_initials(author)}" + end + end + text += "." unless text.end_with?(".") + text + end + + private + + def pub_date_text_for(work) + # Get Pub Date + pub_date = setup_pub_date(work) + format_date(pub_date) + end + + def add_title_text_for(work) + # setup title info + title_info = setup_title_info(work) + format_title(title_info) + end + + def add_publisher_text_for(work) + # Publisher info + pub_info = clean_end_punctuation(setup_pub_info(work)) + if pub_info.blank? + '' + else + pub_info + "." + end + end + + def convert_to_initials(name) + name = name.split(" ") + name.map { |n| n.equal?(name.last) ? n.capitalize : n[0].capitalize }.join(". ") + end + + public + + def format_date(pub_date) + pub_date.blank? ? "" : "(" + pub_date + "). " + end + + def format_title(title_info) + title_info.nil? ? "" : "#{title_info} " + end + end + end + end +end diff --git a/app/helpers/hyrax/citation_behaviors/formatters/chicago_formatter.rb b/app/helpers/hyrax/citation_behaviors/formatters/chicago_formatter.rb new file mode 100644 index 00000000..7390cc89 --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/formatters/chicago_formatter.rb @@ -0,0 +1,64 @@ +# Hyrax Override: Improve Citations Format +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module Formatters + class ChicagoFormatter < BaseFormatter + include Hyrax::CitationsBehaviors::PublicationBehavior + include Hyrax::CitationsBehaviors::TitleBehavior + def format(work) + text = "" + + # setup formatted author list + authors_list = all_authors(work) + text += format_authors(authors_list) + text = " " if text.present? + text += format_title(work.to_s) + pub_info = setup_pub_info(work, false) + text += " #{whitewash(pub_info)}." if pub_info.present? + pub_date = setup_pub_date(work) + text += " #{whitewash(pub_date)}." unless pub_date.nil? + text += " #{add_link_to_original(work)}" + # end + + text.html_safe # rubocop:disable Rails/OutputSafety + end + + def format_authors(authors_list = []) + return '' if authors_list.blank? + text = '' + text += authors_list.first if authors_list.first + authors_list[1..6].each_with_index do |author, index| + text += if index + 2 == authors_list.length # we've skipped the first author + ", and #{author}." + else + ", #{author}" + end + end + text += " et al." if authors_list.length > 7 + # if for some reason the first author ended with a comma + text = text.gsub(',,', ',') + text += "." unless text.end_with?(".") + whitewash(text) + end + + def format_date(pub_date); end + + def format_title(title_info) + return "" if title_info.blank? + title_text = chicago_citation_title(title_info) + title_text += '.' unless title_text.end_with?(".") + title_text = whitewash(title_text) + " #{title_text}" + end + + private + + def whitewash(text) + Loofah.fragment(text.to_s).scrub!(:whitewash).to_s + end + end + end + end +end diff --git a/app/helpers/hyrax/citation_behaviors/formatters/mla_formatter.rb b/app/helpers/hyrax/citation_behaviors/formatters/mla_formatter.rb new file mode 100644 index 00000000..14986a96 --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/formatters/mla_formatter.rb @@ -0,0 +1,75 @@ +# Hyrax Override: Improve Citations Format +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module Formatters + class MlaFormatter < BaseFormatter + include Hyrax::CitationsBehaviors::PublicationBehavior + include Hyrax::CitationsBehaviors::TitleBehavior + + def format(work) + text = '' + + # setup formatted author list + authors = author_list(work).reject(&:blank?) + text += " " + # setup title + title_info = setup_title_info(work) + text += format_title(title_info) + + # Hyrax Override: adds contributor + text += " #{work.contributor.join(', ')}." if work.contributor.present? + + # Publication + pub_info = clean_end_punctuation(setup_pub_info(work, true)) + text += "#{pub_info}. " if pub_info.present? + # text += (pub_info + ".") if pub_info.present? + + # Hyrax Override: adds addtl content for citation + # text += add_link_to_original(work) + text += " #{add_link_to_original(work)}" + # end + + text.html_safe # rubocop:disable Rails/OutputSafety + end + + def format_authors(authors_list = []) + return "" if authors_list.blank? + authors_list = Array.wrap(authors_list) + text = concatenate_authors_from(authors_list) + if text.present? + text += "." unless text.end_with?(".") + text += " " + end + text + end + + def concatenate_authors_from(authors_list) + text = '' + text += authors_list.first + if authors_list.length > 1 + if authors_list.length < 4 + authors_list[1...-1].each do |author| + text += ", #{author}" + end + text += ", and #{authors_list.last}" + else + text += ", et al" + end + end + text + end + private :concatenate_authors_from + + def format_date(pub_date) + " #{pub_date.join(', ')}." + end + + def format_title(title_info) + title_info.blank? ? "" : "#{mla_citation_title(title_info)} " + end + end + end + end +end diff --git a/app/helpers/hyrax/citation_behaviors/name_behavior.rb b/app/helpers/hyrax/citation_behaviors/name_behavior.rb new file mode 100644 index 00000000..a0508eca --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/name_behavior.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module NameBehavior + include Hyrax::CitationsBehaviors::CommonBehavior + # return all unique authors with end punctuation removed + def author_list(work) + all_authors(work) { |author| clean_end_punctuation(CGI.escapeHTML(author)) } + end + + # return all unique authors of a work or nil if none + def all_authors(work, &block) + authors = work.creator.uniq.compact + block_given? ? authors.map(&block) : authors + end + + def given_name_first(name) + name = clean_end_punctuation(name) + return name unless name.include?(',') + temp_name = name.split(/,\s*/) + temp_name.last + " " + temp_name.first + end + + def surname_first(name) + name = name.join('') if name.is_a? Array + # make sure we handle "Cher" correctly + return name if name.include?(',') + name_segments = name.split(' ') + given_name = name_segments.first + surnames = name_segments[1..-1] + if surnames + "#{surnames.join(' ')}, #{given_name}" + else + given_name + end + end + + def abbreviate_name(name) + abbreviated_name = '' + name = name.join('') if name.is_a? Array + + # make sure we handle "Cher" correctly + return name unless name.include?(' ') || name.include?(',') + name = surname_first(name) + name_segments = name.split(/,\s*/) + abbreviated_name += name_segments.first + abbreviated_name += ", #{name_segments.last.first}" if name_segments[1] + abbreviated_name + "." + end + end + end +end diff --git a/app/helpers/hyrax/citation_behaviors/publication_behavior.rb b/app/helpers/hyrax/citation_behaviors/publication_behavior.rb new file mode 100644 index 00000000..f7811180 --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/publication_behavior.rb @@ -0,0 +1,48 @@ +# Hyrax Override: Improve Citations Format +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module PublicationBehavior + include Hyrax::CitationsBehaviors::CommonBehavior + def setup_pub_date(work) + first_date = work.date_created.first if work.date_created + if first_date.present? + first_date = CGI.escapeHTML(first_date) + date_value = first_date.gsub(/[^0-9|n\.d\.]/, "")[0, 4] + return nil if date_value.nil? + end + clean_end_punctuation(date_value) if date_value + end + + # @param [Hyrax::WorkShowPresenter] work_presenter + def setup_pub_place(work_presenter) + work_presenter.based_near_label&.first + end + + def setup_pub_publisher(work) + work.publisher&.first + end + + def setup_pub_info(work, include_date = false) + pub_info = "" + + if (place = setup_pub_place(work)) + pub_info += CGI.escapeHTML(place) + end + + if (publisher = setup_pub_publisher(work)) + # Hyrax Override: format was wrong + # ':' should only be added if there is previous info + pub_info += ":" unless pub_info.empty? + pub_info += " #{CGI.escapeHTML(publisher)}" + end + + pub_date = include_date ? setup_pub_date(work) : nil + pub_info += ". #{pub_date}" unless pub_date.nil? + + pub_info.strip.presence + end + end + end +end diff --git a/app/helpers/hyrax/citation_behaviors/title_behavior.rb b/app/helpers/hyrax/citation_behaviors/title_behavior.rb new file mode 100644 index 00000000..d33b8991 --- /dev/null +++ b/app/helpers/hyrax/citation_behaviors/title_behavior.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module Hyrax + module CitationsBehaviors + module TitleBehavior + include Hyrax::CitationsBehaviors::CommonBehavior + + TITLE_NOCAPS = ["a", "an", "and", "but", "by", "for", "it", "of", "the", "to", "with"].freeze + EXPANDED_NOCAPS = TITLE_NOCAPS + ["about", "across", "before", "without"] + + def chicago_citation_title(title_text) + process_title_parts(title_text) do |w, index| + if (index.zero? && w.casecmp(w).zero?) || (w.length > 1 && w.casecmp(w).zero? && !EXPANDED_NOCAPS.include?(w)) + # the split("-") will handle the capitalization of hyphenated words + w.split("-").map!(&:capitalize).join("-") + else + w + end + end + end + + def mla_citation_title(title_text) + process_title_parts(title_text) do |w| + if TITLE_NOCAPS.include? w + w + else + w.capitalize + end + end + end + + def process_title_parts(title_text, &block) + if block_given? + title_text.split(" ").collect.with_index(&block).join(" ") + else + title_text + end + end + + def setup_title_info(work) + text = '' + title = work.to_s + if title.present? + title = CGI.escapeHTML(title) + title_info = clean_end_punctuation(title.strip) + text += title_info + end + + return nil if text.strip.blank? + clean_end_punctuation(text.strip) + "." + end + end + end +end diff --git a/app/helpers/hyrax/citations_behavior.rb b/app/helpers/hyrax/citations_behavior.rb new file mode 100644 index 00000000..aa3ea963 --- /dev/null +++ b/app/helpers/hyrax/citations_behavior.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Hyrax + module CitationsBehavior + include Hyrax::CitationsBehaviors::CommonBehavior + include Hyrax::CitationsBehaviors::Formatters + include Hyrax::CitationsBehaviors::PublicationBehavior + include Hyrax::CitationsBehaviors::NameBehavior + include Hyrax::CitationsBehaviors::TitleBehavior + + def export_as_apa_citation(work) + Hyrax::CitationsBehaviors::Formatters::ApaFormatter.new(self).format(work) + end + + def export_as_chicago_citation(work) + Hyrax::CitationsBehaviors::Formatters::ChicagoFormatter.new(self).format(work) + end + + def export_as_mla_citation(work) + Hyrax::CitationsBehaviors::Formatters::MlaFormatter.new(self).format(work) + end + + # MIME type: 'application/x-openurl-ctx-kev' + def export_as_openurl_ctx_kev(work) + Hyrax::CitationsBehaviors::Formatters::OpenUrlFormatter.new(self).format(work) + end + end +end diff --git a/app/models/etd.rb b/app/models/etd.rb index 6048a78c..94b6197e 100644 --- a/app/models/etd.rb +++ b/app/models/etd.rb @@ -14,7 +14,7 @@ class Etd < ActiveFedora::Base validates :title, presence: { message: 'Your work must have a title.' } validates :creator, presence: { message: 'Your work must have a creator.' } validates :degree, presence: { message: 'Your work must have a degree.' } - validates :level, presence: { message: 'Your work must have a level.' } + # validates :level, presence: { message: 'Your work must have a level.' } validates :discipline, presence: { message: 'Your work must have a discipline.' } validates :degree_granting_institution, presence: { message: 'Your work must have a degree granting institution.' } # rubocop:disable Style/RegexpLiteral @@ -58,9 +58,9 @@ def video_embed? index.as :stored_searchable, :facetable end - property :level, predicate: ::RDF::URI('https://atla.com/terms/level') do |index| - index.as :stored_searchable - end + # property :level, predicate: ::RDF::URI('https://atla.com/terms/level') do |index| + # index.as :stored_searchable + # end property :discipline, predicate: ::RDF::URI('https://atla.com/terms/discipline') do |index| index.as :stored_searchable, :facetable diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index 1a6c25bd..4bd61d86 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -54,7 +54,7 @@ class SolrDocument attribute :institution, Solr::String, 'institution_tesim' attribute :keyword, Solr::Array, 'keyword_tesim' attribute :language, Solr::Array, 'language_tesim' - attribute :level, Solr::Array, 'level_tesim' + # attribute :level, Solr::Array, 'level_tesim' attribute :license, Solr::Array, 'license_tesim' attribute :official_link, Solr::Array, 'official_link_tesim' attribute :project_name, Solr::Array, 'project_name_tesim' diff --git a/app/presenters/hyrax/etd_presenter.rb b/app/presenters/hyrax/etd_presenter.rb index 605eeebf..0f4cf29b 100644 --- a/app/presenters/hyrax/etd_presenter.rb +++ b/app/presenters/hyrax/etd_presenter.rb @@ -9,7 +9,7 @@ class EtdPresenter < Hyku::WorkShowPresenter :institution, :format, :degree, - :level, + #:level, :discipline, :degree_granting_institution, :advisor, diff --git a/app/presenters/hyrax/file_set_presenter_decorator.rb b/app/presenters/hyrax/file_set_presenter_decorator.rb new file mode 100644 index 00000000..7ed02ba5 --- /dev/null +++ b/app/presenters/hyrax/file_set_presenter_decorator.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +# OVERRIDE Hyrax v3.5.0 to change what appears in the title tags for pages + +module Hyrax + module FileSetPresenterDecorator + def page_title + "#{title.first} | #{I18n.t('hyrax.product_name')} | ID: #{id}" + end + end +end + +Hyrax::FileSetPresenter.prepend(Hyrax::FileSetPresenterDecorator) diff --git a/app/presenters/hyrax/work_show_presenter_decorator.rb b/app/presenters/hyrax/work_show_presenter_decorator.rb new file mode 100644 index 00000000..52aa8407 --- /dev/null +++ b/app/presenters/hyrax/work_show_presenter_decorator.rb @@ -0,0 +1,14 @@ + +# frozen_string_literal: true + +# OVERRIDE Hyrax v3.5.0 to change what appears in the title tags for pages + +module Hyrax + module WorkShowPresenterDecorator + def page_title + "#{title.first} | #{I18n.t('hyrax.product_name')} | ID: #{id}" + end + end +end + +Hyrax::WorkShowPresenter.prepend(Hyrax::WorkShowPresenterDecorator) diff --git a/app/views/_head_tag_extras.html.erb b/app/views/_head_tag_extras.html.erb index d690322c..44caf94e 100644 --- a/app/views/_head_tag_extras.html.erb +++ b/app/views/_head_tag_extras.html.erb @@ -22,3 +22,7 @@ + + + + diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index 6e9082e6..c6dc70ed 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -35,7 +35,7 @@ <%= presenter.attribute_to_html(:event_date, render_as: :faceted, html_dl: true) %> <%= presenter.attribute_to_html(:official_link, render_as: :faceted, html_dl: true) %> <%= presenter.attribute_to_html(:degree, render_as: :faceted, html_dl: true) %> -<%= presenter.attribute_to_html(:level, render_as: :faceted, html_dl: true) %> + <%= presenter.attribute_to_html(:discipline, render_as: :faceted, html_dl: true) %> <%= presenter.attribute_to_html(:degree_granting_institution, render_as: :faceted, html_dl: true) %> <%= presenter.attribute_to_html(:advisor, render_as: :faceted, html_dl: true) %> diff --git a/app/views/hyrax/base/_citations.html.erb b/app/views/hyrax/base/_citations.html.erb new file mode 100644 index 00000000..7087632f --- /dev/null +++ b/app/views/hyrax/base/_citations.html.erb @@ -0,0 +1,35 @@ + + +
+ Note: + These citations are programmatically generated and may be incomplete. +
+