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

[30/50] [abbrv] incubator-brooklyn git commit: serve static content from `_site` using the new `--serve` option

serve static content from `_site` using the new `--serve` option

experimented with using file urls so files could be read directly in the browser
(as @rdowner had done with `build-preview` in the original website),
but the `url` and `baseurl` are not inserted everywhere (and since we prefer relative links
we probably don't want them everywhere, and filesystem doesn't work nicely in `<base>`)),
so that doesn't work too well; serving is a nice and simple option


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

Branch: refs/heads/master
Commit: d6cfde4060e9ff06d62bbb5bc4378ac72c980d1b
Parents: 0806821
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Tue Dec 16 19:03:39 2014 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Wed Dec 17 02:02:57 2014 +0000

----------------------------------------------------------------------
 docs/README.md            | 12 ++++++-
 docs/_build/build.sh      | 79 +++++++++++++++++++++++++++++-------------
 docs/_build/serve-site.sh |  1 +
 docs/index.md             |  7 ++++
 4 files changed, 73 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d6cfde40/docs/README.md
----------------------------------------------------------------------
diff --git a/docs/README.md b/docs/README.md
index ece1396..9a0aad4 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -143,12 +143,22 @@ There are a number of different builds possible; to list these, run:
 
     _build/build.sh help
 
-The normal build outputs to `_site/`.  The three builds which are relevant to updating the live site are:
+The normal build outputs to `_site/`.  The three builds which are most relevant to updating the live site are:
 
 * **website-root**: to build the website only, in the root
 * **guide-latest**: to build the guide only, in `/v/latest/`
 * **guide-version**: to build the guide only, in the versioned namespace e.g. `/v/<version>/`
 
+There are some others, including `test-both`, which apply slightly different configurations
+useful for testing.
+Supported options beyond that include `--serve`, to start a web browser serving the content of `_site/`,
+and `--skip-javadoc`, to speed up the build significantly by skipping javadoc generation.
+A handy command for testing the live files, analogous to `jekyll serve` 
+but with the correct file structure, is:
+
+    _build/build.sh test-both --skip-javadoc --serve
+
+
 Publishing the Website and Guide
 --------------------------------
 

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d6cfde40/docs/_build/build.sh
----------------------------------------------------------------------
diff --git a/docs/_build/build.sh b/docs/_build/build.sh
index c3f9068..ac10b73 100755
--- a/docs/_build/build.sh
+++ b/docs/_build/build.sh
@@ -22,24 +22,24 @@ function help() {
   echo "* original : to build the files in their original location (website it /website and guide in /guide/, for testing)"
   echo "and supported ARGS are:"
   echo "* --skip-javadoc : to skip javadoc build"
+  echo "* --serve : serve files from _site after building (for testing)"
   echo 'with any remaining ARGS passed to jekyll as `jekyll build --config ... ARGS`.'
 }
 
-function deduce_config() {
-  DIRS_TO_MOVE=( )
+function parse_command() {
   case $1 in
   help)
     help
     exit 0 ;;
   website-root)
-    CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-guide.yml,_build/config-website-root.yml
+    JEKYLL_CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-guide.yml,_build/config-website-root.yml
     DIRS_TO_MOVE[0]=website
     DIRS_TO_MOVE_TARGET[0]=""
     SKIP_JAVADOC=true
     SUMMARY="website files in the root"
     ;;
   guide-latest)
-    CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-all-but-guide.yml,_build/config-guide-latest.yml,_build/config-style-latest.yml
+    JEKYLL_CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-all-but-guide.yml,_build/config-guide-latest.yml,_build/config-style-latest.yml
     DIRS_TO_MOVE[0]=guide
     DIRS_TO_MOVE_TARGET[0]=v/latest
     DIRS_TO_MOVE[1]=style
@@ -48,7 +48,7 @@ function deduce_config() {
     SUMMARY="user guide files in /${DIRS_TO_MOVE_TARGET[0]}"
     ;;
   guide-version)
-    CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-all-but-guide.yml,_build/config-guide-version.yml
+    JEKYLL_CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-all-but-guide.yml,_build/config-guide-version.yml
     # Mac bash defaults to v3 not v4, so can't use assoc arrays :(
     DIRS_TO_MOVE[0]=guide
     # BROOKLYN_VERSION_BELOW
@@ -59,14 +59,14 @@ function deduce_config() {
     SUMMARY="user guide files in /${DIRS_TO_MOVE_TARGET[0]}"
     ;;
   test-guide-root)
-    CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-all-but-guide.yml,_build/config-guide-root.yml
+    JEKYLL_CONFIG=_config.yml,_build/config-production.yml,_build/config-exclude-all-but-guide.yml,_build/config-guide-root.yml
     DIRS_TO_MOVE[0]=guide
     DIRS_TO_MOVE_TARGET[0]=""
     JAVADOC_TARGET=_site/use/api/
     SUMMARY="user guide files in the root"
     ;;
   test-both)
-    CONFIG=_config.yml,_build/config-production.yml,_build/config-website-root.yml,_build/config-guide-latest.yml
+    JEKYLL_CONFIG=_config.yml,_build/config-production.yml,_build/config-website-root.yml,_build/config-guide-latest.yml
     DIRS_TO_MOVE[0]=guide
     DIRS_TO_MOVE_TARGET[0]=v/latest
     DIRS_TO_MOVE[1]=website
@@ -75,7 +75,7 @@ function deduce_config() {
     SUMMARY="all files, website in root and guide in /${DIRS_TO_MOVE_TARGET[0]}"
     ;;
   test-both-sub)
-    CONFIG=_config.yml,_build/config-production.yml,_build/config-subpath-brooklyn.yml
+    JEKYLL_CONFIG=_config.yml,_build/config-production.yml,_build/config-subpath-brooklyn.yml
     DIRS_TO_MOVE[0]=guide
     DIRS_TO_MOVE_TARGET[0]=brooklyn/v/latest
     DIRS_TO_MOVE[1]=website
@@ -86,7 +86,7 @@ function deduce_config() {
     SUMMARY="all files in /brooklyn"
     ;;
   original)
-    CONFIG=_config.yml,_build/config-production.yml
+    JEKYLL_CONFIG=_config.yml,_build/config-production.yml
     SUMMARY="all files in their original place"
     ;;
   "")
@@ -98,9 +98,32 @@ function deduce_config() {
   esac
 }
 
+function parse_arguments() {
+  while (( "$#" )); do
+    case $1 in
+    "--serve")
+      SERVE_AFTERWARDS=true
+      shift
+      ;;
+    "--skip-javadoc")
+      SKIP_JAVADOC=true
+      shift
+      ;;
+    "--")
+      shift
+      break
+      ;;
+    *)
+      break
+      ;;
+    esac
+  done
+  JEKYLL_ARGS="$@"
+}
+
 function make_jekyll() {
-  echo JEKYLL running with: jekyll build $CONFIG $@
-  jekyll build --config $CONFIG $@ || return 1
+  echo JEKYLL running with: jekyll build $JEKYLL_CONFIG $JEKYLL_ARGS
+  jekyll build --config $JEKYLL_CONFIG $JEKYLL_ARGS || return 1
   echo JEKYLL completed
   for DI in "${!DIRS_TO_MOVE[@]}"; do
     D=${DIRS_TO_MOVE[$DI]}
@@ -111,22 +134,14 @@ function make_jekyll() {
     cp -r _site/$D/* _site/$DT
     rm -rf _site/$D
   done
+  # normally we exclude things but we can also set TARGET as long_grass and it will get destroyed
   rm -rf _site/long_grass
 }
 
-rm -rf _site
-
-deduce_config $@
-shift
-
-if [ "$1" = "--skip-javadoc" ]; then
-  SKIP_JAVADOC=true
-  shift
-fi
-
-make_jekyll || { echo ERROR: could not build docs in `pwd` ; exit 1 ; }
-
-if [ "$SKIP_JAVADOC" != "true" ]; then
+function make_javadoc() {
+  if [ "$SKIP_JAVADOC" == "true" ]; then
+    return
+  fi
   pushd _build > /dev/null
   rm -rf target/apidocs
   ./make-javadoc.sh || { echo ERROR: failed javadoc build ; exit 1 ; }
@@ -134,8 +149,22 @@ if [ "$SKIP_JAVADOC" != "true" ]; then
   if [ ! -z "$JAVADOC_TARGET" ]; then
     mv _build/target/apidocs/* $JAVADOC_TARGET
   fi
-fi
+}
+
+rm -rf _site
+
+parse_command $@
+shift
+parse_arguments $@
+
+make_jekyll || { echo ERROR: failed jekyll docs build in `pwd` ; exit 1 ; }
+
+make_javadoc || { echo ERROR: failed javadoc build ; exit 1 ; }
 
 # TODO build catalog
 
 echo FINISHED: $SUMMARY of `pwd`/_site 
+
+if [ $SERVE_AFTERWARDS == "true" ]; then
+  _build/serve-site.sh
+fi

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d6cfde40/docs/_build/serve-site.sh
----------------------------------------------------------------------
diff --git a/docs/_build/serve-site.sh b/docs/_build/serve-site.sh
new file mode 100755
index 0000000..69cf70d
--- /dev/null
+++ b/docs/_build/serve-site.sh
@@ -0,0 +1 @@
+ruby -run -e httpd _site/ -p 4000

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d6cfde40/docs/index.md
----------------------------------------------------------------------
diff --git a/docs/index.md b/docs/index.md
index 86a0883..5e9c805 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -11,3 +11,10 @@ Consider looking at:
 * <a href="{{ site.path.guide }}/">the brooklyn user guide (version 0.7.0-SNAPSHOT <!-- BROOKLYN_VERSION --></a>
 
 Also see the file <code>README.md</code> in this directory.
+
+For reference, this build uses the following variables:
+
+* url:  `{{ site.url }}`
+* baseurl: `{{ site.baseurl }}`
+* path map: `{{ site.path }}`
+