From 5aba54fcdbf7b59a38bb4361f3f251654fc42400 Mon Sep 17 00:00:00 2001 From: koilebeit Date: Thu, 31 Oct 2024 16:23:15 +0100 Subject: [PATCH] change sort order, remove period heading --- _layouts/timeline_edtf.html | 10 +++++----- _plugins/sort_edtf.rb | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/_layouts/timeline_edtf.html b/_layouts/timeline_edtf.html index e7a45f96..f33c5c33 100644 --- a/_layouts/timeline_edtf.html +++ b/_layouts/timeline_edtf.html @@ -50,13 +50,13 @@ {%- endif -%} {{ content }} - -

+{% comment %}uncomment on the next lines to display a heading indicating the period of the data in text form{% endcomment %} +{% comment %}

{% assign first_year = sorted_years | first | split: ':' %} {% assign last_year = sorted_years | last | split: ':' %} {% if sorted_years.size > 0 %} - {% if first_year.size == 2 - and last_year.size == 2 + {% if first_year.size == 3 + and last_year.size == 3 and first_year[0] != '' and first_year[1] != '' and last_year[0] != '' @@ -70,7 +70,7 @@

{% else %} No items found {% endif %} -

+ {% endcomment %} diff --git a/_plugins/sort_edtf.rb b/_plugins/sort_edtf.rb index 4be171a4..c9e073b5 100644 --- a/_plugins/sort_edtf.rb +++ b/_plugins/sort_edtf.rb @@ -20,7 +20,7 @@ def compute_numeric_value(cleaned_str) def create_display_format(str) if str.start_with?('-') - "#{str[1..-1].sub(/^0+/, '')} v. Chr." + "#{str[1..-1].sub(/^0+/, '')} v. u. Z." else str.sub(/^0+(?=\d)/, '') end @@ -30,14 +30,14 @@ def sort_edtf(array_of_strings) valid_dates = array_of_strings.reject { |str| str.strip.empty? } parsed_dates = valid_dates.map do |str| - cleaned_str = clean_date_string(str) - numeric_value = compute_numeric_value(cleaned_str) - display_format = create_display_format(str) + cleaned_str = clean_date_string(str) + numeric_value = compute_numeric_value(cleaned_str) + display_format = create_display_format(str) - { numeric: numeric_value, original: str, display_format: display_format } + { numeric: numeric_value, original: str, display_format: display_format } end - sorted_dates = parsed_dates.sort_by { |date| date[:numeric] } + sorted_dates = parsed_dates.sort_by { |date| -date[:numeric] } sorted_dates.map { |date| "#{date[:display_format]}:#{date[:original]}" } end end