Skip to content
Permalink
Browse files
convert site-structure links to be relative paths (preferred)
  • Loading branch information
ahgittin committed Dec 15, 2014
1 parent 55c872a commit b1bf9d777d4f1742014b78656c2d1d98cd91e777
Showing 6 changed files with 41 additions and 27 deletions.
@@ -2,13 +2,29 @@
# Starts from a page called "index.md", and follows "children" links in the YAML front matter
module SiteStructure

ROOT = "website/index.md"
ROOT = "/website/index.md"

class Generator < Jekyll::Generator
def find_page_with_path_absolute_or_relative_to(site, path, referrent)
page = site.pages.detect { |page| "/"+page.path == path }
if !page && referrent
page = site.pages.detect { |page| "/"+page.path == "/"+File.dirname(referrent.path)+"/"+path }
end
if !page
page = site.pages.detect { |page| page.path == path }
puts "WARNING: link to #{path} in #{referrent ? referrent.path : "root"} uses legacy absolute syntax without leading slash" if page
end

throw "Could not find a page called: #{path} (referenced from #{referrent ? referrent.path : "root"})" unless page

page
end

def generate(site)
navgroups = site.pages.detect { |page| page.path == SiteStructure::ROOT }.data['navgroups']
root_page = find_page_with_path_absolute_or_relative_to(site, SiteStructure::ROOT, nil)
navgroups = root_page.data['navgroups']
navgroups.each do |ng|
ng['page'] = site.pages.detect { |page| page.path == ng['page'] }
ng['page'] = find_page_with_path_absolute_or_relative_to(site, ng['page'], root_page)
if not ng['title_in_menu']
ng['title_in_menu'] = ng['title'].capitalize
end
@@ -18,9 +34,7 @@ def generate(site)
end

def gen_structure(site, pagename, parent, navgroups)
page = site.pages.detect { |page| page.path == pagename }

throw "Could not find a page called: #{pagename} (referenced from #{parent ? parent.url : "root"})" unless page
page = find_page_with_path_absolute_or_relative_to(site, pagename, parent)

# My navgroup is (first rule matches):
# 1. what I have explicitly declared
@@ -2,10 +2,10 @@
layout: website-normal
title: Community
children:
- { path: website/community/how-to-contribute.md }
- { path: website/community/migrate-to-apache.md }
- { path: website/community/committers.md }
- { path: website/community/how-to-contribute-docs.md }
- { path: how-to-contribute.md }
- { path: migrate-to-apache.md }
- { path: committers.md }
- { path: how-to-contribute-docs.md }
---

<div class="row">
@@ -3,8 +3,8 @@ layout: website-normal
title: Documentation
children:
- { link: /v/0.7.0-M1, title: User Manual (0.7.0-M1) }
- { path: website/glossary.md }
- { path: website/documentation/install-on-server.md }
- { path: glossary.md }
- { path: documentation/install-on-server.md }
---

## Official User Manual
@@ -16,4 +16,4 @@ Our main user manual is organised by release version. Please pick the version th
and therefore it is not endorsed by Apache.

## Server install
Follow this [guide]({{ site.path.website }}/documentation/install-on-server.html) to install Brooklyn on a production server.
Follow this [guide](documentation/install-on-server.html) to install Brooklyn on a production server.
@@ -3,17 +3,17 @@ layout: website-landing
title: Home
navgroup: home
children:
- { path: website/learnmore/index.md }
- { path: website/download.md }
- { path: website/quickstart/index.md }
- { path: website/documentation.md }
- { path: website/community/index.md }
- { path: learnmore/index.md }
- { path: download.md }
- { path: quickstart/index.md }
- { path: documentation.md }
- { path: community/index.md }
navgroups:
- { id: learnmore, page: website/learnmore/index.md, title: learn more }
- { id: download, page: website/download.md, title: download }
- { id: getstarted, page: website/quickstart/index.md, title: get started, title_in_menu: Get started }
- { id: documentation, page: website/documentation.md, title: documentation, title_in_menu: All documentation }
- { id: website/community, page: website/community/index.md, title: community, title_in_menu: Community home }
- { id: learnmore, page: learnmore/index.md, title: learn more }
- { id: download, page: download.md, title: download }
- { id: getstarted, page: quickstart/index.md, title: get started, title_in_menu: Get started }
- { id: documentation, page: documentation.md, title: documentation, title_in_menu: All documentation }
- { id: website/community, page: community/index.md, title: community, title_in_menu: Community home }
---

<div class="jumbotron">
@@ -2,10 +2,10 @@
layout: website-normal
title: Learn More
children:
- { path: website/learnmore/yaml-explained.md }
- { path: website/learnmore/theory.md, title: Theory }
- { path: yaml-explained.md }
- { path: theory.md, title: Theory }
---

TODO have a list of resources here? or start w yaml explained?

TODO include { path: learnmore/catalog/index.html }
TODO include { path: catalog/index.html }
@@ -2,7 +2,7 @@
title: Getting Started
layout: website-normal
children:
- { path: website/quickstart/policies-and-catalogs.md }
- { path: policies-and-catalogs.md }
---

This guide will walk you through deploying an application to a public cloud.

0 comments on commit b1bf9d7

Please sign in to comment.