Skip to content

Commit

Permalink
change sort order, remove period heading
Browse files Browse the repository at this point in the history
  • Loading branch information
koilebeit committed Oct 31, 2024
1 parent e855c1e commit 5aba54f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions _layouts/timeline_edtf.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
{%- endif -%}

{{ content }}

<h2>
{% comment %}uncomment on the next lines to display a heading indicating the period of the data in text form{% endcomment %}
{% comment %} <h2>
{% 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] != ''
Expand All @@ -70,7 +70,7 @@ <h2>
{% else %}
<span class="text-muted">No items found</span>
{% endif %}
</h2>
</h2> {% endcomment %}

<table id="timeline" class="table table-striped">
<tbody>
Expand Down
12 changes: 6 additions & 6 deletions _plugins/sort_edtf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 5aba54f

Please sign in to comment.