Skip to content

Commit

Permalink
Rangement des données statiques (#2344)
Browse files Browse the repository at this point in the history
* Rangement

* raw date

* meta -> core

* clean

* clean

* clean

* forced_title

* clean

* fix

* fix

---------

Co-authored-by: Sébastien Gaya <sebastien.gaya@gmail.com>
  • Loading branch information
arnaudlevy and SebouChu authored Oct 31, 2024
1 parent 335580e commit 16659fc
Show file tree
Hide file tree
Showing 30 changed files with 151 additions and 213 deletions.
4 changes: 4 additions & 0 deletions app/models/research/publication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class Research::Publication < ApplicationRecord
", term: "%#{sanitize_sql_like(term)}%")
}

def published_at
publication_date
end

def editable?
source == 'osuny'
end
Expand Down
4 changes: 1 addition & 3 deletions app/views/admin/administration/locations/static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
location = @l10n.about
language = @l10n.language
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: location,
Expand Down
69 changes: 69 additions & 0 deletions app/views/admin/application/static/_core.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<%
# Partial arguments
forced_title ||= nil
forced_slug ||= nil
skip_date ||= false
# Preparing variables
title = forced_title || about.to_s
show_subtitle = about.respond_to?(:subtitle)
show_date = about.respond_to?(:published_at) && !skip_date
show_published_at = about.respond_to?(:published_at)
if about.respond_to?(:slug) && about.slug.present?
slug = forced_slug || about.slug
end
if @website
previous_permalinks = about.previous_permalinks_in_website(@website)
hugo = about.hugo(@website) if about.respond_to?(:hugo)
end
%>
<%
#############
# Title and subtitle
#############
%>
title: >-
<%= prepare_text_for_static title %>
<% if show_subtitle %>
subtitle: >-
<%= prepare_text_for_static about.subtitle %>
<% end %>
<%
#############
# Permalinks
#############
%>
<% if @website %>
url: "<%= about.current_permalink_in_website(@website)&.path %>"
<% if slug %>
slug: "<%= slug %>"
<% end %>
<% if previous_permalinks.any? %>
aliases:
<% previous_permalinks.each do |permalink| %>
- <%= permalink.path %>
<% end %>
<% end %>
<% end %>
<%
#############
# Dates & meta
#############
%>
<% if show_date %>
date: <%= about.published_at&.iso8601 %>
<% end %>
lastmod: <%= about.updated_at&.iso8601 %>
meta:
<% if hugo %>
hugo:
permalink: "<%= hugo.permalink %>"
file: "<%= hugo.file %>"
path: "<%= hugo.path %>"
slug: "<%= hugo.slug %>"
<% end %>
dates:
created_at: <%= about.created_at&.iso8601 %>
updated_at: <%= about.updated_at&.iso8601 %>
<% if show_published_at %>
published_at: <%= about.published_at&.iso8601 %>
<% end %>
13 changes: 0 additions & 13 deletions app/views/admin/application/static/_design.json.jbuilder

This file was deleted.

29 changes: 0 additions & 29 deletions app/views/admin/application/static/_permalink.html.erb

This file was deleted.

10 changes: 0 additions & 10 deletions app/views/admin/application/static/_permalink.json.jbuilder

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<%
category = @l10n.about
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: category,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,7 @@
event = @l10n.about
language = @l10n.language
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
subtitle: >-
<%= prepare_text_for_static @l10n.subtitle %>
<%
# https://github.com/osunyorg/admin/issues/1880
if event.archive? %>
date: "<%= event.from_day&.iso8601 %>"
<% elsif event.current? %>
weight: -1
date: "<%= event.from_day&.iso8601 %>"
<% else %>
weight: <%= event.distance_in_days %>
<% end %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n, skip_date: true %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: event,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
<%
depth ||= 0
indentation = ' ' * depth
%>
<%= indentation %>dates:
<%= indentation %> status: "<%= event.status %>"
<%= indentation %> archive: <%= event.archive? %>
<%= indentation %> computed:
<%= indentation %> short: >-
<%= indentation %> <%= date_range_i18n(event.from_day, event.to_day, format: :short, locale: locale) %>
<%= indentation %> long: >-
<%= indentation %> <%= date_range_i18n(event.from_day, event.to_day, format: :long, locale: locale) %>
<%= indentation %> two_lines:
<%= indentation %> short: >-
<%= indentation %> <%= date_range_i18n(event.from_day, event.to_day, format: :short, layout: :two_lines, locale: locale) %>
<%= indentation %> long: >-
<%= indentation %> <%= date_range_i18n(event.from_day, event.to_day, format: :long, layout: :two_lines, locale: locale) %>
<%= indentation %> from:
<%= indentation %> day: <%= event.from_day %>
# Dates override default dates in core, so it comes after
# https://github.com/osunyorg/admin/issues/1880
if event.archive? %>
date: "<%= event.from_day&.iso8601 %>"
<% elsif event.current? %>
weight: -1
date: "<%= event.from_day&.iso8601 %>"
<% else %>
weight: <%= event.distance_in_days %>
<% end %>
dates:
status: "<%= event.status %>"
archive: <%= event.archive? %>
computed:
short: >-
<%= date_range_i18n(event.from_day, event.to_day, format: :short, locale: locale) %>
long: >-
<%= date_range_i18n(event.from_day, event.to_day, format: :long, locale: locale) %>
two_lines:
short: >-
<%= date_range_i18n(event.from_day, event.to_day, format: :short, layout: :two_lines, locale: locale) %>
long: >-
<%= date_range_i18n(event.from_day, event.to_day, format: :long, layout: :two_lines, locale: locale) %>
from:
day: <%= event.from_day %>
<% if event.from_hour %>
<%= indentation %> hour: <%= event.from_hour.strftime "%H:%M" %>
hour: <%= event.from_hour.strftime "%H:%M" %>
<% end %>
<%= indentation %> to:
<%= indentation %> day: <%= event.to_day || event.from_day %>
to:
day: <%= event.to_day || event.from_day %>
<% if event.to_hour %>
<%= indentation %> hour: <%= event.to_hour.strftime "%H:%M" %>
hour: <%= event.to_hour.strftime "%H:%M" %>
<% end %>
<%= indentation %> add_to_calendar:
<%= indentation %> google: "<%= l10n.cal_google_url.html_safe %>"
<%= indentation %> yahoo: "<%= l10n.cal_yahoo_url.html_safe %>"
<%= indentation %> office: "<%= l10n.cal_office_url.html_safe %>"
<%= indentation %> outlook: "<%= l10n.cal_outlook_url.html_safe %>"
<%= indentation %> ical: "<%= l10n.cal_ical_url.html_safe %>"
add_to_calendar:
google: "<%= l10n.cal_google_url.html_safe %>"
yahoo: "<%= l10n.cal_yahoo_url.html_safe %>"
office: "<%= l10n.cal_office_url.html_safe %>"
outlook: "<%= l10n.cal_outlook_url.html_safe %>"
ical: "<%= l10n.cal_ical_url.html_safe %>"
4 changes: 1 addition & 3 deletions app/views/admin/communication/websites/pages/static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
page = @l10n.about
language = @l10n.language
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
breadcrumb_title: >-
<%= prepare_text_for_static @l10n.best_breadcrumb_title %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: page,
Expand Down
30 changes: 0 additions & 30 deletions app/views/admin/communication/websites/pages/static.json.jbuilder

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<%
category = @l10n.about
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: category,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
project = @l10n.about
%>
---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
subtitle: >-
<%= prepare_text_for_static @l10n.subtitle %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
full_width: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<%
category = @l10n.about
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
<%= render 'admin/application/static/permalink',
about: @l10n,
<%= render 'admin/application/static/core', about: @l10n,
forced_slug: @l10n.slug_with_ancestors_slugs(separator: '-') %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
Expand Down
7 changes: 1 addition & 6 deletions app/views/admin/communication/websites/posts/static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@
post = @l10n.about
language = @l10n.language
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
subtitle: >-
<%= prepare_text_for_static @l10n.subtitle %>
date: "<%= @l10n.published_at&.iso8601 %>"
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: post,
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/communication/websites/static.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<%# TODO: Title should be removed safely as website title is now in languages config file. %>
title: >-
<%= prepare_text_for_static @website.original_localization.to_s %>
default:
<% if @website.default_image.attached? %>
image:
Expand Down
4 changes: 1 addition & 3 deletions app/views/admin/education/diplomas/static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ language = @l10n.language
.published_now_in(language)
.ordered if @website.present?
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: diploma,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<%
category = @l10n.about
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: category,
Expand Down
4 changes: 1 addition & 3 deletions app/views/admin/education/programs/static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ administrator_involvements = program.involvements_through_roles
.includes(:person)
.ordered_by_name(language)
%>---
title: >-
<%= prepare_text_for_static @l10n.to_s %>
<%= render 'admin/application/static/permalink', about: @l10n %>
<%= render 'admin/application/static/core', about: @l10n %>
<%= render 'admin/application/static/breadcrumbs', about: @l10n %>
<%= render 'admin/application/static/design',
about: program,
Expand Down
Loading

0 comments on commit 16659fc

Please sign in to comment.