Skip to content

Commit

Permalink
Merge pull request #1051 from ecds/feature/956-single-vol-search
Browse files Browse the repository at this point in the history
Feature/956 single vol search
  • Loading branch information
yl5682 authored Aug 28, 2024
2 parents 473046d + 62cc0e6 commit dd52a50
Show file tree
Hide file tree
Showing 45 changed files with 2,972 additions and 588 deletions.
31 changes: 31 additions & 0 deletions apps/readux/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,27 @@ class PageDetail(TemplateView):
"""Django Template View for :class:`apps.iiif.canvases.models.Canvas`"""
template_name = "page.html"

def get_metadatum(self, volume, key):
"""Attempt to retrieve a value from a volume's metadata by key. If it cannot
be found, return an empty string."""
if hasattr(volume, key):
# first try volume's model attributes
return getattr(volume, key)
elif isinstance(volume.metadata, dict):
# if not a model attr, attempt to get value from volume metadata;
# if metadata is a dict (rare), just lookup by key
return volume.metadata.get(key, "")
else:
# if metadata is a list (more common / correct IIIF spec), find the matching
# "label" attribute by key
meta_list = list(volume.metadata)
metadatum = filter(lambda m: m["label"] == key, meta_list)
try:
# filter() returns an iterator; try to retrieve the first matching entry's value
return next(metadatum).get("value", "") if metadatum else ""
except StopIteration:
return ""

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
manifest = Manifest.objects.get(pid=kwargs['volume'])
Expand Down Expand Up @@ -261,6 +282,16 @@ def get_context_data(self, **kwargs):
context['user_annotation_index'] = user_annotation_index
context['json_data'] = {'json_data': list(user_annotation_index)}

# add custom metadata from django settings to context
if hasattr(settings, 'CUSTOM_METADATA'):
custom_metadata = {}
for key in settings.CUSTOM_METADATA.keys():
# attempt to get this manifest's value for each key
value = self.get_metadatum(manifest, key)
if value:
custom_metadata[key] = value
context["custom_metadata"] = custom_metadata

return context

class ExportOptions(TemplateView, FormMixin):
Expand Down
6 changes: 6 additions & 0 deletions apps/static/css/_components/colors.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Colors
$rx-color-grey-1: #595959;
$rx-color-grey-2: #737373;
$rx-color-grey-3: #eeeeee;
$rx-color-accent-1: #950953;
$rx-color-accent-2: #510029;
80 changes: 80 additions & 0 deletions apps/static/css/_components/uk-switch.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@import './colors.scss';

.uk-switch {
position: relative;
display: inline-block;
height: 17px;
width: 30px;
}

/* Hide default HTML checkbox */
.uk-switch input {
display: none;
}

/* Slider */
.uk-switch-slider {
background-color: rgba(0, 0, 0, 0.22);
position: absolute;
top: 0;
left: 0;
right: 0;
border-radius: 500px;
bottom: 0;
cursor: pointer;
transition-property: background-color;
transition-duration: .2s;
box-shadow: inset 0 0 2px rgba(0, 0, 0, 0.07);
}

/* Switch pointer */
.uk-switch-slider:before {
content: '';
background-color: #fff;
position: absolute;
width: 15px;
height: 15px;
left: 1px;
bottom: 1px;
border-radius: 50%;
transition-property: transform, box-shadow;
transition-duration: .2s;
}

/* Slider active color */
input:checked+.uk-switch-slider {
background-color: $rx-color-accent-1 !important;
}

/* Pointer active animation */
input:checked+.uk-switch-slider:before {
transform: translateX(13px);
}

/* Modifiers */
.uk-switch-slider.uk-switch-on-off {
background-color: #f0506e;
}

input:checked+.uk-switch-slider.uk-switch-on-off {
background-color: #32d296 !important;
}

/* Style Modifier */
.uk-switch-slider.uk-switch-big:before {
transform: scale(1.2);
box-shadow: 0 0 6px rgba(0, 0, 0, 0.22);
}

.uk-switch-slider.uk-switch-small:before {
box-shadow: 0 0 6px rgba(0, 0, 0, 0.22);
}

input:checked+.uk-switch-slider.uk-switch-big:before {
transform: translateX(13px) scale(1.2);
}

/* Inverse Modifier - affects only default */
.uk-light .uk-switch-slider:not(.uk-switch-on-off) {
background-color: rgba(255, 255, 255, 0.22);
}
167 changes: 152 additions & 15 deletions apps/static/css/project.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Colors
$rx-color-grey-1: #595959;
$rx-color-grey-2: #737373;
$rx-color-grey-3: #eeeeee;
$rx-color-accent-1: #950953;
$rx-color-accent-2: #510029;

@import './ecds-annotator.min.css';
@import './_components/colors.scss';
@import './_components/uk-switch.scss';

.selectize-control.plugin-clear_button .clear {
top: -3px !important;
Expand Down Expand Up @@ -556,11 +551,11 @@ p {
min-width: 65px;
}

.rx-breadcrumb-item:not(:last-child)::after,
.rx-page-breadcrumb-item:not(:last-child)::after {
content: "-";
padding: 0 0.5em;
}
// .rx-breadcrumb-item:not(:last-child)::after,
// .rx-page-breadcrumb-item:not(:last-child)::after {
// content: "-";
// padding: 0 0.5em;
// }

.rx-page-title-container {
padding: 0 15px;
Expand Down Expand Up @@ -616,6 +611,9 @@ p {
.rx-info-content {
padding: 0 0 1.25em;
font-size: 0.9rem;
&:last-child {
padding: 0;
}
}

.rx-info-content-label {
Expand Down Expand Up @@ -831,10 +829,10 @@ p {
border: var(--link-color) 1px solid;
font-size: 0.75rem;
letter-spacing: 0.1rem;
opacity: 0.75;
cursor: pointer;
transition: all ease-in-out 100ms;
font-weight: 600;
font-family: 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', 'monospace' !important;

&:active {
background-color: $rx-color-accent-2 !important;
Expand All @@ -852,6 +850,14 @@ p {
}
}

.rx-action-btn:hover .rx-label-copy {
background: var(--link-color);
color: white !important;
font-size: 0.75rem;
letter-spacing: 0.1rem;
cursor: pointer;
opacity: 1;
}

.rx-label-solid {
background: var(--link-color);
Expand Down Expand Up @@ -1334,8 +1340,59 @@ fieldset {
height: 150px;
width: 100%;
}

.rx-volume-title {
font-size: 1rem;
font-weight: bold;
color: var(--link-color);

&:hover {
color: $rx-color-accent-2;
}
}
// end of rx-title

.rx-breadcrumb-item {
font-size: 1rem;
font-weight: bold;
color: var(--link-color);
&:hover {
color: $rx-color-accent-2;
}
}

// properly indent bullet items in the breadcrumb
.uk-navbar li {
text-indent: -1em !important; /* Negative indent to pull first line back */
padding-left: 1em !important; /* Padding to offset the negative indent */

// &::marker {
// content: "↳ "; /* Custom bullet symbol */
// position: absolute;
// left: 0;
// }
}

.uk-navbar li:first-child {
// &::marker {
// content: ""; /* Custom bullet symbol */
// position: absolute;
// left: 0;
// }
}

.long-and-truncated.rx-volume-title {
display: flex;
align-items: center;
}

.long-and-truncated.rx-volume-title .uk-icon {
display: flex;
align-items: center;
margin-left: 8px; /* Optional: Add space between text and icon */
}
// End of breadcrumb

@media (max-width: 395px) {
header#page-bg .collection-label h1 {
font-size: 0.7em;
Expand Down Expand Up @@ -1599,6 +1656,37 @@ fieldset {
}
}

.rx-accordion-head {
background: white;
color: var(--link-color);
border: var(--link-color) 1px solid;
font-size: 0.85rem;
letter-spacing: 0.1rem;
cursor: pointer;
transition: all ease-in-out 100ms;
font-weight: 600;
font-family: 'Consolas', 'Monaco', 'Andale Mono', 'Ubuntu Mono', 'monospace' !important;

&::before {
color: white;
}

&:active {
background-color: $rx-color-accent-2 !important;
border: 1px solid $rx-color-accent-2 !important;
opacity: 1;
}

&:hover {
background: var(--link-color);
color: white !important;
font-size: 0.85rem;
letter-spacing: 0.1rem;
cursor: pointer;
opacity: 1;
}
}

.rx-accordion-handle {
color: var(--link-color) !important;
}
Expand Down Expand Up @@ -1669,7 +1757,7 @@ a.nav-link {
}

.uk-navbar-right {
padding-top: 1rem;
// padding-top: 1rem;
}

.uk-container ul {
Expand Down Expand Up @@ -3503,8 +3591,57 @@ ol#search-results dl {
padding: 10px;
}

.rx-scrollable {
.uk-accordion>:nth-child(n+2) {
margin-top: 10px;
}

.rx-scrollable-area {
max-height: 75vh; /* Maximum height set to 100% of the viewport height */
overflow-y: auto; /* Enables vertical scrolling */
margin-right: -5px;
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */

&::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
}


.padding-right-1rem {
padding-right: 1rem;
}

/* Override the minus sign in UI Kit accordion */
.uk-open > .uk-accordion-title::before {
/* "-" Change the stroke color of the accordion icons to white */
background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2213%22%20height%3D%2213%22%20viewBox%3D%220%200%2013%2013%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%20%20%20%20%3Crect%20fill%3D%22%23950953%22%20width%3D%2213%22%20height%3D%221%22%20x%3D%220%22%20y%3D%226%22%20%2F%3E%0A%3C%2Fsvg%3E);
}

.uk-open > .uk-accordion-title:hover {
/* "-" Change the stroke color of the accordion icons to white */
&::before {
background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2213%22%20height%3D%2213%22%20viewBox%3D%220%200%2013%2013%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%20%20%20%20%3Crect%20fill%3D%22%23fff%22%20width%3D%2213%22%20height%3D%221%22%20x%3D%220%22%20y%3D%226%22%20%2F%3E%0A%3C%2Fsvg%3E)
}
}

.uk-accordion-title::before {
/* "+" Change the stroke color of the accordion icons to white */
background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2213%22%20height%3D%2213%22%20viewBox%3D%220%200%2013%2013%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%20%20%20%20%3Crect%20fill%3D%22%23950953%22%20width%3D%2213%22%20height%3D%221%22%20x%3D%220%22%20y%3D%226%22%20%2F%3E%0A%20%20%20%20%3Crect%20fill%3D%22%23950953%22%20width%3D%221%22%20height%3D%2213%22%20x%3D%226%22%20y%3D%220%22%20%2F%3E%0A%3C%2Fsvg%3E);
}

.uk-accordion-title:hover {
/* "+" Change the stroke color of the accordion icons to white */
&::before {
background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20width%3D%2213%22%20height%3D%2213%22%20viewBox%3D%220%200%2013%2013%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%0A%20%20%20%20%3Crect%20fill%3D%22%23fff%22%20width%3D%2213%22%20height%3D%221%22%20x%3D%220%22%20y%3D%226%22%20%2F%3E%0A%20%20%20%20%3Crect%20fill%3D%22%23fff%22%20width%3D%221%22%20height%3D%2213%22%20x%3D%226%22%20y%3D%220%22%20%2F%3E%0A%3C%2Fsvg%3E);
}
}

/* End */


.uk-padding-1-2 {
padding: 0.5rem;
}
/* Set the theme color of the component */
// $themeColor: #df3f13;
Expand Down
Loading

0 comments on commit dd52a50

Please sign in to comment.