Skip to content

Commit

Permalink
Use a simpler path naming structure for people items.
Browse files Browse the repository at this point in the history
Related to issue #99.
  • Loading branch information
cdchapman committed Nov 23, 2019
1 parent 5e22229 commit 710a9de
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion items/location/redirections.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ location = <%= path_to(linked_data).sub(/\.ttl$/, '') %> {
# Content negotiation for personal profile pages
###

<% @items.find_all("#{@config[:static_root]}#{@config[:people][:page_path]}/*/index.*").each do |profile| %>
<% @items.find_all("#{@config[:static_root]}#{@config[:people_root]}/*/index.*").each do |profile| %>
location <%= path_to(profile) %> {
add_header Vary $vary_header;
add_header Cache-Control $cache_control;
Expand Down
2 changes: 1 addition & 1 deletion lib/data_sources/people.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def person_to_item(person)
new_item(
person[:name],
attributes.merge(person),
Nanoc::Identifier.new("/people/_#{slug}"),
Nanoc::Identifier.new("/_#{slug}"),
attributes_checksum_data: Digest::SHA1.digest(Marshal.dump(person)),
)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def member?(member)
# @return [void]
def populate_member_identifiers
members.each do |member|
member[:web_id] ||= "#{@config[:base_url]}#{@config[:people][:page_path]}/#{member.fetch(:slug)}/##{member.fetch(:hashtag, 'me')}"
member[:web_id] ||= "#{@config[:base_url]}#{@config[:people_root]}/#{member.fetch(:slug)}/##{member.fetch(:hashtag, 'me')}"
end
end

Expand All @@ -79,7 +79,7 @@ def generate_personal_profile_pages
@items.create(
%(<%= render('/personal_profile.*', person_name: '#{member[:name]}') %>),
{ title: member[:name], kind: 'personal-profile-page', description: "Personal profile of #{member[:name]}" },
"#{@config[:static_root]}#{@config[:people][:page_path]}/#{member.fetch(:slug)}/index.erb",
"#{@config[:static_root]}#{@config[:people_root]}/#{member.fetch(:slug)}/index.erb",
binary: false,
)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers/people.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def person_by_name(name)
def path_to_profile_page(person, absolute: false)
web_id = person.fetch(:web_id).to_s
if member?(person)
profile_page_item = @items["#{@config[:static_root]}#{@config[:people][:page_path]}/#{person.fetch(:slug)}/index.*"]
profile_page_item = @items["#{@config[:static_root]}#{@config[:people_root]}/#{person.fetch(:slug)}/index.*"]
path_to(profile_page_item, absolute: absolute)
elsif web_id.start_with?(@config[:base_url])
path_to(web_id, absolute: absolute)
Expand All @@ -72,7 +72,7 @@ def path_to_profile_page(person, absolute: false)
# @return [void]
def populate_people_identifiers
@items.find_all('/people/_*').each do |person|
person[:web_id] ||= "#{@config[:base_url]}#{@config[:people][:page_path]}##{person.fetch(:slug)}"
person[:web_id] ||= "#{@config[:base_url]}#{@config[:people_root]}##{person.fetch(:slug)}"
end
end
end
Expand Down
8 changes: 3 additions & 5 deletions nanoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ data_sources:

- type: people
people_data: 'etc/people.yaml'
items_root: &people_root /people


# Config for Nanoc environments
Expand All @@ -84,8 +85,8 @@ environments:
cache:
short_urls: 'var/short_urls.yaml'

company:
page_path: /company
company_root: /company
people_root: *people_root

erb:
trim_mode: '>'
Expand All @@ -96,9 +97,6 @@ environments:
tag_url: "https://github.com/pentandra/lifepreserver/releases/tag"
version_history_url: "https://github.com/lifepreserver/commits/master"

people:
page_path: /people

site: &site
name: Pentandra
motto: Breaking Research Barriers
Expand Down

0 comments on commit 710a9de

Please sign in to comment.