Upgraded highlight version to 9.1, removed highlight when sample is too long

This commit is contained in:
Anna Bodnia
2016-02-09 15:16:07 +02:00
parent 312eeef8e5
commit 14124c729b
17 changed files with 404 additions and 30 deletions

View File

@@ -82,7 +82,7 @@
.swagger-section pre .vhdl .attribute,
.swagger-section pre .clojure .attribute,
.swagger-section pre .coffeescript .property {
color: #8888ff;
color: #88F;
}
.swagger-section pre .keyword,
.swagger-section pre .id,
@@ -120,6 +120,67 @@
.swagger-section pre .xml .cdata {
opacity: 0.5;
}
.swagger-section .hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #F0F0F0;
}
.swagger-section .hljs,
.swagger-section .hljs-subst {
color: #444;
}
.swagger-section .hljs-keyword,
.swagger-section .hljs-attribute,
.swagger-section .hljs-selector-tag,
.swagger-section .hljs-meta-keyword,
.swagger-section .hljs-doctag,
.swagger-section .hljs-name {
font-weight: bold;
}
.swagger-section .hljs-built_in,
.swagger-section .hljs-literal,
.swagger-section .hljs-bullet,
.swagger-section .hljs-code,
.swagger-section .hljs-addition {
color: #1F811F;
}
.swagger-section .hljs-regexp,
.swagger-section .hljs-symbol,
.swagger-section .hljs-variable,
.swagger-section .hljs-template-variable,
.swagger-section .hljs-link,
.swagger-section .hljs-selector-attr,
.swagger-section .hljs-selector-pseudo {
color: #BC6060;
}
.swagger-section .hljs-type,
.swagger-section .hljs-string,
.swagger-section .hljs-number,
.swagger-section .hljs-selector-id,
.swagger-section .hljs-selector-class,
.swagger-section .hljs-quote,
.swagger-section .hljs-template-tag,
.swagger-section .hljs-deletion {
color: #880000;
}
.swagger-section .hljs-title,
.swagger-section .hljs-section {
color: #880000;
font-weight: bold;
}
.swagger-section .hljs-comment {
color: #888888;
}
.swagger-section .hljs-meta {
color: #2B6EA1;
}
.swagger-section .hljs-emphasis {
font-style: italic;
}
.swagger-section .hljs-strong {
font-weight: bold;
}
.swagger-section .swagger-ui-wrap {
line-height: 1;
font-family: "Droid Sans", sans-serif;

View File

@@ -82,7 +82,7 @@
.swagger-section pre .vhdl .attribute,
.swagger-section pre .clojure .attribute,
.swagger-section pre .coffeescript .property {
color: #8888ff;
color: #88F;
}
.swagger-section pre .keyword,
.swagger-section pre .id,
@@ -120,6 +120,67 @@
.swagger-section pre .xml .cdata {
opacity: 0.5;
}
.swagger-section .hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #F0F0F0;
}
.swagger-section .hljs,
.swagger-section .hljs-subst {
color: #444;
}
.swagger-section .hljs-keyword,
.swagger-section .hljs-attribute,
.swagger-section .hljs-selector-tag,
.swagger-section .hljs-meta-keyword,
.swagger-section .hljs-doctag,
.swagger-section .hljs-name {
font-weight: bold;
}
.swagger-section .hljs-built_in,
.swagger-section .hljs-literal,
.swagger-section .hljs-bullet,
.swagger-section .hljs-code,
.swagger-section .hljs-addition {
color: #1F811F;
}
.swagger-section .hljs-regexp,
.swagger-section .hljs-symbol,
.swagger-section .hljs-variable,
.swagger-section .hljs-template-variable,
.swagger-section .hljs-link,
.swagger-section .hljs-selector-attr,
.swagger-section .hljs-selector-pseudo {
color: #BC6060;
}
.swagger-section .hljs-type,
.swagger-section .hljs-string,
.swagger-section .hljs-number,
.swagger-section .hljs-selector-id,
.swagger-section .hljs-selector-class,
.swagger-section .hljs-quote,
.swagger-section .hljs-template-tag,
.swagger-section .hljs-deletion {
color: #880000;
}
.swagger-section .hljs-title,
.swagger-section .hljs-section {
color: #880000;
font-weight: bold;
}
.swagger-section .hljs-comment {
color: #888888;
}
.swagger-section .hljs-meta {
color: #2B6EA1;
}
.swagger-section .hljs-emphasis {
font-style: italic;
}
.swagger-section .hljs-strong {
font-weight: bold;
}
.swagger-section .swagger-ui-wrap {
line-height: 1;
font-family: "Droid Sans", sans-serif;

View File

@@ -1,4 +1,3 @@
<!DOCTYPE html>
<html>
<head>
@@ -20,7 +19,7 @@
<script src='lib/lodash.min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<script src='lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
<script src='lib/marked.js' type='text/javascript'></script>
<script src='lib/swagger-oauth.js' type='text/javascript'></script>

View File

@@ -1,4 +1,5 @@
'use strict';
/*jslint eqeq: true*/
Handlebars.registerHelper('sanitize', function(html) {
// Strip the script tags from the html, and return it as a Handlebars.SafeString
@@ -51,3 +52,27 @@ Handlebars.registerHelper('renderTextParam', function(param) {
}
return new Handlebars.SafeString(result);
});
Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
switch (operator) {
case '==':
return (v1 == v2) ? options.fn(this) : options.inverse(this);
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this);
case '<':
return (v1 < v2) ? options.fn(this) : options.inverse(this);
case '<=':
return (v1 <= v2) ? options.fn(this) : options.inverse(this);
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this);
case '>=':
return (v1 >= v2) ? options.fn(this) : options.inverse(this);
case '&&':
return (v1 && v2) ? options.fn(this) : options.inverse(this);
case '||':
return (v1 || v2) ? options.fn(this) : options.inverse(this);
default:
return options.inverse(this);
}
});

View File

@@ -132,4 +132,76 @@ pre .xml .cdata {
opacity: 0.5;
}
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: #F0F0F0
}
.hljs,
.hljs-subst {
color: #444
}
.hljs-keyword,
.hljs-attribute,
.hljs-selector-tag,
.hljs-meta-keyword,
.hljs-doctag,
.hljs-name {
font-weight: bold
}
.hljs-built_in,
.hljs-literal,
.hljs-bullet,
.hljs-code,
.hljs-addition {
color: #1F811F
}
.hljs-regexp,
.hljs-symbol,
.hljs-variable,
.hljs-template-variable,
.hljs-link,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #BC6060
}
.hljs-type,
.hljs-string,
.hljs-number,
.hljs-selector-id,
.hljs-selector-class,
.hljs-quote,
.hljs-template-tag,
.hljs-deletion {
color: #880000
}
.hljs-title,
.hljs-section {
color: #880000;
font-weight: bold
}
.hljs-comment {
color: #888888
}
.hljs-meta {
color: #2B6EA1
}
.hljs-emphasis {
font-style: italic
}
.hljs-strong {
font-weight: bold
}
}

View File

@@ -13,13 +13,13 @@
<div class="snippet">
{{#if sampleJSON}}
<div class="snippet_json">
<pre><code>{{sampleJSON}}</code></pre>
<pre><code class="{{#ifCond sampleJSON.length ">" 5000}}nohighlight{{/ifCond}}">{{sampleJSON}}</code></pre>
{{#if isParam}}<small class="notice" data-sw-translate></small>{{/if}}
</div>
{{/if}}
{{#if sampleXML}}
<div class="snippet_xml">
<pre><code>{{sampleXML}}</code></pre>
<pre><code class="{{#ifCond sampleXML.length ">" 5000}}nohighlight{{/ifCond}}">{{sampleXML}}</code></pre>
{{#if isParam}}<small class="notice" data-sw-translate></small>{{/if}}
</div>
{{/if}}