forked from CollectionBuilder/collectionbuilder-csv
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* wip * customize relevant buttons to new timeline * delete temp file * make coderabbit happy
- Loading branch information
Showing
9 changed files
with
141 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
--- | ||
# "Timeline" page | ||
layout: page | ||
custom-foot: js/timeline-js.html | ||
--- | ||
{%- assign field = site.data.theme.timeline-field | default: "date" -%} | ||
{% if site.data.theme.timeline-child-objects == true %} | ||
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid' -%} | ||
{% else %} | ||
{%- assign items = site.data[site.metadata] | where_exp: 'item','item.objectid and item.parentid == nil' -%} | ||
{% endif %} | ||
{%- assign items = items | where_exp: 'item','item[field]' -%} | ||
{%- assign raw-dates = items | map: field | compact | uniq -%} | ||
{% assign regex = '[\dX]{4}' %} | ||
{%- capture clean-years -%}{% for date in raw-dates %}{{date | regex_match: regex | join: ';' }}{% unless forloop.last %};{% endunless %}{%- endfor -%}{%- endcapture -%} | ||
{%- assign uniqueYears = clean-years | remove: " " | replace: ";;",";" | split: ";" | uniq | sort -%} | ||
{%- if site.data.theme.year-navigation -%} | ||
{%- assign navYears = site.data.theme.year-navigation | split: ";" -%} | ||
{%- elsif site.data.theme.year-nav-increment -%} | ||
{%- capture navYears -%} | ||
{%- for i in uniqueYears -%}{%- assign t = i | modulo: site.data.theme.year-nav-increment -%} | ||
{%- if t == 0 -%}{{ i }}{% unless forloop.last %};{% endunless %}{% endif %}{% endfor %}{%- endcapture -%} | ||
{%- assign navYears = navYears | split: ";" -%} | ||
{%- endif -%} | ||
{%- if navYears -%} | ||
<div class="dropdown float-end" id="year-nav"> | ||
<button class="btn btn-primary dropdown-toggle" type="button" id="yearButton" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
Year | ||
</button> | ||
<div class="dropdown-menu" aria-labelledby="yearButton"> | ||
{% for y in navYears %} | ||
<a class="dropdown-item" href="#y{{ y }}">{{ y }}</a>{% endfor %} | ||
</div> | ||
</div> | ||
{%- endif -%} | ||
|
||
{{ content }} | ||
|
||
<h3><a href="#y{{ uniqueYears | first }}">{{ uniqueYears | first }}</a> to <a href="#y{{ uniqueYears | last }}">{{ uniqueYears | last }}</a></h3> | ||
|
||
<table id="timeline" class="table table-striped"> | ||
<tbody> | ||
{% for year in uniqueYears %} | ||
<tr id="y{{ year }}"> | ||
<th> | ||
<h3>{{ year }}</h3> | ||
</th> | ||
<td> | ||
<div class="row"> | ||
{%- assign inYear = items | where_exp: 'item', 'item[field] contains year' -%} | ||
{% for item in inYear %} | ||
<div class="col-lg-4 col-md-6"> | ||
<figure class="figure"> | ||
<a href="{% if item.parentid == nil %}{{ '/items/' | append: item.objectid | append: '.html' | relative_url }}{% elsif item.parentid %}{{ '/items/' | append: item.parentid | append: '.html' | relative_url }}#{{item.objectid }}{% endif %}" > | ||
{% if item.image_thumb %} | ||
<img class="lazyload img-thumbnail timeline-thumb" src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 3 2'%3E%3C/svg%3E" data-src="{{ item.image_thumb | relative_url }}" alt="{{ item.image_alt_text | default: item.description | default: item.title | escape }}" data-bs-toggle="tooltip" data-bs-placement="bottom" title="{{ item.title | escape }}"> | ||
{% else %} | ||
<div class="card"> | ||
<div class="card-body text-center"> | ||
<div class="h5 text-dark">{{ item.title }}</div> | ||
<svg class="bi timeline-thumb text-body" fill="currentColor" aria-hidden="true"> | ||
{%- assign icon_template = item.display_template | default: item.format -%} | ||
<use xlink:href="{{ '/assets/lib/cb-icons.svg' | relative_url }}#{% if icon_template contains 'image' %}icon-image{% elsif icon_template contains 'pdf' %}icon-pdf{% elsif icon_template contains 'audio' %}icon-audio{% elsif icon_template contains 'video' %}icon-video{% elsif icon_template contains 'panorama' %}icon-panorama{% elsif icon_template contains 'compound' %}icon-compound-object{% elsif icon_template contains 'multiple' %}icon-multiple{% else %}icon-default{% endif %}"/> | ||
</svg> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</a> | ||
<figcaption class="figure-caption">{{item.date}}</figcaption> | ||
</figure> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module Jekyll | ||
module RegexMatch | ||
def regex_match(input_str, regex_str) | ||
begin | ||
regex = Regexp.new(regex_str) | ||
input_str.scan(regex).flatten | ||
rescue RegexpError => e | ||
# Handle invalid regex pattern | ||
return [] | ||
end | ||
end | ||
|
||
def regex_match_once(input_str, regex_str) | ||
begin | ||
regex = Regexp.new(regex_str) | ||
match = input_str.match(regex) | ||
return match.nil? ? nil : match[0] | ||
rescue RegexpError => e | ||
# Handle invalid regex pattern | ||
return nil | ||
end | ||
end | ||
end | ||
end | ||
|
||
Liquid::Template.register_filter(Jekyll::RegexMatch) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Jekyll | ||
module SortEDTF | ||
def sort_edtf(array_of_strings) | ||
sorted = array_of_strings.map { |str| str.gsub('X', '0') } | ||
sorted.sort_by { |str| str[/\d+/].to_i } | ||
end | ||
end | ||
end | ||
|
||
Liquid::Template.register_filter(Jekyll::SortEDTF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
title: Timeline | ||
layout: timeline | ||
layout: timeline_edtf | ||
permalink: /timeline.html | ||
--- | ||
|
||
|