You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2014/01/09 16:38:20 UTC
svn commit: r1556841 - in /libcloud/site/trunk: ./
source/_assets/css/main.css source/_assets/js/code-examples.js
source/_layouts/default.html source/index.html
Author: tomaz
Date: Thu Jan 9 15:38:20 2014
New Revision: 1556841
URL: http://svn.apache.org/r1556841
Log:
Annotate code examples on the front page.
Added:
libcloud/site/trunk/source/_assets/js/code-examples.js
Modified:
libcloud/site/trunk/ (props changed)
libcloud/site/trunk/source/_assets/css/main.css
libcloud/site/trunk/source/_layouts/default.html
libcloud/site/trunk/source/index.html
Propchange: libcloud/site/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu Jan 9 15:38:20 2014
@@ -1 +1 @@
-.bundle
+node_modules/
Modified: libcloud/site/trunk/source/_assets/css/main.css
URL: http://svn.apache.org/viewvc/libcloud/site/trunk/source/_assets/css/main.css?rev=1556841&r1=1556840&r2=1556841&view=diff
==============================================================================
--- libcloud/site/trunk/source/_assets/css/main.css (original)
+++ libcloud/site/trunk/source/_assets/css/main.css Thu Jan 9 15:38:20 2014
@@ -237,6 +237,14 @@ code {
font-size: 11pt !important;
}
+code span[id] {
+ cursor: pointer;
+}
+
+code span[id]:hover {
+ background-color: white;
+}
+
/* Footer */
footer {
margin: 20px 0;
Added: libcloud/site/trunk/source/_assets/js/code-examples.js
URL: http://svn.apache.org/viewvc/libcloud/site/trunk/source/_assets/js/code-examples.js?rev=1556841&view=auto
==============================================================================
--- libcloud/site/trunk/source/_assets/js/code-examples.js (added)
+++ libcloud/site/trunk/source/_assets/js/code-examples.js Thu Jan 9 15:38:20 2014
@@ -0,0 +1,94 @@
+/* global jQuery: true */
+
+var LINE_TOOLTIPS = {
+ 'compute-1': {
+ '4': [
+ 'Obtain a reference to the provider driver class. <br /><br />Keep in ',
+ 'mind that Libcloud supports more than 30 providers total and ',
+ 'Provider.RACKSPACE constant can be replaced with a provider constant ',
+ 'of any other of the supported providers.'
+ ],
+ '5': [
+ 'Instantiate the driver with your provider credentials. ',
+ 'Rackspace driver supports multiple regions so in this case, "region" ',
+ 'argument is used as well.'
+ ],
+
+ '7': [
+ 'List all the available sizes. <br /><br />In Libcloud, size ',
+ 'represents a server hardware configuration. Usually this is amount ',
+ 'of the available RAM, bandwidth, CPU speed and disk size. Most of ',
+ 'the drivers also expose an hourly price (in dollars) for the Node of',
+ 'this size.'
+ ],
+ '8': [
+ 'List all the available images.<br /><br />In Libcloud, image ',
+ 'represents an operating system image.'
+ ],
+
+ '10': 'Select a size we would like to use.',
+ '11': 'Select an image we would like to use.',
+
+ '13': 'Create a node using a previously selected size and image.'
+ },
+ 'dns-1': {
+ '4': 'Obtain a reference to the provider driver class.',
+ '5': 'Instantiate the driver with your provider credentials.',
+
+ '7': 'List all the available zones on this account.',
+ '8': 'Select the zone we would like to operate on.',
+
+ '10': [
+ 'Create a new "A" record with a name of "www" and a value of ',
+ '"127.0.0.1" under the selected zone.'
+ ]
+ }
+};
+
+jQuery(document).ready(function($) {
+ $('.example code span[id]').on('mouseover click', function(e) {
+ var tooltips, lineNumber, content, parentElem, key, options, tooltip,
+ hasTooltip;
+
+ parentElem = $(this).closest('div.example');
+ key = parentElem.attr('data-example');
+
+ tooltips = LINE_TOOLTIPS[key];
+
+ if (!tooltips) {
+ return;
+ }
+
+ hasTooltip = $(this).attr('title') !== undefined;
+ lineNumber = $(this).attr('id').replace('line-', '');
+ tooltip = tooltips[lineNumber];
+
+ if (hasTooltip) {
+ // Popover for this line has already been created.
+ return;
+ }
+
+ if (!tooltip) {
+ // No tool tip for this line.
+ return;
+ }
+
+ if (tooltip instanceof Array) {
+ content = tooltip.join('');
+ }
+ else {
+ content = tooltip;
+ }
+
+ options = {
+ 'content': content,
+ 'placement': 'auto right',
+ 'html': true,
+ 'trigger': 'hover',
+ 'container': 'body'
+ };
+
+ $(this).popover(options);
+ $(this).popover('show');
+ });
+});
Modified: libcloud/site/trunk/source/_layouts/default.html
URL: http://svn.apache.org/viewvc/libcloud/site/trunk/source/_layouts/default.html?rev=1556841&r1=1556840&r2=1556841&view=diff
==============================================================================
--- libcloud/site/trunk/source/_layouts/default.html (original)
+++ libcloud/site/trunk/source/_layouts/default.html Thu Jan 9 15:38:20 2014
@@ -120,6 +120,12 @@
- _assets/js/main.js
{% endjavascript_asset_tag %}
+ {% if page.url == "/" or page.url == "/index.html" %}
+ {% javascript_asset_tag index %}
+ - _assets/js/code-examples.js
+ {% endjavascript_asset_tag %}
+ {% endif %}
+
{% include analytics.html %}
</body>
</html>
Modified: libcloud/site/trunk/source/index.html
URL: http://svn.apache.org/viewvc/libcloud/site/trunk/source/index.html?rev=1556841&r1=1556840&r2=1556841&view=diff
==============================================================================
--- libcloud/site/trunk/source/index.html (original)
+++ libcloud/site/trunk/source/index.html Thu Jan 9 15:38:20 2014
@@ -2,6 +2,8 @@
layout: default
title: Apache Libcloud is a standard Python library that abstracts away differences among multiple cloud provider APIs
description: Apache Libcloud is a Python library that abstracts away differences among multiple cloud provider APIs
+javascript_files:
+ - _assets/js/code-examples.js
---
<div class="row section">
<div class="col-lg-12">
@@ -79,9 +81,9 @@ description: Apache Libcloud is a Python
</div>
<div class="row section row-3">
- <div class="col-md-6">
+ <div class="col-md-6 example" data-example="compute-1">
<h3>Compute Example - Create a node</h3>
- {% highlight python %}
+ {% highlight python linespans=line %}
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
@@ -100,9 +102,9 @@ print(node)
<p>For more compute examples, see <a href="https://libcloud.readthedocs.org/en/latest/compute/examples.html">documentation</a>.</p>
</div>
- <div class="col-md-6">
+ <div class="col-md-6 example" data-example="dns-1">
<h3>DNS Example - Create a DNS record</h3>
- {% highlight python %}
+ {% highlight python linespans=line %}
from libcloud.dns.types import Provider, RecordType
from libcloud.dns.providers import get_driver