forked from 0x2620/pandora
use Ox.SyntaxHighlighter on /api/
This commit is contained in:
parent
75f7516978
commit
55992dd834
4 changed files with 37 additions and 96 deletions
|
@ -5,9 +5,7 @@
|
|||
<title>{{sitename}} API</title>
|
||||
|
||||
<link rel="shortcut icon" type="image/png" href="/static/png/icon.png"/>
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/highlight.css"/>
|
||||
<script type="text/javascript" src="/static/oxjs/build/Ox.js"></script>
|
||||
<script type="text/javascript" src="/static/js/api/highlight.pack.js"></script>
|
||||
<script type="text/javascript" src="/static/js/api/pandora.js"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
pre code {
|
||||
display: block;
|
||||
background: #F0F0F0;
|
||||
}
|
||||
|
||||
pre code,
|
||||
.xml .title {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.string,
|
||||
.title,
|
||||
.parent,
|
||||
.tag .attribute .value,
|
||||
.rules .value,
|
||||
.rules .value .number,
|
||||
.preprocessor,
|
||||
.instancevar,
|
||||
.aggregate,
|
||||
.template_tag,
|
||||
.django .variable,
|
||||
.addition,
|
||||
.flow,
|
||||
.stream {
|
||||
color: #800;
|
||||
}
|
||||
|
||||
.comment,
|
||||
.annotation,
|
||||
.template_comment,
|
||||
.diff .header,
|
||||
.chunk {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.number,
|
||||
.regexp,
|
||||
.literal,
|
||||
.change {
|
||||
color: #080;
|
||||
}
|
||||
|
||||
.decorator,
|
||||
.filter .argument,
|
||||
.localvars,
|
||||
.array,
|
||||
.attr_selector,
|
||||
.pi,
|
||||
.doctype,
|
||||
.deletion,
|
||||
.envvar,
|
||||
.shebang {
|
||||
color: #88F;
|
||||
}
|
||||
|
||||
.keyword,
|
||||
.id,
|
||||
.title,
|
||||
.aggregate {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.html .css,
|
||||
.html .javascript,
|
||||
.html .vbscript {
|
||||
opacity: 0.5;
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -125,33 +125,44 @@ function constructList() {
|
|||
hash = '#';
|
||||
if(data.ids.length)
|
||||
data.ids.forEach(function(id) {
|
||||
info.append($("<h2>").html(id));
|
||||
var $doc =$('<pre>')
|
||||
.html(app.actions[id].doc.replace('/\n/<br>\n/g'))
|
||||
.appendTo(info);
|
||||
var $code = $('<code class="python">')
|
||||
.html(app.actions[id].code[1].replace('/\n/<br>\n/g'))
|
||||
.hide();
|
||||
/*
|
||||
var $button = Ox.Button({
|
||||
type: "image",
|
||||
options: [
|
||||
{id: "one", title: "right"},
|
||||
{id: "two", title: "down"},
|
||||
],
|
||||
})
|
||||
.addClass("margin")
|
||||
.click(function() { $code.toggle()})
|
||||
.appendTo(info);
|
||||
*/
|
||||
var f = app.actions[id].code[0];
|
||||
$('<span>')
|
||||
.html(' View Source ('+f+')')
|
||||
.click(function() { $code.toggle()})
|
||||
.appendTo(info)
|
||||
$('<pre>').append($code).appendTo(info)
|
||||
hljs.highlightBlock($code[0], ' ');
|
||||
info.append(
|
||||
$("<h2>")
|
||||
.html(id)
|
||||
.css({
|
||||
marginBottom: '8px'
|
||||
})
|
||||
);
|
||||
var code = app.actions[id].code[1],
|
||||
f = app.actions[id].code[0],
|
||||
line = Math.round(Ox.last(f.split(':')) || 0),
|
||||
doc = app.actions[id].doc.replace('/\n/<br>\n/g'),
|
||||
$code, $doc;
|
||||
|
||||
$doc = Ox.SyntaxHighlighter({
|
||||
source: doc,
|
||||
})
|
||||
.appendTo(info);
|
||||
|
||||
Ox.Button({
|
||||
title: 'View Source (' + f + ')',
|
||||
}).bindEvent({
|
||||
click: function() {
|
||||
$code.toggle();
|
||||
}
|
||||
})
|
||||
.css({
|
||||
margin: '4px'
|
||||
})
|
||||
.appendTo(info);
|
||||
$code = Ox.SyntaxHighlighter({
|
||||
showLineNumbers: true,
|
||||
source: code,
|
||||
offset: line
|
||||
})
|
||||
.css({
|
||||
borderWidth: '1px',
|
||||
}).appendTo(info).hide();
|
||||
Ox.print(code);
|
||||
hash += id + ','
|
||||
});
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue