Skip to content
Snippets Groups Projects
Unverified Commit da92a09c authored by Sébastien Gaya's avatar Sébastien Gaya
Browse files

permalink facets

parent 8f1bf050
No related branches found
No related tags found
No related merge requests found
......@@ -43,18 +43,4 @@ class Communication::Website::Configs::Permalinks < Communication::Website
"admin/communication/websites/configs/permalinks/static"
end
def permalinks_data
@permalinks_data ||= begin
# TODO : Clean
data = Communication::Website::Permalink.config_in_website(self)
data[:categories] = "#{self.special_page(:communication_posts).path_without_language}:slug/" if has_communication_posts? && has_communication_categories?
data[:organizations] = "#{self.special_page(:organizations).path_without_language}:slug/" if has_organizations?
data[:diplomas] = "#{self.special_page(:education_diplomas).path_without_language}:slug/" if has_education_diplomas?
data[:administrators] = "#{self.special_page(:persons).path_without_language}:slug/roles/" if has_administrators?
data[:teachers] = "#{self.special_page(:persons).path_without_language}:slug/programs/" if has_teachers?
data[:researchers] = "#{self.special_page(:persons).path_without_language}:slug/papers/" if has_researchers?
data
end
end
end
......@@ -24,10 +24,16 @@
#
class Communication::Website::Permalink < ApplicationRecord
MAPPING = {
"Communication::Website::Category" => Communication::Website::Permalink::Category,
"Communication::Website::Page" => Communication::Website::Permalink::Page,
"Communication::Website::Post" => Communication::Website::Permalink::Post,
"Education::Diploma" => Communication::Website::Permalink::Diploma,
"University::Organization" => Communication::Website::Permalink::Organization,
"University::Person" => Communication::Website::Permalink::Person,
"University::Person::Author" => Communication::Website::Permalink::Author
"University::Person::Administrator" => Communication::Website::Permalink::Administrator,
"University::Person::Author" => Communication::Website::Permalink::Author,
"University::Person::Researcher" => Communication::Website::Permalink::Researcher,
"University::Person::Teacher" => Communication::Website::Permalink::Teacher
}
include WithUniversity
......
class Communication::Website::Permalink::Administrator < Communication::Website::Permalink
def self.required_for_website?(website)
website.has_administrators?
end
def self.static_config_key
:administrators
end
def self.pattern_in_website(website)
"#{website.special_page(:persons).path_without_language}:slug/roles/"
end
protected
def published?
about.for_website?(website)
end
def published_path
pattern.gsub(":slug", about.slug)
end
end
class Communication::Website::Permalink::Category < Communication::Website::Permalink
def self.required_for_website?(website)
website.has_communication_posts? && website.has_communication_categories?
end
def self.static_config_key
:categories
end
def self.pattern_in_website(website)
"#{self.special_page(:communication_posts).path_without_language}:slug/"
end
protected
def published_path
pattern.gsub(":slug", about.path)
end
end
class Communication::Website::Permalink::Diploma < Communication::Website::Permalink
def self.required_for_website?(website)
website.has_education_diplomas?
end
def self.static_config_key
:diplomas
end
def self.pattern_in_website(website)
"#{website.special_page(:education_diplomas).path_without_language}:slug/"
end
protected
def published?
about.for_website?(website)
end
def published_path
pattern.gsub(":slug", about.slug)
end
end
class Communication::Website::Permalink::Organization < Communication::Website::Permalink
def self.required_for_website?(website)
website.has_organizations?
end
def self.static_config_key
:organizations
end
def self.pattern_in_website(website)
"#{website.special_page(:organizations).path_without_language}:slug/"
end
protected
def published?
about.for_website?(website)
end
def published_path
pattern.gsub(":slug", about.slug)
end
end
class Communication::Website::Permalink::Researcher < Communication::Website::Permalink
def self.required_for_website?(website)
website.has_researchers?
end
def self.static_config_key
:researchers
end
def self.pattern_in_website(website)
"#{website.special_page(:persons).path_without_language}:slug/papers/"
end
protected
def published?
about.for_website?(website)
end
def published_path
pattern.gsub(":slug", about.slug)
end
end
class Communication::Website::Permalink::Teacher < Communication::Website::Permalink
def self.required_for_website?(website)
website.has_teachers?
end
def self.static_config_key
:teachers
end
def self.pattern_in_website(website)
"#{website.special_page(:persons).path_without_language}:slug/programs/"
end
protected
def published?
about.for_website?(website)
end
def published_path
pattern.gsub(":slug", about.slug)
end
end
<% @website.config_permalinks.permalinks_data.each do |key, value| %>
<% Communication::Website::Permalink.config_in_website(@website).each do |key, value| %>
<%= key %>: <%= value %>
<% end %>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment