You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2014/12/17 18:54:08 UTC

[31/50] [abbrv] incubator-brooklyn-site git commit: convert site-structure links to be relative paths (preferred)

convert site-structure links to be relative paths (preferred)


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/commit/b1bf9d77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/tree/b1bf9d77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/diff/b1bf9d77

Branch: refs/heads/master
Commit: b1bf9d777d4f1742014b78656c2d1d98cd91e777
Parents: 55c872a
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Dec 15 15:36:44 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Dec 15 16:50:39 2014 +0000

----------------------------------------------------------------------
 _plugins/site_structure.rb  | 26 ++++++++++++++++++++------
 website/community/index.md  |  8 ++++----
 website/documentation.md    |  6 +++---
 website/index.md            | 20 ++++++++++----------
 website/learnmore/index.md  |  6 +++---
 website/quickstart/index.md |  2 +-
 6 files changed, 41 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/b1bf9d77/_plugins/site_structure.rb
----------------------------------------------------------------------
diff --git a/_plugins/site_structure.rb b/_plugins/site_structure.rb
index 9ccfc7b..049cc65 100644
--- a/_plugins/site_structure.rb
+++ b/_plugins/site_structure.rb
@@ -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 @@ module SiteStructure
     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

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/b1bf9d77/website/community/index.md
----------------------------------------------------------------------
diff --git a/website/community/index.md b/website/community/index.md
index 45de6f6..e998e69 100644
--- a/website/community/index.md
+++ b/website/community/index.md
@@ -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">

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/b1bf9d77/website/documentation.md
----------------------------------------------------------------------
diff --git a/website/documentation.md b/website/documentation.md
index f029e62..f6454d6 100644
--- a/website/documentation.md
+++ b/website/documentation.md
@@ -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.

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/b1bf9d77/website/index.md
----------------------------------------------------------------------
diff --git a/website/index.md b/website/index.md
index 6b09127..31fa351 100644
--- a/website/index.md
+++ b/website/index.md
@@ -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">

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/b1bf9d77/website/learnmore/index.md
----------------------------------------------------------------------
diff --git a/website/learnmore/index.md b/website/learnmore/index.md
index 1fe1201..3befae6 100644
--- a/website/learnmore/index.md
+++ b/website/learnmore/index.md
@@ -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 }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/b1bf9d77/website/quickstart/index.md
----------------------------------------------------------------------
diff --git a/website/quickstart/index.md b/website/quickstart/index.md
index 233c00f..0c6cc3e 100644
--- a/website/quickstart/index.md
+++ b/website/quickstart/index.md
@@ -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.