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:53:51 UTC

[14/50] [abbrv] incubator-brooklyn-site git commit: improve dev experience working with this site (offline and simpler)

improve dev experience working with this site (offline and simpler)

plugin which allows using local files so we can develop offline, used in several places;
and tweak the config instructions and scripting mechanism to use this, and not to need scripts for debug usage, and to have fewer files in root


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/10ef0f9c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/tree/10ef0f9c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/diff/10ef0f9c

Branch: refs/heads/master
Commit: 10ef0f9cd66c125e572f93d8dacc39a6764e4a97
Parents: 17d7fe1
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Mon Oct 6 14:08:43 2014 -0700
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Mon Dec 15 16:39:24 2014 +0000

----------------------------------------------------------------------
 .gitignore                     |    1 -
 README.md                      |   24 +-
 _config.yml                    |   24 +-
 _config_for_publication.yml    |    2 -
 _layouts/base.html             |    8 +-
 _layouts/homepage.html         |    1 +
 _layouts/normal.html           |    1 +
 _plugins/dependency_url.rb     |   31 +
 _scripts/build-for-publication |    6 -
 _scripts/build-preview         |   11 -
 _scripts/production-build.sh   |    9 +
 _scripts/production-config.yml |    8 +
 style/deps/README.md           |    3 +
 style/deps/bootstrap.css       | 5785 ++++++++++++++++++++++
 style/deps/bootstrap.js        | 1951 ++++++++
 style/deps/bootstrap.min.css   |    7 +
 style/deps/bootstrap.min.js    |    6 +
 style/deps/jquery.js           | 9190 +++++++++++++++++++++++++++++++++++
 style/deps/jquery.min.js       |    4 +
 19 files changed, 17033 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index abf48c4..50cda82 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
 _site
-_config_local.yml
 *~
 .idea
 .project

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index cba9589..2399f25 100644
--- a/README.md
+++ b/README.md
@@ -55,26 +55,20 @@ Building and previewing the website
 
 Run the command:
 
-    jekyll serve
-    
-or:
-
     jekyll serve --watch
-
-This will start up a local web server. The URL is printed by Jekyll when the server starts. It will continue to run
-until you press Ctrl+C.
+    
+This will start up a local web server. The URL is printed by Jekyll when the server starts,
+e.g. http://localhost:4000/brooklyn/ . The server will continue to run until you press Ctrl+C.
+Modified files will be detected and regenerated (but that might take up to 1m).
+Leave off the `--watch` argument to abandon that behaviour, or use `jekyll build` instead
+to generate a site in `_site` without a server, for instance if your browser supports running from disk.
 
 
-### Using file:/// URLs
-Run this script:
 
-    ./_scripts/build-preview
+### Combining with Brooklyn user-manual / version docs
 
-This will run Jekyll using a base URL of type `file://` for the repository
-directory. This means that it is possible to browse the generated files,
-located in the `_site` directory, using a web browser pointed at your
-filesystem. Unfortunately it does mean that moving the files, or attempting to
-point a web server host at them, will not work.
+TODO: Some links should come from the incubator-brooklyn/docs/ project.
+They can run in debug mode on a different port.
 
 
 Building and publishing the website

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_config.yml
----------------------------------------------------------------------
diff --git a/_config.yml b/_config.yml
index 4bf0e21..4d93eba 100644
--- a/_config.yml
+++ b/_config.yml
@@ -1,7 +1,29 @@
-exclude: ['LICENSE.md', 'README.md', 'Gemfile', 'Gemfile.lock' ]
+
+# Development mode jekyll configuration
+
+# This will be picked up and the docs should display with a simple:
+#
+#     jekyll serve --watch
+
+# See in _scripts/ for more advanced dev and prod considerations.
 
 # Deliberately add the "/brooklyn" to the URL to catch out places where a document uses a link starting "/" - these
 # links should either be relative or use {{site.url}}. We want to preserve this behaviour to allow the possibility of
 # "staging servers" which may publish preview copies of the site at a non-root URL.
+
 url: http://0.0.0.0:4000/brooklyn
 baseurl: /brooklyn
+
+
+# Use local copies of depenedencies (but provide the full URL so it is easy to switch to remote locations)
+
+dependency_mode: local
+dependency_urls:
+  bootstrap.css: https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css
+  bootstrap.js: https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js
+  jquery.js: https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
+
+
+# These files should not be marked down (in addition to _* contents)
+
+exclude: ['LICENSE.md', 'README.md', 'Gemfile', 'Gemfile.lock' ]

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_config_for_publication.yml
----------------------------------------------------------------------
diff --git a/_config_for_publication.yml b/_config_for_publication.yml
deleted file mode 100644
index 0f67044..0000000
--- a/_config_for_publication.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-baseurl: ""
-url: https://brooklyn.incubator.apache.org

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_layouts/base.html
----------------------------------------------------------------------
diff --git a/_layouts/base.html b/_layouts/base.html
index 9bc6600..7eb7d8a 100644
--- a/_layouts/base.html
+++ b/_layouts/base.html
@@ -5,7 +5,7 @@
 <title>{{ page.title }} - Apache Brooklyn (incubating)</title>
 <meta http-equiv="content-type" content="text/html; charset=utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
-<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
+<link href="{% dependency_url bootstrap.css %}" rel="stylesheet">
 <link href="{{site.url}}/style/css/bootstrap-theme.css" rel="stylesheet">
 <link href="{{site.url}}/style/css/theme.css" rel="stylesheet">
 </head>
@@ -57,8 +57,9 @@
 
 {{ content }}
 
-<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
-<script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
+<script src="{% dependency_url jquery.js %}"></script>
+<script src="{% dependency_url bootstrap.js %}"></script>
+
 <script language="JavaScript" type="application/javascript">
     $(window).resize(function () { 
         $('body').css('padding-top', parseInt($('#header').css("height"))+10);
@@ -70,5 +71,6 @@
         $('body').css('padding-bottom', parseInt($('#footer').css("height"))+10);
     });</script>
 </body>
+
 </html>
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_layouts/homepage.html
----------------------------------------------------------------------
diff --git a/_layouts/homepage.html b/_layouts/homepage.html
index 829142c..476ba6b 100644
--- a/_layouts/homepage.html
+++ b/_layouts/homepage.html
@@ -1,4 +1,5 @@
 ---
+# layout for front page, contianing only the footer, with a bit more text
 layout: base
 ---
 <div class="container slightlyNarrowContainer">

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_layouts/normal.html
----------------------------------------------------------------------
diff --git a/_layouts/normal.html b/_layouts/normal.html
index 519e900..a4df66e 100644
--- a/_layouts/normal.html
+++ b/_layouts/normal.html
@@ -1,4 +1,5 @@
 ---
+# layout for most pages, inheriting base for the menu bar, and providing a main column of content and a menu column
 layout: base
 ---
 <div class="container">

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_plugins/dependency_url.rb
----------------------------------------------------------------------
diff --git a/_plugins/dependency_url.rb b/_plugins/dependency_url.rb
new file mode 100644
index 0000000..61fbca9
--- /dev/null
+++ b/_plugins/dependency_url.rb
@@ -0,0 +1,31 @@
+# tag to write the correct URL depending whether we are running with dependencies local (for offline) or remote (eg using a CDN)
+
+# specify a map of <basename>: <remote_url> in the key `dependency_urls` in your `_config.yml`,
+# then, if `dependency_mode: local` is defined, the path `{{site.url}//style/deps/<basename>` will be used,
+# otherwise the <remote_url> will be used
+
+module JekyllDependencyUrl
+  class DependencyUrlTag < Liquid::Tag
+    def initialize(tag_name, text, tokens)
+      super
+      @text = text
+    end
+    def render(context)
+	jekyllSite = context.registers[:site]
+        mode = context['site']['dependency_mode']
+        if mode != 'local'
+          result = context['site']['dependency_urls'][@text.strip]
+          if result.to_s == ''
+            raise 'No value in dependency_urls specified for ' + @text.strip
+          end
+        end
+        if result.to_s == ''
+          result = context['site']['url'] + "/style/deps/" + @text.strip
+        end
+        return result
+    end
+  end
+end
+
+Liquid::Template.register_tag('dependency_url', JekyllDependencyUrl::DependencyUrlTag)
+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_scripts/build-for-publication
----------------------------------------------------------------------
diff --git a/_scripts/build-for-publication b/_scripts/build-for-publication
deleted file mode 100755
index affe61a..0000000
--- a/_scripts/build-for-publication
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash -e
-
-set -x
-
-rm -rf _site
-jekyll build --config _config.yml,_config_for_publication.yml

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_scripts/build-preview
----------------------------------------------------------------------
diff --git a/_scripts/build-preview b/_scripts/build-preview
deleted file mode 100755
index 6b4bc13..0000000
--- a/_scripts/build-preview
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/bash -e
-
-set -x
-
-sitedir=$( cd $( dirname $0 ); cd ..; pwd )/_site
-siteurl="file://${sitedir}"
-echo > _config_local.yml "baseurl: \"\""
-echo >> _config_local.yml "url: ${siteurl}"
-
-rm -rf _site
-jekyll build --config _config.yml,_config_local.yml

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_scripts/production-build.sh
----------------------------------------------------------------------
diff --git a/_scripts/production-build.sh b/_scripts/production-build.sh
new file mode 100755
index 0000000..b9a5134
--- /dev/null
+++ b/_scripts/production-build.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -e
+
+set -x
+
+rm -rf _site
+( jekyll build --config _config.yml,_scripts/production-config.yml && 
+    echo site docs are in `pwd`/_site ) ||
+  echo ERROR - could not build docs in `pwd`
+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/_scripts/production-config.yml
----------------------------------------------------------------------
diff --git a/_scripts/production-config.yml b/_scripts/production-config.yml
new file mode 100644
index 0000000..e9a1f08
--- /dev/null
+++ b/_scripts/production-config.yml
@@ -0,0 +1,8 @@
+
+url: https://brooklyn.incubator.apache.org
+baseurl: ""
+
+dependency_mode: remote
+
+# NB: should inherit (and override) the root _config.yml
+

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn-site/blob/10ef0f9c/style/deps/README.md
----------------------------------------------------------------------
diff --git a/style/deps/README.md b/style/deps/README.md
new file mode 100644
index 0000000..997e1ad
--- /dev/null
+++ b/style/deps/README.md
@@ -0,0 +1,3 @@
+
+This directory contains third-party dependencies.  Originals are downloaded from the locations described in /_config.yml.
+