2017-03-22 05:46:24 +03:00
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
2017-03-22 20:34:06 +03:00
<link rel="apple-touch-icon" sizes="57x57" href=/static/img/cowyo/apple-icon-57x57.png>
<link rel="apple-touch-icon" sizes="60x60" href=/static/img/cowyo/img/cowyo/apple-icon-60x60.png>
<link rel="apple-touch-icon" sizes="72x72" href=/static/img/cowyo/apple-icon-72x72.png>
<link rel="apple-touch-icon" sizes="76x76" href=/static/img/cowyo/apple-icon-76x76.png>
<link rel="apple-touch-icon" sizes="114x114" href=/static/img/cowyo/apple-icon-114x114.png>
<link rel="apple-touch-icon" sizes="120x120" href=/static/img/cowyo/apple-icon-120x120.png>
<link rel="apple-touch-icon" sizes="144x144" href=/static/img/cowyo/apple-icon-144x144.png>
<link rel="apple-touch-icon" sizes="152x152" href=/static/img/cowyo/apple-icon-152x152.png>
<link rel="apple-touch-icon" sizes="180x180" href=/static/img/cowyo/apple-icon-180x180.png>
<link rel="icon" type="image/png" sizes="192x192" href=/static/img/cowyo/android-icon-192x192.png>
<link rel="icon" type="image/png" sizes="32x32" href=/static/img/cowyo/favicon-32x32.png>
<link rel="icon" type="image/png" sizes="96x96" href=/static/img/cowyo/favicon-96x96.png>
<link rel="icon" type="image/png" sizes="16x16" href=/static/img/cowyo/favicon-16x16.png>
<link rel="manifest" href=/static/img/cowyo/manifest.json>
<meta name="msapplication-TileColor" content=" #fff " >
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="theme-color" content=" #fff " >
2017-03-22 05:46:24 +03:00
2017-03-22 06:06:35 +03:00
<script type="text/javascript" src="/static/js/jquery-1.8.3.js"></script>
<link rel="stylesheet" type="text/css" href="/static/css/github-markdown.css">
<link rel="stylesheet" type="text/css" href="/static/css/menus-min.css">
<link rel="stylesheet" type="text/css" href="/static/css/base-min.css">
2017-03-22 23:29:53 +03:00
<link rel="stylesheet" href="/static/css/highlight.css">
<script src="/static/js/highlight.min.js"></script>
2017-03-22 17:09:09 +03:00
<script type="text/javascript" src="/static/js/highlight.pack.js"></script>
2017-03-22 05:46:24 +03:00
<style type="text/css">
2017-09-11 17:38:20 +03:00
{{ if .ListPage }}
/* Required for lists */
span { cursor: pointer; }
{{ end }}
body {
background: #fff ;
}
.success {
color: #5cb85c;
font-weight: bold;
}
.failure {
color: #d 9534 f ;
font-weight: bold;
}
.pure-menu a {
color: #777;
}
#wrap {
position: absolute;
2017-09-11 21:08:48 +03:00
top: 50px;
2017-09-11 17:38:20 +03:00
left: 0px;
right: 0px;
bottom: 0px;
}
#pad {
height:100%;
}
{{ if .EditPage }}
body {
overflow:hidden;
}
{{ end }}
body #pad textarea {
width: 100%;
height: 100%;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
position: absolute;
left: 0;
right: 0;
bottom: 0;
2017-09-11 21:11:22 +03:00
top: 0;
2017-09-11 17:38:20 +03:00
border: 0;
border: none;
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
resize: none;
font-size: 1.0em;
{{ if .HasDotInName }}
font-family: "Lucida Console", Monaco, monospace;
{{else}}
font-family: 'Open Sans','Segoe UI',Tahoma,Arial,sans-serif;
{{ end }}
}
.markdown-body ul, .markdown-body ol {
padding-left: 0em;
}
@media (min-width: 5em) {
div #menu , div # rendered, body #pad textarea {
padding-left: 2%;
padding-right: 2%;
}
.pure-menu .pure-menu-horizontal {
max-width: 300px;
}
.pure-menu-disabled, .pure-menu-heading, .pure-menu-link {
2017-09-11 21:11:22 +03:00
padding-left:1.2em;
padding-right:em;
2017-09-11 17:38:20 +03:00
}
}
@media (min-width: 50em) {
div #menu , div # rendered, body #pad textarea {
padding-left: 10%;
padding-right: 10%;
}
.pure-menu-disabled, .pure-menu-heading, .pure-menu-link {
padding: .5em 1em;
}
}
@media (min-width: 70em) {
div #menu , div # rendered, body #pad textarea {
padding-left: 15%;
padding-right: 15%;
}
}
@media (min-width: 100em) {
div #menu , div # rendered, body #pad textarea {
padding-left: 20%;
padding-right: 20%;
}
}
2017-03-22 05:46:24 +03:00
</style>
<title>{{ .Page }}</title>
<script type='text/javascript'>
2017-04-15 08:15:00 +03:00
oulipo = false;
2017-03-22 05:46:24 +03:00
//<![CDATA[
$(window).load(function() {
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce(func, wait, immediate) {
var timeout;
return function() {
2017-03-23 18:57:25 +03:00
$(' #saveEditButton ' ).removeClass()
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text( " Editing " );
var context = this,
args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
// This will apply the debounce effect on the keyup event
// And it only fires 500ms or half a second after the user stopped typing
$(' #userInput ' ).on( ' keyup ' , debounce(function() {
console.log('typing occurred');
2017-04-15 08:15:00 +03:00
if (oulipo == true) { $(' #userInput ' ).val($( ' # userInput').val().replace(/e/g,"")); }
2017-03-23 18:57:25 +03:00
$(' #saveEditButton ' ).removeClass()
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text( " Saving " )
upload();
}, 500));
function upload() {
$.ajax({
type: 'POST',
url: '/update',
data: JSON.stringify({
new_text: $(' #userInput ' ).val(),
page: "{{ .Page }}"
}),
success: function(data) {
2017-03-23 18:57:25 +03:00
$(' #saveEditButton ' ).removeClass()
if (data.success == true) {
$(' #saveEditButton ' ).addClass( " success " );
} else {
$(' #saveEditButton ' ).addClass( " failure " );
}
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(data.message);
},
error: function(xhr, error) {
2017-03-24 01:16:15 +03:00
$(' #saveEditButton ' ).removeClass()
$(' #saveEditButton ' ).addClass( " failure " );
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(error);
},
contentType: "application/json",
dataType: 'json'
});
}
function primeForSelfDestruct() {
$.ajax({
type: 'POST',
url: '/prime',
data: JSON.stringify({
page: "{{ .Page }}"
}),
success: function(data) {
2017-03-23 18:57:25 +03:00
$(' #saveEditButton ' ).removeClass()
if (data.success == true) {
$(' #saveEditButton ' ).addClass( " success " );
} else {
$(' #saveEditButton ' ).addClass( " failure " );
}
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(data.message);
},
error: function(xhr, error) {
2017-03-24 01:16:15 +03:00
$(' #saveEditButton ' ).removeClass()
$(' #saveEditButton ' ).addClass( " failure " );
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(error);
},
contentType: "application/json",
dataType: 'json'
});
}
function lockPage(passphrase) {
$.ajax({
type: 'POST',
url: '/lock',
data: JSON.stringify({
page: "{{ .Page }}",
passphrase: passphrase
}),
success: function(data) {
2017-03-23 18:57:25 +03:00
$(' #saveEditButton ' ).removeClass()
if (data.success == true) {
$(' #saveEditButton ' ).addClass( " success " );
} else {
$(' #saveEditButton ' ).addClass( " failure " );
}
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(data.message);
2017-03-23 19:26:40 +03:00
if (data.success == true && $(' #lockPage ' ).text() == " Lock " ) {
window.location = "/{{ .Page }}/view";
}
if (data.success == true && $(' #lockPage ' ).text() == " Unlock " ) {
window.location = "/{{ .Page }}/edit";
}
2017-03-22 05:46:24 +03:00
},
error: function(xhr, error) {
2017-03-23 18:57:25 +03:00
$(' #saveEditButton ' ).removeClass()
$(' #saveEditButton ' ).addClass( " failure " );
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(error);
},
contentType: "application/json",
dataType: 'json'
});
}
2017-10-15 16:49:40 +03:00
function publishPage() {
$.ajax({
type: 'POST',
url: '/publish',
data: JSON.stringify({
page: "{{ .Page }}",
publish: $(' #publishPage ' ).text() == " Publish "
}),
success: function(data) {
$(' #saveEditButton ' ).removeClass()
if (data.success == true) {
$(' #saveEditButton ' ).addClass( " success " );
} else {
$(' #saveEditButton ' ).addClass( " failure " );
}
$(' #saveEditButton ' ).text(data.message);
if (data.message == "Unpublished") {
$(' #publishPage ' ).text( " Publish " );
} else {
$(' #publishPage ' ).text( " Unpublish " );
}
},
error: function(xhr, error) {
$(' #saveEditButton ' ).removeClass()
$(' #saveEditButton ' ).addClass( " failure " );
$(' #saveEditButton ' ).text(error);
},
contentType: "application/json",
dataType: 'json'
});
}
2017-03-22 05:46:24 +03:00
function encryptPage(passphrase) {
$.ajax({
type: 'POST',
url: '/encrypt',
data: JSON.stringify({
page: "{{ .Page }}",
passphrase: passphrase
}),
success: function(data) {
2017-03-23 19:26:40 +03:00
$(' #saveEditButton ' ).removeClass()
if (data.success == true) {
$(' #saveEditButton ' ).addClass( " success " );
} else {
$(' #saveEditButton ' ).addClass( " failure " );
}
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(data.message);
2017-03-23 19:26:40 +03:00
if (data.success == true && $(' #encryptPage ' ).text() == " Encrypt " ) {
2017-03-22 06:10:41 +03:00
window.location = "/{{ .Page }}/view";
2017-03-23 19:26:40 +03:00
}
if (data.success == true && $(' #encryptPage ' ).text() == " Decrypt " ) {
window.location = "/{{ .Page }}/edit";
}
2017-03-22 05:46:24 +03:00
},
error: function(xhr, error) {
2017-03-24 01:16:15 +03:00
$(' #saveEditButton ' ).removeClass()
$(' #saveEditButton ' ).addClass( " failure " );
2017-03-22 05:46:24 +03:00
$(' #saveEditButton ' ).text(error);
},
contentType: "application/json",
dataType: 'json'
});
}
2017-03-23 22:31:09 +03:00
function clearOld() {
$.ajax({
type: 'DELETE',
url: '/oldlist',
data: JSON.stringify({
page: "{{ .Page }}"
}),
success: function(data) {
$(' #saveEditButton ' ).removeClass()
if (data.success == true) {
$(' #saveEditButton ' ).addClass( " success " );
} else {
$(' #saveEditButton ' ).addClass( " failure " );
}
$(' #saveEditButton ' ).text(data.message);
if (data.success == true) {
window.location = "/{{ .Page }}/list";
}
},
error: function(xhr, error) {
2017-03-24 01:16:15 +03:00
$(' #saveEditButton ' ).removeClass();
$(' #saveEditButton ' ).addClass( " failure " );
2017-03-23 22:31:09 +03:00
$(' #saveEditButton ' ).text(error);
},
contentType: "application/json",
dataType: 'json'
});
}
2017-03-22 05:46:24 +03:00
$(" #encryptPage " ).click(function(e) {
e.preventDefault();
2017-03-24 01:16:15 +03:00
var passphrase = prompt("Please enter a passphrase. Note: Encrypting will remove all previous history.", "");
2017-03-22 05:46:24 +03:00
if (passphrase != null) {
encryptPage(passphrase);
}
});
$(" #erasePage " ).click(function(e) {
e.preventDefault();
var r = confirm("Are you sure you want to erase?");
if (r == true) {
window.location = "/{{ .Page }}/erase";
} else {
x = "You pressed Cancel!";
}
});
$(" #selfDestructPage " ).click(function(e) {
e.preventDefault();
var r = confirm("This will erase the page the next time it is opened, are you sure you want to do that?");
if (r == true) {
primeForSelfDestruct();
} else {
x = "You pressed Cancel!";
}
});
$(" #lockPage " ).click(function(e) {
e.preventDefault();
var passphrase = prompt("Please enter a passphrase to lock", "");
if (passphrase != null) {
2017-03-23 19:39:14 +03:00
if ($(' #lockPage ' ).text() == " Lock " ) {
2017-03-24 01:16:15 +03:00
$(' #saveEditButton ' ).removeClass();
2017-03-23 19:39:14 +03:00
$(" #saveEditButton " ).text( " Locking " );
} else {
2017-03-24 01:16:15 +03:00
$(' #saveEditButton ' ).removeClass();
2017-03-23 19:39:14 +03:00
$(" #saveEditButton " ).text( " Unlocking " );
}
2017-03-22 05:46:24 +03:00
lockPage(passphrase);
// POST encrypt page
// reload page
}
});
2017-10-15 16:49:40 +03:00
$(" #publishPage " ).click(function(e) {
e.preventDefault();
2017-10-15 16:58:43 +03:00
var message = " This will add your page to the sitemap.xml so it will be indexed by search engines.";
2017-10-15 16:49:40 +03:00
if ($(' #publishPage ' ).text() == " Unpublish " ) {
message = "";
}
var confirmed = confirm("Are you sure?" + message);
if (confirmed == true) {
if ($(' #publishPage ' ).text() == " Unpublish " ) {
$(' #saveEditButton ' ).removeClass();
$(" #saveEditButton " ).text( " Unpublishing " );
} else {
$(' #saveEditButton ' ).removeClass();
$(" #saveEditButton " ).text( " Publishing " );
}
publishPage();
}
});
2017-03-23 22:31:09 +03:00
$(" #clearOld " ).click(function(e) {
e.preventDefault();
2017-03-24 01:16:15 +03:00
var r = confirm("This will erase all cleared list items, are you sure you want to do that? (Versions will stay in history).");
2017-03-23 22:31:09 +03:00
if (r == true) {
clearOld()
} else {
x = "You pressed Cancel!";
}
});
2017-03-22 17:09:09 +03:00
$("textarea").keydown(function(e) {
if(e.keyCode === 9) { // tab was pressed
// get caret position/selection
var start = this.selectionStart;
var end = this.selectionEnd;
var $ this = $(this);
var value = $ this . val ();
// set textarea value to: text before caret + tab + text after caret
$ this . val (value.substring(0, start)
+ "\t"
+ value.substring(end));
// put caret at right position again (add one for the tab)
this.selectionStart = this.selectionEnd = start + 1;
// prevent the focus lose
e.preventDefault();
}
});
2017-03-22 20:19:39 +03:00
$('.deletable').click(function(event) {
event.preventDefault();
var lineNum = $(this).attr('id')
$.ajax({
url: "/listitem" + '?' + $.param({
"lineNum": lineNum,
"page": "{{ .Page }}"
}),
type: 'DELETE',
success: function() {
window.location.reload(true);
}
});
});
2017-03-22 05:46:24 +03:00
}); //]]>
</script>
2017-03-22 17:09:09 +03:00
<script>hljs.initHighlightingOnLoad();</script>
2017-03-22 05:46:24 +03:00
</head>
2017-09-11 17:38:20 +03:00
<body id="pad">
2017-03-22 05:46:24 +03:00
<article class="markdown-body">
2017-09-11 17:38:20 +03:00
<div class="pure-menu pure-menu-horizontal" id="menu">
2017-03-22 05:46:24 +03:00
<ul class="pure-menu-list">
<li></li>
<!-- Required to keep them level? -->
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover">
2017-03-24 05:23:06 +03:00
<a href=" #" id="menuLink1" class="pure-menu-link">{{ .Page }}</a>
2017-03-22 05:46:24 +03:00
<ul class="pure-menu-children">
2017-03-22 20:34:06 +03:00
<li class="pure-menu-item"><a href="/" class="pure-menu-link">New</a></li>
2017-03-24 01:28:19 +03:00
<li class="pure-menu-item"><a href="https://github.com/schollz/cowyo" class="pure-menu-link">Source</a></li>
2017-10-15 16:49:40 +03:00
{{ if .EditPage }}
<li class="pure-menu-item"><a href=" #" class="pure-menu-link" id="publishPage">
{{- if .IsPublished -}}
Unpublish
{{- else -}}
Publish
{{- end -}}
</a></li>
{{ end }}
2017-03-22 20:34:06 +03:00
<hr>
2017-03-23 19:26:40 +03:00
{{ if (or (.IsLocked) (.IsEncrypted) )}}
{{ else }}
2017-03-22 17:49:51 +03:00
<li class="pure-menu-item"><a href=" #" class="pure-menu-link" id="encryptPage">{{ if .IsEncrypted }}Decrypt{{ else }}Encrypt{{end}}</a></li>
<li class="pure-menu-item"><a href=" #" class="pure-menu-link" id="lockPage">{{ if .IsLocked }}Unlock{{ else }}Lock{{end}}</a></li>
2017-03-22 05:46:24 +03:00
<li class="pure-menu-item"><a href="/{{ .Page }}/history" class="pure-menu-link">History</a></li>
<hr>
<li class="pure-menu-item"><a href=" #" class="pure-menu-link" id="selfDestructPage">Self-destruct</a></li>
<li class="pure-menu-item"><a href=" #" class="pure-menu-link" id="erasePage">Erase</a></li>
2017-03-23 19:26:40 +03:00
{{ end }}
2017-03-22 05:46:24 +03:00
</ul>
</li>
2017-09-29 15:48:32 +03:00
<!--
<li class="pure-menu-item {{ with .ViewPage }}pure-menu-selected{{ end }}">
<a href="/{{ .Page }}/view" class="pure-menu-link">View</a>
</li>-->
<li class="pure-menu-item pure-menu-has-children pure-menu-allow-hover {{ with .ViewPage }}pure-menu-selected{{ end }}">
<a href=" #" id="menuLink1" class="pure-menu-link">View</a>
<ul class="pure-menu-children">
<li class="pure-menu-item">
<a href="/{{ .Page }}/view" class="pure-menu-link">Current</a>
</li>
{{ range .RecentlyEdited}}
<li class="pure-menu-item"><a class="pure-menu-link" href="/{{.}}/view/">{{.}}</a></li>
{{ end }}
</ul>
</li>
2017-03-23 19:26:40 +03:00
{{ if (or (.IsLocked) (.IsEncrypted) )}}
{{ if .IsLocked }}
2017-03-24 01:16:15 +03:00
<li class="pure-menu-item"><a href=" #" class="pure-menu-link" id="lockPage">{{ if .IsLocked }}Unlock{{ else }}Lock{{end}}</a></li>
2017-03-24 01:28:19 +03:00
<li class="pure-menu-item" class="pure-menu-link"><a href=" #"><span id="saveEditButton"></span></a></li>
2017-03-23 19:26:40 +03:00
{{ else }}
2017-03-24 01:16:15 +03:00
<li class="pure-menu-item"><a href=" #" class="pure-menu-link" id="encryptPage">{{ if .IsEncrypted }}Decrypt{{ else }}Encrypt{{end}}</a></li>
2017-03-24 01:28:19 +03:00
<li class="pure-menu-item" class="pure-menu-link"><a href=" #"><span id="saveEditButton"></span></a></li>
2017-03-23 19:26:40 +03:00
{{ end }}
2017-03-23 22:31:09 +03:00
{{else}}
{{ if .ListPage }}
2017-03-24 02:42:20 +03:00
<li class="pure-menu-item {{ with .ListPage }}pure-menu-selected{{ end }}"><a href=" #" class="pure-menu-link" id="clearOld">Clear done</a></li>
2017-03-23 22:31:09 +03:00
{{ else }}
<li class="pure-menu-item {{ with .ListPage }}pure-menu-selected{{ end }}"><a href="/{{ .Page }}/list" class="pure-menu-link">List</a></li>
{{ end }}
2017-03-22 20:34:06 +03:00
<li class="pure-menu-item {{ with .EditPage }}pure-menu-selected{{ end }}"><a href="/{{ .Page }}/edit" class="pure-menu-link"><span id="saveEditButton">Edit</span></a></li>
2017-03-23 19:26:40 +03:00
{{end}}
2017-03-22 20:34:06 +03:00
2017-09-29 15:48:32 +03:00
2017-03-22 05:46:24 +03:00
</ul>
</div>
<div id="wrap">
2017-10-15 16:58:43 +03:00
{{ if .EditPage }} <div id="pad"><textarea autofocus placeholder="Use markdown to write your note! New: you can publish your note when you are done ({{ .Page }} -> Publish)." id="userInput">{{ .RawPage }}</textarea></div>{{ end }}
2017-09-11 17:38:20 +03:00
<div id="rendered">
{{ if .DontKnowPage }} <strong><center>{{ .Route }} not understood!</center></strong>{{ end }}
2017-10-13 02:08:38 +03:00
{{ if .ViewPage }}{{ .RenderedPage }}
{{ end }}
2017-03-22 05:46:24 +03:00
{{ if .HistoryPage }}
2017-03-24 16:09:41 +03:00
<h1>History</h1>
2017-03-22 05:46:24 +03:00
<ul>
2017-03-22 17:16:16 +03:00
{{range $i, $e := .Versions}}
2017-03-24 16:09:41 +03:00
<li style="list-style: none;">
<a href="/{{ $.Page }}/view?version={{ $e}}">View</a> <a href="/{{ $.Page }}/list?version={{ $e}}">List</a> <a href="/{{ $.Page }}/raw?version={{ $e}}">Raw</a>
{{index $.VersionsText $i}} ({{if lt (index $.VersionsChangeSums $i) 0}}<span style="color:red">{{else}}<span style="color:green">+{{end}}{{index $.VersionsChangeSums $i}}</span>)</li>
2017-03-22 05:46:24 +03:00
{{end}}
</ul>
{{ end }}
2017-03-22 20:19:39 +03:00
{{ if .ListPage }}
{{ range $ index , $ element := .ListItems }}
{{ $ element }}
{{ end }}
{{ end }}
2017-03-22 05:46:24 +03:00
2017-03-24 16:58:37 +03:00
{{ if .DirectoryPage }}
<table style="width:100%">
<tr>
<th>Document</th>
<th>Current size</th>
<th>Num Edits</th>
<th>Last Edited</th>
</tr>
{{range $i, $e := .FileNames}}
<tr>
<td><a href="/{{ $e }}/view">{{ $e }}</a></td>
<td>{{index $.FileSizes $i}}</td>
<td>{{index $.FileNumChanges $i}}</td>
<td>{{index $.FileLastEdited $i}}</td>
</tr>
{{ end }}
</table>
{{end}}
2017-09-11 17:38:20 +03:00
</div>
2017-03-22 05:46:24 +03:00
</div>
</article>
</body>
</html>