diff --git a/.gitignore b/.gitignore index 48a309237..5a9b95519 100644 --- a/.gitignore +++ b/.gitignore @@ -146,7 +146,6 @@ assets/upload/* !assets/upload/index.html *_dev -snippets # profiler *.profile diff --git a/apps/cms/templatetags/readux_templatetags.py b/apps/cms/templatetags/readux_templatetags.py index e9b708e0b..66d0e3d2b 100644 --- a/apps/cms/templatetags/readux_templatetags.py +++ b/apps/cms/templatetags/readux_templatetags.py @@ -2,7 +2,23 @@ register = Library() + @register.filter_function def order_by(queryset, args): - args = [x.strip() for x in args.split(',')] + args = [x.strip() for x in args.split(",")] return queryset.order_by(*args) + + +@register.filter +def dict_item(dictionary, key): + """'Template filter to allow accessing dictionary value by variable key. + Example use:: + + {{ mydict|dict_item:keyvar }} + """ + # adapted from Princeton-CDH/geniza project https://github.com/Princeton-CDH/geniza/ + try: + return dictionary[key] + except AttributeError: + # fail silently if something other than a dict is passed + return None diff --git a/apps/static/css/project.css b/apps/static/css/project.css index cfef32f3b..840b2e05e 100644 --- a/apps/static/css/project.css +++ b/apps/static/css/project.css @@ -41,6 +41,20 @@ em { border: 1px solid transparent; } +#search-form .scope-and-keyword { + display: flex; + flex-flow: row nowrap; + margin: 1rem 0 0; + gap: 0.5rem; +} + +#search-form .scope-and-keyword .scope { + flex: 0 1 auto; +} +#search-form .scope-and-keyword .keyword { + flex: 1 0 auto; +} + .uk-tab > .uk-active > a { border-color: var(--link-color) !important; color: var(--link-color) !important; } @@ -1829,12 +1843,35 @@ ol#search-results dl { margin-left: 2rem; } /* Clamp summary to 3 lines */ -ol#search-results dd.result-volume-summary { +ol#search-results .result-volume-summary { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; } +/* search result highlighting */ +ol#search-results em { + color: #510029 !important; + font-weight: bold; + font-style: normal; } + +/* results within full text */ +ol#search-results .result-page a { + display: flex; + flex-flow: row nowrap; + justify-content: flex-start; + align-items: center; + font-size: 0.8rem; + gap: 1rem; + padding: 0.25rem 1rem; } + +ol#search-results .result-page .page-number { + min-width: 2rem; + max-width: 2rem;} +ol#search-results .result-page img { + max-width: 100px; + max-height: 100px; } + .sr-only { position: absolute; width: 1px; diff --git a/apps/templates/search_results.html b/apps/templates/search_results.html index 091a3f2e7..a08889a76 100644 --- a/apps/templates/search_results.html +++ b/apps/templates/search_results.html @@ -48,16 +48,21 @@

Search

accept-charset="utf-8" >
-
-
- - {{ form.q }} +
+
+ {{ form.scope }} +
+
+
+ + {{ form.q }} +
- - Search for individual whole keywords. Multiple words will be searched as - 'or' (e.g. Rome London = Rome or London). -
+ + Search for individual whole keywords. Multiple words will be searched as + 'or' (e.g. Rome London = Rome or London). +
{{ form.sort.label }}
{{ form.sort }} diff --git a/apps/templates/snippets/volume_result.html b/apps/templates/snippets/volume_result.html index f8ba8bd09..7d3633bd1 100644 --- a/apps/templates/snippets/volume_result.html +++ b/apps/templates/snippets/volume_result.html @@ -1,3 +1,4 @@ +{% load readux_templatetags %}
  • @@ -7,7 +8,7 @@

    class="nav-link" href="{% url 'volumeall' volume.pid %}" > - {% if volume.meta.highlight.label %} + {% if 'highlight' in volume.meta and volume.meta.highlight.label %} {% for fragment in volume.meta.highlight.label %} {{ fragment|safe }} {% endfor %} @@ -16,7 +17,7 @@

    {% endif %} {% else %} - {% if volume.meta.highlight.label %} + {% if 'highlight' in volume.meta and volume.meta.highlight.label %} {% for fragment in volume.meta.highlight.label %} {{ fragment|safe }} {% endfor %} @@ -34,7 +35,7 @@

    Author{{volume.authors|pluralize}}