brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [06/10] brooklyn-docs git commit: Finished URL rewriting and formatting
Date Thu, 25 Feb 2016 15:39:44 GMT
Finished URL rewriting and formatting


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

Branch: refs/heads/master
Commit: f3c06f5cda1e97fe325d678f0e64c501c286a709
Parents: 70c731f
Author: Duncan Godwin <duncan.godwin@cloudsoftcorp.com>
Authored: Tue Feb 9 14:45:15 2016 +0000
Committer: Duncan Godwin <duncan.godwin@cloudsoftcorp.com>
Committed: Thu Feb 25 14:52:55 2016 +0000

----------------------------------------------------------------------
 _build/buildPDF.sh                |   4 +-
 _config.yml                       |   1 +
 _includes/singlepage-content.html |  17 +-----
 _includes/singlepage-item.html    |   3 +
 _layouts/singlePage.html          |  11 +++-
 _plugins/regex_filter.rb          | 108 ++++++++++++++++++++++++++++++++-
 _plugins/stringTools.rb           |  11 +++-
 guide/start/blueprints.md         |   6 +-
 guide/start/managing.md           |  24 ++++----
 guide/start/running.md            |  17 +++++-
 style/css/singlePage.css          |  11 +++-
 zoneMergeManual.html              |   5 +-
 zoneMergeStarted.html             |   3 +
 13 files changed, 183 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/_build/buildPDF.sh
----------------------------------------------------------------------
diff --git a/_build/buildPDF.sh b/_build/buildPDF.sh
index 54ff597..a3d1196 100755
--- a/_build/buildPDF.sh
+++ b/_build/buildPDF.sh
@@ -20,6 +20,8 @@ command -v wkhtmltopdf >/dev/null 2>&1 || {
 wkhtmltopdf --page-size Letter --margin-top 0.75in --margin-right 0.75in --margin-bottom
0.75in --margin-left 0.75in --encoding UTF-8 $1 $2
 if [ $? -eq 1 ] ; then
 	echo "Note that ContentNotFoundError is usually because of the invalid relational path of
a local resource such as an image"
-else	
+elif [ $? -eq 0 ] ; then
 	echo "PDF Built successfully."
+else 
+	exit $?
 fi
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/_config.yml
----------------------------------------------------------------------
diff --git a/_config.yml b/_config.yml
index bb44fb5..8e32e3b 100644
--- a/_config.yml
+++ b/_config.yml
@@ -51,6 +51,7 @@ brooklyn-base-url: https://brooklyn.apache.org
 pdf-rewrite-prefixes: 
     '/guide' : '/v/0.9.0-SNAPSHOT'
     '/website' : ''
+    '/community' : '/community'
     
 brooklyn-version: 0.9.0-SNAPSHOT # BROOKLYN_VERSION
 brooklyn-snapshot-git-branch: master   # if line above is SNAPSHOT this should point to corresponding
git branch (e.g. master, 0.4)

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/_includes/singlepage-content.html
----------------------------------------------------------------------
diff --git a/_includes/singlepage-content.html b/_includes/singlepage-content.html
index 18fc1b7..7d24206 100644
--- a/_includes/singlepage-content.html
+++ b/_includes/singlepage-content.html
@@ -26,25 +26,14 @@
 	{% comment %}<!-- Build the page directory by removing the file name from the item url
-->{% endcomment %}
 	{% capture page_url %}{{ item_url | replace_regex:'[^\/]*$', '' }}{% endcapture %}
 	
-	{% comment %}<!-- If the URL is prefixed with a pdf-rewrite-prefix, remove it -->{%
endcomment %}
-	{% for part in site.pdf-rewrite-prefixes %}
-	  {% capture prefixed %}{{ page_url | startsWith: part[0] }}{% endcapture %}
-	  {% if prefixed == "true"  %}
-	  	{% capture page_url %}{{ part[1] }}{{ page_url | removePrefix: part[0] }}{% endcapture
%}
-	  {% endif %}
-	{% endfor %}
-	
 	{% capture new_img %}img src=".{{ page_url }}{% endcapture %}
-	{% capture new_href %}href="{{ site.brooklyn-base-url }}{{ brooklyn-version }}{{ page_url
}}{% endcapture %}
 	
 	{% comment %}<!-- Build a regex which replaces the current path with an absolute one
but leaves any sub folders such as /images -->{% endcomment %}
-	{% capture img_regex %}(img(.*)src="{{ page_url | replace:'/','\/' }})|(img(.*)src="){%
endcapture %}
-	
-	{% comment %}<!-- Build a regex which replaces the current links with an absolute one
but leaves any sub folders such as /images and ignores # or external links -->{% endcomment
%}
-	{% capture link_regex %}(href="{{ page_url | replace:'/','\/' }})|(href="(?!http)(?!#)){%
endcapture %}
+	{% capture img_regex %}(img(.*?)src="{{ page_url | replace:'/','\/' }})|(img(.*?)src="){%
endcapture %}
 	
 	{% comment %}<!-- Filter the content of the included page -->{% endcomment %}
-	{% capture content_filtered %}{{ item_content | replace_regex: img_regex, new_img | replace_regex:
link_regex, new_href }}{% endcapture %}
+	{% capture content_filtered %}{{ item_content | replace_regex: img_regex, new_img | refactorURL:
'href="(.*?)"', site, site.pages, page.availablePages, page, item }}{% endcapture %}
+	
 	{{ content_filtered }}
 	</div>
 	 {% endif %}

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/_includes/singlepage-item.html
----------------------------------------------------------------------
diff --git a/_includes/singlepage-item.html b/_includes/singlepage-item.html
index 8725939..4ede485 100644
--- a/_includes/singlepage-item.html
+++ b/_includes/singlepage-item.html
@@ -7,6 +7,9 @@
 	{% set_hash_entry item content item_content %}
 	{% set_hash_entry item data item_data %}
 	
+	{% comment %}<!-- Build a list of all the pages included in this manual -->{% endcomment
%}
+	{{ page.availablePages | appendToArray: item }}
+	
 	{% capture pid %}{{ item.title | remove:'/' | replace:' ','-' | downcase }}{% endcapture
%}
 	<a id="{{ item_path }}" name="{{ item_path }}" href="javascript:void(0);"></a>
 	{{ page.my_array['test'] = 'test' }}

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/_layouts/singlePage.html
----------------------------------------------------------------------
diff --git a/_layouts/singlePage.html b/_layouts/singlePage.html
index adb3c03..5e738c3 100644
--- a/_layouts/singlePage.html
+++ b/_layouts/singlePage.html
@@ -11,10 +11,17 @@
 
 <link href=".{{site.path.style}}/css/website.css" rel="stylesheet">
 <link rel="stylesheet" href=".{{ site.path.style }}/css/singlePage.css" type="text/css"
media="screen" />
-<style>.{{ page.pageMask }}{ display: none; }</style>
+<style>.{{ page.css_hide_class }}{ display: none; } .{{ page.css_show_class }}{ display:
inline !important; visibility: visible !important; }</style>
+<script>
+[]
+.forEach
+.call(document.querySelectorAll('a[target="_blank"]'),
+ function(link) {
+  link.removeAttribute('target');
+});
+</script>
 </head>
 
-
 <body>
 
 {{ content }}

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/_plugins/regex_filter.rb
----------------------------------------------------------------------
diff --git a/_plugins/regex_filter.rb b/_plugins/regex_filter.rb
index 4ece039..b82169d 100644
--- a/_plugins/regex_filter.rb
+++ b/_plugins/regex_filter.rb
@@ -9,4 +9,110 @@ module Jekyll
   end
 end
 
-Liquid::Template.register_filter(Jekyll::RegexFilter)
\ No newline at end of file
+Liquid::Template.register_filter(Jekyll::RegexFilter)
+
+
+#######
+# This function rewrites a link in the following manner
+#
+# 1) If the link is fully external leave it as an unaltered link
+# 2) If the link is an anchor, convert to the anchor scheme used in PDF generation
+# 3) If the link target is in the PDF, change the link to point at the anchor in the PDF
+# 4) If the link is pointing at somewhere on the brooklyn site which is not included in this
PDF, point to the website with a specific version, so https://brooklyn.apache.org/v/0.9.0-SNAPSHOT/start/concept-quickstart.html
for instance
+#
+# * Input - the document body, site - the jekyll site object, page - all pages, availablePages
- ones included in this merge, mergePage - the root merge page, currentPage - the current
page being merged
+module RefactorURL
+  def refactorURL(input, reg_str, site, pages, availablePages, mergePage, currentPage)
+    if input == nil
+      return nil
+    end
+    
+    # generate document id, this will be used for the anchors
+    $pid = "id-undefined"
+    if currentPage['title'] != nil
+      $pid = currentPage['title'].downcase.delete('/')
+      $pid.gsub!(/\s+/, '-')
+    end
+    
+    # re-write any ids to our internal references
+    input.gsub!("id=\"", "id=\"internalLink_"+$pid+"_")
+    
+    # get rid of any opening in new tabs, they'll break our anchors
+    input.gsub!(" target=\"_blank\"", "")
+    
+    # make a multi-line regex for finding URLs within the document body
+    re = Regexp.new reg_str, Regexp::MULTILINE
+    
+    # for each url matched replace using the following rules
+    input.gsub(re) {
+      
+      $newLink = "#"
+      # there should only be one capturing group (the URL), so use the first
+      $match = Regexp.last_match.captures[0]
+      # the URL is now in match
+      if $match.start_with?('http')
+        # 1) it's an external link, leave it as it is
+        $newLink = $match
+      elsif $match.start_with?('#')
+        # 2) it's an anchor in the local document re-write with the local document id prefixed
 
+        $newLink = "#internalLink_"+$pid+"_"+($match.gsub! '#', '')
+      else
+        # 3/4) it's a link to a page within the site scope
+        
+        # -- Firstly clean up the URL
+        if $match =~ /#/
+          # if there's an anchor remove it (anything after the #)
+          $match = $match[/[^#]+/]
+        end
+        # swap ./ for absolute path
+        if $match.start_with?('./')
+          $match = currentPage['dir']+"/"+$match[2, $match.length]
+        # if the string doesnt start with a / it cant be prefixed by the path, so prefix
it
+        elsif !($match.start_with?('/'))
+          $match = currentPage['dir']+"/"+$match
+        end
+        # add index.html to the end if it's just a folder
+        if $match.end_with?('/')
+          $match = $match+"index.html"
+        end
+        
+        # -- now work out if the linked to page is within the page scope
+        $pageOutOfScope = true;
+        for page in availablePages
+          if (page['url'] == $match)
+            # 3) the page is within the scope of the document, swap it for an anchor
+            $pageOutOfScope = false;
+#            puts "In Scope "+$match
+            # get the pid for this specific page
+            $current_pid = page['title'].downcase.delete('/')
+            $current_pid.gsub!(/\s+/, '-')
+            # make the link an anchor to it
+            $newLink = "#contentsLink-"+$current_pid
+          end
+        end
+        # 4) page is out of scope of the document put an absolute URL
+        if $pageOutOfScope
+#          puts $match+" not in scope - "+$newLink
+          $notFoundPrefix = true
+          # go through the URL prefixes in the site and swap them for the website paths
+          for prefix in site['pdf-rewrite-prefixes']
+            
+            # make an absolute external URL for the link
+            if $match.start_with?(prefix[0])
+              $notFoundPrefix = false
+              $newLink = site['brooklyn-base-url']+prefix[1]+$match[prefix[0].length, $match.length]
+            end
+          end 
+          if $notFoundPrefix
+            puts $match+" not found prefix"
+            $newLink = site['brooklyn-base-url']+"/v/"+site['brooklyn-version']+$match
+          end
+        end
+      end
+      # return the re-written link wrapped in the property
+      "href=\""+$newLink+"\""
+    }
+  end
+
+  Liquid::Template.register_filter self
+end

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/_plugins/stringTools.rb
----------------------------------------------------------------------
diff --git a/_plugins/stringTools.rb b/_plugins/stringTools.rb
index 929a7c5..96f001b 100644
--- a/_plugins/stringTools.rb
+++ b/_plugins/stringTools.rb
@@ -23,4 +23,13 @@ module RemovePrefixFilter
   end
 
   Liquid::Template.register_filter self
-end
\ No newline at end of file
+end
+
+module Append
+  def appendToArray(array, addition)
+    (array ||= []) << addition
+    ""
+  end
+
+  Liquid::Template.register_filter self
+end

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/guide/start/blueprints.md
----------------------------------------------------------------------
diff --git a/guide/start/blueprints.md b/guide/start/blueprints.md
index e282e8d..c823eb7 100644
--- a/guide/start/blueprints.md
+++ b/guide/start/blueprints.md
@@ -126,4 +126,8 @@ you can monitor the progress of the application deployment and verify
if it was
 
 ## Next
 
-Having deployed an application, the next step is **[monitoring and managing](managing.html)**
it.
\ No newline at end of file
+<div class="started-pdf-exclude">
+
+Having deployed an application, the next step is **[monitoring and managing](managing.html)**
it.
+
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/guide/start/managing.md
----------------------------------------------------------------------
diff --git a/guide/start/managing.md b/guide/start/managing.md
index 51ff7b1..add6ce6 100644
--- a/guide/start/managing.md
+++ b/guide/start/managing.md
@@ -141,7 +141,7 @@ brooklyn.wrapper_app   true
 
 ## Entities
 
-An *Entity* is Apache Brooklyn's representation of a software package or service which it
can control or interact with. All of the entities Apache Brooklyn can use are listed in the
__[Brooklyn Catalog](../../website/learnmore/catalog/)__. 
+An *Entity* is Apache Brooklyn's representation of a software package or service which it
can control or interact with. All of the entities Apache Brooklyn can use are listed in the
__[Brooklyn Catalog]({{ site.path.website }}/learnmore/catalog/)__. 
 
 To list the entities of the application you can use the `entity` or `ent` command:
 
@@ -208,15 +208,15 @@ To explore sensors on a specific entity use the `sensor` command with
an entity
 $ br application Tomcat entity tomcatServer sensor
 {% endhighlight %}
 <pre>
-Name                                            Description                             
                                                                        Value   
-download.addon.urls                             URL patterns for downloading named add-ons
(will substitute things like ${version} automatically)                   
-download.url                                    URL pattern for downloading the installer
(will substitute things like ${version} automatically)                 "http://download.nextag.com/apache/tomcat/tomcat-7/v${version}/bin/apache-tomcat-${version}.tar.gz"
  
-expandedinstall.dir                             Directory for installed artifacts (e.g. expanded
dir after unpacking .tgz)                                       "/home/vagrant/brooklyn-managed-processes/installs/TomcatServer_7.0.65/apache-tomcat-7.0.65"
  
-host.address                                    Host IP address                         
                                                                        "10.10.10.101"   
-host.name                                       Host name                               
                                                                        "10.10.10.101"   
-host.sshAddress                                 user@host:port for ssh'ing (or null if inappropriate)
                                                           "vagrant@10.10.10.101:22"   
-host.subnet.address                             Host address as known internally in the subnet
where it is running (if different to host.name)                   "10.10.10.101"   
-host.subnet.hostname                            Host name as known internally in the subnet
where it is running (if different to host.name)                      "10.10.10.101"   
+Name                 Description                                                        
                              Value   
+download.addon.urls  URL patterns for downloading named add-ons (will substitute things like
${version} automatically) 
+download.url         URL pattern for downloading the installer (will substitute things like
${version} automatically)  "http://download.nextag.com/apache/tomcat/tomcat-7/v${version}/bin/apache-tomcat-${version}.tar.gz"
  
+expandedinstall.dir  Directory for installed artifacts (e.g. expanded dir after unpacking
.tgz)                        "/home/vagrant/brooklyn-managed-processes/installs/TomcatServer_7.0.65/apache-tomcat-7.0.65"
  
+host.address         Host IP address                                                    
                              "10.10.10.101"   
+host.name            Host name                                                          
                              "10.10.10.101"   
+host.sshAddress      user@host:port for ssh'ing (or null if inappropriate)              
                              "vagrant@10.10.10.101:22"   
+host.subnet.address  Host address as known internally in the subnet where it is running (if
different to host.name)    "10.10.10.101"   
+host.subnet.hostname Host name as known internally in the subnet where it is running (if
different to host.name)       "10.10.10.101"   
 # etc. etc.
 </pre>
 
@@ -239,9 +239,9 @@ Effectors are a means by which you can manipulate the entities in an application
 $ br application Tomcat effector
 {% endhighlight %}
 <pre>
-Name            Description                                                             
                                                                                         
                    Parameters   
+Name            Description                                           Parameters   
 restart         Restart the process/service represented by an entity                    
                                                                                         
                       
-start           Start the process/service represented by an entity                      
                                                                                         
                    locations   
+start           Start the process/service represented by an entity    locations   
 stop            Stop the process/service represented by an entity                       
                                                                                         
                       
 </pre>
 

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/guide/start/running.md
----------------------------------------------------------------------
diff --git a/guide/start/running.md b/guide/start/running.md
index e7631f1..ca1936c 100644
--- a/guide/start/running.md
+++ b/guide/start/running.md
@@ -23,8 +23,9 @@ Two methods of deployment are detailed in this tutorial, using virtualisation
wi
 <div class="tab-content">
 <div id="impl-1" class="tab-pane fade in active">
 
-[Vagrant](https://www.vagrantup.com/){:target="_blank"} is a software package which automates
the process of setting up virtual machines (VM) such as [Oracle VirtualBox](https://www.virtualbox.org){:target="_blank"}.
We recommend it as
-the easiest way of getting started with Apache Brooklyn.
+<strong class="hidden started-pdf-include">a) Vagrant</strong>
+
+[Vagrant](https://www.vagrantup.com/){:target="_blank"} is a software package which automates
the process of setting up virtual machines (VM) such as [Oracle VirtualBox](https://www.virtualbox.org){:target="_blank"}.
We recommend it as the easiest way of getting started with Apache Brooklyn.
 
 Firstly, download and install:
 
@@ -44,6 +45,8 @@ $ cd apache-brooklyn-{{site.brooklyn-version}}-vagrant
 </div>
 <div id="impl-2" class="tab-pane fade">
 
+<strong class="hidden started-pdf-include">b) Local Install</strong>
+
 Download the Apache Brooklyn binary distribution as described on [the download page]({{site.path.website}}/download/){:target="_blank"}.
 
 {% if brooklyn_version contains 'SNAPSHOT' %}
@@ -88,6 +91,8 @@ you may wish to set up other configuration options first:
 <div class="tab-content">
 <div id="impl-1" class="tab-pane fade in active">
 
+<strong class="hidden started-pdf-include">a) Vagrant</strong>
+
 Now start Apache Brooklyn with the following command:
 
 {% highlight bash %}
@@ -103,6 +108,8 @@ $ vagrant ssh brooklyn --command 'sudo journalctl -n15 -f -u brooklyn'
 </div>
 <div id="impl-2" class="tab-pane fade">
 
+<strong class="hidden started-pdf-include">b) Local Install</strong>
+
 Now start Apache Brooklyn with the following command:
 
 {% highlight bash %}
@@ -132,4 +139,8 @@ The CLI provides the command `br`, it's full usage is described in the
user manu
 
 ## Next
 
-<div class="started-pdf-exclude">The first thing we want to do with Brooklyn is **[deploy
a blueprint](blueprints.html)**.</div>
+<div class="started-pdf-exclude">
+
+The first thing we want to do with Brooklyn is **[deploy a blueprint](blueprints.html)**.
+
+</div>

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/style/css/singlePage.css
----------------------------------------------------------------------
diff --git a/style/css/singlePage.css b/style/css/singlePage.css
index 781e590..4b03262 100644
--- a/style/css/singlePage.css
+++ b/style/css/singlePage.css
@@ -1,6 +1,13 @@
+/* Fix the bootstrap parts so they show the content not the controls*/
 .nav.nav-tabs{
 	display: none;
 }
+.tab-content > .tab-pane {
+    display: inline;
+}
+.fade {
+    opacity: 1;
+}
 #next{
 	display: none;
 }
@@ -8,7 +15,7 @@
     display: block;
 }
 .section-breaker {
-page-break-before:always;
+	page-break-before:always;
 }
 .panel-heading{
 	padding-bottom: 15px;
@@ -28,7 +35,7 @@ page-break-before:always;
 	padding-right: 0px;
 	padding-left: 0px;
 }
-pre{
+pre, pre code{
 	overflow: auto;
 	white-space: pre-wrap;       /* CSS 3 */
     white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/zoneMergeManual.html
----------------------------------------------------------------------
diff --git a/zoneMergeManual.html b/zoneMergeManual.html
index e088395..3111d01 100644
--- a/zoneMergeManual.html
+++ b/zoneMergeManual.html
@@ -2,6 +2,9 @@
 title: Apache Brooklyn Manual
 layout: singlePage
 page_mask: usermanual-pdf-exclude
+css_hide_class: usermanual-pdf-exclude
+css_show_class: usermanual-pdf-include
+availablePages: []
 ---
 {% comment %}<!-- This page builds the single page manual for the PDF, note that this
name must be retained for conversion order -->{% endcomment %}
 
@@ -10,7 +13,7 @@ page_mask: usermanual-pdf-exclude
 		<h1>Apache Brooklyn: User Manual</h1>
 	</header>
 		<h1>Contents</h1>
-	
+		
 	    <nav><ul>
 		  {% assign visited = "" | split: "|" %}
 	      {% for node in site.data.menu  %}

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/f3c06f5c/zoneMergeStarted.html
----------------------------------------------------------------------
diff --git a/zoneMergeStarted.html b/zoneMergeStarted.html
index 11323b7..3cc0e3a 100644
--- a/zoneMergeStarted.html
+++ b/zoneMergeStarted.html
@@ -2,6 +2,9 @@
 title: Apache Brooklyn Manual
 layout: singlePage
 page_mask: started-pdf-exclude
+css_hide_class: started-pdf-exclude
+css_show_class: started-pdf-include
+availablePages: []
 ---
 {% comment %}<!-- This page builds the single page getting started for the PDF, note that
this name must be retained for conversion order -->{% endcomment %}
 


Mime
View raw message