Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions app/helpers/admin/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,6 @@ def submit(form, **options)
**options
end

def prepare_html_for_static(text)
university = current_university || @website&.university || @about&.university
html = Static::Html.new(text, about: @about, university: university).prepared
# Les notes vont de 1 à n sur la page, il faut donc que l'index soit pour toute la page (tout le fichier static).
# C'est pour cela qu'on passe par le helper, ce qui garde @index.
prepare_notes html
end

def prepare_text_for_static(text, depth: 1)
Static::Text.new(text, depth: depth, about: @about).prepared
end

def prepare_code_for_static(text, depth: 1)
Static::Code.new(text, depth: depth, about: @about).prepared
end

def has_content?(html)
strip_tags(html.to_s).present?
end
Expand All @@ -125,12 +109,6 @@ def indent(text, depth)
text
end

def prepare_media_for_static(object, key)
media = object[key]['id']
rescue
''
end

def collection(list)
list.ordered.map do |e|
{
Expand Down
40 changes: 40 additions & 0 deletions app/helpers/admin/osuny_static_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
module Admin::OsunyStaticHelper

def prepare_html_for_static(text)
university = current_university || @website&.university || @about&.university
html = Static::Html.new(text, about: @about, university: university).prepared
# Les notes vont de 1 à n sur la page, il faut donc que l'index soit pour toute la page (tout le fichier static).
# C'est pour cela qu'on passe par le helper, ce qui garde @index.
prepare_notes html
end

def prepare_text_for_static(text, depth: 1)
Static::Text.new(text, depth: depth, about: @about).prepared
end

def prepare_code_for_static(text, depth: 1)
Static::Code.new(text, depth: depth, about: @about).prepared
end

def prepare_media_for_static(object, key)
media = object[key]['id']
rescue
''
end

def osuny_static_text(key, value, depth: 1)
return if value.blank?
indentation = ' ' * (depth-1)
prepared = prepare_text_for_static(value)
raw "#{indentation}#{key}: >-\n#{indentation} #{prepared}"
end

def osuny_static_html(key, value, depth: 1)
text = strip_tags(value.to_s)
return if text.blank?
indentation = ' ' * (depth-1)
prepared = prepare_html_for_static(value)
raw "#{indentation}#{key}: >-\n#{indentation} #{prepared}"
end

end
4 changes: 4 additions & 0 deletions app/services/osuny/address_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def city
about.try(:city)
end

def country?
country.present?
end

def country
country_object&.common_name || country_string
end
Expand Down
7 changes: 3 additions & 4 deletions app/views/admin/administration/locations/static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ language = @l10n.language
toc_offcanvas: true %>
<%= render 'admin/application/l10n/static', about: @l10n %>
<%= render 'admin/application/images/featured/static', about: @l10n %>
<%= render 'admin/application/summary/static', about: @l10n %>
<%= osuny_static_html 'summary', @l10n.summary %>
<%= render 'admin/application/static/hugo/collection',
key: :programs,
collection: location.programs.ordered(language),
Expand All @@ -33,12 +33,11 @@ location.diplomas.ordered.each do |diploma|
hugo = l10n.hugo(@website)
next if hugo.file.blank?
%>
- name: >-
<%= l10n.to_s %>
permalink: "<%= hugo.permalink %>"
- permalink: "<%= hugo.permalink %>"
path: "<%= hugo.path %>"
slug: "<%= hugo.slug %>"
file: "<%= hugo.file %>"
<%= osuny_static_text 'name', l10n.to_s, depth: 3 %>
programs:
<%= render 'admin/education/programs/static_list',
diploma: diploma,
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/application/categories/static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ children:
<%= render 'admin/application/l10n/static', about: @l10n %>
<%= render 'admin/application/images/featured/static', about: @l10n %>
<%= render 'admin/application/images/shared/static', about: @l10n %>
<%= render 'admin/application/meta_description/static', about: @l10n %>
<%= render 'admin/application/summary/static', about: @l10n %>
<%= osuny_static_text 'meta_description', @l10n.meta_description %>
<%= osuny_static_html 'summary', @l10n.summary %>
header_text: >-
<%= prepare_html_for_static @l10n.header_text %>
<%= render 'admin/application/header_cta/static', about: @l10n %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ if category_l10n.present?
if hugo.file.present?
%>
<%= render 'admin/application/static/hugo/single', hugo: hugo, depth: 3 %>
name: >-
<%= prepare_text_for_static category_l10n.to_s %>
<%= osuny_static_text 'name', category_l10n.to_s, depth: 5 %>
<%
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ if category_l10n.present?
count = category.count_objects_in(language, @website)
if hugo.file.present? && count > 0 %>
<%= render 'admin/application/static/hugo/single', hugo: hugo, depth: depth %>
<%= indentation %> name: >-
<%= indentation %> <%= prepare_text_for_static category_l10n.to_s %>
<%= osuny_static_text 'name', category_l10n.to_s, depth: 5 %>
<%= indentation %> count: <%= count %>
<% if category.children.any? %>
<%= indentation %> children:
Expand All @@ -22,4 +21,4 @@ if category_l10n.present?
end
end
end
%>
%>
14 changes: 8 additions & 6 deletions app/views/admin/application/categories/widget/_static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ taxonomies:
<%
# First, all free categories in a "fake" taxonomy
if free_categories_content.present? %>
- name: >-
<%= t('category.title') %>
slug: ""
- permalink: ""
path: ""
slug: ""
file: ""
<%= osuny_static_text 'name', t('category.title'), depth: 3 %>
categories:
<%= free_categories_content.html_safe %>
<% end %>
Expand All @@ -52,10 +53,11 @@ taxonomies:
language: language
}.join('')
if taxonomy_content.present? %>
- name: >-
<%= prepare_text_for_static taxonomy_l10n.to_s %>
slug: "<%= hugo.slug %>"
- permalink: "<%= hugo.permalink %>"
path: "<%= hugo.path %>"
slug: "<%= hugo.slug %>"
file: "<%= hugo.file %>"
<%= osuny_static_text 'name', taxonomy_l10n.to_s, depth: 3 %>
categories:
<%= taxonomy_content.html_safe %>
<%
Expand Down
12 changes: 5 additions & 7 deletions app/views/admin/application/connections/_backlinks.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ backlinks = about.backlinks_for(@website)
%>
backlinks:
current_website:
name: "<%= @website.to_s_in(language) %>"
<%= osuny_static_text 'name', @website.to_s_in(language), depth: 3 %>
<%
backlinks.each do |identifier, list|
%>
Expand All @@ -28,9 +28,8 @@ other_websites.each do |website|
backlinks = about.backlinks_for(website)
next if backlinks.empty?
%>
- name: >-
<%= prepare_text_for_static website.to_s_in(language) %>
identifier: "<%= website.id %>"
- identifier: "<%= website.id %>"
<%= osuny_static_text 'name', website.to_s_in(language), depth: 4 %>
<%
backlinks.each do |identifier, list|
%>
Expand All @@ -41,9 +40,8 @@ other_websites.each do |website|
element = object[:element]
url = "#{website.url}#{hugo.permalink}"
%>
- name: >-
<%= prepare_text_for_static element.to_s %>
url: "<%= url %>"
- url: "<%= url %>"
<%= osuny_static_text 'name', element.to_s, depth: 6 %>
<%
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,23 @@ should_show = is_information_public?(about, :address)
<% if present && should_show %>
<%= indentation %>postal_address:
<%= indentation %> data:
<%= indentation %> address_name: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.address_name %>
<%= indentation %> address: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.address %>
<%= indentation %> address_additional: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.address_additional %>
<%= indentation %> zipcode: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.zipcode %>
<%= indentation %> city: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.city %>
<%= osuny_static_text 'address_name', address_formatter.address_name, depth: depth+3 %>
<%= osuny_static_text 'address', address_formatter.address, depth: depth+3 %>
<%= osuny_static_text 'address_additional', address_formatter.address_additional, depth: depth+3 %>
<%= osuny_static_text 'zipcode', address_formatter.zipcode, depth: depth+3 %>
<%= osuny_static_text 'city', address_formatter.city, depth: depth+3 %>
<% if address_formatter.country? %>
<%= indentation %> country:
<%= indentation %> name: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.country %>
<%= indentation %> alpha2: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.country_alpha2 %>
<%= indentation %> alpha3: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.country_alpha3 %>
<%= osuny_static_text 'name', address_formatter.country, depth: depth+4 %>
<%= osuny_static_text 'alpha2', address_formatter.country_alpha2, depth: depth+4 %>
<%= osuny_static_text 'alpha3', address_formatter.country_alpha3, depth: depth+4 %>
<% end %>
<% if about.respond_to?(:latitude) %>
<%= indentation %> geolocation:
<%= indentation %> latitude: <%= about.latitude %>
<%= indentation %> longitude: <%= about.longitude %>
<% end %>
<%= indentation %> text: >-
<%= indentation %> <%= prepare_text_for_static address_formatter.to_s %>
<%= osuny_static_text 'text', address_formatter.to_s, depth: depth+2 %>
<%= indentation %> html: >-
<%= indentation %> <%= address_formatter.to_html.html_safe %>
<% end %>
3 changes: 1 addition & 2 deletions app/views/admin/application/header_cta/_static.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
header_cta:
<% if about.header_cta %>
label: >-
<%= prepare_text_for_static about.header_cta_label %>
target: "<%= about.header_cta_url %>"
external: <%= about.header_cta_url_external?(@website) %>
<%= osuny_static_text 'label', about.header_cta_label, depth: 2 %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ if best_featured_image&.attached?
image:
id: "<%= best_featured_image.blob.id %>"
alt: "<%= about.best_featured_image_alt %>"
credit: >-
<%= prepare_html_for_static about.best_featured_image_credit %>
<%= osuny_static_html 'credit', about.best_featured_image_credit, depth: 2 %>
<% end %>

This file was deleted.

This file was deleted.

3 changes: 1 addition & 2 deletions app/views/admin/application/static/_breadcrumbs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ localizations.each do |l10n|
permalink = hugo.permalink
last = l10n == localizations.last
%>
- title: >-
<%= title %>
- title: "<%= title %>"
<% if !last || last_item.present? %>
path: "<%= permalink %>"
<% end %>
Expand Down
34 changes: 11 additions & 23 deletions app/views/admin/application/static/_core.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,17 @@ end
# Title and subtitle
#############
%>
title: >-
<%= prepare_text_for_static title %>
<% if show_subtitle %>
subtitle: >-
<%= prepare_text_for_static about.subtitle %>
<% end %>
<%= osuny_static_text 'title', title %>
<%= osuny_static_text 'breadcrumb_title', about.try(:best_breadcrumb_title) %>
<%= osuny_static_text 'subtitle', about.try(:subtitle) %>
<%= osuny_static_html 'header_text', about.try(:header_text) %>
<%
#############
# Body classes
#############
bodyclass_object = about.respond_to?(:about) ? about.about : about
if bodyclass_object.respond_to?(:best_bodyclass) %>
bodyclass: >-
<%= bodyclass_object.best_bodyclass %>
<%
end
%>
<%= osuny_static_text 'bodyclass', bodyclass_object.try(:best_bodyclass) %>
<%
#############
# Permalinks
Expand Down Expand Up @@ -84,21 +78,16 @@ search:
<% if about.respond_to?(:about_id) %>
about_id: "<%= about.about_id %>"
<% end %>
<% if hugo %>
url: "<%= hugo.permalink %>"
<% end %>
kind: "<%= about.class.model_name %>"
<% if about.respond_to?(:language) && about.language.present? %>
lang: "<%= about.language.iso_code %>"
<% end %>
title: >-
<%= prepare_text_for_static search_title %>
<% if about.respond_to?(:summary) %>
summary: >-
<%= prepare_html_for_static about.summary %>
<% end %>
<% if about.respond_to?(:contents_full_text) %>
body: >-
<%= prepare_html_for_static simple_format(about.contents_full_text) %>
<% end %>
<%= osuny_static_text 'title', search_title, depth: 2 %>
<%= osuny_static_html 'summary', about.try(:summary), depth: 2 %>
<%= osuny_static_html 'body', simple_format(about.contents_full_text), depth: 2 if about.respond_to?(:contents_full_text) %>
<%
#############
# Federation
Expand All @@ -112,8 +101,7 @@ federation:
<% if canonical_hugo.present? %>
canonical_url: <%= "#{canonical_website.url}#{canonical_hugo.permalink}" %>
website:
name: >-
<%= prepare_text_for_static canonical_website.to_s_in(about.language) if about.respond_to?(:language) %>
<%= osuny_static_text 'name', canonical_website.to_s_in(about.language), depth: 3 if about.respond_to?(:language) %>
url: "<%= canonical_website.url %>"
hugo:
permalink: "<%= canonical_hugo.permalink %>"
Expand Down
3 changes: 0 additions & 3 deletions app/views/admin/application/static/attribute/_text.html.erb

This file was deleted.

2 changes: 0 additions & 2 deletions app/views/admin/application/summary/_static.html.erb

This file was deleted.

This file was deleted.

Loading
Loading