mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
b887bea41c
Former-commit-id: cb52bcce9e36fe059872e5298c608040011da5aa [formerly 804a85c4e976173c7e05c2c71e2e191e3f99703a] [formerly 7731ace2dc06dada2037bbb9dce7c53f4c61a32f [formerly 248528a355
]]
Former-commit-id: 758ed4a14ccb3872d95f90048c5c687013d6e374 [formerly 721ef84965ab49b4fb1073d8f5c707b4972cb23f]
Former-commit-id: 22e7b776e2c4d191ea84eae7b1dfcf09fe23acda
328 lines
9.5 KiB
Cheetah
328 lines
9.5 KiB
Cheetah
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>{{ .Title }}</title>
|
|
|
|
{{ template "header" }}
|
|
|
|
<link rel="stylesheet" type="text/css" href="/static/css/view.css">
|
|
<link rel="stylesheet" type="text/css" href="/static/css/katex.min.css">
|
|
<script src="/static/js/katex.min.js"></script>
|
|
|
|
<style>
|
|
a.deleteable {
|
|
cursor: pointer;
|
|
}
|
|
@media (min-width: 1200px) {
|
|
.container {
|
|
max-width: 960px;
|
|
}
|
|
}
|
|
</style>
|
|
{{ if .Coding }}
|
|
<style>
|
|
.CodeMirror {
|
|
border: 1px solid #eee;
|
|
height: auto;
|
|
}
|
|
|
|
|
|
textarea {
|
|
width: 100%;
|
|
margin: 5px 0;
|
|
padding: 10px;
|
|
border: none;
|
|
overflow: auto;
|
|
outline: none;
|
|
font-size: large;
|
|
-webkit-box-shadow: none;
|
|
-moz-box-shadow: none;
|
|
box-shadow: none;
|
|
font-family: Tahoma, sans-serif;
|
|
}
|
|
|
|
body {
|
|
margin: 0;
|
|
background: #fff;
|
|
max-width: 800px;
|
|
margin: 0 auto;
|
|
padding-bottom: 65px;
|
|
}
|
|
|
|
|
|
</style>
|
|
{{ end }}
|
|
<script src="/static/js/sweetalert-dev.js"></script>
|
|
<link rel="stylesheet" href="/static/css/sweetalert.css">
|
|
|
|
{{ if .Coding }}
|
|
<script src="/static/js/codemirror.js"></script>
|
|
<link rel="stylesheet" href="/static/css/codemirror.css">
|
|
<script src="/static/js/{{ .CodeType }}.js"></script>
|
|
{{ if eq .CodeType "htmlmixed" }}
|
|
<script src="/static/js/css.js"></script>
|
|
<script src="/static/js/javascript.js"></script>
|
|
<script src="/static/js/xml.js"></script>
|
|
{{ end }}
|
|
{{ end }}
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<!-- Fixed navbar -->
|
|
<nav class="navbar navbar-default navbar-fixed-bottom">
|
|
<div class="container">
|
|
<div class="navbar-header">
|
|
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
|
|
<span class="sr-only">Toggle navigation</span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
<span class="icon-bar"></span>
|
|
</button>
|
|
<a class="navbar-brand" href="/">{{ .Title }}</a>
|
|
</div>
|
|
<div id="navbar" class="collapse navbar-collapse">
|
|
<ul class="nav navbar-nav">
|
|
<li>{{ if .Locked }}<a href="#" class="postunlock"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span>{{else}}<a href="/{{ .Title }}"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>{{end}} Edit</a></li>
|
|
<li class="dropdown active">
|
|
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" class="active"><span class="glyphicon glyphicon-sunglasses" aria-hidden="true"></span> View <span class="caret"></span></a>
|
|
<ul class="dropdown-menu">
|
|
<li class="dropdown-header">Time edited: {{ .TotalTime }}</li>
|
|
<li role="separator" class="divider"></li>
|
|
<li class="dropdown-header">Other versions</li>
|
|
<li><a href="/{{ .Title }}/view?version=0">First</a></li>
|
|
{{ range .Versions }}
|
|
<li><a href="/{{ $.Title }}/view?version={{ .VersionNum }}">{{ .VersionDate }}</a></li>
|
|
{{ end }}
|
|
<li><a href="/{{ .Title }}/view">Current</a></li>
|
|
{{ if .LockedOrEncrypted }}
|
|
<li class="dropdown-header">Options</li>
|
|
{{ if .Encrypted }}
|
|
<li><a href="#" class="postdecrypt">Decrypt</a></li>
|
|
{{end }}
|
|
{{ if .Locked }}
|
|
<li><a href="#" class="postunlock">Unlock</a></li>
|
|
{{end }}
|
|
{{ end }}
|
|
</ul>
|
|
</li>
|
|
<li><a href="/{{ .Title }}/list"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span> List</a></li>
|
|
<li><a href="/Help/view"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> Help</a></li>
|
|
</ul>
|
|
</div>
|
|
<!--/.nav-collapse -->
|
|
</div>
|
|
</nav>
|
|
|
|
{{ if .Coding }}
|
|
|
|
<div>
|
|
<textarea autofocus rows={{ .NumRows }} class='auto_submit_item' id="emit_data" name="emit_data" placeholder="Start typing, it will save automatically.">{{ .CurrentText }}</textarea>
|
|
</div>
|
|
|
|
{{ else }}
|
|
<div class="yue">
|
|
{{ if .Encrypted }}
|
|
<pre>
|
|
{{ .Body }}
|
|
</pre>
|
|
{{ else }}
|
|
{{ .Body }}
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
|
|
<script>
|
|
$( document ).ready(function() {
|
|
|
|
{{ if .Encrypted }}
|
|
{{ if .Prompt }}
|
|
var pass1 = "";
|
|
swal({
|
|
title: "Decryption",
|
|
text: "Enter your passphrase:",
|
|
type: "input", inputType: "password",
|
|
showCancelButton: true,
|
|
closeOnConfirm: false,
|
|
animation: "slide-from-top",
|
|
inputPlaceholder: "Write something"
|
|
}, function(inputValue) {
|
|
if (inputValue === false) return false;
|
|
if (inputValue === "") {
|
|
swal.showInputError("You need to write something!");
|
|
return false
|
|
}
|
|
pass1 = inputValue;
|
|
$.ajax({
|
|
type: "POST",
|
|
//the url where you want to sent the userName and password to
|
|
url: '/{{ .Title }}/decrypt',
|
|
dataType: 'json',
|
|
data: JSON.stringify({
|
|
text: " ",
|
|
password: pass1
|
|
}),
|
|
success: function (data) {
|
|
if (data['success'] == true) {
|
|
swal("Decryption", "Decrypted!", "success");
|
|
window.location.href = '/{{ .Title }}/view';
|
|
} else {
|
|
swal("Decryption", data['status'], "error");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
{{ end }}
|
|
$('.postdecrypt').click(function(event) {
|
|
var pass1 = "";
|
|
event.preventDefault();
|
|
swal({
|
|
title: "Decryption",
|
|
text: "Enter your passphrase:",
|
|
type: "input", inputType: "password",
|
|
showCancelButton: true,
|
|
closeOnConfirm: false,
|
|
animation: "slide-from-top",
|
|
inputPlaceholder: "Write something"
|
|
}, function(inputValue) {
|
|
if (inputValue === false) return false;
|
|
if (inputValue === "") {
|
|
swal.showInputError("You need to write something!");
|
|
return false
|
|
}
|
|
pass1 = inputValue;
|
|
$.ajax({
|
|
type: "POST",
|
|
//the url where you want to sent the userName and password to
|
|
url: '/{{ .Title }}/decrypt',
|
|
dataType: 'json',
|
|
data: JSON.stringify({
|
|
text: " ",
|
|
password: pass1
|
|
}),
|
|
success: function (data) {
|
|
if (data['success'] == true) {
|
|
swal("Decryption", "Decrypted!", "success");
|
|
window.location.href = '/{{ .Title }}/view';
|
|
} else {
|
|
swal("Decryption", data['status'], "error");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
{{ end }}
|
|
|
|
{{ if .Locked }}
|
|
|
|
$('.postunlock').click(function(event) {
|
|
var pass1 = "";
|
|
event.preventDefault();
|
|
swal({
|
|
title: "Unlock",
|
|
text: "Enter your passphrase:",
|
|
type: "input", inputType: "password",
|
|
showCancelButton: true,
|
|
closeOnConfirm: false,
|
|
animation: "slide-from-top",
|
|
inputPlaceholder: "Write something"
|
|
}, function(inputValue) {
|
|
if (inputValue === false) return false;
|
|
if (inputValue === "") {
|
|
swal.showInputError("You need to write something!");
|
|
return false
|
|
}
|
|
pass1 = inputValue;
|
|
$.ajax({
|
|
type: "POST",
|
|
//the url where you want to sent the userName and password to
|
|
url: '/{{ .Title }}/unlock',
|
|
dataType: 'json',
|
|
data: JSON.stringify({
|
|
text: " ",
|
|
password: pass1
|
|
}),
|
|
success: function (data) {
|
|
if (data['success'] == true) {
|
|
swal("Unlock", "Unlocked!", "success");
|
|
window.location.href = '/{{ .Title }}';
|
|
} else {
|
|
swal("Unlock", data['status'], "error");
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
{{ end }}
|
|
|
|
|
|
|
|
var texi = document.getElementsByClassName("texi");
|
|
Array.prototype.forEach.call(texi, function(el) {
|
|
katex.render(el.getAttribute("data-expr"), el, { displayMode: false });
|
|
});
|
|
|
|
var texp = document.getElementsByClassName("texp");
|
|
Array.prototype.forEach.call(texp, function(el) {
|
|
katex.render(el.getAttribute("data-expr"), el, { displayMode: true });
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
$(document).keydown(function(e){
|
|
if( e.which === 69 && e.ctrlKey && e.shiftKey ){
|
|
console.log('control + shift + e');
|
|
window.location = "/{{ .Title }}";
|
|
}
|
|
});
|
|
|
|
|
|
$(document).keydown(function(e){
|
|
if( e.which === 76 && e.ctrlKey && e.shiftKey ){
|
|
console.log('control + shift + l');
|
|
window.location = "/{{ .Title }}/list";
|
|
}
|
|
});
|
|
|
|
|
|
{{ if .AdminKey }}
|
|
$('.deleteable').click(function(event) {
|
|
event.preventDefault();
|
|
var deleteName = $(this).attr('id')
|
|
var href = $(this).attr('href')
|
|
console.log(deleteName)
|
|
$.ajax({
|
|
url: "/deletepage" + '?' + $.param({
|
|
"DeleteName": deleteName,
|
|
"AdminKey": "{{ .AdminKey }}"
|
|
}),
|
|
type: 'DELETE',
|
|
success: function() {
|
|
window.location.reload(true);
|
|
}
|
|
});
|
|
|
|
});
|
|
{{ end }}
|
|
</script>
|
|
|
|
|
|
{{ if .Coding }}
|
|
<script>
|
|
var editor = CodeMirror.fromTextArea(document.getElementById("emit_data"), {
|
|
lineNumbers: true,
|
|
mode: "{{ .CodeType }}",
|
|
matchBrackets: true,
|
|
viewportMargin: Infinity,
|
|
readOnly: true
|
|
});
|
|
editor.setSize("100%", "100%")
|
|
</script>
|
|
{{ end }}
|
|
</body>
|
|
|
|
</html>
|