1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut-pastebin synced 2025-06-07 22:26:01 -04:00
perlbuut-pastebin/templates/viewer.html
2017-04-23 00:41:05 -04:00

114 lines
3 KiB
HTML
Executable file

[% BLOCK body_style %]
<style type="text/css" media="screen">
#editor, #paste {
margin: auto;
position: relative !important;
width: 100%;
font-variant-ligatures: none;
}
html, body, #content {
width: 100%;
}
.options label {
padding-right: 0.5em;
}
.options label:not(:first-child) {
padding-left: 2em;
}
@font-face {
font-family: "AnonymousPro";
src: url("/static/fonts/AnonymousPro-Regular.woff2") format('woff2');
}
</style>
[% END %]
[% BLOCK page_header %]
<div class="row">
<div class="col-md-3">
<b>Who: </b>[% who | html %]
</div>
<div class="col-md-3">
<b>When: </b>[% when %]
</div>
<div class="col-md-6">
<b>What: </b>[% what | html %]
</div>
</div>
[% END %]
[% BLOCK body %]
<form action="/edit/[% paste_id %]" method="GET" id="form">
<div id="content" class="container">
<div class="panel">
<div class="panel-heading">
[% PROCESS page_header %]
</div>
</div>
<div class="panel-body">
<div class="row">
<div class="options">
<label>Raw Viewer</label>
<input type="checkbox" id="raw_editor"/>
<label><a href="/raw/[% id %]">Raw Link</a></label>
<!-- TODO this should come from the eval server somehow -->
</div>
<div class="col-md-12">
<pre id="paste">[% paste | html %]</pre>
<pre id="editor"></pre>
</div>
</div>
<div class="row">
<div id="eval" class="col-md-12">
<h3>Program Output:</h3>
<pre>[% eval | html %]</pre>
</div>
</div>
<div class="panel-footer">
<input value="Fork and Edit" type="submit" id="submit" />
</div>
</div>
</div>
</form>
<script src="/static/ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
//editor.setTheme("ace/theme/twilight");
editor.session.setMode("ace/mode/perl");
var use_editor = function() {
if ($("#raw_editor").is(":checked")) {
$("#editor").hide();
$("#paste").show();
} else {
console.log($("#paste").text());
editor.setValue($("#paste").text(),0);
editor.clearSelection();
$("#paste").hide();
$("#editor").show();
}
};
use_editor();
$("#raw_editor").on("change", use_editor);
editor.setReadOnly(true);
editor.setOptions({maxLines: Infinity, fontFamily: ['AnonymousPro', 'monospace', 'mono']});
/*function resizeAce() {
var h = window.innerHeight;
var ch = h - 400;
var m = ch > 360 ? ch : 360;
// $('#editor').css('height', m.toString() + 'px');
};
$(window).on('resize', function () {
resizeAce();
});
resizeAce();*/
$("#submit").on('click', function () {
$("#paste").text(editor.getValue()); // copy to the textarea
});
</script>
[% END %]