aglio-theme-olio
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -0,1 +1,9 @@ | ||
# 1.3.0 - 2015-10-30 | ||
* Support built-in layout templates by name using `--theme-layout name`. | ||
* Add a three-paned theme layout called `triple`. Use it with `--theme-layout triple`. All variable/color schemes are supported. [#161](https://github.com/danielgtaylor/aglio/issues/161) | ||
* Show example URI for each action so that users with little URI template experience can quickly understand how URI parameters should work. [#138](https://github.com/danielgtaylor/aglio/issues/138) | ||
* Add variables to better control font information, table styling, column sizing, hover effects, and more. This makes it even easier to modify existing themes to match your project's or company's style. | ||
* Add a new simplified theme called `streak`. Use with `--theme-variables streak`. | ||
# 1.2.1 - 2015-09-01 | ||
@@ -2,0 +10,0 @@ |
@@ -236,3 +236,7 @@ // Generated by CoffeeScript 1.9.3 | ||
getTemplate = function(name, verbose, done) { | ||
var compiledPath, key, load; | ||
var builtin, compiledPath, key, load; | ||
builtin = path.join(ROOT, 'templates', name + ".jade"); | ||
if (!fs.existsSync(name) && fs.existsSync(builtin)) { | ||
name = builtin; | ||
} | ||
key = "template-" + name; | ||
@@ -305,8 +309,8 @@ if (cache[key]) { | ||
modifyUriTemplate = function(templateUri, parameters) { | ||
var block, closeIndex, index, lastIndex, param, parameterBlocks, parameterSet, parameterValidator; | ||
modifyUriTemplate = function(templateUri, parameters, colorize) { | ||
var block, closeIndex, index, lastIndex, param, parameterBlocks, parameterNames, parameterSet, parameterValidator; | ||
parameterValidator = function(b) { | ||
return parameters.indexOf(querystring.unescape(b.replace(/^\*|\*$/, ''))) !== -1; | ||
return parameterNames.indexOf(querystring.unescape(b.replace(/^\*|\*$/, ''))) !== -1; | ||
}; | ||
parameters = (function() { | ||
parameterNames = (function() { | ||
var i, len, results; | ||
@@ -346,3 +350,3 @@ results = []; | ||
} else { | ||
segment = ["{"]; | ||
segment = !colorize ? ["{"] : []; | ||
if (v.querySet) { | ||
@@ -357,4 +361,17 @@ segment.push("?"); | ||
} | ||
segment.push(v.parameters.join()); | ||
segment.push("}"); | ||
segment.push(v.parameters.map(function(name) { | ||
if (!colorize) { | ||
return name; | ||
} else { | ||
if (v.querySet || v.formSet || v.reservedSet) { | ||
param = parameters[parameterNames.indexOf(querystring.unescape(name.replace(/^\*|\*$/, '')))]; | ||
return ("<span class=\"hljs-attribute\">" + name + "=</span>") + ("<span class=\"hljs-literal\">" + param.example + "</span>"); | ||
} else { | ||
return "<span class=\"hljs-attribute\">" + name + "</span>"; | ||
} | ||
} | ||
}).join(colorize ? '&' : ',')); | ||
if (!colorize) { | ||
segment.push("}"); | ||
} | ||
uri.push(segment.join("")); | ||
@@ -367,3 +384,3 @@ } | ||
decorate = function(api, md, slugCache) { | ||
var action, err, example, i, item, knownParams, len, name, newParams, param, ref, resource, resourceGroup, results, reversed, slugify; | ||
var action, err, example, i, item, j, knownParams, len, len1, meta, name, newParams, param, ref, ref1, resource, resourceGroup, results, reversed, slugify; | ||
slugify = slug.bind(slug, slugCache); | ||
@@ -375,6 +392,13 @@ if (api.description) { | ||
} | ||
ref = api.resourceGroups || []; | ||
ref = api.metadata || []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
meta = ref[i]; | ||
if (meta.name === 'HOST') { | ||
api.host = meta.value; | ||
} | ||
} | ||
ref1 = api.resourceGroups || []; | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
resourceGroup = ref[i]; | ||
for (j = 0, len1 = ref1.length; j < len1; j++) { | ||
resourceGroup = ref1[j]; | ||
resourceGroup.elementId = slugify(resourceGroup.name, true); | ||
@@ -388,15 +412,15 @@ resourceGroup.elementLink = "#" + resourceGroup.elementId; | ||
results.push((function() { | ||
var j, len1, ref1, results1; | ||
ref1 = resourceGroup.resources || []; | ||
var k, len2, ref2, results1; | ||
ref2 = resourceGroup.resources || []; | ||
results1 = []; | ||
for (j = 0, len1 = ref1.length; j < len1; j++) { | ||
resource = ref1[j]; | ||
for (k = 0, len2 = ref2.length; k < len2; k++) { | ||
resource = ref2[k]; | ||
resource.elementId = slugify(resourceGroup.name + "-" + resource.name, true); | ||
resource.elementLink = "#" + resource.elementId; | ||
results1.push((function() { | ||
var k, l, len2, len3, ref2, results2; | ||
ref2 = resource.actions || []; | ||
var l, len3, len4, m, ref3, results2; | ||
ref3 = resource.actions || []; | ||
results2 = []; | ||
for (k = 0, len2 = ref2.length; k < len2; k++) { | ||
action = ref2[k]; | ||
for (l = 0, len3 = ref3.length; l < len3; l++) { | ||
action = ref3[l]; | ||
action.elementId = slugify(resourceGroup.name + "-" + resource.name + "-" + action.method, true); | ||
@@ -413,4 +437,4 @@ action.elementLink = "#" + action.elementId; | ||
reversed = (action.parameters || []).concat([]).reverse(); | ||
for (l = 0, len3 = reversed.length; l < len3; l++) { | ||
param = reversed[l]; | ||
for (m = 0, len4 = reversed.length; m < len4; m++) { | ||
param = reversed[m]; | ||
if (knownParams[param.name]) { | ||
@@ -424,20 +448,25 @@ continue; | ||
action.uriTemplate = modifyUriTemplate((action.attributes || {}).uriTemplate || resource.uriTemplate || '', action.parameters); | ||
action.colorizedUriTemplate = modifyUriTemplate((action.attributes || {}).uriTemplate || resource.uriTemplate || '', action.parameters, true); | ||
action.hasRequest = false; | ||
results2.push((function() { | ||
var len4, m, ref3, results3; | ||
ref3 = action.examples || []; | ||
var len5, n, ref4, results3; | ||
ref4 = action.examples || []; | ||
results3 = []; | ||
for (m = 0, len4 = ref3.length; m < len4; m++) { | ||
example = ref3[m]; | ||
for (n = 0, len5 = ref4.length; n < len5; n++) { | ||
example = ref4[n]; | ||
results3.push((function() { | ||
var len5, n, ref4, results4; | ||
ref4 = ['requests', 'responses']; | ||
var len6, o, ref5, results4; | ||
ref5 = ['requests', 'responses']; | ||
results4 = []; | ||
for (n = 0, len5 = ref4.length; n < len5; n++) { | ||
name = ref4[n]; | ||
for (o = 0, len6 = ref5.length; o < len6; o++) { | ||
name = ref5[o]; | ||
results4.push((function() { | ||
var len6, o, ref5, results5; | ||
ref5 = example[name] || []; | ||
var len7, p, ref6, results5; | ||
ref6 = example[name] || []; | ||
results5 = []; | ||
for (o = 0, len6 = ref5.length; o < len6; o++) { | ||
item = ref5[o]; | ||
for (p = 0, len7 = ref6.length; p < len7; p++) { | ||
item = ref6[p]; | ||
if (name === 'requests' && !action.hasRequest) { | ||
action.hasRequest = true; | ||
} | ||
item.hasContent = item.description || Object.keys(item.headers).length || item.body || item.schema; | ||
@@ -444,0 +473,0 @@ try { |
{ | ||
"name": "aglio-theme-olio", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Default theme for the Aglio API Blueprint renderer", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
@@ -13,2 +13,19 @@ /* eslint-env browser */ | ||
/* | ||
Get a list of direct child elements by class name. | ||
*/ | ||
function childrenByClass(element, name) { | ||
var filtered = []; | ||
for (var i = 0; i < element.children.length; i++) { | ||
var child = element.children[i]; | ||
var classNames = child.className.split(' '); | ||
if (classNames.indexOf(name) !== -1) { | ||
filtered.push(child); | ||
} | ||
} | ||
return filtered; | ||
} | ||
/* | ||
Get an array [width, height] of the window. | ||
@@ -51,2 +68,28 @@ */ | ||
function toggleTabButton(event) { | ||
var i, index; | ||
var button = event.target; | ||
// Get index of the current button. | ||
var buttons = childrenByClass(button.parentNode, 'tab-button'); | ||
for (i = 0; i < buttons.length; i++) { | ||
if (buttons[i] === button) { | ||
index = i; | ||
button.className = 'tab-button active'; | ||
} else { | ||
buttons[i].className = 'tab-button'; | ||
} | ||
} | ||
// Hide other tabs and show this one. | ||
var tabs = childrenByClass(button.parentNode.parentNode, 'tab'); | ||
for (i = 0; i < tabs.length; i++) { | ||
if (i === index) { | ||
tabs[i].style.display = 'block'; | ||
} else { | ||
tabs[i].style.display = 'none'; | ||
} | ||
} | ||
} | ||
/* | ||
@@ -139,3 +182,3 @@ Collapse or show a navigation menu. It will not be hidden unless it | ||
function init() { | ||
var i; | ||
var i, j; | ||
@@ -153,2 +196,15 @@ // Make collapse buttons clickable | ||
var responseCodes = document.querySelectorAll('.example-names'); | ||
for (i = 0; i < responseCodes.length; i++) { | ||
var tabButtons = childrenByClass(responseCodes[i], 'tab-button'); | ||
for (j = 0; j < tabButtons.length; j++) { | ||
tabButtons[j].onclick = toggleTabButton; | ||
// Show by default? | ||
if (j === 0) { | ||
toggleTabButton({target: tabButtons[j]}); | ||
} | ||
} | ||
} | ||
// Make nav items clickable to collapse/expand their content. | ||
@@ -155,0 +211,0 @@ var navItems = document.querySelectorAll('nav .resource-group .heading'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
97280
16
818