Merge pull request #4175 from bshamblen/master

Fixes for html2 template
This commit is contained in:
Tony Tam 2016-11-11 14:11:15 -08:00 committed by GitHub
commit cafcf51e3f
4 changed files with 386 additions and 158 deletions

View File

@ -12,70 +12,84 @@
{{>js_prettify}} {{>js_prettify}}
{{>js_bootstrap}} {{>js_bootstrap}}
{{>marked}}
<script> <script>
$( document ).ready(function() { $( document ).ready(function() {
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: false,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false
});
var textFile = null; var textFile = null;
/// Function to be used to download a text json schema /// Function to be used to download a text json schema
function makeTextFile(text) { function makeTextFile(text) {
var data = new Blob([text], {type: 'text/plain'}); var data = new Blob([text], {type: 'text/plain'});
// If we are replacing a previously generated file we need to // If we are replacing a previously generated file we need to
// manually revoke the object URL to avoid memory leaks. // manually revoke the object URL to avoid memory leaks.
if (textFile !== null) { if (textFile !== null) {
window.URL.revokeObjectURL(textFile); window.URL.revokeObjectURL(textFile);
}
textFile = window.URL.createObjectURL(data);
var a = document.createElement("a");
document.body.appendChild(a);
a.style = "display: none";
a.href = textFile;
a.download = 'schema.txt';
a.click();
return textFile;
};
/// TODO: Implement resizing for expanding within iframe
function callResize() {
window.parent.postMessage('resize', "*");
} }
textFile = window.URL.createObjectURL(data); function processMarked() {
$(".marked").each(function() {
var a = document.createElement("a"); $(this).html(marked($(this).html()));
document.body.appendChild(a); });
a.style = "display: none"; }
a.href = textFile;
a.download = 'schema.txt';
a.click();
return textFile;
};
/// TODO: Implement resizing for expanding within iframe
function callResize() {
window.parent.postMessage('resize', "*");
}
// load google web fonts // load google web fonts
loadGoogleFontCss(); loadGoogleFontCss();
// Bootstrap Scrollspy // Bootstrap Scrollspy
$(this).scrollspy({ target: '#scrollingNav', offset: 18 }); $(this).scrollspy({ target: '#scrollingNav', offset: 18 });
// Content-Scroll on Navigation click. // Content-Scroll on Navigation click.
$('.sidenav').find('a').on('click', function(e) { $('.sidenav').find('a').on('click', function(e) {
e.preventDefault(); e.preventDefault();
var id = $(this).attr('href'); var id = $(this).attr('href');
if ($(id).length > 0) if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 400); $('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 400);
window.location.hash = $(this).attr('href'); window.location.hash = $(this).attr('href');
}); });
// Quickjump on Pageload to hash position. // Quickjump on Pageload to hash position.
if(window.location.hash) { if(window.location.hash) {
var id = window.location.hash; var id = window.location.hash;
if ($(id).length > 0) if ($(id).length > 0)
$('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0); $('html,body').animate({ scrollTop: parseInt($(id).offset().top) }, 0);
} }
function initDynamic() { function initDynamic() {
// tabs // tabs
$('.nav-tabs-examples a').click(function (e) { $('.nav-tabs-examples a').click(function (e) {
e.preventDefault(); e.preventDefault();
@ -83,35 +97,35 @@ function initDynamic() {
}); });
$('.nav-tabs-examples').find('a:first').tab('show'); $('.nav-tabs-examples').find('a:first').tab('show');
// call scrollspy refresh method // call scrollspy refresh method
$(window).scrollspy('refresh'); $(window).scrollspy('refresh');
}
} initDynamic();
initDynamic();
// Pre- / Code-Format // Pre- / Code-Format
prettyPrint(); prettyPrint();
//Convert elements with "marked" class to markdown
processMarked();
/** /**
* Load google fonts. * Load google fonts.
*/ */
function loadGoogleFontCss() { function loadGoogleFontCss() {
WebFont.load({ WebFont.load({
active: function() { active: function() {
// Update scrollspy // Update scrollspy
$(window).scrollspy('refresh') $(window).scrollspy('refresh')
}, },
google: { google: {
families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7'] families: ['Source Code Pro', 'Source Sans Pro:n4,n6,n7']
} }
}); });
} }
}); });
</script> </script>
<style type="text/css"> <style type="text/css">
@ -192,7 +206,7 @@ function loadGoogleFontCss() {
<hr> <hr>
<p>{{{appDescription}}}</p> <p class="marked">{{appDescription}}</p>
</div> </div>
</div> </div>
<div id="sections"> <div id="sections">
@ -224,7 +238,7 @@ function loadGoogleFontCss() {
<div class="clearfix"></div> <div class="clearfix"></div>
<p></p> <p></p>
<p>{{notes}}</p> <p class="marked">{{notes}}</p>
<p></p> <p></p>
<br /> <br />
@ -375,6 +389,21 @@ curl -X <span style="text-transform: uppercase;">{{httpMethod}}</span>{{#authMet
</table> </table>
{{/hasBodyParam}} {{/hasBodyParam}}
{{#hasFormParams}}
<div class="methodsubtabletitle">Form parameters</div>
<table id="methodsubtable">
<tr>
<th width="150px">Name</th>
<th>Description</th>
</tr>
<!---->
{{#formParams}}
{{>param}}
{{/formParams}}
</table>
{{/hasFormParams}}
{{#hasQueryParams}} {{#hasQueryParams}}
<div class="methodsubtabletitle">Query parameters</div> <div class="methodsubtabletitle">Query parameters</div>
<table id="methodsubtable"> <table id="methodsubtable">

View File

@ -56,7 +56,7 @@ var _createClass = (function () { function defineProperties(target, props) { for
var _templateObject = _taggedTemplateLiteral(['\n <div class="any">\n ', '\n\n <span class="type type-any">&lt;any&gt;</span>\n\n ', '\n\t\t \n\t\t ', '\n\t\t ', '\n\t\t ', '\n </div>\n '], ['\n <div class="any">\n ', '\n\n <span class="type type-any">&lt;any&gt;</span>\n\n ', '\n\t\t \n\t\t ', '\n\t\t ', '\n\t\t ', '\n </div>\n ']), var _templateObject = _taggedTemplateLiteral(['\n <div class="any">\n ', '\n\n <span class="type type-any">&lt;any&gt;</span>\n\n ', '\n\t\t \n\t\t ', '\n\t\t ', '\n\t\t ', '\n </div>\n '], ['\n <div class="any">\n ', '\n\n <span class="type type-any">&lt;any&gt;</span>\n\n ', '\n\t\t \n\t\t ', '\n\t\t ', '\n\t\t ', '\n </div>\n ']),
_templateObject2 = _taggedTemplateLiteral(['\n <a class="title"><span class="toggle-handle"></span>', ' </a>\n '], ['\n <a class="title"><span class="toggle-handle"></span>', ' </a>\n ']), _templateObject2 = _taggedTemplateLiteral(['\n <a class="title"><span class="toggle-handle"></span>', ' </a>\n '], ['\n <a class="title"><span class="toggle-handle"></span>', ' </a>\n ']),
_templateObject3 = _taggedTemplateLiteral(['\n <div class="inner description">', '</div>\n '], ['\n <div class="inner description">', '</div>\n ']), _templateObject3 = _taggedTemplateLiteral(['\n <div class="inner description marked">', '</div>\n '], ['\n <div class="inner description marked">', '</div>\n ']),
_templateObject4 = _taggedTemplateLiteral(['\n <div class="inner required">Required: ', '</div>\n '], ['\n <div class="inner required">Required: ', '</div>\n ']), _templateObject4 = _taggedTemplateLiteral(['\n <div class="inner required">Required: ', '</div>\n '], ['\n <div class="inner required">Required: ', '</div>\n ']),
_templateObject5 = _taggedTemplateLiteral(['\n <div class="inner default">Default: ', '</div>\n '], ['\n <div class="inner default">Default: ', '</div>\n ']), _templateObject5 = _taggedTemplateLiteral(['\n <div class="inner default">Default: ', '</div>\n '], ['\n <div class="inner default">Default: ', '</div>\n ']),
_templateObject6 = _taggedTemplateLiteral(['\n <div class="inner pattern">Pattern: ', '</div>\n '], ['\n <div class="inner pattern">Pattern: ', '</div>\n ']), _templateObject6 = _taggedTemplateLiteral(['\n <div class="inner pattern">Pattern: ', '</div>\n '], ['\n <div class="inner pattern">Pattern: ', '</div>\n ']),
@ -160,7 +160,7 @@ var JSONSchemaView = (function () {
return ''; return '';
} }
return ('\n <!-- Any -->\n ' + (0, _helpersJs._if)(this.isAny)(_templateObject, (0, _helpersJs._if)(this.showToggle)(_templateObject2, this.schema.title || ''), (0, _helpersJs._if)(this.schema.description && !this.isCollapsed)(_templateObject3, this.schema.description), (0, _helpersJs._if)(this.schema.required && !this.isCollapsed)(_templateObject4, this.schema.required), (0, _helpersJs._if)(this.schema['default'] && !this.isCollapsed)(_templateObject5, this.schema['default']), (0, _helpersJs._if)(this.schema.pattern && !this.isCollapsed)(_templateObject6, this.schema.pattern)) + '\n\n <!-- Primitive -->\n ' + (0, _helpersJs._if)(this.isPrimitive)(_templateObject7, (0, _helpersJs._if)(this.showToggle)(_templateObject2, this.schema.title || ''), this.schema.type, (0, _helpersJs._if)(!this.isCollapsed && this.schema.format)(_templateObject8, this.schema.format), (0, _helpersJs._if)(!this.isCollapsed && this.schema.minimum)(_templateObject9, this.schema.minimum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.exclusiveMinimum)(_templateObject10, this.schema.exclusiveMinimum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.maximum)(_templateObject11, this.schema.maximum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.exclusiveMaximum)(_templateObject12, this.schema.exclusiveMaximum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.minLength)(_templateObject13, this.schema.minLength), (0, _helpersJs._if)(!this.isCollapsed && this.schema.maxLength)(_templateObject14, this.schema.maxLength), (0, _helpersJs._if)(this.schema.description && !this.isCollapsed)(_templateObject3, this.schema.description), (0, _helpersJs._if)(this.schema.required && !this.isCollapsed)(_templateObject15), (0, _helpersJs._if)(this.schema['default'] && !this.isCollapsed)(_templateObject5, this.schema['default']), (0, _helpersJs._if)(this.schema.pattern && !this.isCollapsed)(_templateObject6, this.schema.pattern), (0, _helpersJs._if)(!this.isCollapsed && this.schema['enum'])(_templateObject16, this['enum'](this.schema, this.isCollapsed, this.open)), (0, _helpersJs._if)(this.schema.allOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'allOf')), (0, _helpersJs._if)(this.schema.oneOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'oneOf')), (0, _helpersJs._if)(this.schema.anyOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'anyOf'))) + '\n\n\n <!-- Array -->\n ' + (0, _helpersJs._if)(this.isArray)(_templateObject18, this.schema.title || '', (0, _helpersJs._if)(this.isCollapsed)(_templateObject19), (0, _helpersJs._if)(!this.isCollapsed && (this.schema.uniqueItems || this.schema.minItems || this.schema.maxItems))(_templateObject20, this.schema.minItems || 0, this.schema.maxItems || '∞', (0, _helpersJs._if)(!this.isCollapsed && this.schema.uniqueItems)(_templateObject21)), (0, _helpersJs._if)(!this.isCollapsed && this.schema.description)(_templateObject22, this.schema.description), (0, _helpersJs._if)(!this.isCollapsed && this.schema['enum'])(_templateObject16, this['enum'](this.schema, this.isCollapsed, this.open)), (0, _helpersJs._if)(this.schema.allOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'allOf')), (0, _helpersJs._if)(this.schema.oneOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'oneOf')), (0, _helpersJs._if)(this.schema.anyOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'anyOf')), (0, _helpersJs._if)(!this.isCollapsed)(_templateObject23)) + '\n\n <!-- Object -->\n ' + (0, _helpersJs._if)(!this.isPrimitive && !this.isArray && !this.isAny)(_templateObject24, this.schema.title || '', (0, _helpersJs._if)(this.isCollapsed)(_templateObject25), (0, _helpersJs._if)(!this.isCollapsed && this.schema.description)(_templateObject22, this.schema.description), return ('\n <!-- Any -->\n ' + (0, _helpersJs._if)(this.isAny)(_templateObject, (0, _helpersJs._if)(this.showToggle)(_templateObject2, this.schema.title || ''), (0, _helpersJs._if)(this.schema.description && !this.isCollapsed)(_templateObject3, marked(this.schema.description || "")), (0, _helpersJs._if)(this.schema.required && !this.isCollapsed)(_templateObject4, this.schema.required), (0, _helpersJs._if)(this.schema['default'] && !this.isCollapsed)(_templateObject5, this.schema['default']), (0, _helpersJs._if)(this.schema.pattern && !this.isCollapsed)(_templateObject6, this.schema.pattern)) + '\n\n <!-- Primitive -->\n ' + (0, _helpersJs._if)(this.isPrimitive)(_templateObject7, (0, _helpersJs._if)(this.showToggle)(_templateObject2, this.schema.title || ''), this.schema.type, (0, _helpersJs._if)(!this.isCollapsed && this.schema.format)(_templateObject8, this.schema.format), (0, _helpersJs._if)(!this.isCollapsed && this.schema.minimum)(_templateObject9, this.schema.minimum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.exclusiveMinimum)(_templateObject10, this.schema.exclusiveMinimum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.maximum)(_templateObject11, this.schema.maximum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.exclusiveMaximum)(_templateObject12, this.schema.exclusiveMaximum), (0, _helpersJs._if)(!this.isCollapsed && this.schema.minLength)(_templateObject13, this.schema.minLength), (0, _helpersJs._if)(!this.isCollapsed && this.schema.maxLength)(_templateObject14, this.schema.maxLength), (0, _helpersJs._if)(this.schema.description && !this.isCollapsed)(_templateObject3, marked(this.schema.description || "")), (0, _helpersJs._if)(this.schema.required && !this.isCollapsed)(_templateObject15), (0, _helpersJs._if)(this.schema['default'] && !this.isCollapsed)(_templateObject5, this.schema['default']), (0, _helpersJs._if)(this.schema.pattern && !this.isCollapsed)(_templateObject6, this.schema.pattern), (0, _helpersJs._if)(!this.isCollapsed && this.schema['enum'])(_templateObject16, this['enum'](this.schema, this.isCollapsed, this.open)), (0, _helpersJs._if)(this.schema.allOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'allOf')), (0, _helpersJs._if)(this.schema.oneOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'oneOf')), (0, _helpersJs._if)(this.schema.anyOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'anyOf'))) + '\n\n\n <!-- Array -->\n ' + (0, _helpersJs._if)(this.isArray)(_templateObject18, this.schema.title || '', (0, _helpersJs._if)(this.isCollapsed)(_templateObject19), (0, _helpersJs._if)(!this.isCollapsed && (this.schema.uniqueItems || this.schema.minItems || this.schema.maxItems))(_templateObject20, this.schema.minItems || 0, this.schema.maxItems || '∞', (0, _helpersJs._if)(!this.isCollapsed && this.schema.uniqueItems)(_templateObject21)), (0, _helpersJs._if)(!this.isCollapsed && this.schema.description)(_templateObject22, marked(this.schema.description || "")), (0, _helpersJs._if)(!this.isCollapsed && this.schema['enum'])(_templateObject16, this['enum'](this.schema, this.isCollapsed, this.open)), (0, _helpersJs._if)(this.schema.allOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'allOf')), (0, _helpersJs._if)(this.schema.oneOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'oneOf')), (0, _helpersJs._if)(this.schema.anyOf && !this.isCollapsed)(_templateObject17, this.xOf(this.schema, 'anyOf')), (0, _helpersJs._if)(!this.isCollapsed)(_templateObject23)) + '\n\n <!-- Object -->\n ' + (0, _helpersJs._if)(!this.isPrimitive && !this.isArray && !this.isAny)(_templateObject24, this.schema.title || '', (0, _helpersJs._if)(this.isCollapsed)(_templateObject25), (0, _helpersJs._if)(!this.isCollapsed && this.schema.description)(_templateObject22, marked(this.schema.description || "")),
(0, _helpersJs._if)(this.schema.required && !this.isCollapsed && this.options.isBodyParam != true)(_templateObject26, this.schema.required), (0, _helpersJs._if)(this.schema.required && !this.isCollapsed && this.options.isBodyParam != true)(_templateObject26, this.schema.required),
(0, _helpersJs._if)(this.schema.required && !this.isCollapsed && this.options.isBodyParam == true)(_templateObject266, this.schema.required), (0, _helpersJs._if)(this.schema.required && !this.isCollapsed && this.options.isBodyParam == true)(_templateObject266, this.schema.required),

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long