Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I19 add campus features #34

Merged
merged 5 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/assets/images/US-InU-K.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/US-InU-N.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/US-InU-Sb.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/US-InU-Se.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/US-InU.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/US-iniu.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/US-inrmiue.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/images/blacklight/arrow-return-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/assets/images/blacklight/campus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/assets/images/blacklight/chevron-double-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions app/assets/stylesheets/arclight.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ $logo-image: image_url('arclight/logo.png') !default;
@import 'bootstrap';
@import 'blacklight/blacklight';
@import 'arclight/application';
@import 'breadcrumbs';
@import 'campus';
@import 'scroll_to_top';
38 changes: 38 additions & 0 deletions app/assets/stylesheets/breadcrumbs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Override breadcrumb heirarchy styles from arclight

.al-show-breadcrumb {
.breadcrumb {
svg {
height: 1rem;
width: 1rem;
fill: #6E757C;
}

.breadcrumb-item:first-of-type::before,
.breadcrumb-item + .breadcrumb-item::before {
content: '';
}

.breadcrumb-item {
display: block;
}

.breadcrumb-item-1 {
padding-left: 1rem;
}

.breadcrumb-item-2 {
.breadcrumb {
padding-left: 1rem;

li:last-child:not(:first-child) {
padding-left: 1rem;
}
}
}

.breadcrumb-campus-link {
flex: 1 0 100%;
}
}
}
54 changes: 54 additions & 0 deletions app/assets/stylesheets/campus.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.campus {
background-color: #fff;
margin: 1em 0;
border-radius: 1em;
padding: 0.5em;

.campus-header {
margin: 0.1rem;
min-height: 4rem;
font-size: 20px;
}

.campus_image {
height: auto;
display: inline-block;
max-width: 100%;
}

.campus_footer {
margin-top: 0.5em;
}

.campus_link {
margin-bottom: 0;
}

a.button {
text-decoration: none;
}

a:hover {
color: #990000;
background: none;
background-color: transparent;
text-decoration: none;
}

.button {
display: inline-block;
cursor: pointer;
-webkit-appearance: none;
border: 1px solid transparent;
border-width: 2px;
border-radius: 20px;
padding: 0.5625em 1em;
margin: 0 0 1rem;
font-size: 1rem;
background-color: #900;
color: #fff;
font-family: BentonSansBold, Helvetica, Arial, sans-serif;
font-weight: 400;
transition: background-color 0.2s ease-out, color 0.2s ease-out, border-color 0.18s ease-out;
}
}
19 changes: 19 additions & 0 deletions app/assets/stylesheets/scroll_to_top.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// scroll to top button
.scrollToTop {
margin: 0;
position: fixed;
bottom: 8.5%;
right: 0;
z-index: 100;
display: none;
text-decoration: none;
color: #ffffff;
background-color: rgba(153, 0, 0, 0.7);
padding: 10px 20px 10px 10px;
font-size: 12px;
}
.scrollToTop:hover {
background-color: rgba(153, 0, 0, 1);
color: #ffffff;
text-decoration: none;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<%#
OVERRIDE Arclight v1.4.0 to add campus
@see: Ngao::Arclight::BreadcrumbsHierarchyComponent
%>

<ol class="breadcrumb">
<li class="breadcrumb-home-link">
<%= link_to t('arclight.routes.home'), root_path %>
</li>
<li class="breadcrumb-campus-link">
<span aria-hidden="true"><%= blacklight_icon :campus, classes: 'al-collection-content-icon' %></span>
<span class="breadcrumb-text"><%= @campus %></span>
</li>
<li class="breadcrumb-item breadcrumb-item-1">
<span aria-hidden="true"><%= blacklight_icon :repository, classes: 'al-repository-content-icon' %></span>
<span class="breadcrumb-text"><%= repository %></span>
<ol class="breadcrumb">
<% if collection %>
<li class="breadcrumb-item breadcrumb-item-2">
<span aria-hidden="true"><%= blacklight_icon 'arrow-return-right', classes: 'al-collection-content-icon' %></span>
<span class="breadcrumb-text"><%= link_to collection.label, solr_document_path(collection.id) %></span>

<ol class="breadcrumb">
<% parents_under_collection.each do |parent| %>
<li class="breadcrumb-item breadcrumb-item-3">
<span aria-hidden="true"><%= blacklight_icon 'arrow-return-right', classes: 'al-collection-content-icon' %></span>
<span class="breadcrumb-text"><%= link_to parent.label, solr_document_path(parent.id) %></span>
</li>
<% end %>

<li class="breadcrumb-item breadcrumb-item-4">
<span aria-hidden="true"><%= blacklight_icon 'arrow-return-right', classes: 'al-collection-content-icon' %></span>
<span class="breadcrumb-text"><%= @presenter.heading %></span>
</li>
</ol>
</li>
<% else # this is a collection %>
<li class="breadcrumb-item breadcrumb-item-4">
<span aria-hidden="true"><%= blacklight_icon 'arrow-return-right', classes: 'al-collection-content-icon' %></span>
<span class="breadcrumb-text"><%= @presenter.heading %></span>
</li>
<% end %>
</ol>
</li>
</ol>
25 changes: 25 additions & 0 deletions app/components/ngao/arclight/breadcrumbs_hierarchy_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

# Using inheritance to override the initialize method to add the campus

module Ngao
module Arclight
class BreadcrumbsHierarchyComponent < ::Arclight::BreadcrumbsHierarchyComponent
include CampusHelper

def initialize(presenter:)
super

@campus = add_campus_link(presenter.document)
end

private

def add_campus_link(document)
campus_name = content_tag(:span, convert_campus_id(document.campus))
search_query = "/?f[campus_unit_sim][]=#{document.campus}&q=&search_field=all_fields"
link_to(campus_name, search_query)
end
end
end
end
23 changes: 23 additions & 0 deletions app/controllers/arclight/repositories_controller_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# OVERRIDE: Arclight v1.4.0 to add campus level
module Arclight
module RepositoriesControllerDecorator
def index
super
set_campuses
end

private

def set_campuses
@campuses =
@repositories.group_by(&:campus)
.sort do |a, b|
helpers.convert_campus_id(a.first).downcase <=> helpers.convert_campus_id(b.first).downcase
end
end
end
end

Arclight::RepositoriesController.prepend(Arclight::RepositoriesControllerDecorator)
7 changes: 6 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class CatalogController < ApplicationController
# config.show.title_field = 'title_display'
config.show.document_component = Arclight::DocumentComponent
config.show.sidebar_component = Arclight::SidebarComponent
config.show.breadcrumb_component = Arclight::BreadcrumbsHierarchyComponent
config.show.breadcrumb_component = Ngao::Arclight::BreadcrumbsHierarchyComponent
config.show.embed_component = UniversalViewer
config.show.access_component = Arclight::AccessComponent
config.show.online_status_component = Arclight::OnlineStatusIndicatorComponent
Expand Down Expand Up @@ -138,6 +138,7 @@ class CatalogController < ApplicationController
# :index_range can be an array or range of prefixes that will be used to create the navigation
# (note: It is case sensitive when searching values)

config.add_facet_field 'campus_unit_sim', label: 'Campus', helper_method: :render_campus_facet
config.add_facet_field 'collection', field: 'collection_ssim', limit: 10
config.add_facet_field 'creators', field: 'creator_ssim', limit: 10
config.add_facet_field 'date_range', field: 'date_range_isim', range: true
Expand All @@ -152,6 +153,8 @@ class CatalogController < ApplicationController
# handler defaults, or have no facets.
config.add_facet_fields_to_solr_request!

config.add_index_field 'campus_unit_ssm', label: 'Campus', helper_method: :render_campus_name

# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
config.add_index_field 'highlight', accessor: 'highlights', separator_options: {
Expand Down Expand Up @@ -423,6 +426,8 @@ class CatalogController < ApplicationController
# Collection and Component Show Page Access Tab - How to Cite Section
config.add_cite_field 'prefercite', field: 'prefercite_html_tesm', helper_method: :render_html_tags

config.add_contact_field 'campus_unit_ssm', label: 'Campus', helper_method: :render_campus_name

# Collection and Component Show Page Access Tab - Contact Section
config.add_contact_field 'repository_contact', values: ->(_, document, _) { document.repository_config&.contact }

Expand Down
9 changes: 9 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ module ApplicationHelper
def additional_locale_routing_scopes
[blacklight, arclight_engine]
end

def render_campus_name(args)
key = args[:value] || []
convert_campus_id(key[0])
end

def render_campus_facet(options = {})
convert_campus_id(options)
end
end
23 changes: 23 additions & 0 deletions app/helpers/campus_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module CampusHelper
include ActiveSupport::Concern

CAMPUSES = {
'US-InU' => 'Indiana University Bloomington',
'US-InU-Sb' => 'Indiana University South Bend',
'US-InU-Se' => 'Indiana University Southeast',
'US-inrmiue' => 'Indiana University East',
'US-InU-K' => 'Indiana University Kokomo',
'US-iniu' => 'IUPUI',
'US-InU-N' => 'Indiana University Northwest'
}.freeze

def convert_campus_id(value)
CAMPUSES[value] || 'Indiana University'
end

def campus_image(campus)
"#{campus}.jpg"
end
end
3 changes: 2 additions & 1 deletion app/javascript/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ import bootstrap from "bootstrap"
import githubAutoCompleteElement from "@github/auto-complete-element"
import Blacklight from "blacklight"

import "arclight"
import "arclight"
import "repositories"
28 changes: 28 additions & 0 deletions app/javascript/repositories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
document.addEventListener('DOMContentLoaded', function() {
$('.campus_link').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 160
}, 1000);
return false;
}
}
});

$(window).scroll(function(){
if ($(this).scrollTop() > 600) {
$(".scrollToTop").fadeIn(1000)
} else {
$(".scrollToTop").fadeOut(1000);
}
});

//Click event to scroll to top
$(".scrollToTop").click(function(){
$('html, body').animate({scrollTop : 0},500);
return false;
});
});
12 changes: 12 additions & 0 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,16 @@ class SolrDocument
# and Blacklight::Document::SemanticFields#to_semantic_values
# Recommendation: Use field names from Dublin Core
use_extension(Blacklight::Document::DublinCore)

def campus
collection? ? first('campus_unit_ssm') : collection.first('campus_unit_ssm')
end

def parent_campus
fetch('parent_campus_unit_ssm', [])
end

def containers
fetch('containers_ssim', [])
end
end
16 changes: 16 additions & 0 deletions app/views/arclight/repositories/_campus_card.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="col-xs-6 col-sm-6 col-md-4 col-lg-3">
<div class="campus">
<div class="text-center">
<h3 class="campus-header"><%= convert_campus_id(campus) %></h3>
</div>
<div>
<%= image_tag(campus_image(campus), class: 'campus_image', alt:"#{convert_campus_id(campus)}") %>
</div>
<div class="text-center campus_footer">
<a class="button campus_link" href="#<%= campus %>">
<div class="sr-only visually-hidden"><%= "Explore #{convert_campus_id(campus)} Repositories" %></div>
<div aria-hidden="true">Explore Repositories</div>
</a>
</div>
</div>
</div>
Loading
Loading