1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
cowyo/templates/view.tmpl

338 lines
10 KiB
Cheetah
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<title>{{ .Title }}</title>
2016-02-07 19:05:38 +03:00
{{ template "header" }}
<link rel="stylesheet" type="text/css" href="/static/css/view.css">
2016-02-07 21:21:24 +03:00
<link rel="stylesheet" type="text/css" href="/static/css/katex.min.css">
<script src="/static/js/katex.min.js"></script>
2016-02-11 05:16:54 +03:00
<style>
a.deleteable {
cursor: pointer;
}
body {
margin: 0;
background: #fff;
max-width: 900px;
margin: 0 auto;
padding-bottom: 65px;
}
2016-02-11 05:16:54 +03:00
</style>
2016-03-29 18:50:06 +03:00
{{ 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;
}
2016-03-30 20:11:30 +03:00
2016-03-29 18:50:06 +03:00
</style>
{{ end }}
2016-03-14 16:42:19 +03:00
<script src="/static/js/sweetalert-dev.js"></script>
<link rel="stylesheet" href="/static/css/sweetalert.css">
2016-03-29 23:21:48 +03:00
{{ 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>
2016-02-07 19:05:38 +03:00
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-bottom">
<div class="container">
<!-- <div class="navbar-header">
2016-02-07 19:05:38 +03:00
<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> -->
2016-02-07 19:05:38 +03:00
<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>
2016-02-11 00:40:21 +03:00
<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>
2016-02-10 02:44:00 +03:00
<ul class="dropdown-menu">
2016-02-14 16:01:28 +03:00
<li class="dropdown-header">Time edited: {{ .TotalTime }}</li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Other versions</li>
2016-02-10 02:44:00 +03:00
<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>
2016-03-15 04:39:09 +03:00
{{ if .LockedOrEncrypted }}
2016-03-14 16:42:19 +03:00
<li class="dropdown-header">Options</li>
2016-03-15 04:39:09 +03:00
{{ if .Encrypted }}
2016-03-14 16:42:19 +03:00
<li><a href="#" class="postdecrypt">Decrypt</a></li>
2016-03-15 04:39:09 +03:00
{{end }}
{{ if .Locked }}
<li><a href="#" class="postunlock">Unlock</a></li>
{{end }}
2016-03-14 16:42:19 +03:00
{{ end }}
2016-02-10 02:44:00 +03:00
</ul>
</li>
2016-02-11 00:40:21 +03:00
<li><a href="/{{ .Title }}/list"><span class="glyphicon glyphicon-align-left" aria-hidden="true"></span> List</a></li>
2016-04-07 17:15:46 +03:00
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false" class="active"><span class="glyphicon glyphicon-globe" aria-hidden="true"></span> More &nbsp; <span class="caret"></span></a>
2016-04-07 17:15:46 +03:00
<ul class="dropdown-menu">
<li>
<a class="trigger right-caret">Recent</a>
<ul class="dropdown-menu sub-menu">
{{ range .RecentlyEdited}}
<li><a href="/{{.}}/view"> {{.}}</a></li>
{{ end }}
</ul>
</li>
2016-04-07 17:15:46 +03:00
<li><a href="/Help/view"> Help</a></li>
<li><a href="/PrivacyPolicy/view"> Privacy Policy</a></li>
</ul>
</li>
2016-02-07 19:05:38 +03:00
</ul>
</div>
<!--/.nav-collapse -->
</div>
</nav>
2016-03-29 18:50:06 +03:00
{{ 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">
2016-03-14 16:56:12 +03:00
{{ if .Encrypted }}
<pre>
{{ .Body }}
</pre>
{{ else }}
{{ .Body }}
2016-03-14 16:56:12 +03:00
{{ end }}
</div>
2016-03-29 18:50:06 +03:00
{{ end }}
2016-02-07 21:21:24 +03:00
<script>
$( document ).ready(function() {
2016-02-07 21:38:39 +03:00
2016-03-15 04:39:09 +03:00
{{ if .Encrypted }}
{{ if .Prompt }}
var pass1 = "";
swal({
title: "Decryption",
text: "Enter your passphrase:",
2016-03-23 02:42:18 +03:00
type: "input", inputType: "password",
2016-03-15 04:39:09 +03:00
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");
}
}
2016-03-15 04:39:09 +03:00
});
});
{{ end }}
$('.postdecrypt').click(function(event) {
var pass1 = "";
event.preventDefault();
swal({
title: "Decryption",
text: "Enter your passphrase:",
2016-03-23 02:42:18 +03:00
type: "input", inputType: "password",
2016-03-15 04:39:09 +03:00
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");
}
}
});
});
});
2016-03-14 21:31:28 +03:00
{{ end }}
2016-03-15 04:39:09 +03:00
{{ if .Locked }}
$('.postunlock').click(function(event) {
var pass1 = "";
event.preventDefault();
swal({
title: "Unlock",
text: "Enter your passphrase:",
2016-03-23 02:42:18 +03:00
type: "input", inputType: "password",
2016-03-15 04:39:09 +03:00
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
2016-03-14 16:42:19 +03:00
}
2016-03-15 04:39:09 +03:00
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");
}
}
});
});
2016-03-14 16:42:19 +03:00
});
2016-03-15 04:39:09 +03:00
{{ 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 });
});
2016-03-14 16:42:19 +03:00
2016-02-07 21:21:24 +03:00
});
$(document).keydown(function(e){
if( e.which === 69 && e.ctrlKey && e.shiftKey ){
console.log('control + shift + e');
window.location = "/{{ .Title }}";
}
});
2016-02-07 21:21:24 +03:00
2016-02-11 04:43:51 +03:00
$(document).keydown(function(e){
if( e.which === 76 && e.ctrlKey && e.shiftKey ){
console.log('control + shift + l');
window.location = "/{{ .Title }}/list";
}
});
2016-03-14 16:42:19 +03:00
2016-02-11 05:16:54 +03:00
{{ 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 }}
2016-02-07 21:21:24 +03:00
</script>
2016-03-29 18:50:06 +03:00
{{ 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>