Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def show
breadcrumb
end

def preview
render layout: 'admin/layouts/preview'
end

def new
@event.parent = @website.events.find(params[:parent_id]) if params.has_key?(:parent_id)
@categories = categories
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/admin/education/programs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class Admin::Education::ProgramsController < Admin::Education::Programs::Applica

before_action :load_teacher_people, only: [:new, :edit, :create, :update]

include Admin::HasPreview
include Admin::HasStaticAction
include Admin::Localizable

Expand Down Expand Up @@ -36,7 +37,6 @@ def show
end

def preview
@website = @program.websites&.first
render layout: 'admin/layouts/preview'
end

Expand Down Expand Up @@ -90,6 +90,11 @@ def restore

protected

def prepare_preview
super
@body_class += ' offcanvas-toc'
end

def load_part
part_from_params = params.dig('education_program', 'part')
@part = part_from_params if ['admission', 'certification', 'pedagogy', 'presentation', 'results'].include?(part_from_params)
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/admin/university/organizations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Admin::University::OrganizationsController < Admin::University::Applicatio
through_association: :organizations,
except: :restore

include Admin::HasPreview
include Admin::HasStaticAction
include Admin::Localizable

Expand Down Expand Up @@ -36,6 +37,10 @@ def show
breadcrumb
end

def preview
render layout: 'admin/layouts/preview'
end

def new
@categories = categories
breadcrumb
Expand Down Expand Up @@ -87,6 +92,11 @@ def restore

protected

def prepare_preview
super
@body_class += ' full-width'
end

def breadcrumb
super
add_breadcrumb University::Organization.model_name.human(count: 2),
Expand Down
10 changes: 10 additions & 0 deletions app/controllers/admin/university/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Admin::University::PeopleController < Admin::University::ApplicationContro
through_association: :people,
except: :restore

include Admin::HasPreview
include Admin::HasStaticAction
include Admin::Localizable

Expand Down Expand Up @@ -43,6 +44,10 @@ def show
breadcrumb
end

def preview
render layout: 'admin/layouts/preview'
end

def new
@categories = categories
breadcrumb
Expand Down Expand Up @@ -95,6 +100,11 @@ def restore

protected

def prepare_preview
super
@body_class += ' full-width'
end

def breadcrumb
super
add_breadcrumb University::Person.model_name.human(count: 2),
Expand Down
9 changes: 8 additions & 1 deletion app/controllers/concerns/admin/has_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Admin::HasPreview

included do
before_action :set_preview, only: :show
before_action :prepare_preview, only: :preview
end

def preview
Expand All @@ -11,9 +12,15 @@ def preview
end

protected

def set_preview
@preview = true
end

def prepare_preview
@website ||= resource.websites&.first || current_university.websites.first
@body_class = resource.hugo_body_class
@body_class += ' full-width' if resource.try(:full_width)
end

end
4 changes: 4 additions & 0 deletions app/models/communication/website/agenda/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ def sorting_time
from_day.in_time_zone.to_time
end

def hugo_body_class
'events__page'
end

protected

# Methods for Communication::Website::Agenda::Period::InPeriod
Expand Down
4 changes: 4 additions & 0 deletions app/models/communication/website/agenda/exhibition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ def references
menus
end

def hugo_body_class
'exhibitions__page'
end

protected

def list_blocks_template_kind
Expand Down
4 changes: 4 additions & 0 deletions app/models/communication/website/jobboard/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,8 @@ def current?
from_day <= Date.current && (to_day.nil? || Date.current <= to_day)
end

def hugo_body_class
'jobs__page'
end

end
4 changes: 4 additions & 0 deletions app/models/communication/website/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def self.direct_connection_permitted_about_class
nil
end

def hugo_body_class
'pages__section'
end

protected

def last_ordered_element
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def dependencies
def git_path_relative
'locations/_index.html'
end

def hugo_body_class
'locations__taxonomy'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def git_path_relative
def special_page_categories
website.agenda_categories
end

def hugo_body_class
'events__section'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def git_path_relative
def special_page_categories
website.agenda_categories
end

def hugo_body_class
'exhibitions__section'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def git_path_relative
def special_page_categories
website.jobboard_categories
end

def hugo_body_class
'jobs__section'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def git_path_relative
def special_page_categories
website.portfolio_categories
end

def hugo_body_class
'projects__section'
end
end
4 changes: 4 additions & 0 deletions app/models/communication/website/page/communication_post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ def git_path_relative
def special_page_categories
website.post_categories
end

def hugo_body_class
'posts__section'
end
end
4 changes: 4 additions & 0 deletions app/models/communication/website/page/education_diploma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def dependencies
def git_path_relative
'diplomas/_index.html'
end

def hugo_body_class
'diplomas__taxonomy'
end
end
4 changes: 4 additions & 0 deletions app/models/communication/website/page/education_program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ def git_path_relative
def special_page_categories
university.education_program_categories
end

def hugo_body_class
'programs__section'
end
end
4 changes: 4 additions & 0 deletions app/models/communication/website/page/education_school.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ def dependencies
def git_path_relative
'schools/_index.html'
end

def hugo_body_class
'schools__section'
end
end
4 changes: 4 additions & 0 deletions app/models/communication/website/page/home.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ def git_path_relative
def default_parent
nil
end

def hugo_body_class
'page__home'
end
end
4 changes: 4 additions & 0 deletions app/models/communication/website/page/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ def git_path_relative
def special_page_categories
university.person_categories
end

def hugo_body_class
'persons__section'
end
end
4 changes: 4 additions & 0 deletions app/models/communication/website/portfolio/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ def references
menus
end

def hugo_body_class
'projects__page'
end

protected

def list_blocks_template_kind
Expand Down
4 changes: 4 additions & 0 deletions app/models/communication/website/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def published_at_in(language)
localization_for(language).try(:published_at)
end

def hugo_body_class
'posts__page'
end

protected

def update_authors_status_if_necessary!
Expand Down
4 changes: 4 additions & 0 deletions app/models/education/program.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def programs
Education::Program.where(id: id)
end

def hugo_body_class
'programs__section'
end

protected

def check_accessibility
Expand Down
4 changes: 4 additions & 0 deletions app/models/university/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def references
mentions_by_blocks
end

def hugo_body_class
'organizations__page'
end

protected

def blocks_mentioning_self
Expand Down
4 changes: 4 additions & 0 deletions app/models/university/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ def full_street_address
[address, "#{zipcode} #{city} #{country}".strip].join(', ')
end

def hugo_body_class
'persons__page'
end

def to_s_with_mail_in(language)
best_localization_for(language).to_s_with_mail
end
Expand Down
15 changes: 15 additions & 0 deletions app/views/admin/application/preview/_featured_image.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%
if l10n.featured_image.present? && l10n.featured_image.attached?
format = ActiveStorage::Utils.format(l10n.featured_image)
%>
<figure class="featured-image image-<%= format %>">
<%= kamifusen_tag l10n.featured_image, alt: l10n.featured_image_alt %>
<% if l10n.featured_image_credit.present? %>
<figcaption>
<div class="credit">
<%= sanitize l10n.featured_image_credit %>
</div>
</figcaption>
<% end %>
</figure>
<% end %>
9 changes: 3 additions & 6 deletions app/views/admin/application/preview/_hero.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
@title = @l10n.title
@subtitle = @l10n.try(:subtitle)
@summary = @l10n.summary
@image = @l10n.featured_image

hero_classes = "hero"
if @image.present? && @image.attached?
format = ActiveStorage::Utils.format(@image)
if @l10n.featured_image.present? && @l10n.featured_image.attached?
format = ActiveStorage::Utils.format(@l10n.featured_image)
hero_classes += " hero--with-image hero--image-#{format}" if format.present?
end
%>
Expand All @@ -30,9 +29,7 @@ end
<h1><%= @title %></h1>
<% end %>
</div>
<figure>
<%= kamifusen_tag @image if @image.present? && @image.attached? %>
</figure>
<%= render 'admin/application/preview/featured_image', l10n: @l10n %>
</div>
</div>
</header>
4 changes: 1 addition & 3 deletions app/views/admin/application/preview/preview.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<%= render 'admin/application/preview/hero' %>
<div class="document-content">
<div class="blocks">
<%= render 'admin/communication/contents/show',
about: @l10n,
strip_javascript: true %>
<%= render 'admin/communication/contents/show', about: @l10n, strip_javascript: true %>
</div>
</div>
</main>
Expand Down
Loading
Loading