Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49E2D18184 for ; Mon, 1 Feb 2016 17:45:34 +0000 (UTC) Received: (qmail 30415 invoked by uid 500); 1 Feb 2016 17:45:12 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 30359 invoked by uid 500); 1 Feb 2016 17:45:12 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 29625 invoked by uid 99); 1 Feb 2016 17:45:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Feb 2016 17:45:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 48EFDE07F7; Mon, 1 Feb 2016 17:45:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: heneveld@apache.org To: commits@brooklyn.apache.org Date: Mon, 01 Feb 2016 17:45:57 -0000 Message-Id: In-Reply-To: <04e7fe8ce5ec4915b32d09a0a4643d83@git.apache.org> References: <04e7fe8ce5ec4915b32d09a0a4643d83@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [49/51] [abbrv] [partial] brooklyn-docs git commit: move subdir from incubator up a level as it is promoted to its own repo (first non-incubator commit!) http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_extra/simple_java_examples/example_files/tomcat_nginx.java ---------------------------------------------------------------------- diff --git a/_extra/simple_java_examples/example_files/tomcat_nginx.java b/_extra/simple_java_examples/example_files/tomcat_nginx.java new file mode 100644 index 0000000..20db33d --- /dev/null +++ b/_extra/simple_java_examples/example_files/tomcat_nginx.java @@ -0,0 +1,17 @@ +// TODO Untested code; see brooklyn-example for better maintained examples! +public class TomcatClusterWithNginxApp extends AbstractApplication { + @Override + public void init() { + addChild(EntitySpec.create(NginxController.class) + .configure("domain", "brooklyn.geopaas.org") + .configure("port", "8000+") + .configure("portNumberSensor", Attributes.HTTP_PORT)); + + addChild(EntitySpec.create(ControlledDynamicWebAppCluster.class) + .configure("controller", nginxController) + .configure("memberSpec", : EntitySpec.create(TomcatServer.class) + .configure("httpPort", "8080+") + .configure("war", "/path/to/booking-mvc.war")) + .configure("initialSize", 2)); + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_extra/simple_java_examples/example_files/tomcat_simple.java ---------------------------------------------------------------------- diff --git a/_extra/simple_java_examples/example_files/tomcat_simple.java b/_extra/simple_java_examples/example_files/tomcat_simple.java new file mode 100644 index 0000000..480a333 --- /dev/null +++ b/_extra/simple_java_examples/example_files/tomcat_simple.java @@ -0,0 +1,9 @@ +// TODO Untested code; see brooklyn-example for better maintained examples! +public class TomcatServerApp extends AbstractApplication { + @Override + public void init() { + addChild(EntitySpec.create(TomcatServer.class) + .configure("httpPort", "8080+") + .configure("war", "/path/to/booking-mvc.war"))); + } +} http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_extra/simple_java_examples/examples.md ---------------------------------------------------------------------- diff --git a/_extra/simple_java_examples/examples.md b/_extra/simple_java_examples/examples.md new file mode 100644 index 0000000..334b2ec --- /dev/null +++ b/_extra/simple_java_examples/examples.md @@ -0,0 +1,121 @@ +--- +title: Examples +layout: website-normal +toc: ../guide_toc.json +categories: [use, guide, defining-applications] +--- + +** TODO: this examples page is deprecated; +code is out-of-date, and better examples are described on the web site. +need to figure out if this page should be kept at all +(indeed if the "guide" is even still relevant)** + + +### Integrating with a Maven project + +If you have a Maven-based project, integrate this XML fragment with your pom.xml: + + + +{% highlight xml %} + + + io.brooklyn + brooklyn-all + 0.9.0-SNAPSHOT + + + + + cloudsoft-releases + http://developers.cloudsoftcorp.com/download/maven2/ + + + libs-snapshot-local + http://ccweb.cloudsoftcorp.com/maven/libs-snapshot-local/ + + true + never + fail + + +{% endhighlight %} + + +### Starting a Tomcat Server + +The code below starts a Tomcat server on the local machine. + +The ``main`` method defines the application, and passes it to the ``BrooklynLauncher`` to be managed. +It is then started in a localhost location (other locations are shown in the next section). + +The Tomcat's configuration indicates that the given WAR should be deployed to the Tomcat server when it is started. + +{% highlight java %} +{% readj example_files/tomcat_simple.java %} +{% endhighlight %} + +The ``wars`` config is also supported (with config keys ``ROOT_WAR`` and ``NAMED_WARS`` the long-hand syntax); +they accept EARs and other common archives, and can be described as files or as URLs (as Strings), +with URLs supporting an optional ``classpath://org/acme/resources/xxx.war`` syntax. + + +### Starting Tomcat in Amazon EC2 + +To start a tomcat node or cluster in Amazon EC2, the application is identical to that for localhost. +The only difference is the location supplied. + +The Brooklyn CLI can be used to launch the application in your choice of location, such as: + +{% highlight bash %} +brooklyn launch --app TomcatServerApp --location localhost +brooklyn launch --app TomcatServerApp --location aws-ec2:eu-west-1 +{% endhighlight %} + + +### Starting a Tomcat Cluster with Nginx + +The code below starts a Tomcat cluster along with an Nginx instance, where each Tomcat server in the cluster is registered with the Nginx instance. + +{% highlight java %} +{% readj example_files/tomcat_nginx.java %} +{% endhighlight %} + +This creates a cluster that of Tomcat servers, along with an Nginx instance. The ``NginxController`` instance +is notified whenever a member of the cluster joins or leaves; the entity is configured to look at the ``HTTP_PORT`` +attribute of that instance so that the Nginx configuration can be updated with the ip:port of the cluster member. + + + + +Starting a Multi-location Tomcat Fabric +--------------------------------------- + + + + + +The ``ControlledDynamicWebAppCluster`` entity used above can also be used with a DynamicFabric to start +a web-cluster in each location. + +{% highlight java %} +{% readj example_files/tomcat_multi-location.java %} +{% endhighlight %} + + +Examples Source +--------------- + +Source code for (more up-to-date!) examples is available for download from GitHub. To retrieve the source, execute the following command: + + git clone git@github.com:apache/incubator-brooklyn.git + cd incubator-brooklyn/examples + +You can also [browse the code](https://github.com/apache/incubator-brooklyn/tree/examples) on the web. http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_extra/update-docs.md ---------------------------------------------------------------------- diff --git a/_extra/update-docs.md b/_extra/update-docs.md new file mode 100644 index 0000000..5abb056 --- /dev/null +++ b/_extra/update-docs.md @@ -0,0 +1,14 @@ +--- +layout: website-normal +title: Updating the Docs +toc: /guide/toc.json +--- + + + +The Brooklyn docs live in the **docs** project in the Brooklyn codebase. +It's built using standard jekyll/markdown with a few extensions. + +Instructions for building and working with docs are in a `README.md` file +in that folder; for the most recent version of instructions click +[here](https://github.com/apache/incubator-brooklyn/tree/master/docs/README.md). http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/base-head.html ---------------------------------------------------------------------- diff --git a/_includes/base-head.html b/_includes/base-head.html new file mode 100644 index 0000000..0773dc2 --- /dev/null +++ b/_includes/base-head.html @@ -0,0 +1,30 @@ + +{{ page.title }} - Apache Brooklyn (incubating) + + + + + + + + + + + + + + + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/base-scss.scss ---------------------------------------------------------------------- diff --git a/_includes/base-scss.scss b/_includes/base-scss.scss new file mode 100644 index 0000000..aec3e2f --- /dev/null +++ b/_includes/base-scss.scss @@ -0,0 +1,36 @@ + +$fonts: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif; +$header_fonts: Avenir, $fonts; + +// colors + +/* this green is approx what is in the logo (taken from image picker) */ +$brooklyn_green: #6db34b; +$bootstrap_theme_green_gradient_upper: #5cb85c; +$bootstrap_theme_green_gradient_lower: #48a648; +$vibrant_bg_green: $bootstrap_theme_green_gradient_lower; +$vibrant_fg_green: #483; + +$white_fa: #fafafa; +$white_f5: #f5f5f5; +$white_ee: #eee; +$white_dd: #ddd; // for borders and tooltip bg +$gray_aa: #aaa; +$gray_88: #888; +$gray_66: #666; + +$blackish: #393939; + +$bootstrap_blue_border: #428bca; + +// roles for colors + +$text_color: $blackish; + +$a_color: $vibrant_fg_green; +$a_hover_color: $brooklyn_green; + +//$code_bg_color: #e8eded; +$code_bg_color: $white_f5; + +$footer_icon_gray: $gray_88; http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/feature-image.html ---------------------------------------------------------------------- diff --git a/_includes/feature-image.html b/_includes/feature-image.html new file mode 100644 index 0000000..89bedcd --- /dev/null +++ b/_includes/feature-image.html @@ -0,0 +1,4 @@ + +
+ +
http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/feature-item-end.html ---------------------------------------------------------------------- diff --git a/_includes/feature-item-end.html b/_includes/feature-item-end.html new file mode 100644 index 0000000..f208df5 --- /dev/null +++ b/_includes/feature-item-end.html @@ -0,0 +1,14 @@ + +{% if include.img %} +{% comment %} + does not work to do: { % include feature-image.html src='{{ include.img }}' % } + so we repeat that snippet :( +{% endcomment %} + +
+ +
+ +{% endif %} + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/feature-item.html ---------------------------------------------------------------------- diff --git a/_includes/feature-item.html b/_includes/feature-item.html new file mode 100644 index 0000000..e91d6c2 --- /dev/null +++ b/_includes/feature-item.html @@ -0,0 +1,4 @@ + +
+
{{ include.title }}
+
http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/fields.md ---------------------------------------------------------------------- diff --git a/_includes/fields.md b/_includes/fields.md new file mode 100644 index 0000000..d9e74b7 --- /dev/null +++ b/_includes/fields.md @@ -0,0 +1,32 @@ + +{% if site.brooklyn-version contains 'SNAPSHOT' %}{% capture SNAPSHOT %}true{% endcapture %}{% endif %} + +{% capture brooklyn_properties_url_path %}{{ site.path.guide }}/start/brooklyn.properties{% endcapture %} +{% capture brooklyn_properties_url_live %}{{ site.url_root }}{{ brooklyn_properties_url_path }}{% endcapture %} + +{% capture brooklyn_group_id %}org.apache.brooklyn{% endcapture %} +{% capture brooklyn_group_id_path %}org/apache/brooklyn{% endcapture %} + +{% capture this_repo_base_url %}https://repository.apache.org{% endcapture %} +{% capture this_repo_base_url_search %}{{ this_repo_base_url }}/index.html#nexus-search{% endcapture %} +{% capture this_repo_base_url_artifact %}{{ this_repo_base_url }}/service/local/artifact/maven/redirect{% endcapture %} + +{% capture apache_snapshots_repo_groupid_url %}{{ this_repo_base_url }}/content/repositories/snapshots/{{ brooklyn_group_id_path }}{% endcapture %} +{% capture apache_releases_repo_groupid_url %}{{ this_repo_base_url }}/content/repositories/releases/{{ brooklyn_group_id_path }}{% endcapture %} + +{% capture this_repo_base_url_content %}{% if SNAPSHOT %}{{ apache_snapshots_repo_groupid_url }}{% else %}{{ apache_releases_repo_groupid_url }}{% endif %}{% endcapture %} +{% capture this_dist_url_list %}{{ this_repo_base_url_content }}/brooklyn-dist/{{ site.brooklyn-version }}/{% endcapture %} + +{% if SNAPSHOT %} + + {% capture this_dist_url_zip %}{{ this_repo_base_url_artifact }}?r=snapshots&g={{ brooklyn_group_id }}&a=brooklyn-dist&v={{ site.brooklyn-version }}&c=dist&e=zip{% endcapture %} + {% capture this_dist_url_tgz %}{{ this_repo_base_url_artifact }}?r=snapshots&g={{ brooklyn_group_id }}&a=brooklyn-dist&v={{ site.brooklyn-version }}&c=dist&e=tar.gz{% endcapture %} +{% else %} + {% capture this_dist_url_zip %}{{ this_dist_url_list }}/brooklyn-dist-{{ site.brooklyn-version }}-dist.zip{% endcapture %} + {% capture this_dist_url_tgz %}{{ this_dist_url_list }}/brooklyn-dist-{{ site.brooklyn-version }}-dist.tar.gz{% endcapture %} +{% endif %} + +{% capture this_anything_url_search %}{{ this_repo_base_url_search }};gav~{{ brooklyn_group_id }}~~{{ site.brooklyn-version }}~~{% endcapture %} +{% capture this_dist_url_search %}{{ this_repo_base_url_search }};gav~{{ brooklyn_group_id }}~brooklyn-dist~{{ site.brooklyn-version }}~~{% endcapture %} + + http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/footer.html ---------------------------------------------------------------------- diff --git a/_includes/footer.html b/_includes/footer.html new file mode 100644 index 0000000..316fe5a --- /dev/null +++ b/_includes/footer.html @@ -0,0 +1,16 @@ + http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/java_link.html ---------------------------------------------------------------------- diff --git a/_includes/java_link.html b/_includes/java_link.html new file mode 100644 index 0000000..9411877 --- /dev/null +++ b/_includes/java_link.html @@ -0,0 +1,18 @@ +{% comment %} + +includes a code-formatted class name with link to its javadoc and optionally its source code + +usage: + +{ % include java_link.html class_name="JcloudsLocationConfig" package_path="org/apache/brooklyn/location/jclouds" project_subpath="location/jclouds" % } + + +{% endcomment %}{% if include.project_subpath %}{{ include.class_name }} + (javadoc, + src){% comment %} +{% endcomment %}{% else %} +{{ include.class_name }} +{% endif %}{% comment %} + +must NOT have a newline at the end here, as the include is often done inline +{% endcomment %} http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/list-children.html ---------------------------------------------------------------------- diff --git a/_includes/list-children.html b/_includes/list-children.html new file mode 100644 index 0000000..0c327f3 --- /dev/null +++ b/_includes/list-children.html @@ -0,0 +1,9 @@ +{% comment %} +TODO style this much better +{% endcomment %} + +
\ No newline at end of file http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/sidemenu.html ---------------------------------------------------------------------- diff --git a/_includes/sidemenu.html b/_includes/sidemenu.html new file mode 100644 index 0000000..ec3cf1c --- /dev/null +++ b/_includes/sidemenu.html @@ -0,0 +1,244 @@ +
+{% comment %} + + Case 1) If we're the landing page show nothing. + Case 2) If we're contained in the top (landing page) menu, show our menu if we have one. + Case 3a) Otherwise if we're contained in a menu, show that menu. + Case 3b) And if we have a menu, show our menu nested. + + Note the breadcrumbs are offset:1. This is because usually breadcrumbs include the root; + but also if we're overriding breadcrumbs it gives us a way to set a topmenu item (making it breadcrumb[0]) + while customizing the side menu (make self breadcrumb[1]). +{% endcomment %} + +{% unless page.landing %} + {% if page.menu_parent %} + {% if page.menu_parent.landing %} {% comment %} case 2 {% endcomment %} + {% for item in page.breadcrumb_pages offset:1 %} +

+ + {{ item.title_in_menu }}

+ {% endfor %} + + {% for item in page.menu %} + {{ item.title_in_menu }} + {% if item.external %} {% endif %} + {% endfor %} + + {% else %} {% comment %} case 3a {% endcomment %} + {% for item in page.menu_parent.breadcrumb_pages offset:1 %} +

+ + {{ item.title_in_menu }} + {% if item.external %} {% endif %}

+ {% endfor %} + {% for item in page.menu_parent.menu %} + {% if page.breadcrumb_paths contains item.menu_path %}{% assign in_menu = true %}{% else %}{% assign in_menu = false %}{% endif %} + {% if in_menu and page.menu %} + {% comment %} case 3b {% endcomment %} + {{ item.title_in_menu }} + {% if item.external %} {% endif %} +
+ {% for item2 in page.menu %} + {% capture item_section_classes %}{% if item2.section %} section{% endif %}{% endcapture %} + + {{ item2.title_in_menu }} + {% if item2.external %} {% endif %} + {% endfor %} +
+ {% else %} + {% comment %} case 3a side menu item {% endcomment %} + {{ item.title_in_menu }} + {% if item.external %} {% endif %} + {% endif %} + {% endfor %} + + {% endif %} + {% elsif page.menu %} + + {% endif %} +{% endunless %} + +
+
+ + + http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/sitemap-item.html ---------------------------------------------------------------------- diff --git a/_includes/sitemap-item.html b/_includes/sitemap-item.html new file mode 100644 index 0000000..e2034f5 --- /dev/null +++ b/_includes/sitemap-item.html @@ -0,0 +1,36 @@ +{% pop site_items item %} +{% set_hash_entry item path item_path %} +{% set_hash_entry item url item_url %} + +{% unless item_path %} + {% unless item_url %} + {% puts error, null item_url %} + {% putp item %} + {% putv item_url %} + {% fail item missing path and url (jekyll block evaluation order can cause this) %} + {% endunless %} +{% endunless %} + + +
  • + {% if visited contains item_path %} + {{ item['title'] }}   + {% elsif item['external'] %} + {{ item['title'] }}   + + {% else %} + {{ item['title'] }} + {% if item['menu'] %} + {% push visited item_path %} +
      + {% push site_items item %} + {% assign last_item = site_items[-1] %} + {% for item in last_item['menu'] %} + {% push site_items item %} + {% include sitemap-item.html %} + {% endfor %} + {% pop site_items item %} +
    + {% endif %} + {% endif %} +
  • http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_includes/topmenu.html ---------------------------------------------------------------------- diff --git a/_includes/topmenu.html b/_includes/topmenu.html new file mode 100644 index 0000000..0275794 --- /dev/null +++ b/_includes/topmenu.html @@ -0,0 +1,75 @@ + http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_layouts/base.html ---------------------------------------------------------------------- diff --git a/_layouts/base.html b/_layouts/base.html new file mode 100644 index 0000000..29b735f --- /dev/null +++ b/_layouts/base.html @@ -0,0 +1,186 @@ + + + + + + +{{ content }} + + + + + + + + + http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_layouts/website-base.html ---------------------------------------------------------------------- diff --git a/_layouts/website-base.html b/_layouts/website-base.html new file mode 100644 index 0000000..8f8c24a --- /dev/null +++ b/_layouts/website-base.html @@ -0,0 +1,33 @@ +--- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +layout: base +--- + + + + {% include base-head.html %} + + + + + + +{% include topmenu.html %} + +{{ content }} http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_layouts/website-landing.html ---------------------------------------------------------------------- diff --git a/_layouts/website-landing.html b/_layouts/website-landing.html new file mode 100644 index 0000000..7d2a6e4 --- /dev/null +++ b/_layouts/website-landing.html @@ -0,0 +1,43 @@ +--- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# layout for front page, contianing only the footer, with a bit more text +layout: website-base +--- +
    + {{ content }} +
    + + http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_layouts/website-normal.html ---------------------------------------------------------------------- diff --git a/_layouts/website-normal.html b/_layouts/website-normal.html new file mode 100644 index 0000000..a89bb91 --- /dev/null +++ b/_layouts/website-normal.html @@ -0,0 +1,39 @@ +--- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# layout for most website pages, inheriting base for the menu bar, and providing a main column of content and a menu column +# (not used for the landing page, and not used for the guide) +# +# menu_customizations can be used, including force_inactive to prevent highlighting +layout: website-base +--- +
    +
    +
    +
    +

    {{ page.title }}

    + {{ content }} +
    + +
    + {% include sidemenu.html %} +
    +
    +
    + +{% include footer.html %} http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_licensing/README ---------------------------------------------------------------------- diff --git a/_licensing/README b/_licensing/README new file mode 100644 index 0000000..2fc5f2e --- /dev/null +++ b/_licensing/README @@ -0,0 +1,24 @@ + +We don't distribute docs as part of the source build so we're not obliged to report the JS we include +or generate a special LICENSE file as brooklyn-dist/dist/licensing does for the distributed projects. + +(This project just gets the usual brooklyn license.) + +However we might consider recording the licenses used in the docs. So we note +that third-party software bundled by the docs include: + +* bloodhound (aka typeahead) +* glossarizer + +And other things used by brooklyn, in style/{deps,js}. + +--- + +This project includes the software: glossarizer + Available at: https://github.com/PebbleRoad/glossarizer + Developed by: Vinay M, PebbleRoad Pte Ltd (http://www.pebbleroad.com) + Version used: 1.5 + Used under the following license: The MIT License (http://opensource.org/licenses/MIT) + Copyright (c) Vinay M, PebbleRoad Pte Ltd (2004-2016) + + http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_plugins/brooklyn_jekyll_util.rb ---------------------------------------------------------------------- diff --git a/_plugins/brooklyn_jekyll_util.rb b/_plugins/brooklyn_jekyll_util.rb new file mode 100644 index 0000000..fd3688d --- /dev/null +++ b/_plugins/brooklyn_jekyll_util.rb @@ -0,0 +1,129 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# useful tags: + +# printing +# puts message +# putv variable_to_print_raw +# putp variable_to_pretty_print + +# eval and control flow +# set_hash_entry hash key variable_to_set # because sometimes jekyll eval order is different +# fail message # to fail with a message + +# stack manipulation: +# push stack x # pushs x to stack and clears x +# pop stack x # pops from stack into x +# useful e.g. in recursive include calls where x might overwritten + +require 'pp' + +module BrooklynJekyllUtil + class PutsTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + puts "#{@text}" + end + end + class PutvTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + puts "#{@text}: #{context[@text]}" + end + end + class PutpTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + puts "#{@text}:" + PP.pp(context[@text]) + nil + end + end + + class SetHashEntryTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + args = @text.split(/\W+/) + raise "Need 3 args, the hash, the key, and the var to set" unless args.length == 3 +# puts "getting #{args[0]}['#{args[1]}']" +# PP.pp(context[args[0]]) +# PP.pp(context[args[0]][args[1]]) + + context[args[2]] = context[args[0]][args[1]] + nil + end + end + + class FailTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + raise "Fail#{@text.length>0 ? ": #{@text}" : ""}" + end + end + + class PushTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + args = @text.split(/\W+/) + raise "Need 2 args, the stack and the var" unless args.length == 2 + context[args[0]] = [] unless context[args[0]] + context[args[0]].push(context[args[1]]) + context[args[1]] = nil + end + end + class PopTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + args = @text.split(/\W+/) + raise "Need 2 args, the stack and the var" unless args.length == 2 + context[args[1]] = context[args[0]].pop(); + nil + end + end +end + +Liquid::Template.register_tag('puts', BrooklynJekyllUtil::PutsTag) +Liquid::Template.register_tag('putv', BrooklynJekyllUtil::PutvTag) +Liquid::Template.register_tag('putp', BrooklynJekyllUtil::PutpTag) +Liquid::Template.register_tag('set_hash_entry', BrooklynJekyllUtil::SetHashEntryTag) +Liquid::Template.register_tag('fail', BrooklynJekyllUtil::FailTag) +Liquid::Template.register_tag('push', BrooklynJekyllUtil::PushTag) +Liquid::Template.register_tag('pop', BrooklynJekyllUtil::PopTag) http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_plugins/brooklyn_metadata.rb ---------------------------------------------------------------------- diff --git a/_plugins/brooklyn_metadata.rb b/_plugins/brooklyn_metadata.rb new file mode 100644 index 0000000..ee0ba7b --- /dev/null +++ b/_plugins/brooklyn_metadata.rb @@ -0,0 +1,64 @@ +# Inserts several useful fields that can be referenced using {{ name }} syntax +# +# TODO: move things from fields.md to here +# +# site.brooklyn.version: brooklyn version, such as 0.7.0-M1 (taken from brooklyn-version in _config.yml) +# site.brooklyn.is_snapshot: true if this is a snapshot version, otherwise false +# +module BrooklynMetadata + + BROOKLYN_VERSION = "0.9.0-SNAPSHOT" unless defined? BROOKLYN_VERSION + + class Generator < Jekyll::Generator + def generate(site) + raise "Brooklyn version mismatch" if BrooklynMetadata::BROOKLYN_VERSION != site.config['brooklyn-version'] + + is_snapshot = BrooklynMetadata::BROOKLYN_VERSION.end_with?('-SNAPSHOT') + + if is_snapshot + git_branch = 'master' unless site.data['git_branch'] + url_set = { + "search" => { + "all" => "https://oss.sonatype.org/index.html#nexus-search;gav~io.brooklyn~~#{ BrooklynMetadata::BROOKLYN_VERSION }~~", + "dist" => "https://oss.sonatype.org/index.html#nexus-search;gav~io.brooklyn~brooklyn-dist~#{ BrooklynMetadata::BROOKLYN_VERSION }~~", + }, + "dist" => { + "base" => "https://oss.sonatype.org/content/groups/public/io/brooklyn/brooklyn-dist/#{ BrooklynMetadata::BROOKLYN_VERSION }/", + "zip" => "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=io.brooklyn&v=#{ BrooklynMetadata::BROOKLYN_VERSION }&a=brooklyn-dist&c=dist&e=zip", + "tgz" => "https://oss.sonatype.org/service/local/artifact/maven/redirect?r=snapshots&g=io.brooklyn&v=#{ BrooklynMetadata::BROOKLYN_VERSION }&a=brooklyn-dist&c=dist&e=tar.gz" + } + } + + else + git_branch = BrooklynMetadata::BROOKLYN_VERSION unless site.data['git_branch'] + url_set = { + "search" => { + "all" => "http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.brooklyn%22%20AND%20v%3A%22#{ BrooklynMetadata::BROOKLYN_VERSION }%22", + "dist" => "http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.brooklyn%22%20AND%20a%3A%22brooklyn-dist%22%20AND%20v%3A%22#{ BrooklynMetadata::BROOKLYN_VERSION }%22", + }, + "dist" => { + "base" => "http://repo1.maven.org/maven2/io/brooklyn/brooklyn-dist/#{ BrooklynMetadata::BROOKLYN_VERSION }/", + "zip" => "http://repo1.maven.org/maven2/io/brooklyn/brooklyn-dist/#{ BrooklynMetadata::BROOKLYN_VERSION }/brooklyn-dist-#{ BrooklynMetadata::BROOKLYN_VERSION }-dist.zip", + "tgz" => "http://repo1.maven.org/maven2/io/brooklyn/brooklyn-dist/#{ BrooklynMetadata::BROOKLYN_VERSION }/brooklyn-dist-#{ BrooklynMetadata::BROOKLYN_VERSION }-dist.tar.gz" + } + } + end + + url_set["git"] = "https://github.com/apache/incubator-brooklyn/tree/#{ git_branch }" + + site.config['brooklyn'] = { + "version" => BrooklynMetadata::BROOKLYN_VERSION, + "is_snapshot" => is_snapshot, + "is_release" => !is_snapshot, + "url" => url_set, + "git_branch" => git_branch + } + + # config is preferred of data, because you can write just {{ site.brooklyn.xxx }}, + # also note {{ site.brooklyn-version }} v {{ site.brooklyn-stable-version }} from _config.yml + # but some places referenced site.data.brooklyn (i think these have been remove) + site.data['brooklyn'] = site.config['brooklyn'] + + end + end +end http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_plugins/dependency_url.rb ---------------------------------------------------------------------- diff --git a/_plugins/dependency_url.rb b/_plugins/dependency_url.rb new file mode 100644 index 0000000..8a72e17 --- /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 : in the key `dependency_urls` in your `_config.yml`, +# then, if `dependency_mode: local` is defined, the path `{{site.path.style}}/deps/` will be used, +# otherwise the 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']['path']['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/brooklyn-docs/blob/6e86cb02/_plugins/json.rb ---------------------------------------------------------------------- diff --git a/_plugins/json.rb b/_plugins/json.rb new file mode 100644 index 0000000..b36a6b2 --- /dev/null +++ b/_plugins/json.rb @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +require 'json' + +module JsonFilter + def json(input) + input.to_json + end + + Liquid::Template.register_filter self +end http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_plugins/jsonball.rb ---------------------------------------------------------------------- diff --git a/_plugins/jsonball.rb b/_plugins/jsonball.rb new file mode 100644 index 0000000..c12a441 --- /dev/null +++ b/_plugins/jsonball.rb @@ -0,0 +1,103 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +require 'json' + +# JSON parser tag, creating map for use in jekyll markdown + +# usage: {% jsonball varname from TYPE PARAM %} +# +# where TYPE is one of {data,var,file,page}, described below + +# drop this into your _plugins/ folder, then you can write, e.g. +# +# {% jsonball foo from data { "a": "b" } %} +# +# and then later refer to {{ foo.a }} to get b inserted + +# more usefully, you can load it from a variable x, e.g. +# {% capture x %}{% include toc.json %}{% endcapture %} +# +# {% jsonball foo from var x %} + +# even better, to read from a file, say toc.json +# (absolute, or relative to the page being jekylled): +# +# {% jsonball foo from file toc.json %} +# +# then e.g. {% for record in jsonball %} {{ record.name }} {% endfor %} +# to print out all the name entries (or build a fancy TOC sidebar) + +# and finally, if that json file might itself contain liquid tags, +# or need jekylling, treat it as a page and it will get jekylled +# (we use this for toc.json reading from subdirs' toc.json files): +# +# {% jsonball foo from page toc.json %} + +module JekyllJsonball + class JsonballTag < Liquid::Tag + + def initialize(tag_name, text, tokens) + super + @text = text + end + + def render(context) + if /(.+) from var (.+)/.match(@text) + context[$1] = JSON context[$2] + return '' + end + if /(.+) from data (.+)/.match(@text) + context[$1] = JSON $2 + return '' + end + if /(.+) from file (.+)/.match(@text) + context[$1] = JSON page_relative_file_contents(context, $2.strip) + return '' + end + if /(.+) from page (.+)/.match(@text) + context[$1] = JSON jekylled_page_relative_file_contents(context, $2.strip) + return '' + end + # syntax error + return 'ERROR:bad_jsonball_syntax' + end + + def page_relative_file_contents(context, filename) + jekyllSite = context.registers[:site] + dir = jekyllSite.source+'/'+File.dirname(context['page']['url']) + filename = context[filename] || filename + if !filename.match(/\/.*/) + filename = dir + '/' + filename + end + file = File.open(filename, "rb") + return file.read + end + + def jekylled_page_relative_file_contents(context, filename) + jekyllSite = context.registers[:site] + filename = context[filename] || filename + targetPage = Jekyll::Page.new(jekyllSite, jekyllSite.source, File.dirname(context['page']['url']), filename) + targetPage.render(jekyllSite.layouts, jekyllSite.site_payload) + targetPage.output + end + + end +end + +Liquid::Template.register_tag('jsonball', JekyllJsonball::JsonballTag) http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_plugins/read.rb ---------------------------------------------------------------------- diff --git a/_plugins/read.rb b/_plugins/read.rb new file mode 100644 index 0000000..23cf0f2 --- /dev/null +++ b/_plugins/read.rb @@ -0,0 +1,81 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# tag to read and insert a file relative to the current working directory +# (like include, but in the dir where it is invoked) + +# there is also readj which reads a file and applies jekyll processing to it +# handy if we want to include a toc.json file which itself calls {% readj child/toc.json %} +# (note however variables do not seem to be exported when use readj (TODO), +# although they are exported if you have _includes/file.md and use the standard include file) + +# the argument can be a variable or a filename literal (not quoted) +# TODO: figure out how to accept a quoted string as an argument + +require 'pathname' + +module JekyllRead + class ReadTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + filename = @text.strip + filename = context[filename] || filename + + # Pathname API ignores first arg below if second is absolute + file = Pathname.new(File.dirname(context['page']['path'])) + filename + file = file.cleanpath + # is there a better way to trim a leading / ? + file = file.relative_path_from(Pathname.new("/")) unless file.relative? + raise "No such file #{file} in read call (from #{context['page']['path']})" unless file.exist? + + file = File.open(file, "rb") + return file.read + end + end + + class ReadjTag < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + filename = @text.strip + filename = context[filename] || filename + # Pathname API ignores first arg below if second is absolute + page = context['page'] || context.registers[:page] + file = Pathname.new(File.dirname(page['path'])) + filename + file = file.cleanpath + # is there a better way to trim a leading / ? + file = file.relative_path_from(Pathname.new("/")) unless file.relative? + raise "No such file #{file} in readj call (from #{context['page']['path']})" unless file.exist? + + # with readj we support vars and paths relative to a file being readj'd + jekyllSite = context.registers[:site] + targetPage = Jekyll::Page.new(jekyllSite, jekyllSite.source, File.dirname(file), File.basename(file)) + targetPage.render(jekyllSite.layouts, jekyllSite.site_payload) + return targetPage.output + end + end +end + +Liquid::Template.register_tag('read', JekyllRead::ReadTag) +Liquid::Template.register_tag('readj', JekyllRead::ReadjTag) http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_plugins/site_structure.rb ---------------------------------------------------------------------- diff --git a/_plugins/site_structure.rb b/_plugins/site_structure.rb new file mode 100644 index 0000000..5b0c488 --- /dev/null +++ b/_plugins/site_structure.rb @@ -0,0 +1,344 @@ +# +# Builds a hierarchical structure for the site, based on the YAML front matter of each page +# +# Starts from a page called "/index.md" (or the value of `root_menu_page` in _config.yml), +# and follows `children` links in the YAML front matter, building up a variable called `data` +# on `site` and on each referred `page`. +# +# In Ruby data is in page.data['menu'], but in templates `page.data` is promoted, +# so you should just refer to things in markdown as `{{ page.menu }}`. +# +# Each `page.menu` entry will contain: +# * `url` - URL (relative or absolute) to link to +# * `title_in_menu` - title to show +# * `menu_path` - the path of this page for the purposes of looking in breadcrumbs (usually page.path, unless overriden) +# * `breadcrumbs_pages` - page items for ancestor items (and self) +# * `breadcrumbs_paths` - paths of breadcrumb pages (useful for `if .. contains` jekyll tests) +# * `menu_parent` - the parent menu which contains this page +# * `menu_customization` - a hash of customization set in front matter or in children (can be any data you like) +# * (in addition the entry may *be* the actual page object when the item is a page whose menu is not overridden) +# +# To build, set `children` as a list of either strings (the relative or absolute path to the child .md file), +# or as maps indicating the target, one of: +# * `path` to a markdownfile +# * `link` as an URL +# * `section` anchored in this file (annotated with ``) +# And optionally: +# * a `title` (required for `link`), to override the title from the file +# * an optional `menu` block (for `path` only) to override the menu inherited from the `children` record noted at `path` +# * `menu_customization` to set arbitrary data available (e.g. for templates to use when styling) +# * `href_path` (for `path` only) to specify that a click should send to a different page than the path used to produce the menu +# +# For instance: +# +#children: +#- child.md +#- { path: child.md } +# # identical to above +#- { path: subchild.md, title: "Sub Child" } +# # different child, with custom title +#- { path: subchild.md, href_path: subchild_alt.md } +# # takes title and menu from subchild page, but links to subchild_alt +#- { path: child.md, menu: [ { path: subchild.md, title: "Sub-Child with New Name" } ] } +# # child, but with custom sub-menu and custom title in there +#- { path: child.md, menu: null } # suppress sub-menu (note `null` not `nil` because this is yaml) +# # child again, but suppressing sub-menu (note `null` not `nil` because this is yaml) +#- { section: Foo } +#- { section: Bar } +# # various sections in *this* doc (to make highlighting work for sections requires +# # extra JS responding to scrolls; otherwise the parent page remains highlighted) +# +# The menu is automatically generated for all files referenced from the root menu. +# You can also set `breadcrumbs` as a list of paths in a page to force breadcrumbs, and +# `menu_proxy_for` to have `menu_path` set differently to the usual `path` (highlight another page in a menu via breadcrumbs) +# or `menu_parent` to a path to the menu which should be the parent of the current node. +# +# The hash `menu_customization` allows you to pass arbitrary data around, e.g. for use in styling. +# +# Additionally URL rewriting is done if a path map is set in _config.yaml, +# with `path: { xxx: /new_xxx }` causing `/xxx/foo.html` to be rewritten as `/new_xxx/foo.html`. +# +module SiteStructure + + DEBUG = false + + require 'yaml' +# require 'pp' + + class RewritePaths < Liquid::Tag + def initialize(tag_name, text, tokens) + super + @text = text + end + def render(context) + page = context['page'] + site = context['site'] + RewritePaths.rewrite_paths(site, page) + end + + def self.rewrite_paths(site, page) + path = page['path'] + page_hash = (page.is_a? Hash) ? page : page.data + # set url_basedir and apply path mapping + page_hash['url_basedir'] = File.dirname(path)+"/" + page_hash['url_basedir'].prepend("/") unless page_hash['url_basedir'].start_with? "/" + + config_hash = (site.is_a? Hash) ? site : site.config + + if ((config_hash['path']) && (config_hash['path'].is_a? Hash)) + config_hash['path'].each {|key, value| + if (path.start_with?(key)) + if ((!page.is_a? Hash) && page.url) + page.url.slice!("/"+key) + page.url.prepend(value) + end + + page_hash['url_basedir'].slice!("/"+key) + page_hash['url_basedir'].prepend(value) + end + } + end + + nil + end + end + + Liquid::Template.register_tag('rewrite_paths', SiteStructure::RewritePaths) + + + class Generator < Jekyll::Generator + + @@verbose = false; + + def self.find_page_with_path_absolute_or_relative_to(site, path, referrent, structure_processed_pages) + uncleaned_path = path + + # Pathname API ignores first arg below if second is absolute +# puts "converting #{path} wrt #{referrent ? referrent.path : ""}" + file = Pathname.new(File.dirname(referrent ? referrent.path : "")) + path + + if file.to_s.end_with? "/" + if File.exist? File.join(file, 'index.md') + file += 'index.md' + elsif File.exist? File.join(file, 'index.html') + file += 'index.html' + else + file += 'index.md' + end + end + + file = file.cleanpath + # is there a better way to trim a leading / ? + file = file.relative_path_from(Pathname.new("/")) unless file.relative? + path = "#{file}" + + # look in our cache + page = structure_processed_pages[path] + return page if page != nil + + # look in site cache + page = site.pages.detect { |page| page.path == path } + if !page + page = site.pages.detect { |page| '/'+page.path == uncleaned_path } + puts "WARNING: link to #{path} in #{referrent ? referrent.path : "root"} uses legacy absolute syntax without leading slash" if page + end + + unless page + # could not load it from pages, look on disk + + if file.exist? + puts "INFO: reading excluded file #{file} for site structure generation" if SiteStructure::DEBUG + page = Jekyll::Page.new(site, site.source, File.dirname(file), File.basename(file)) + # make sure right url is set + RewritePaths.rewrite_paths(site, page) + end + + unless page + raise "No such file #{path} in site_structure call (from #{referrent ? referrent.path : ""})" unless SiteStructure::DEBUG + puts "Could not find a page called: #{path} (referenced from #{referrent ? referrent.path : "root"}); skipping" + return nil + end + end + + # and put in cache + structure_processed_pages[path] = page + + page + end + + def generate(site) + # rewrite paths + site.pages.each { |p| RewritePaths.rewrite_paths(site, p) } + structure_processed_pages = {} + # process root page + root_menu_page = site.config['root_menu_page'] + puts "site_structure processing root menu page #{root_menu_page}" if @@verbose + site.data.merge!( Generator.gen_structure(site, { 'path' => root_menu_page }, nil, [], [], structure_processed_pages).data ) if root_menu_page + # process all pages + puts "site_structure now processing all pages" if @@verbose + site.pages.each { |p| + Generator.gen_structure(site, { 'path' => p.path }, nil, [], [], structure_processed_pages) if (p.path.end_with?(".md") || p.path.end_with?(".html")) && (!p['menu_processed']) + } + site.data['structure_processed_pages'] = structure_processed_pages +# puts "ROOT menu is #{site.data['menu']}" +# puts "PAGE menu is #{structure_processed_pages['website/documentation/index.'].data['menu']}" +# (but note, in the context hash map 'data' on pages is promoted, so you access it like {{ page.menu }}) + end + + # processes liquid tags, e.g. in a link or path object + def self.render_liquid(site, page, content) + return content unless page + info = { :filters => [Jekyll::Filters], :registers => { :site => site, :page => page } } + page.render_liquid(content, site.site_payload, info) + end + + def self.gen_structure(site, item, parent, breadcrumb_pages_in, breadcrumb_paths_in, structure_processed_pages) + puts "gen_structure #{item} from #{parent ? parent.path : 'root'} (#{breadcrumb_paths_in})" if @@verbose + breadcrumb_pages = breadcrumb_pages_in.dup + breadcrumb_paths = breadcrumb_paths_in.dup + if (item.is_a? String) + item = { 'path' => item } + end + if (item['path']) + page = find_page_with_path_absolute_or_relative_to(site, render_liquid(site, parent, item['path']), parent, structure_processed_pages) + # if nil and find_page doesn't raise, we are in debug mode, silently ignore + return nil unless page + # build up the menu info + if (item.length==1 && !page['menu_processed']) + puts "setting up #{item} from #{page.path} as original" if @@verbose + data = page.data + result = page + else + puts "setting up #{item} from #{page.path} as copy" if @@verbose + # if other fields are set on 'item' then we are overriding, so we have to take a duplicate + unless page['menu_processed'] + # force processing if not yet processed, breadcrumbs etc set from that page + puts "making copy of #{page.path}" if @@verbose + page = gen_structure(site, "/"+page.path, parent, breadcrumb_pages_in, breadcrumb_paths_in, structure_processed_pages) + puts "copy is #{page.path}" if @@verbose + end + data = page.data.dup + data['data'] = data + result = data + end + data['path'] = page.path + if item['href_path'] + href_page = find_page_with_path_absolute_or_relative_to(site, render_liquid(site, page, item['href_path']), parent, structure_processed_pages) + else + href_page = page + end + data['url'] = href_page.url + puts "data is #{data}" if @@verbose + data['page'] = page + breadcrumb_pages << page + breadcrumb_paths << page.path + + elsif (item['section']) + puts "setting up #{item} as section" if @@verbose + section = item['section'] + section_cleaned = section.gsub(%r{[^A-Za-z0-9]+}, "-").downcase; + section_cleaned.slice!(1) if section_cleaned.start_with?("-") + section_cleaned.chomp!("-") # 0..-1) if section_cleaned.end_with?("-") + link = (parent ? parent.url : "") + '#' + section_cleaned + data = { 'link' => link, 'url' => link, 'section' => section_cleaned, 'section_title' => section } + data['title'] = item['title'] if item['title'] + data['title'] = section unless data['title'] + # nothing for breadcrumbs + data['data'] = data + result = data + + elsif (item['link']) + puts "setting up #{item} as link" if @@verbose + link = render_liquid(site, parent, item['link']) + data = { 'link' => link, 'url' => link, 'external' => true } + data['title'] = item['title'] if item['title'] + breadcrumb_pages << data + breadcrumb_paths << data['link'] + data['data'] = data + result = data + else + raise "Link to #{item} in #{parent ? parent.path : nil} must have path or section or link" + end + + data['menu_customization'] = {}.merge(data['menu_customization'] || {}).merge(item['menu_customization'] || {}) + + data['breadcrumb_pages'] ||= breadcrumb_pages + data['breadcrumb_paths'] ||= breadcrumb_paths + data['menu_parent'] ||= parent + + data['title_in_menu'] = render_liquid(site, parent, item['title_in_menu'] || item['title'] || data['title_in_menu'] || data['title']) + data['title'] ||= data['title_in_menu'] +# puts "built #{data}, now looking at children" + + # if already processed then return now that we have set custom item overrides (don't recurse through children) + return result if data['menu'] + + data['menu_path'] = page.path if page + + if data['menu_proxy_for'] + menu_proxy_for = gen_structure(site, { 'path' => data['menu_proxy_for'], 'no_copy' => "because breadcrumbs won't be right" }, page, [], [], structure_processed_pages) + raise "missing menu_proxy_for #{data['menu_proxy_for']} in #{page.path}" unless menu_proxy_for + data['menu_path'] = menu_proxy_for['path'] + # copy other data across + data.merge!(menu_proxy_for.select {|key, value| ['breadcrumb_paths', 'breadcrumb_pages', 'menu', 'title_in_menu', 'menu_parent', 'menu_customization'].include?(key) }) + end + + if data['breadcrumbs'] + # if custom breadcrumbs set on page, use them instead + breadcrumb_pages = data['breadcrumb_pages'] = data['breadcrumbs'].collect { |path| + result = find_page_with_path_absolute_or_relative_to(site, render_liquid(site, parent, path), page, structure_processed_pages) + raise "missing breadcrumb #{path} in #{page.path}" unless result + result + } + breadcrumb_paths = data['breadcrumb_paths'] = data['breadcrumb_pages'].collect { |p| p.path } + end + + if data['menu_parent'] + if data['menu_parent'].is_a? String + # if custom menu_parent was set as a string then load it + parent_result = find_page_with_path_absolute_or_relative_to(site, render_liquid(site, parent, data['menu_parent']), page, structure_processed_pages) + raise "missing parent #{data['menu_parent']} in #{page['path']}" unless parent_result + data['menu_parent'] = parent_result + if !data['breadcrumbs'] + # TODO should we inherit actual menu parent breadcrumbs if not set on page? + end + end + else + # set menu_parent from breadcrumbs if not set (e.g. we are loading an isolated page) + data['menu_parent'] = page['breadcrumb_pages'][-1] + end + + if (data['children']) + data['menu'] = [] + puts "children of #{data['path']} - #{data['children']}" if @@verbose + data['children'].each do |child| + sub = gen_structure(site, child, page, breadcrumb_pages, breadcrumb_paths, structure_processed_pages) + if sub + if (!(child.is_a? String) && child.has_key?('menu')) + # process custom menu override + sub['menu'] = child['menu'] + if (sub['menu'] != nil) + if sub['menu'].is_a? String + sub['menu'] = YAML.load(render_liquid(site, page, sub['menu'])) if sub['menu'].is_a? String + end + sub['menu'] = sub['menu'].collect { |mi| + gen_structure(site, mi, page, breadcrumb_pages, breadcrumb_paths, structure_processed_pages) + } + sub['menu'].compact! + end + end + data['menu'] << sub + puts "sub is #{sub['url']}" if @@verbose + else + raise "could not find #{child} in #{page.path}" + end + end + puts "end children of #{data['path']}" if @@verbose + end + + data['menu_processed']=true + puts "done #{item}" if @@verbose + result + end + end +end http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/_plugins/trim.rb ---------------------------------------------------------------------- diff --git a/_plugins/trim.rb b/_plugins/trim.rb new file mode 100644 index 0000000..047a346 --- /dev/null +++ b/_plugins/trim.rb @@ -0,0 +1,25 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +module TrimFilter + def trim(input) + input.strip + end + + Liquid::Template.register_filter self +end http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/brooklyn-docs/.gitattributes ---------------------------------------------------------------------- diff --git a/brooklyn-docs/.gitattributes b/brooklyn-docs/.gitattributes deleted file mode 100644 index 7920d0e..0000000 --- a/brooklyn-docs/.gitattributes +++ /dev/null @@ -1,6 +0,0 @@ -#Don't auto-convert line endings for shell scripts on Windows (breaks the scripts) -* text=auto -*.sh text eol=lf -*.bat text eol=crlf -*.ps1 text eol=crlf -*.ini text eol=crlf http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/brooklyn-docs/.gitignore ---------------------------------------------------------------------- diff --git a/brooklyn-docs/.gitignore b/brooklyn-docs/.gitignore deleted file mode 100644 index 806a062..0000000 --- a/brooklyn-docs/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -\#*\# -*~ -*.bak -*.swp -*.swo -.DS_Store - -atlassian-ide-plugin.xml -*.class - -target/ -test-output/ - -.project -.classpath -.settings/ -.metadata/ - -.idea/ -*.iml - -nbactions.xml -nb-configuration.xml - -prodDb.* - -*.log -brooklyn*.log.* - -*brooklyn-persisted-state/ - -ignored -_site -_config_local.yml -.sass-cache -style/js/catalog/items.js http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/6e86cb02/brooklyn-docs/Gemfile ---------------------------------------------------------------------- diff --git a/brooklyn-docs/Gemfile b/brooklyn-docs/Gemfile deleted file mode 100644 index 11d388b..0000000 --- a/brooklyn-docs/Gemfile +++ /dev/null @@ -1,11 +0,0 @@ -#ruby=ruby-2.1.2 -#ruby-gemset=incubator-brooklyn-site - -source 'https://rubygems.org' -ruby '2.1.2' - -gem 'jekyll' -gem 'therubyracer' -gem 'html-proofer' -gem 'json' -