mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
Merge pull request #99 from DanielHeath/master
Fade-out items while waiting for a delete to go through
This commit is contained in:
commit
f998015f0c
2
.gitignore
vendored
2
.gitignore
vendored
@ -24,4 +24,4 @@ _testmain.go
|
||||
*.prof
|
||||
|
||||
data/*
|
||||
cowyo
|
||||
cowyodist
|
||||
|
14
Gopkg.lock
generated
14
Gopkg.lock
generated
@ -25,6 +25,12 @@
|
||||
packages = ["."]
|
||||
revision = "75ee37df8664a47cd5d9eb84d41e1f2b08086893"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/danielheath/gin-teeny-security"
|
||||
packages = ["."]
|
||||
revision = "0bc769386cc5a75bd79ccdcceaf0f977eeb6990e"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/garyburd/redigo"
|
||||
packages = ["internal","redis"]
|
||||
@ -109,6 +115,12 @@
|
||||
revision = "4048872b16cc0fc2c5fd9eacf0ed2c2fedaa0c8c"
|
||||
version = "v1.5"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/schollz/cowyo"
|
||||
packages = ["encrypt"]
|
||||
revision = "684ff4e692da7ce06781b2fecb47b34fc100faf4"
|
||||
version = "v2.8.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/schollz/cryptopasta"
|
||||
@ -238,6 +250,6 @@
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "3b488719d6a087407dfd8d956f305228c41a71472ce5c12d09c3a22cdaacbbcb"
|
||||
inputs-digest = "78100cdb84da20268b3f0840cd94ee575c61b892b6474f3744499256026625af"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
11
Makefile
11
Makefile
@ -6,12 +6,12 @@ LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}" -a -installsuffix cgo
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go-bindata static/... templates/...
|
||||
go-bindata static/... templates/...
|
||||
go build ${LDFLAGS}
|
||||
|
||||
.PHONY: quick
|
||||
quick:
|
||||
go-bindata static/... templates/...
|
||||
go-bindata static/... templates/...
|
||||
go build
|
||||
|
||||
.PHONY: linuxarm
|
||||
@ -27,7 +27,10 @@ linux32:
|
||||
.PHONY: linux64
|
||||
linux64:
|
||||
env GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o dist/cowyo_linux_amd64
|
||||
#cd dist && upx --brute cowyo_linux_amd64
|
||||
ssh camlistore "sudo initctl stop cowyo"
|
||||
scp dist/cowyo_linux_amd64 camlistore:cowyo/cowyo
|
||||
ssh camlistore "chmod +x cowyo/cowyo"
|
||||
ssh camlistore "sudo initctl start cowyo"
|
||||
|
||||
.PHONY: windows
|
||||
windows:
|
||||
@ -41,5 +44,3 @@ osx:
|
||||
|
||||
.PHONY: release
|
||||
release: osx windows linux64 linux32 linuxarm
|
||||
|
||||
|
||||
|
88
bindata.go
88
bindata.go
File diff suppressed because one or more lines are too long
45
handlers.go
45
handlers.go
@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
// "github.com/gin-contrib/static"
|
||||
secretRequired "github.com/danielheath/gin-teeny-security"
|
||||
"github.com/gin-contrib/multitemplate"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -22,11 +23,29 @@ var defaultLock string
|
||||
var debounceTime int
|
||||
var diaryMode bool
|
||||
|
||||
func serve(host, port, crt_path, key_path string, TLS bool, cssFile string, defaultPage string, defaultPassword string, debounce int, diary bool) {
|
||||
func serve(
|
||||
host,
|
||||
port,
|
||||
crt_path,
|
||||
key_path string,
|
||||
TLS bool,
|
||||
cssFile string,
|
||||
defaultPage string,
|
||||
defaultPassword string,
|
||||
debounce int,
|
||||
diary bool,
|
||||
secret string,
|
||||
secretCode string,
|
||||
allowInsecure bool,
|
||||
) {
|
||||
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
router := gin.Default()
|
||||
store := sessions.NewCookieStore([]byte("secret"))
|
||||
store := sessions.NewCookieStore([]byte(secret))
|
||||
router.Use(sessions.Sessions("mysession", store))
|
||||
if secretCode != "" {
|
||||
router.Use(secretRequired.RequiresSecretAccessCode(secretCode, "/login/"))
|
||||
}
|
||||
router.HTMLRender = loadTemplates("index.tmpl")
|
||||
// router.Use(static.Serve("/static/", static.LocalFile("./static", true)))
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
@ -77,6 +96,9 @@ func serve(host, port, crt_path, key_path string, TLS bool, cssFile string, defa
|
||||
// set diary mode
|
||||
diaryMode = diary
|
||||
|
||||
// Allow iframe/scripts in markup?
|
||||
allowInsecureHtml = allowInsecure
|
||||
|
||||
if TLS {
|
||||
http.ListenAndServeTLS(host+":"+port, crt_path, key_path, router)
|
||||
} else {
|
||||
@ -215,9 +237,7 @@ func handlePageRequest(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
p := Open(page)
|
||||
fmt.Println(command)
|
||||
if len(command) < 2 {
|
||||
fmt.Println(p.IsPublished)
|
||||
if p.IsPublished {
|
||||
c.Redirect(302, "/"+page+"/read")
|
||||
} else {
|
||||
@ -237,7 +257,6 @@ func handlePageRequest(c *gin.Context) {
|
||||
// Disallow anything but viewing locked/encrypted pages
|
||||
if (p.IsEncrypted || p.IsLocked) &&
|
||||
(command[0:2] != "/v" && command[0:2] != "/r") {
|
||||
fmt.Println("IS LOCKED")
|
||||
c.Redirect(302, "/"+page+"/view")
|
||||
return
|
||||
}
|
||||
@ -295,18 +314,11 @@ func handlePageRequest(c *gin.Context) {
|
||||
c.Data(200, contentType(p.Name), []byte(rawText))
|
||||
return
|
||||
}
|
||||
log.Debug(command)
|
||||
log.Debug("%v", command[0:2] != "/e" &&
|
||||
command[0:2] != "/v" &&
|
||||
command[0:2] != "/l" &&
|
||||
command[0:2] != "/h" &&
|
||||
command[0:2] != "/r")
|
||||
|
||||
var FileNames, FileLastEdited []string
|
||||
var FileSizes, FileNumChanges []int
|
||||
var DirectoryEntries []DirectoryEntry
|
||||
if page == "ls" {
|
||||
command = "/view"
|
||||
FileNames, FileSizes, FileNumChanges, FileLastEdited = DirectoryList()
|
||||
DirectoryEntries = DirectoryList()
|
||||
}
|
||||
|
||||
// swap out /view for /read if it is published
|
||||
@ -325,10 +337,7 @@ func handlePageRequest(c *gin.Context) {
|
||||
command[0:2] != "/l" &&
|
||||
command[0:2] != "/h",
|
||||
"DirectoryPage": page == "ls",
|
||||
"FileNames": FileNames,
|
||||
"FileSizes": FileSizes,
|
||||
"FileNumChanges": FileNumChanges,
|
||||
"FileLastEdited": FileLastEdited,
|
||||
"DirectoryEntries": DirectoryEntries,
|
||||
"Page": page,
|
||||
"RenderedPage": template.HTML([]byte(rawHTML)),
|
||||
"RawPage": rawText,
|
||||
|
31
main.go
31
main.go
@ -38,7 +38,22 @@ func main() {
|
||||
} else {
|
||||
fmt.Printf("\nRunning cowyo server (version %s) at http://%s:%s\n\n", version, host, c.GlobalString("port"))
|
||||
}
|
||||
serve(c.GlobalString("host"), c.GlobalString("port"), c.GlobalString("cert"), c.GlobalString("key"), TLS, c.GlobalString("css"), c.GlobalString("default-page"), c.GlobalString("lock"), c.GlobalInt("debounce"), c.GlobalBool("diary"))
|
||||
|
||||
serve(
|
||||
c.GlobalString("host"),
|
||||
c.GlobalString("port"),
|
||||
c.GlobalString("cert"),
|
||||
c.GlobalString("key"),
|
||||
TLS,
|
||||
c.GlobalString("css"),
|
||||
c.GlobalString("default-page"),
|
||||
c.GlobalString("lock"),
|
||||
c.GlobalInt("debounce"),
|
||||
c.GlobalBool("diary"),
|
||||
c.GlobalString("cookie-secret"),
|
||||
c.GlobalString("access-code"),
|
||||
c.GlobalBool("allow-insecure-markup"),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
app.Flags = []cli.Flag{
|
||||
@ -82,6 +97,10 @@ func main() {
|
||||
Value: "",
|
||||
Usage: "show default-page/read instead of editing (default: show random editing)",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "allow-insecure-markup",
|
||||
Usage: "Skip HTML sanitization",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "lock",
|
||||
Value: "",
|
||||
@ -100,6 +119,16 @@ func main() {
|
||||
Name: "diary",
|
||||
Usage: "turn diary mode (doing New will give a timestamped page)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "access-code",
|
||||
Value: "",
|
||||
Usage: "Secret code to login with before accessing any wiki stuff",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "cookie-secret",
|
||||
Value: "secret",
|
||||
Usage: "random data to use for cookies; changing it will invalidate all sessions",
|
||||
},
|
||||
}
|
||||
app.Commands = []cli.Command{
|
||||
{
|
||||
|
35
page.go
35
page.go
@ -6,6 +6,7 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -41,20 +42,32 @@ func Open(name string) (p *Page) {
|
||||
return p
|
||||
}
|
||||
|
||||
func DirectoryList() (names []string, lengths []int, numchanges []int, lastEdited []string) {
|
||||
type DirectoryEntry struct {
|
||||
Name string
|
||||
Length int
|
||||
Numchanges int
|
||||
LastEdited time.Time
|
||||
}
|
||||
|
||||
func (d DirectoryEntry) LastEditTime() string {
|
||||
return d.LastEdited.Format("Mon Jan 2 15:04:05 MST 2006")
|
||||
}
|
||||
|
||||
func DirectoryList() []DirectoryEntry {
|
||||
files, _ := ioutil.ReadDir(pathToData)
|
||||
names = make([]string, len(files))
|
||||
lengths = make([]int, len(files))
|
||||
numchanges = make([]int, len(files))
|
||||
lastEdited = make([]string, len(files))
|
||||
entries := make([]DirectoryEntry, len(files))
|
||||
for i, f := range files {
|
||||
names[i] = DecodeFileName(f.Name())
|
||||
p := Open(names[i])
|
||||
lengths[i] = len(p.Text.GetCurrent())
|
||||
numchanges[i] = p.Text.NumEdits()
|
||||
lastEdited[i] = time.Unix(p.Text.LastEditTime()/1000000000, 0).Format("Mon Jan 2 15:04:05 MST 2006")
|
||||
name := DecodeFileName(f.Name())
|
||||
p := Open(name)
|
||||
entries[i] = DirectoryEntry{
|
||||
Name: name,
|
||||
Length: len(p.Text.GetCurrent()),
|
||||
Numchanges: p.Text.NumEdits(),
|
||||
LastEdited: time.Unix(p.Text.LastEditTime()/1000000000, 0),
|
||||
}
|
||||
}
|
||||
return
|
||||
sort.Slice(entries, func(i, j int) bool { return entries[i].LastEdited.After(entries[j].LastEdited) })
|
||||
return entries
|
||||
}
|
||||
|
||||
func DecodeFileName(s string) string {
|
||||
|
17
page_test.go
17
page_test.go
@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// "fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -17,9 +16,19 @@ func TestListFiles(t *testing.T) {
|
||||
p.Update("A different bunch of data")
|
||||
p = Open("testpage3")
|
||||
p.Update("Not much else")
|
||||
n, l, _, _ := DirectoryList()
|
||||
if strings.Join(n, " ") != "testpage testpage2 testpage3" {
|
||||
t.Errorf("Names: %s, Lengths: %d", n, l)
|
||||
n := DirectoryList()
|
||||
if len(n) != 3 {
|
||||
t.Error("Expected three directory entries")
|
||||
t.FailNow()
|
||||
}
|
||||
if n[0].Name != "testpage" {
|
||||
t.Error("Expected testpage to be first")
|
||||
}
|
||||
if n[1].Name != "testpage2" {
|
||||
t.Error("Expected testpage2 to be second")
|
||||
}
|
||||
if n[2].Name != "testpage3" {
|
||||
t.Error("Expected testpage3 to be last")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,9 @@ body {
|
||||
.pure-menu a {
|
||||
color: #777;
|
||||
}
|
||||
.deleting {
|
||||
opacity: 0.5;
|
||||
}
|
||||
#wrap {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
@ -143,7 +146,7 @@ body#pad textarea {
|
||||
|
||||
|
||||
<script type='text/javascript'>
|
||||
oulipo = false;
|
||||
oulipo = false;
|
||||
//<![CDATA[
|
||||
$(window).load(function() {
|
||||
// Returns a function, that, as long as it continues to be invoked, will not
|
||||
@ -247,12 +250,12 @@ body#pad textarea {
|
||||
$('#saveEditButton').addClass("failure");
|
||||
}
|
||||
$('#saveEditButton').text(data.message);
|
||||
if (data.success == true && $('#lockPage').text() == "Lock") {
|
||||
if (data.success == true && $('#lockPage').text() == "Lock") {
|
||||
window.location = "/{{ .Page }}/view";
|
||||
}
|
||||
if (data.success == true && $('#lockPage').text() == "Unlock") {
|
||||
}
|
||||
if (data.success == true && $('#lockPage').text() == "Unlock") {
|
||||
window.location = "/{{ .Page }}/edit";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').removeClass()
|
||||
@ -283,7 +286,7 @@ body#pad textarea {
|
||||
if (data.message == "Unpublished") {
|
||||
$('#publishPage').text("Publish");
|
||||
} else {
|
||||
$('#publishPage').text("Unpublish");
|
||||
$('#publishPage').text("Unpublish");
|
||||
}
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
@ -312,12 +315,12 @@ body#pad textarea {
|
||||
$('#saveEditButton').addClass("failure");
|
||||
}
|
||||
$('#saveEditButton').text(data.message);
|
||||
if (data.success == true && $('#encryptPage').text() == "Encrypt") {
|
||||
if (data.success == true && $('#encryptPage').text() == "Encrypt") {
|
||||
window.location = "/{{ .Page }}/view";
|
||||
}
|
||||
if (data.success == true && $('#encryptPage').text() == "Decrypt") {
|
||||
}
|
||||
if (data.success == true && $('#encryptPage').text() == "Decrypt") {
|
||||
window.location = "/{{ .Page }}/edit";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').removeClass()
|
||||
@ -344,9 +347,9 @@ body#pad textarea {
|
||||
$('#saveEditButton').addClass("failure");
|
||||
}
|
||||
$('#saveEditButton').text(data.message);
|
||||
if (data.success == true) {
|
||||
if (data.success == true) {
|
||||
window.location = "/{{ .Page }}/list";
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').removeClass();
|
||||
@ -396,7 +399,7 @@ body#pad textarea {
|
||||
if (passphrase != null) {
|
||||
if ($('#lockPage').text() == "Lock") {
|
||||
$('#saveEditButton').removeClass();
|
||||
$("#saveEditButton").text("Locking");
|
||||
$("#saveEditButton").text("Locking");
|
||||
} else {
|
||||
$('#saveEditButton').removeClass();
|
||||
$("#saveEditButton").text("Unlocking");
|
||||
@ -417,11 +420,11 @@ body#pad textarea {
|
||||
if (confirmed == true) {
|
||||
if ($('#publishPage').text() == "Unpublish") {
|
||||
$('#saveEditButton').removeClass();
|
||||
$("#saveEditButton").text("Unpublishing");
|
||||
$("#saveEditButton").text("Unpublishing");
|
||||
} else {
|
||||
$('#saveEditButton').removeClass();
|
||||
$("#saveEditButton").text("Publishing");
|
||||
}
|
||||
}
|
||||
publishPage();
|
||||
}
|
||||
});
|
||||
@ -460,17 +463,19 @@ body#pad textarea {
|
||||
|
||||
$('.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);
|
||||
}
|
||||
});
|
||||
var lineNum = $(this).attr('id');
|
||||
|
||||
$.ajax({
|
||||
url: "/listitem" + '?' + $.param({
|
||||
"lineNum": lineNum,
|
||||
"page": "{{ .Page }}"
|
||||
}),
|
||||
type: 'DELETE',
|
||||
success: function() {
|
||||
window.location.reload(true);
|
||||
}
|
||||
});
|
||||
event.target.classList.add('deleting');
|
||||
});
|
||||
|
||||
|
||||
@ -483,7 +488,7 @@ body#pad textarea {
|
||||
<body id="pad">
|
||||
<article class="markdown-body">
|
||||
|
||||
{{ if .ReadPage }}
|
||||
{{ if .ReadPage }}
|
||||
<div id="wrap">
|
||||
<div id="rendered">
|
||||
{{ .RenderedPage }}
|
||||
@ -535,7 +540,7 @@ body#pad textarea {
|
||||
<a href="#" id="menuLink1" class="pure-menu-link">View</a>
|
||||
<ul class="pure-menu-children">
|
||||
<li class="pure-menu-item">
|
||||
<a href="/{{ .Page }}/read" class="pure-menu-link">Current</a>
|
||||
<a href="/{{ .Page }}/read" class="pure-menu-link">Current</a>
|
||||
</li>
|
||||
{{ range .RecentlyEdited}}
|
||||
<li class="pure-menu-item"><a class="pure-menu-link" href="/{{.}}/read">{{.}}</a></li>
|
||||
@ -560,7 +565,7 @@ body#pad textarea {
|
||||
<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>
|
||||
{{end}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
@ -569,7 +574,7 @@ body#pad textarea {
|
||||
|
||||
<div id="wrap">
|
||||
{{ 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 }}
|
||||
<div id="rendered">
|
||||
<div id="rendered">
|
||||
{{ if .DontKnowPage }} <strong><center>{{ .Route }} not understood!</center></strong>{{ end }}
|
||||
{{ if .ViewPage }}{{ .RenderedPage }}
|
||||
{{ end }}
|
||||
@ -593,21 +598,21 @@ body#pad textarea {
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<th>Document</th>
|
||||
<th>Current size</th>
|
||||
<th>Num Edits</th>
|
||||
<th>Last Edited</th>
|
||||
<th>Current size</th>
|
||||
<th>Num Edits</th>
|
||||
<th>Last Edited</th>
|
||||
</tr>
|
||||
{{range $i, $e := .FileNames}}
|
||||
{{range .DirectoryEntries}}
|
||||
<tr>
|
||||
<td><a href="/{{ $e }}/view">{{ $e }}</a></td>
|
||||
<td>{{index $.FileSizes $i}}</td>
|
||||
<td>{{index $.FileNumChanges $i}}</td>
|
||||
<td>{{index $.FileLastEdited $i}}</td>
|
||||
<td><a href="/{{ .Name }}/view">{{ .Name }}</a></td>
|
||||
<td>{{.Length}}</td>
|
||||
<td>{{.Numchanges}}</td>
|
||||
<td>{{.LastEditTime}}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</table>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
|
6
utils.go
6
utils.go
@ -20,6 +20,7 @@ import (
|
||||
var animals []string
|
||||
var adjectives []string
|
||||
var aboutPageText string
|
||||
var allowInsecureHtml bool
|
||||
|
||||
var log *lumber.ConsoleLogger
|
||||
|
||||
@ -174,6 +175,11 @@ func exists(path string) bool {
|
||||
|
||||
func MarkdownToHtml(s string) string {
|
||||
unsafe := blackfriday.MarkdownCommon([]byte(s))
|
||||
|
||||
if allowInsecureHtml {
|
||||
return string(unsafe)
|
||||
}
|
||||
|
||||
pClean := bluemonday.UGCPolicy()
|
||||
pClean.AllowElements("img")
|
||||
pClean.AllowAttrs("alt").OnElements("img")
|
||||
|
15
vendor/github.com/danielheath/gin-teeny-security/.gitignore
generated
vendored
Normal file
15
vendor/github.com/danielheath/gin-teeny-security/.gitignore
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
|
||||
.glide/
|
||||
vendor
|
117
vendor/github.com/danielheath/gin-teeny-security/Gopkg.lock
generated
vendored
Normal file
117
vendor/github.com/danielheath/gin-teeny-security/Gopkg.lock
generated
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/boj/redistore"
|
||||
packages = ["."]
|
||||
revision = "fc113767cd6b051980f260d6dbe84b2740c46ab0"
|
||||
version = "v1.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/bradfitz/gomemcache"
|
||||
packages = ["memcache"]
|
||||
revision = "1952afaa557dc08e8e0d89eafab110fb501c1a2b"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/bradleypeabody/gorilla-sessions-memcache"
|
||||
packages = ["."]
|
||||
revision = "75ee37df8664a47cd5d9eb84d41e1f2b08086893"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/garyburd/redigo"
|
||||
packages = ["internal","redis"]
|
||||
revision = "d1ed5c67e5794de818ea85e6b522fda02623a484"
|
||||
version = "v1.4.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/gin-contrib/sessions"
|
||||
packages = ["."]
|
||||
revision = "cccdeef56346e7037ca92de250c2b55ef5e7ffe3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/gin-contrib/sse"
|
||||
packages = ["."]
|
||||
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gin-gonic/gin"
|
||||
packages = [".","binding","render"]
|
||||
revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
|
||||
version = "v1.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = ["proto"]
|
||||
revision = "1e59b77b52bf8e4b449a57e6f79f21226d571845"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gorilla/context"
|
||||
packages = ["."]
|
||||
revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gorilla/securecookie"
|
||||
packages = ["."]
|
||||
revision = "667fe4e3466a040b780561fe9b51a83a3753eefc"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gorilla/sessions"
|
||||
packages = ["."]
|
||||
revision = "ca9ada44574153444b00d3fd9c8559e4cc95f896"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/kidstuff/mongostore"
|
||||
packages = ["."]
|
||||
revision = "256d65ac5b0e35e7c5ebb3f175c0bed1e5c2b253"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-isatty"
|
||||
packages = ["."]
|
||||
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
||||
version = "v0.0.3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/ugorji/go"
|
||||
packages = ["codec"]
|
||||
revision = "9831f2c3ac1068a78f50999a30db84270f647af6"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
revision = "2c42eef0765b9837fbdab12011af7830f55f88f0"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/go-playground/validator.v8"
|
||||
packages = ["."]
|
||||
revision = "5f1438d3fca68893a817e4a66806cea46a9e4ebf"
|
||||
version = "v8.18.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "v2"
|
||||
name = "gopkg.in/mgo.v2"
|
||||
packages = [".","bson","internal/json","internal/sasl","internal/scram"]
|
||||
revision = "3f83fa5005286a7fe593b055f0d7771a7dce4655"
|
||||
|
||||
[[projects]]
|
||||
branch = "v2"
|
||||
name = "gopkg.in/yaml.v2"
|
||||
packages = ["."]
|
||||
revision = "d670f9405373e636a5a2765eea47fac0c9bc91a4"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "d185a6d39b5e201aa40795d091e9a9aac336d3dd891d7716a511e7f5b6fb6dda"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
4
vendor/github.com/danielheath/gin-teeny-security/Gopkg.toml
generated
vendored
Normal file
4
vendor/github.com/danielheath/gin-teeny-security/Gopkg.toml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/gin-gonic/gin"
|
||||
version = "1.2.0"
|
661
vendor/github.com/danielheath/gin-teeny-security/LICENSE
generated
vendored
Normal file
661
vendor/github.com/danielheath/gin-teeny-security/LICENSE
generated
vendored
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
2
vendor/github.com/danielheath/gin-teeny-security/README.md
generated
vendored
Normal file
2
vendor/github.com/danielheath/gin-teeny-security/README.md
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# gin-teeny-security
|
||||
A tiny middleware to add low-fi protection to personal pages
|
65
vendor/github.com/danielheath/gin-teeny-security/gin-teeny-security.go
generated
vendored
Normal file
65
vendor/github.com/danielheath/gin-teeny-security/gin-teeny-security.go
generated
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
// A GIN middleware providing low-fi security for personal stuff.
|
||||
package gin_teeny_security
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
import "github.com/gin-contrib/sessions"
|
||||
import "net/http"
|
||||
|
||||
// Forces you to a login page until you provide a secret code.
|
||||
// No CSRF protection, so any script on any page can log you
|
||||
// out (or in, if they know the password).
|
||||
// The rest of your site needs XSS protection on forms or any site on the
|
||||
// net can inject stuff. If you're sending open CORS headers this
|
||||
// would be particularly bad.
|
||||
func RequiresSecretAccessCode(secretAccessCode, path string) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
session := sessions.Default(c)
|
||||
if c.Request.URL.Path == path {
|
||||
if c.Request.Method == "POST" {
|
||||
c.Request.ParseForm()
|
||||
|
||||
if c.Request.PostForm.Get("secretAccessCode") == secretAccessCode {
|
||||
c.Header("Location", "/")
|
||||
session.Set("secretAccessCode", secretAccessCode)
|
||||
session.Save()
|
||||
c.AbortWithStatus(http.StatusFound)
|
||||
return
|
||||
} else {
|
||||
session.Set("secretAccessCode", "")
|
||||
session.Save()
|
||||
c.Data(http.StatusForbidden, "text/html", []byte(`
|
||||
<h1>Login</h1>
|
||||
<h2>Wrong password</h2>
|
||||
<form action="`+path+`" method="POST">
|
||||
<input name="secretAccessCode" />
|
||||
<input type="submit" value="Login" />
|
||||
</form>
|
||||
`))
|
||||
c.Abort()
|
||||
return
|
||||
}
|
||||
} else if c.Request.Method == "GET" {
|
||||
c.Data(http.StatusOK, "text/html", []byte(`
|
||||
<h1>Login</h1>
|
||||
<form action="`+path+`" method="POST">
|
||||
<input name="secretAccessCode" />
|
||||
<input type="submit" value="Login" />
|
||||
</form>
|
||||
`))
|
||||
c.Abort()
|
||||
return
|
||||
} else {
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
v := session.Get("secretAccessCode")
|
||||
if v != secretAccessCode {
|
||||
c.Header("Location", path)
|
||||
c.AbortWithStatus(http.StatusTemporaryRedirect)
|
||||
} else {
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
}
|
1
vendor/github.com/schollz/cowyo/.gitattributes
generated
vendored
Normal file
1
vendor/github.com/schollz/cowyo/.gitattributes
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
static/* linguist-vendored
|
27
vendor/github.com/schollz/cowyo/.gitignore
generated
vendored
Normal file
27
vendor/github.com/schollz/cowyo/.gitignore
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
|
||||
data/*
|
||||
cowyo
|
8
vendor/github.com/schollz/cowyo/.travis.yml
generated
vendored
Normal file
8
vendor/github.com/schollz/cowyo/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- tip
|
||||
|
||||
before_install:
|
||||
- go get -u github.com/schollz/cowyo
|
||||
- go get -u github.com/jteeuwen/go-bindata/...
|
25
vendor/github.com/schollz/cowyo/Dockerfile
generated
vendored
Normal file
25
vendor/github.com/schollz/cowyo/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
# First build step
|
||||
FROM golang:1.9-alpine as builder
|
||||
|
||||
WORKDIR /go/src/cowyo
|
||||
COPY . .
|
||||
# Disable crosscompiling
|
||||
ENV CGO_ENABLED=0
|
||||
|
||||
# Install git and make, compile and cleanup
|
||||
RUN apk add --no-cache git make \
|
||||
&& go get -u github.com/schollz/cowyo \
|
||||
&& go get -u github.com/jteeuwen/go-bindata/... \
|
||||
&& make \
|
||||
&& apk del --purge git make \
|
||||
&& rm -rf /var/cache/apk*
|
||||
|
||||
# Second build step uses the minimal scratch Docker image
|
||||
FROM scratch
|
||||
# Copy the binary from the first step
|
||||
COPY --from=builder /go/src/cowyo/cowyo /usr/local/bin/cowyo
|
||||
# Expose data folder
|
||||
VOLUME /data
|
||||
EXPOSE 8050
|
||||
# Start cowyo listening on any host
|
||||
CMD ["cowyo", "--host", "0.0.0.0"]
|
243
vendor/github.com/schollz/cowyo/Gopkg.lock
generated
vendored
Normal file
243
vendor/github.com/schollz/cowyo/Gopkg.lock
generated
vendored
Normal file
@ -0,0 +1,243 @@
|
||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "dmitri.shuralyov.com/kebabcase"
|
||||
packages = ["."]
|
||||
revision = "bf160e40a7918fbe9dc3cc841a023d87242bd2eb"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/boj/redistore"
|
||||
packages = ["."]
|
||||
revision = "fc113767cd6b051980f260d6dbe84b2740c46ab0"
|
||||
version = "v1.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/bradfitz/gomemcache"
|
||||
packages = ["memcache"]
|
||||
revision = "1952afaa557dc08e8e0d89eafab110fb501c1a2b"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/bradleypeabody/gorilla-sessions-memcache"
|
||||
packages = ["."]
|
||||
revision = "75ee37df8664a47cd5d9eb84d41e1f2b08086893"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/garyburd/redigo"
|
||||
packages = ["internal","redis"]
|
||||
revision = "34a326de1fea52965fa5ad664d3fc7163dd4b0a1"
|
||||
version = "v1.2.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/gin-contrib/multitemplate"
|
||||
packages = ["."]
|
||||
revision = "bbc6daf6024bc4c48f334a0490321cd48a24da3d"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/gin-contrib/sessions"
|
||||
packages = ["."]
|
||||
revision = "cccdeef56346e7037ca92de250c2b55ef5e7ffe3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/gin-contrib/sse"
|
||||
packages = ["."]
|
||||
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gin-gonic/gin"
|
||||
packages = [".","binding","render"]
|
||||
revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
|
||||
version = "v1.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/golang/protobuf"
|
||||
packages = ["proto"]
|
||||
revision = "1643683e1b54a9e88ad26d98f81400c8c9d9f4f9"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gorilla/context"
|
||||
packages = ["."]
|
||||
revision = "1ea25387ff6f684839d82767c1733ff4d4d15d0a"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gorilla/securecookie"
|
||||
packages = ["."]
|
||||
revision = "667fe4e3466a040b780561fe9b51a83a3753eefc"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/gorilla/sessions"
|
||||
packages = ["."]
|
||||
revision = "ca9ada44574153444b00d3fd9c8559e4cc95f896"
|
||||
version = "v1.1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/jcelliott/lumber"
|
||||
packages = ["."]
|
||||
revision = "dd349441af25132d146d7095c6693a15431fc9b1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/kidstuff/mongostore"
|
||||
packages = ["."]
|
||||
revision = "256d65ac5b0e35e7c5ebb3f175c0bed1e5c2b253"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/mattn/go-isatty"
|
||||
packages = ["."]
|
||||
revision = "0360b2af4f38e8d38c7fce2a9f4e702702d73a39"
|
||||
version = "v0.0.3"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/microcosm-cc/bluemonday"
|
||||
packages = ["."]
|
||||
revision = "68fecaef60268522d2ac3f0123cec9d3bcab7b6e"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/russross/blackfriday"
|
||||
packages = ["."]
|
||||
revision = "4048872b16cc0fc2c5fd9eacf0ed2c2fedaa0c8c"
|
||||
version = "v1.5"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/schollz/cryptopasta"
|
||||
packages = ["."]
|
||||
revision = "dcd61c7d42a11660da3789311050e961c0a5be55"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/schollz/versionedtext"
|
||||
packages = ["."]
|
||||
revision = "1cef32a305b7272d4df0454533de5e4ba67adfc1"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/sergi/go-diff"
|
||||
packages = ["diffmatchpatch"]
|
||||
revision = "2fc9cd33b5f86077aa3e0f442fa0476a9fa9a1dc"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/github_flavored_markdown"
|
||||
packages = ["."]
|
||||
revision = "cccd3ce4f8e394ae9f87de0bd8b37e00625913d9"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/go"
|
||||
packages = ["parserutil","printerutil","reflectfind","reflectsource"]
|
||||
revision = "c661e953e604ba4a84a3c4e458462a481bd6ce72"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/go-goon"
|
||||
packages = ["."]
|
||||
revision = "37c2f522c041b74919a9e5e3a6c5c47eb34730a5"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/graphql"
|
||||
packages = ["ident"]
|
||||
revision = "cf6db17b893acfad0ca1929ba6be45bf854790ed"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/highlight_diff"
|
||||
packages = ["."]
|
||||
revision = "09bb4053de1b1d872a9f25dc21378fa71dca4e4e"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/highlight_go"
|
||||
packages = ["."]
|
||||
revision = "78fb10f4a5f89e812a5e26ab723b954a51226086"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/octiconssvg"
|
||||
packages = ["."]
|
||||
revision = "8c9861b86a08c72d14e0285d0dc313bb6df52295"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/sanitized_anchor_name"
|
||||
packages = ["."]
|
||||
revision = "86672fcb3f950f35f2e675df2240550f2a50762f"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/sourcegraph/annotate"
|
||||
packages = ["."]
|
||||
revision = "f4cad6c6324d3f584e1743d8b3e0e017a5f3a636"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/sourcegraph/syntaxhighlight"
|
||||
packages = ["."]
|
||||
revision = "bd320f5d308e1a3c4314c678d8227a0d72574ae7"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/ugorji/go"
|
||||
packages = ["codec"]
|
||||
revision = "50189f05eaf5a0c17e5084eb8f7fb91e23699840"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
packages = ["bcrypt","blowfish"]
|
||||
revision = "bd6f299fb381e4c3393d1c4b1f0b94f5e77650c8"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/net"
|
||||
packages = ["html","html/atom"]
|
||||
revision = "01c190206fbdffa42f334f4b2bf2220f50e64920"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/sys"
|
||||
packages = ["unix"]
|
||||
revision = "4fe5d7925040acd225bf9c7cee65e82d07f06bff"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/go-playground/validator.v8"
|
||||
packages = ["."]
|
||||
revision = "5f1438d3fca68893a817e4a66806cea46a9e4ebf"
|
||||
version = "v8.18.2"
|
||||
|
||||
[[projects]]
|
||||
branch = "v2"
|
||||
name = "gopkg.in/mgo.v2"
|
||||
packages = [".","bson","internal/json","internal/sasl","internal/scram"]
|
||||
revision = "3f83fa5005286a7fe593b055f0d7771a7dce4655"
|
||||
|
||||
[[projects]]
|
||||
name = "gopkg.in/urfave/cli.v1"
|
||||
packages = ["."]
|
||||
revision = "cfb38830724cc34fedffe9a2a29fb54fa9169cd1"
|
||||
version = "v1.20.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "v2"
|
||||
name = "gopkg.in/yaml.v2"
|
||||
packages = ["."]
|
||||
revision = "eb3733d160e74a9c7e442f435eb3bea458e1d19f"
|
||||
|
||||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "3b488719d6a087407dfd8d956f305228c41a71472ce5c12d09c3a22cdaacbbcb"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
66
vendor/github.com/schollz/cowyo/Gopkg.toml
generated
vendored
Normal file
66
vendor/github.com/schollz/cowyo/Gopkg.toml
generated
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
# Gopkg.toml example
|
||||
#
|
||||
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
|
||||
# for detailed Gopkg.toml documentation.
|
||||
#
|
||||
# required = ["github.com/user/thing/cmd/thing"]
|
||||
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project"
|
||||
# version = "1.0.0"
|
||||
#
|
||||
# [[constraint]]
|
||||
# name = "github.com/user/project2"
|
||||
# branch = "dev"
|
||||
# source = "github.com/myfork/project2"
|
||||
#
|
||||
# [[override]]
|
||||
# name = "github.com/x/y"
|
||||
# version = "2.4.0"
|
||||
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/gin-contrib/multitemplate"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/gin-contrib/sessions"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/gin-gonic/gin"
|
||||
version = "1.2.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/jcelliott/lumber"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/microcosm-cc/bluemonday"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/russross/blackfriday"
|
||||
version = "1.5"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/schollz/cryptopasta"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/schollz/versionedtext"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/shurcooL/github_flavored_markdown"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "golang.org/x/crypto"
|
||||
|
||||
[[constraint]]
|
||||
name = "gopkg.in/urfave/cli.v1"
|
||||
version = "1.20.0"
|
21
vendor/github.com/schollz/cowyo/LICENSE
generated
vendored
Normal file
21
vendor/github.com/schollz/cowyo/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Zack
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
40
vendor/github.com/schollz/cowyo/Makefile
generated
vendored
Normal file
40
vendor/github.com/schollz/cowyo/Makefile
generated
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
# Make a release with
|
||||
# make -j4 release
|
||||
|
||||
VERSION=$(shell git describe)
|
||||
LDFLAGS=-ldflags "-s -w -X main.version=${VERSION}" -a -installsuffix cgo
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
go-bindata static/... templates/...
|
||||
go build ${LDFLAGS}
|
||||
|
||||
.PHONY: quick
|
||||
quick:
|
||||
go-bindata static/... templates/...
|
||||
go build
|
||||
|
||||
.PHONY: linuxarm
|
||||
linuxarm:
|
||||
env GOOS=linux GOARCH=arm go build ${LDFLAGS} -o dist/cowyo_linux_arm
|
||||
#cd dist && upx --brute cowyo_linux_arm
|
||||
|
||||
.PHONY: linux64
|
||||
linux64:
|
||||
env GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o dist/cowyo_linux_amd64
|
||||
#cd dist && upx --brute cowyo_linux_amd64
|
||||
|
||||
.PHONY: windows
|
||||
windows:
|
||||
env GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o dist/cowyo_windows_amd64.exe
|
||||
#cd dist && upx --brute cowyo_windows_amd64.exe
|
||||
|
||||
.PHONY: osx
|
||||
osx:
|
||||
env GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o dist/cowyo_osx_amd64
|
||||
#cd dist && upx --brute cowyo_osx_amd64
|
||||
|
||||
.PHONY: release
|
||||
release: osx windows linux64 linuxarm
|
||||
|
||||
|
124
vendor/github.com/schollz/cowyo/README.md
generated
vendored
Normal file
124
vendor/github.com/schollz/cowyo/README.md
generated
vendored
Normal file
@ -0,0 +1,124 @@
|
||||
|
||||
<p align="center">
|
||||
<img
|
||||
src="/static/img/logo.png"
|
||||
width="260" height="80" border="0" alt="linkcrawler">
|
||||
<br>
|
||||
<a href="https://travis-ci.org/schollz/cowyo"><img src="https://img.shields.io/travis/schollz/cowyo.svg?style=flat-square" alt="Build Status"></a>
|
||||
<a href="https://github.com/schollz/cowyo/releases/latest"><img src="https://img.shields.io/badge/version-2.8.0-brightgreen.svg?style=flat-square" alt="Version"></a>
|
||||
</p>
|
||||
|
||||
<p align="center">A feature-rich wiki for minimalists</a></p>
|
||||
|
||||
*cowyo* is a self-contained wiki server that makes jotting notes easy and _fast_. The most important feature here is _simplicity_. Other features include versioning, page locking, self-destructing messages, encryption, and listifying. You can [download *cowyo* as a single executable](https://github.com/schollz/cowyo/releases/latest) or install it with Go. Try it out at https://cowyo.com.
|
||||
|
||||
There is now [a command-line tool, *cowyodel*](https://github.com/schollz/cowyodel) to interact with *cowyo* and transfer information between computers with only a code phrase: [schollz/cowyodel](https://github.com/schollz/cowyodel).
|
||||
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
## Install
|
||||
|
||||
If you have go
|
||||
|
||||
```
|
||||
go get -u github.com/schollz/cowyo/...
|
||||
```
|
||||
|
||||
or just [download the latest release](https://github.com/schollz/cowyo/releases/latest).
|
||||
|
||||
## Run
|
||||
|
||||
To run just double click or from the command line:
|
||||
|
||||
```
|
||||
cowyo
|
||||
```
|
||||
|
||||
and it will start a server listening on `0.0.0.0:8050`. To view it, just go to http://localhost:8050 (the server prints out the local IP for your info if you want to do LAN networking). You can change the port with `-port X`, and you can listen *only* on localhost using `-host localhost`.
|
||||
|
||||
### Running with TLS
|
||||
|
||||
Specify a matching pair of SSL Certificate and Key to run cowyo using https. *cowyo* will now run in a secure session.
|
||||
|
||||
*N.B. Let's Encrypt is a CA that signs free and signed certificates.*
|
||||
|
||||
```
|
||||
cowyo --cert "/path/to/server.crt" --key "/p/t/server.key"
|
||||
```
|
||||
|
||||
### Running with Docker
|
||||
|
||||
You can easily get started with Docker. First pull the latest image and create the volume with:
|
||||
|
||||
```
|
||||
docker run -d --name cowyo -p 8050:8050 schollz/cowyo
|
||||
```
|
||||
|
||||
Then you can stop it with `docker stop cowyo` and start it again with `docker start cowyo`.
|
||||
|
||||
### Running as a micro-CMS
|
||||
|
||||
There are a couple of command-line flags that you can use to make your own micro-CMS.
|
||||
|
||||
```
|
||||
cowyo -lock 123 -default-page index.html -css mystyle.css
|
||||
```
|
||||
|
||||
The `-lock` flag will automatically lock every page with the passphrase "123". Also, the default behavior will be to redirect `/` to `/index.html`. Also, every page that is published will automatically redirect to `/mypage/read` which will show the custom CSS file if it is supplied with `-css`.
|
||||
|
||||
## Usage
|
||||
|
||||
*cowyo* is straightforward to use. Here are some of the basic features:
|
||||
|
||||
### Editing
|
||||
|
||||
When you open a document you'll be directed to an alliterative animal (which is supposed to be easy to remember). You can write in Markdown. Saving is performed as soon as you stop writing. You can easily link pages using [[PageName]] as you edit.
|
||||
|
||||
![Editing](http://i.imgur.com/vEs2U8z.gif)
|
||||
|
||||
### History
|
||||
|
||||
You can easily see previous versions of your documents.
|
||||
|
||||
![History](http://i.imgur.com/CxhRkyo.gif)
|
||||
|
||||
### Lists
|
||||
|
||||
You can easily make lists and check them off.
|
||||
|
||||
![Lists](http://i.imgur.com/7xbauy8.gif)
|
||||
|
||||
### Locking
|
||||
|
||||
Locking prevents other users from editing your pages without a passphrase.
|
||||
|
||||
![Locking](http://i.imgur.com/xwUFV8b.gif)
|
||||
|
||||
### Encryption
|
||||
|
||||
Encryption is performed using AES-256.
|
||||
|
||||
![Encryption](http://i.imgur.com/rWoqoLB.gif)
|
||||
|
||||
### Self-destructing pages
|
||||
|
||||
Just like in mission impossible.
|
||||
|
||||
![Self-destructing](http://i.imgur.com/upMxFQh.gif)
|
||||
|
||||
## Development
|
||||
|
||||
You can run the tests using
|
||||
|
||||
```
|
||||
$ cd $GOPATH/src/github.com/schollz/cowyo
|
||||
$ go test ./...
|
||||
```
|
||||
|
||||
Any contributions are welcome.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
1215
vendor/github.com/schollz/cowyo/bindata.go
generated
vendored
Normal file
1215
vendor/github.com/schollz/cowyo/bindata.go
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
vendor/github.com/schollz/cowyo/docker-compose.yml
generated
vendored
Normal file
9
vendor/github.com/schollz/cowyo/docker-compose.yml
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
version: "2"
|
||||
|
||||
services:
|
||||
cowyo:
|
||||
build: .
|
||||
ports:
|
||||
- 8050:8050
|
||||
volumes:
|
||||
- ./data:/data
|
28
vendor/github.com/schollz/cowyo/encrypt/encrypt.go
generated
vendored
Normal file
28
vendor/github.com/schollz/cowyo/encrypt/encrypt.go
generated
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
package encrypt
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
|
||||
"github.com/schollz/cryptopasta"
|
||||
)
|
||||
|
||||
func EncryptString(toEncrypt string, password string) (string, error) {
|
||||
key := sha256.Sum256([]byte(password))
|
||||
encrypted, err := cryptopasta.Encrypt([]byte(toEncrypt), &key)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return hex.EncodeToString(encrypted), nil
|
||||
}
|
||||
|
||||
func DecryptString(toDecrypt string, password string) (string, error) {
|
||||
key := sha256.Sum256([]byte(password))
|
||||
contentData, err := hex.DecodeString(toDecrypt)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
bDecrypted, err := cryptopasta.Decrypt(contentData, &key)
|
||||
return string(bDecrypted), err
|
||||
}
|
22
vendor/github.com/schollz/cowyo/encrypt/encrypt_test.go
generated
vendored
Normal file
22
vendor/github.com/schollz/cowyo/encrypt/encrypt_test.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
package encrypt
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestEncryption(t *testing.T) {
|
||||
s, err := EncryptString("some string", "some password")
|
||||
if err != nil {
|
||||
t.Errorf("What")
|
||||
}
|
||||
d, err := DecryptString(s, "some wrong password")
|
||||
if err == nil {
|
||||
t.Errorf("Should throw error for bad password")
|
||||
}
|
||||
d, err = DecryptString(s, "some password")
|
||||
if err != nil {
|
||||
t.Errorf("Should not throw password")
|
||||
}
|
||||
if d != "some string" {
|
||||
t.Errorf("Problem decoding")
|
||||
}
|
||||
|
||||
}
|
647
vendor/github.com/schollz/cowyo/handlers.go
generated
vendored
Executable file
647
vendor/github.com/schollz/cowyo/handlers.go
generated
vendored
Executable file
@ -0,0 +1,647 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
// "github.com/gin-contrib/static"
|
||||
"github.com/gin-contrib/multitemplate"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/schollz/cowyo/encrypt"
|
||||
)
|
||||
|
||||
var customCSS []byte
|
||||
var defaultLock string
|
||||
var debounceTime int
|
||||
var diaryMode bool
|
||||
|
||||
func serve(host, port, crt_path, key_path string, TLS bool, cssFile string, defaultPage string, defaultPassword string, debounce int, diary bool) {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
router := gin.Default()
|
||||
store := sessions.NewCookieStore([]byte("secret"))
|
||||
router.Use(sessions.Sessions("mysession", store))
|
||||
router.HTMLRender = loadTemplates("index.tmpl")
|
||||
// router.Use(static.Serve("/static/", static.LocalFile("./static", true)))
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
if defaultPage != "" {
|
||||
c.Redirect(302, "/"+defaultPage+"/read")
|
||||
} else {
|
||||
c.Redirect(302, "/"+randomAlliterateCombo())
|
||||
}
|
||||
})
|
||||
router.GET("/:page", func(c *gin.Context) {
|
||||
page := c.Param("page")
|
||||
c.Redirect(302, "/"+page+"/")
|
||||
})
|
||||
router.GET("/:page/*command", handlePageRequest)
|
||||
router.POST("/update", handlePageUpdate)
|
||||
router.POST("/relinquish", handlePageRelinquish) // relinquish returns the page no matter what (and destroys if nessecary)
|
||||
router.POST("/exists", handlePageExists)
|
||||
router.POST("/prime", handlePrime)
|
||||
router.POST("/lock", handleLock)
|
||||
router.POST("/publish", handlePublish)
|
||||
router.POST("/encrypt", handleEncrypt)
|
||||
router.DELETE("/oldlist", handleClearOldListItems)
|
||||
router.DELETE("/listitem", deleteListItem)
|
||||
|
||||
// start long-processes as threads
|
||||
go thread_SiteMap()
|
||||
|
||||
// collect custom CSS
|
||||
if len(cssFile) > 0 {
|
||||
var errRead error
|
||||
customCSS, errRead = ioutil.ReadFile(cssFile)
|
||||
if errRead != nil {
|
||||
fmt.Println(errRead.Error())
|
||||
return
|
||||
}
|
||||
fmt.Printf("Loaded CSS file, %d bytes\n", len(customCSS))
|
||||
}
|
||||
|
||||
// lock all pages automatically
|
||||
if defaultPassword != "" {
|
||||
fmt.Println("running with locked pages")
|
||||
defaultLock = HashPassword(defaultPassword)
|
||||
}
|
||||
|
||||
// set the debounce time
|
||||
debounceTime = debounce
|
||||
|
||||
// set diary mode
|
||||
diaryMode = diary
|
||||
|
||||
if TLS {
|
||||
http.ListenAndServeTLS(host+":"+port, crt_path, key_path, router)
|
||||
} else {
|
||||
router.Run(host + ":" + port)
|
||||
}
|
||||
}
|
||||
|
||||
func loadTemplates(list ...string) multitemplate.Render {
|
||||
r := multitemplate.New()
|
||||
|
||||
for _, x := range list {
|
||||
templateString, err := Asset("templates/" + x)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
tmplMessage, err := template.New(x).Parse(string(templateString))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
r.Add(x, tmplMessage)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func handlePageRelinquish(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
}
|
||||
var json QueryJSON
|
||||
err := c.BindJSON(&json)
|
||||
if err != nil {
|
||||
log.Trace(err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong JSON"})
|
||||
return
|
||||
}
|
||||
if len(json.Page) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Must specify `page`"})
|
||||
return
|
||||
}
|
||||
message := "Relinquished"
|
||||
p := Open(json.Page)
|
||||
name := p.Meta
|
||||
if name == "" {
|
||||
name = json.Page
|
||||
}
|
||||
text := p.Text.GetCurrent()
|
||||
isLocked := p.IsEncrypted
|
||||
isEncrypted := p.IsEncrypted
|
||||
destroyed := p.IsPrimedForSelfDestruct
|
||||
if !p.IsLocked && p.IsPrimedForSelfDestruct {
|
||||
p.Erase()
|
||||
message = "Relinquished and erased"
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": true,
|
||||
"name": name,
|
||||
"message": message,
|
||||
"text": text,
|
||||
"locked": isLocked,
|
||||
"encrypted": isEncrypted,
|
||||
"destroyed": destroyed})
|
||||
}
|
||||
|
||||
func thread_SiteMap() {
|
||||
for {
|
||||
log.Info("Generating sitemap...")
|
||||
ioutil.WriteFile(path.Join(pathToData, "sitemap.xml"), []byte(generateSiteMap()), 0644)
|
||||
log.Info("..finished generating sitemap")
|
||||
time.Sleep(24 * time.Hour)
|
||||
}
|
||||
}
|
||||
|
||||
func generateSiteMap() (sitemap string) {
|
||||
files, _ := ioutil.ReadDir(pathToData)
|
||||
lastEdited := make([]string, len(files))
|
||||
names := make([]string, len(files))
|
||||
i := 0
|
||||
for _, f := range files {
|
||||
names[i] = DecodeFileName(f.Name())
|
||||
p := Open(names[i])
|
||||
if p.IsPublished {
|
||||
lastEdited[i] = time.Unix(p.Text.LastEditTime()/1000000000, 0).Format("2006-01-02")
|
||||
i++
|
||||
}
|
||||
}
|
||||
names = names[:i]
|
||||
lastEdited = lastEdited[:i]
|
||||
sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`
|
||||
for i := range names {
|
||||
sitemap += fmt.Sprintf(`
|
||||
<url>
|
||||
<loc>https://cowyo.com/%s/read</loc>
|
||||
<lastmod>%s</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
`, names[i], lastEdited[i])
|
||||
}
|
||||
sitemap += "</urlset>"
|
||||
return
|
||||
}
|
||||
|
||||
func handlePageRequest(c *gin.Context) {
|
||||
page := c.Param("page")
|
||||
command := c.Param("command")
|
||||
|
||||
if page == "sitemap.xml" {
|
||||
siteMap, err := ioutil.ReadFile(path.Join(pathToData, "sitemap.xml"))
|
||||
if err != nil {
|
||||
c.Data(http.StatusInternalServerError, contentType("sitemap.xml"), []byte(""))
|
||||
} else {
|
||||
c.Data(http.StatusOK, contentType("sitemap.xml"), siteMap)
|
||||
}
|
||||
return
|
||||
} else if page == "favicon.ico" {
|
||||
data, _ := Asset("/static/img/cowyo/favicon.ico")
|
||||
c.Data(http.StatusOK, contentType("/static/img/cowyo/favicon.ico"), data)
|
||||
return
|
||||
} else if page == "static" {
|
||||
filename := page + command
|
||||
var data []byte
|
||||
fmt.Println(filename)
|
||||
if filename == "static/css/custom.css" {
|
||||
data = customCSS
|
||||
} else {
|
||||
var errAssset error
|
||||
data, errAssset = Asset(filename)
|
||||
if errAssset != nil {
|
||||
c.String(http.StatusInternalServerError, "Could not find data")
|
||||
}
|
||||
}
|
||||
c.Data(http.StatusOK, contentType(filename), data)
|
||||
return
|
||||
}
|
||||
p := Open(page)
|
||||
fmt.Println(command)
|
||||
if len(command) < 2 {
|
||||
fmt.Println(p.IsPublished)
|
||||
if p.IsPublished {
|
||||
c.Redirect(302, "/"+page+"/read")
|
||||
} else {
|
||||
c.Redirect(302, "/"+page+"/edit")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
version := c.DefaultQuery("version", "ajksldfjl")
|
||||
|
||||
// use the default lock
|
||||
if defaultLock != "" && p.IsNew() {
|
||||
p.IsLocked = true
|
||||
p.PassphraseToUnlock = defaultLock
|
||||
}
|
||||
|
||||
// Disallow anything but viewing locked/encrypted pages
|
||||
if (p.IsEncrypted || p.IsLocked) &&
|
||||
(command[0:2] != "/v" && command[0:2] != "/r") {
|
||||
fmt.Println("IS LOCKED")
|
||||
c.Redirect(302, "/"+page+"/view")
|
||||
return
|
||||
}
|
||||
|
||||
// Destroy page if it is opened and primed
|
||||
if p.IsPrimedForSelfDestruct && !p.IsLocked && !p.IsEncrypted {
|
||||
p.Update("*This page has self-destructed. You can not return to it.*\n\n" + p.Text.GetCurrent())
|
||||
p.Erase()
|
||||
command = "/view"
|
||||
}
|
||||
if command == "/erase" {
|
||||
if !p.IsLocked && !p.IsEncrypted {
|
||||
p.Erase()
|
||||
c.Redirect(302, "/"+page+"/edit")
|
||||
} else {
|
||||
c.Redirect(302, "/"+page+"/view")
|
||||
}
|
||||
return
|
||||
}
|
||||
rawText := p.Text.GetCurrent()
|
||||
rawHTML := p.RenderedPage
|
||||
|
||||
// Check to see if an old version is requested
|
||||
versionInt, versionErr := strconv.Atoi(version)
|
||||
if versionErr == nil && versionInt > 0 {
|
||||
versionText, err := p.Text.GetPreviousByTimestamp(int64(versionInt))
|
||||
if err == nil {
|
||||
rawText = versionText
|
||||
rawHTML = GithubMarkdownToHTML(rawText)
|
||||
}
|
||||
}
|
||||
|
||||
// Get history
|
||||
var versionsInt64 []int64
|
||||
var versionsChangeSums []int
|
||||
var versionsText []string
|
||||
if command[0:2] == "/h" {
|
||||
versionsInt64, versionsChangeSums = p.Text.GetMajorSnapshotsAndChangeSums(60) // get snapshots 60 seconds apart
|
||||
versionsText = make([]string, len(versionsInt64))
|
||||
for i, v := range versionsInt64 {
|
||||
versionsText[i] = time.Unix(v/1000000000, 0).Format("Mon Jan 2 15:04:05 MST 2006")
|
||||
}
|
||||
versionsText = reverseSliceString(versionsText)
|
||||
versionsInt64 = reverseSliceInt64(versionsInt64)
|
||||
versionsChangeSums = reverseSliceInt(versionsChangeSums)
|
||||
}
|
||||
|
||||
if command[0:3] == "/ra" {
|
||||
c.Writer.Header().Set("Content-Type", contentType(p.Name))
|
||||
c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
c.Writer.Header().Set("Access-Control-Max-Age", "86400")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Max")
|
||||
c.Writer.Header().Set("Access-Control-Allow-Credentials", "true")
|
||||
c.Data(200, contentType(p.Name), []byte(rawText))
|
||||
return
|
||||
}
|
||||
log.Debug(command)
|
||||
log.Debug("%v", command[0:2] != "/e" &&
|
||||
command[0:2] != "/v" &&
|
||||
command[0:2] != "/l" &&
|
||||
command[0:2] != "/h" &&
|
||||
command[0:2] != "/r")
|
||||
|
||||
var FileNames, FileLastEdited []string
|
||||
var FileSizes, FileNumChanges []int
|
||||
if page == "ls" {
|
||||
command = "/view"
|
||||
FileNames, FileSizes, FileNumChanges, FileLastEdited = DirectoryList()
|
||||
}
|
||||
|
||||
// swap out /view for /read if it is published
|
||||
if p.IsPublished {
|
||||
rawHTML = strings.Replace(rawHTML, "/view", "/read", -1)
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||
"EditPage": command[0:2] == "/e", // /edit
|
||||
"ViewPage": command[0:2] == "/v", // /view
|
||||
"ListPage": command[0:2] == "/l", // /list
|
||||
"HistoryPage": command[0:2] == "/h", // /history
|
||||
"ReadPage": command[0:2] == "/r", // /history
|
||||
"DontKnowPage": command[0:2] != "/e" &&
|
||||
command[0:2] != "/v" &&
|
||||
command[0:2] != "/l" &&
|
||||
command[0:2] != "/h",
|
||||
"DirectoryPage": page == "ls",
|
||||
"FileNames": FileNames,
|
||||
"FileSizes": FileSizes,
|
||||
"FileNumChanges": FileNumChanges,
|
||||
"FileLastEdited": FileLastEdited,
|
||||
"Page": page,
|
||||
"RenderedPage": template.HTML([]byte(rawHTML)),
|
||||
"RawPage": rawText,
|
||||
"Versions": versionsInt64,
|
||||
"VersionsText": versionsText,
|
||||
"VersionsChangeSums": versionsChangeSums,
|
||||
"IsLocked": p.IsLocked,
|
||||
"IsEncrypted": p.IsEncrypted,
|
||||
"ListItems": renderList(rawText),
|
||||
"Route": "/" + page + command,
|
||||
"HasDotInName": strings.Contains(page, "."),
|
||||
"RecentlyEdited": getRecentlyEdited(page, c),
|
||||
"IsPublished": p.IsPublished,
|
||||
"CustomCSS": len(customCSS) > 0,
|
||||
"Debounce": debounceTime,
|
||||
"DiaryMode": diaryMode,
|
||||
"Date": time.Now().Format("2006-01-02"),
|
||||
})
|
||||
}
|
||||
|
||||
func getRecentlyEdited(title string, c *gin.Context) []string {
|
||||
session := sessions.Default(c)
|
||||
var recentlyEdited string
|
||||
v := session.Get("recentlyEdited")
|
||||
editedThings := []string{}
|
||||
if v == nil {
|
||||
recentlyEdited = title
|
||||
} else {
|
||||
editedThings = strings.Split(v.(string), "|||")
|
||||
if !stringInSlice(title, editedThings) {
|
||||
recentlyEdited = v.(string) + "|||" + title
|
||||
} else {
|
||||
recentlyEdited = v.(string)
|
||||
}
|
||||
}
|
||||
session.Set("recentlyEdited", recentlyEdited)
|
||||
session.Save()
|
||||
editedThingsWithoutCurrent := make([]string, len(editedThings))
|
||||
i := 0
|
||||
for _, thing := range editedThings {
|
||||
if thing == title {
|
||||
continue
|
||||
}
|
||||
if strings.Contains(thing, "icon-") {
|
||||
continue
|
||||
}
|
||||
editedThingsWithoutCurrent[i] = thing
|
||||
i++
|
||||
}
|
||||
return editedThingsWithoutCurrent[:i]
|
||||
}
|
||||
|
||||
func handlePageExists(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
}
|
||||
var json QueryJSON
|
||||
err := c.BindJSON(&json)
|
||||
if err != nil {
|
||||
log.Trace(err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong JSON", "exists": false})
|
||||
return
|
||||
}
|
||||
p := Open(json.Page)
|
||||
if len(p.Text.GetCurrent()) > 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": json.Page + " found", "exists": true})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": json.Page + " not found", "exists": false})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func handlePageUpdate(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
NewText string `json:"new_text"`
|
||||
IsEncrypted bool `json:"is_encrypted"`
|
||||
IsPrimed bool `json:"is_primed"`
|
||||
Meta string `json:"meta"`
|
||||
}
|
||||
var json QueryJSON
|
||||
err := c.BindJSON(&json)
|
||||
if err != nil {
|
||||
log.Trace(err.Error())
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong JSON"})
|
||||
return
|
||||
}
|
||||
if len(json.NewText) > 100000000 {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Too much"})
|
||||
return
|
||||
}
|
||||
if len(json.Page) == 0 {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Must specify `page`"})
|
||||
return
|
||||
}
|
||||
log.Trace("Update: %v", json)
|
||||
p := Open(json.Page)
|
||||
var message string
|
||||
success := false
|
||||
if p.IsLocked {
|
||||
message = "Locked, must unlock first"
|
||||
} else if p.IsEncrypted {
|
||||
message = "Encrypted, must decrypt first"
|
||||
} else {
|
||||
p.Meta = json.Meta
|
||||
p.Update(json.NewText)
|
||||
if json.IsEncrypted {
|
||||
p.IsEncrypted = true
|
||||
}
|
||||
if json.IsPrimed {
|
||||
p.IsPrimedForSelfDestruct = true
|
||||
}
|
||||
p.Save()
|
||||
message = "Saved"
|
||||
success = true
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": success, "message": message})
|
||||
}
|
||||
|
||||
func handlePrime(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
}
|
||||
var json QueryJSON
|
||||
if c.BindJSON(&json) != nil {
|
||||
c.String(http.StatusBadRequest, "Problem binding keys")
|
||||
return
|
||||
}
|
||||
log.Trace("Update: %v", json)
|
||||
p := Open(json.Page)
|
||||
if p.IsLocked {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Locked"})
|
||||
return
|
||||
} else if p.IsEncrypted {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Encrypted"})
|
||||
return
|
||||
}
|
||||
p.IsPrimedForSelfDestruct = true
|
||||
p.Save()
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": "Primed"})
|
||||
}
|
||||
|
||||
func handleLock(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
Passphrase string `json:"passphrase"`
|
||||
}
|
||||
|
||||
var json QueryJSON
|
||||
if c.BindJSON(&json) != nil {
|
||||
c.String(http.StatusBadRequest, "Problem binding keys")
|
||||
return
|
||||
}
|
||||
p := Open(json.Page)
|
||||
if defaultLock != "" && p.IsNew() {
|
||||
p.IsLocked = true
|
||||
p.PassphraseToUnlock = defaultLock
|
||||
}
|
||||
|
||||
if p.IsEncrypted {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Encrypted"})
|
||||
return
|
||||
}
|
||||
var message string
|
||||
if p.IsLocked {
|
||||
err2 := CheckPasswordHash(json.Passphrase, p.PassphraseToUnlock)
|
||||
if err2 != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Can't unlock"})
|
||||
return
|
||||
}
|
||||
p.IsLocked = false
|
||||
message = "Unlocked"
|
||||
} else {
|
||||
p.IsLocked = true
|
||||
p.PassphraseToUnlock = HashPassword(json.Passphrase)
|
||||
message = "Locked"
|
||||
}
|
||||
fmt.Println(p)
|
||||
p.Save()
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": message})
|
||||
}
|
||||
|
||||
func handlePublish(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
Publish bool `json:"publish"`
|
||||
}
|
||||
|
||||
var json QueryJSON
|
||||
if c.BindJSON(&json) != nil {
|
||||
c.String(http.StatusBadRequest, "Problem binding keys")
|
||||
return
|
||||
}
|
||||
p := Open(json.Page)
|
||||
p.IsPublished = json.Publish
|
||||
p.Save()
|
||||
message := "Published"
|
||||
if !p.IsPublished {
|
||||
message = "Unpublished"
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": message})
|
||||
}
|
||||
|
||||
func handleEncrypt(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
Passphrase string `json:"passphrase"`
|
||||
}
|
||||
|
||||
var json QueryJSON
|
||||
if c.BindJSON(&json) != nil {
|
||||
c.String(http.StatusBadRequest, "Problem binding keys")
|
||||
return
|
||||
}
|
||||
p := Open(json.Page)
|
||||
if p.IsLocked {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Locked"})
|
||||
return
|
||||
}
|
||||
q := Open(json.Page)
|
||||
var message string
|
||||
if p.IsEncrypted {
|
||||
decrypted, err2 := encrypt.DecryptString(p.Text.GetCurrent(), json.Passphrase)
|
||||
if err2 != nil {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Wrong password"})
|
||||
return
|
||||
}
|
||||
q.Erase()
|
||||
q = Open(json.Page)
|
||||
q.Update(decrypted)
|
||||
q.IsEncrypted = false
|
||||
q.IsLocked = p.IsLocked
|
||||
q.IsPrimedForSelfDestruct = p.IsPrimedForSelfDestruct
|
||||
message = "Decrypted"
|
||||
} else {
|
||||
currentText := p.Text.GetCurrent()
|
||||
encrypted, _ := encrypt.EncryptString(currentText, json.Passphrase)
|
||||
q.Erase()
|
||||
q = Open(json.Page)
|
||||
q.Update(encrypted)
|
||||
q.IsEncrypted = true
|
||||
q.IsLocked = p.IsLocked
|
||||
q.IsPrimedForSelfDestruct = p.IsPrimedForSelfDestruct
|
||||
message = "Encrypted"
|
||||
}
|
||||
q.Save()
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": message})
|
||||
}
|
||||
|
||||
func deleteListItem(c *gin.Context) {
|
||||
lineNum, err := strconv.Atoi(c.DefaultQuery("lineNum", "None"))
|
||||
page := c.Query("page") // shortcut for c.Request.URL.Query().Get("lastname")
|
||||
if err == nil {
|
||||
p := Open(page)
|
||||
|
||||
_, listItems := reorderList(p.Text.GetCurrent())
|
||||
newText := p.Text.GetCurrent()
|
||||
for i, lineString := range listItems {
|
||||
// fmt.Println(i, lineString, lineNum)
|
||||
if i+1 == lineNum {
|
||||
// fmt.Println("MATCHED")
|
||||
if strings.Contains(lineString, "~~") == false {
|
||||
// fmt.Println(p.Text, "("+lineString[2:]+"\n"+")", "~~"+lineString[2:]+"~~"+"\n")
|
||||
newText = strings.Replace(newText+"\n", lineString[2:]+"\n", "~~"+strings.TrimSpace(lineString[2:])+"~~"+"\n", 1)
|
||||
} else {
|
||||
newText = strings.Replace(newText+"\n", lineString[2:]+"\n", lineString[4:len(lineString)-2]+"\n", 1)
|
||||
}
|
||||
p.Update(newText)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(200, gin.H{
|
||||
"success": true,
|
||||
"message": "Done.",
|
||||
})
|
||||
} else {
|
||||
c.JSON(200, gin.H{
|
||||
"success": false,
|
||||
"message": err.Error(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func handleClearOldListItems(c *gin.Context) {
|
||||
type QueryJSON struct {
|
||||
Page string `json:"page"`
|
||||
}
|
||||
|
||||
var json QueryJSON
|
||||
if c.BindJSON(&json) != nil {
|
||||
c.String(http.StatusBadRequest, "Problem binding keys")
|
||||
return
|
||||
}
|
||||
p := Open(json.Page)
|
||||
if p.IsEncrypted {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Encrypted"})
|
||||
return
|
||||
}
|
||||
if p.IsLocked {
|
||||
c.JSON(http.StatusOK, gin.H{"success": false, "message": "Locked"})
|
||||
return
|
||||
}
|
||||
lines := strings.Split(p.Text.GetCurrent(), "\n")
|
||||
newLines := make([]string, len(lines))
|
||||
newLinesI := 0
|
||||
for _, line := range lines {
|
||||
if strings.Count(line, "~~") != 2 {
|
||||
newLines[newLinesI] = line
|
||||
newLinesI++
|
||||
}
|
||||
}
|
||||
p.Update(strings.Join(newLines[0:newLinesI], "\n"))
|
||||
p.Save()
|
||||
c.JSON(http.StatusOK, gin.H{"success": true, "message": "Cleared"})
|
||||
}
|
62
vendor/github.com/schollz/cowyo/listify.go
generated
vendored
Normal file
62
vendor/github.com/schollz/cowyo/listify.go
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func reorderList(text string) ([]template.HTML, []string) {
|
||||
listItemsString := ""
|
||||
for _, lineString := range strings.Split(text, "\n") {
|
||||
if len(lineString) > 1 {
|
||||
if string(lineString[0]) != "-" {
|
||||
listItemsString += "- " + lineString + "\n"
|
||||
} else {
|
||||
listItemsString += lineString + "\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get ordering of template.HTML for rendering
|
||||
renderedListString := MarkdownToHtml(listItemsString)
|
||||
listItems := []template.HTML{}
|
||||
endItems := []template.HTML{}
|
||||
for _, lineString := range strings.Split(renderedListString, "\n") {
|
||||
if len(lineString) > 1 {
|
||||
if strings.Contains(lineString, "<del>") || strings.Contains(lineString, "</ul>") {
|
||||
endItems = append(endItems, template.HTML(lineString))
|
||||
} else {
|
||||
listItems = append(listItems, template.HTML(lineString))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// get ordering of strings for deleting
|
||||
listItemsStringArray := []string{}
|
||||
endItemsStringArray := []string{}
|
||||
for _, lineString := range strings.Split(listItemsString, "\n") {
|
||||
if len(lineString) > 1 {
|
||||
if strings.Contains(lineString, "~~") {
|
||||
endItemsStringArray = append(endItemsStringArray, lineString)
|
||||
} else {
|
||||
listItemsStringArray = append(listItemsStringArray, lineString)
|
||||
}
|
||||
}
|
||||
}
|
||||
return append(listItems, endItems...), append(listItemsStringArray, endItemsStringArray...)
|
||||
}
|
||||
|
||||
func renderList(currentRawText string) []template.HTML {
|
||||
listItems, _ := reorderList(currentRawText)
|
||||
for i := range listItems {
|
||||
newHTML := strings.Replace(string(listItems[i]), "</a>", "</a>"+`<span id="`+strconv.Itoa(i)+`" class="deletable">`, -1)
|
||||
newHTML = strings.Replace(newHTML, "<a href=", "</span><a href=", -1)
|
||||
newHTML = strings.Replace(newHTML, "<li>", "<li>"+`<span id="`+strconv.Itoa(i)+`" class="deletable">`, -1)
|
||||
newHTML = strings.Replace(newHTML, "</li>", "</span></li>", -1)
|
||||
newHTML = strings.Replace(newHTML, "<li>"+`<span id="`+strconv.Itoa(i)+`" class="deletable"><del>`, "<li><del>"+`<span id="`+strconv.Itoa(i)+`" class="deletable">`, -1)
|
||||
newHTML = strings.Replace(newHTML, "</del></span></li>", "</span></del></li>", -1)
|
||||
listItems[i] = template.HTML([]byte(newHTML))
|
||||
}
|
||||
return listItems
|
||||
}
|
132
vendor/github.com/schollz/cowyo/main.go
generated
vendored
Executable file
132
vendor/github.com/schollz/cowyo/main.go
generated
vendored
Executable file
@ -0,0 +1,132 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"gopkg.in/urfave/cli.v1"
|
||||
)
|
||||
|
||||
var version string
|
||||
var pathToData string
|
||||
|
||||
func main() {
|
||||
app := cli.NewApp()
|
||||
app.Name = "cowyo"
|
||||
app.Usage = "a simple wiki"
|
||||
app.Version = version
|
||||
app.Compiled = time.Now()
|
||||
app.Action = func(c *cli.Context) error {
|
||||
if !c.GlobalBool("debug") {
|
||||
turnOffDebugger()
|
||||
}
|
||||
pathToData = c.GlobalString("data")
|
||||
os.MkdirAll(pathToData, 0755)
|
||||
host := c.GlobalString("host")
|
||||
crt_f := c.GlobalString("cert") // crt flag
|
||||
key_f := c.GlobalString("key") // key flag
|
||||
if host == "" {
|
||||
host = GetLocalIP()
|
||||
}
|
||||
TLS := false
|
||||
if crt_f != "" && key_f != "" {
|
||||
TLS = true
|
||||
}
|
||||
if TLS {
|
||||
fmt.Printf("\nRunning cowyo server (version %s) at https://%s:%s\n\n", version, host, c.GlobalString("port"))
|
||||
} else {
|
||||
fmt.Printf("\nRunning cowyo server (version %s) at http://%s:%s\n\n", version, host, c.GlobalString("port"))
|
||||
}
|
||||
serve(c.GlobalString("host"), c.GlobalString("port"), c.GlobalString("cert"), c.GlobalString("key"), TLS, c.GlobalString("css"), c.GlobalString("default-page"), c.GlobalString("lock"), c.GlobalInt("debounce"), c.GlobalBool("diary"))
|
||||
return nil
|
||||
}
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "data",
|
||||
Value: "data",
|
||||
Usage: "data folder to use",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "olddata",
|
||||
Value: "",
|
||||
Usage: "data folder for migrating",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "host",
|
||||
Value: "",
|
||||
Usage: "host to use",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "port,p",
|
||||
Value: "8050",
|
||||
Usage: "port to use",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "cert",
|
||||
Value: "",
|
||||
Usage: "absolute path to SSL public sertificate",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "key",
|
||||
Value: "",
|
||||
Usage: "absolute path to SSL private key",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "css",
|
||||
Value: "",
|
||||
Usage: "use a custom CSS file",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "default-page",
|
||||
Value: "",
|
||||
Usage: "show default-page/read instead of editing (default: show random editing)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "lock",
|
||||
Value: "",
|
||||
Usage: "password to lock editing all files (default: all pages unlocked)",
|
||||
},
|
||||
cli.IntFlag{
|
||||
Name: "debounce",
|
||||
Value: 500,
|
||||
Usage: "debounce time for saving data, in milliseconds",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "debug, d",
|
||||
Usage: "turn on debugging",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "diary",
|
||||
Usage: "turn diary mode (doing New will give a timestamped page)",
|
||||
},
|
||||
}
|
||||
app.Commands = []cli.Command{
|
||||
{
|
||||
Name: "migrate",
|
||||
Aliases: []string{"m"},
|
||||
Usage: "migrate from the old cowyo",
|
||||
Action: func(c *cli.Context) error {
|
||||
if !c.GlobalBool("debug") {
|
||||
turnOffDebugger()
|
||||
}
|
||||
pathToData = c.GlobalString("data")
|
||||
pathToOldData := c.GlobalString("olddata")
|
||||
if len(pathToOldData) == 0 {
|
||||
fmt.Printf("You need to specify folder with -olddata")
|
||||
return nil
|
||||
}
|
||||
os.MkdirAll(pathToData, 0755)
|
||||
if !exists(pathToOldData) {
|
||||
fmt.Printf("Can not find '%s', does it exist?", pathToOldData)
|
||||
return nil
|
||||
}
|
||||
migrate(pathToOldData, pathToData)
|
||||
return nil
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
app.Run(os.Args)
|
||||
|
||||
}
|
33
vendor/github.com/schollz/cowyo/migrate.go
generated
vendored
Executable file
33
vendor/github.com/schollz/cowyo/migrate.go
generated
vendored
Executable file
@ -0,0 +1,33 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
)
|
||||
|
||||
func migrate(pathToOldData, pathToData string) error {
|
||||
files, err := ioutil.ReadDir(pathToOldData)
|
||||
if len(files) == 0 {
|
||||
return err
|
||||
}
|
||||
for _, f := range files {
|
||||
if f.Mode().IsDir() {
|
||||
continue
|
||||
}
|
||||
fmt.Printf("Migrating %s", f.Name())
|
||||
p := Open(f.Name())
|
||||
bData, err := ioutil.ReadFile(path.Join(pathToOldData, f.Name()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = p.Update(string(bData))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = p.Save(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
116
vendor/github.com/schollz/cowyo/page.go
generated
vendored
Executable file
116
vendor/github.com/schollz/cowyo/page.go
generated
vendored
Executable file
@ -0,0 +1,116 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/schollz/versionedtext"
|
||||
)
|
||||
|
||||
// Page is the basic struct
|
||||
type Page struct {
|
||||
Name string
|
||||
Text versionedtext.VersionedText
|
||||
Meta string
|
||||
RenderedPage string
|
||||
IsLocked bool
|
||||
PassphraseToUnlock string
|
||||
IsEncrypted bool
|
||||
IsPrimedForSelfDestruct bool
|
||||
IsPublished bool
|
||||
}
|
||||
|
||||
func Open(name string) (p *Page) {
|
||||
p = new(Page)
|
||||
p.Name = name
|
||||
p.Text = versionedtext.NewVersionedText("")
|
||||
p.Render()
|
||||
bJSON, err := ioutil.ReadFile(path.Join(pathToData, encodeToBase32(strings.ToLower(name))+".json"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = json.Unmarshal(bJSON, &p)
|
||||
if err != nil {
|
||||
p = new(Page)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func DirectoryList() (names []string, lengths []int, numchanges []int, lastEdited []string) {
|
||||
files, _ := ioutil.ReadDir(pathToData)
|
||||
names = make([]string, len(files))
|
||||
lengths = make([]int, len(files))
|
||||
numchanges = make([]int, len(files))
|
||||
lastEdited = make([]string, len(files))
|
||||
for i, f := range files {
|
||||
names[i] = DecodeFileName(f.Name())
|
||||
p := Open(names[i])
|
||||
lengths[i] = len(p.Text.GetCurrent())
|
||||
numchanges[i] = p.Text.NumEdits()
|
||||
lastEdited[i] = time.Unix(p.Text.LastEditTime()/1000000000, 0).Format("Mon Jan 2 15:04:05 MST 2006")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func DecodeFileName(s string) string {
|
||||
s2, _ := decodeFromBase32(strings.Split(s, ".")[0])
|
||||
return s2
|
||||
}
|
||||
|
||||
// Update cleans the text and updates the versioned text
|
||||
// and generates a new render
|
||||
func (p *Page) Update(newText string) error {
|
||||
// Trim space from end
|
||||
newText = strings.TrimRight(newText, "\n\t ")
|
||||
|
||||
// Update the versioned text
|
||||
p.Text.Update(newText)
|
||||
|
||||
// Render the new page
|
||||
p.Render()
|
||||
|
||||
return p.Save()
|
||||
}
|
||||
|
||||
var rBracketPage = regexp.MustCompile(`\[\[(.*?)\]\]`)
|
||||
|
||||
func (p *Page) Render() {
|
||||
if p.IsEncrypted {
|
||||
p.RenderedPage = "<code>" + p.Text.GetCurrent() + "</code>"
|
||||
return
|
||||
}
|
||||
|
||||
// Convert [[page]] to [page](/page/view)
|
||||
currentText := p.Text.GetCurrent()
|
||||
for _, s := range rBracketPage.FindAllString(currentText, -1) {
|
||||
currentText = strings.Replace(currentText, s, "["+s[2:len(s)-2]+"](/"+s[2:len(s)-2]+"/view)", 1)
|
||||
}
|
||||
p.Text.Update(currentText)
|
||||
p.RenderedPage = MarkdownToHtml(p.Text.GetCurrent())
|
||||
}
|
||||
|
||||
func (p *Page) Save() error {
|
||||
bJSON, err := json.MarshalIndent(p, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(path.Join(pathToData, encodeToBase32(strings.ToLower(p.Name))+".json"), bJSON, 0644)
|
||||
}
|
||||
|
||||
func (p *Page) IsNew() bool {
|
||||
return !exists(path.Join(pathToData, encodeToBase32(strings.ToLower(p.Name))+".json"))
|
||||
}
|
||||
|
||||
func (p *Page) Erase() error {
|
||||
log.Trace("Erasing " + p.Name)
|
||||
return os.Remove(path.Join(pathToData, encodeToBase32(strings.ToLower(p.Name))+".json"))
|
||||
}
|
||||
|
||||
func (p *Page) Published() bool {
|
||||
return p.IsPublished
|
||||
}
|
49
vendor/github.com/schollz/cowyo/page_test.go
generated
vendored
Executable file
49
vendor/github.com/schollz/cowyo/page_test.go
generated
vendored
Executable file
@ -0,0 +1,49 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
// "fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestListFiles(t *testing.T) {
|
||||
pathToData = "testdata"
|
||||
os.MkdirAll(pathToData, 0755)
|
||||
defer os.RemoveAll(pathToData)
|
||||
p := Open("testpage")
|
||||
p.Update("Some data")
|
||||
p = Open("testpage2")
|
||||
p.Update("A different bunch of data")
|
||||
p = Open("testpage3")
|
||||
p.Update("Not much else")
|
||||
n, l, _, _ := DirectoryList()
|
||||
if strings.Join(n, " ") != "testpage testpage2 testpage3" {
|
||||
t.Errorf("Names: %s, Lengths: %d", n, l)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGeneral(t *testing.T) {
|
||||
pathToData = "testdata"
|
||||
os.MkdirAll(pathToData, 0755)
|
||||
defer os.RemoveAll(pathToData)
|
||||
p := Open("testpage")
|
||||
err := p.Update("**bold**")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if strings.TrimSpace(p.RenderedPage) != "<p><strong>bold</strong></p>" {
|
||||
t.Errorf("Did not render: '%s'", p.RenderedPage)
|
||||
}
|
||||
err = p.Update("**bold** and *italic*")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
p.Save()
|
||||
|
||||
p2 := Open("testpage")
|
||||
if strings.TrimSpace(p2.RenderedPage) != "<p><strong>bold</strong> and <em>italic</em></p>" {
|
||||
t.Errorf("Did not render: '%s'", p2.RenderedPage)
|
||||
}
|
||||
|
||||
}
|
11
vendor/github.com/schollz/cowyo/static/css/base-min.css
generated
vendored
Normal file
11
vendor/github.com/schollz/cowyo/static/css/base-min.css
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/*!
|
||||
Pure v0.6.2
|
||||
Copyright 2013 Yahoo!
|
||||
Licensed under the BSD License.
|
||||
https://github.com/yahoo/pure/blob/master/LICENSE.md
|
||||
*/
|
||||
/*!
|
||||
normalize.css v^3.0 | MIT License | git.io/normalize
|
||||
Copyright (c) Nicolas Gallagher and Jonathan Neal
|
||||
*/
|
||||
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */img,legend{border:0}legend,td,th{padding:0}html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,optgroup,strong{font-weight:700}dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-.5em}sub{bottom:-.25em}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{box-sizing:content-box;height:0}pre,textarea{overflow:auto}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{height:auto}input[type=search]{-webkit-appearance:textfield;box-sizing:content-box}input[type=search]::-webkit-search-cancel-button,input[type=search]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}table{border-collapse:collapse;border-spacing:0}.hidden,[hidden]{display:none!important}.pure-img{max-width:100%;height:auto;display:block}
|
1
vendor/github.com/schollz/cowyo/static/css/github-markdown.css
generated
vendored
Normal file
1
vendor/github.com/schollz/cowyo/static/css/github-markdown.css
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
vendor/github.com/schollz/cowyo/static/css/highlight.css
generated
vendored
Normal file
1
vendor/github.com/schollz/cowyo/static/css/highlight.css
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
.hljs{display:block;overflow-x:auto;padding:0.5em;background:#F0F0F0}.hljs,.hljs-subst{color:#444}.hljs-comment{color:#888888}.hljs-keyword,.hljs-attribute,.hljs-selector-tag,.hljs-meta-keyword,.hljs-doctag,.hljs-name{font-weight:bold}.hljs-type,.hljs-string,.hljs-number,.hljs-selector-id,.hljs-selector-class,.hljs-quote,.hljs-template-tag,.hljs-deletion{color:#880000}.hljs-title,.hljs-section{color:#880000;font-weight:bold}.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr,.hljs-selector-pseudo{color:#BC6060}.hljs-literal{color:#78A960}.hljs-built_in,.hljs-bullet,.hljs-code,.hljs-addition{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta-string{color:#4d99bf}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:bold}
|
7
vendor/github.com/schollz/cowyo/static/css/menus-min.css
generated
vendored
Normal file
7
vendor/github.com/schollz/cowyo/static/css/menus-min.css
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
/*!
|
||||
Pure v0.6.2
|
||||
Copyright 2013 Yahoo!
|
||||
Licensed under the BSD License.
|
||||
https://github.com/yahoo/pure/blob/master/LICENSE.md
|
||||
*/
|
||||
.pure-menu{box-sizing:border-box}.pure-menu-fixed{position:fixed;left:0;top:0;z-index:3}.pure-menu-item,.pure-menu-list{position:relative}.pure-menu-list{list-style:none;margin:0;padding:0}.pure-menu-item{padding:0;margin:0;height:100%}.pure-menu-heading,.pure-menu-link{display:block;text-decoration:none;white-space:nowrap}.pure-menu-horizontal{width:100%;white-space:nowrap}.pure-menu-horizontal .pure-menu-list{display:inline-block}.pure-menu-horizontal .pure-menu-heading,.pure-menu-horizontal .pure-menu-item,.pure-menu-horizontal .pure-menu-separator{display:inline-block;zoom:1;vertical-align:middle}.pure-menu-item .pure-menu-item{display:block}.pure-menu-children{display:none;position:absolute;left:100%;top:0;margin:0;padding:0;z-index:3}.pure-menu-horizontal .pure-menu-children{left:0;top:auto;width:inherit}.pure-menu-active>.pure-menu-children,.pure-menu-allow-hover:hover>.pure-menu-children{display:block;position:absolute}.pure-menu-has-children>.pure-menu-link:after{padding-left:.5em;content:"\25B8";font-size:small}.pure-menu-horizontal .pure-menu-has-children>.pure-menu-link:after{content:"\25BE"}.pure-menu-scrollable{overflow-y:scroll;overflow-x:hidden}.pure-menu-scrollable .pure-menu-list{display:block}.pure-menu-horizontal.pure-menu-scrollable .pure-menu-list{display:inline-block}.pure-menu-horizontal.pure-menu-scrollable{white-space:nowrap;overflow-y:hidden;overflow-x:auto;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;padding:.5em 0}.pure-menu-horizontal.pure-menu-scrollable::-webkit-scrollbar{display:none}.pure-menu-horizontal .pure-menu-children .pure-menu-separator,.pure-menu-separator{background-color:#ccc;height:1px;margin:.3em 0}.pure-menu-horizontal .pure-menu-separator{width:1px;height:1.3em;margin:0 .3em}.pure-menu-horizontal .pure-menu-children .pure-menu-separator{display:block;width:auto}.pure-menu-heading{text-transform:uppercase;color:#565d64}.pure-menu-link{color:#777}.pure-menu-children{background-color:#fff}.pure-menu-disabled,.pure-menu-heading,.pure-menu-link{padding:.5em 1em}.pure-menu-disabled{opacity:.5}.pure-menu-disabled .pure-menu-link:hover{background-color:transparent}.pure-menu-active>.pure-menu-link,.pure-menu-link:focus,.pure-menu-link:hover{background-color:#eee}.pure-menu-selected .pure-menu-link,.pure-menu-selected .pure-menu-link:visited{color:#000}
|
BIN
vendor/github.com/schollz/cowyo/static/img/logo.png
generated
vendored
Executable file
BIN
vendor/github.com/schollz/cowyo/static/img/logo.png
generated
vendored
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
3
vendor/github.com/schollz/cowyo/static/js/highlight.min.js
generated
vendored
Normal file
3
vendor/github.com/schollz/cowyo/static/js/highlight.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
2
vendor/github.com/schollz/cowyo/static/js/highlight.pack.js
generated
vendored
Executable file
2
vendor/github.com/schollz/cowyo/static/js/highlight.pack.js
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
9472
vendor/github.com/schollz/cowyo/static/js/jquery-1.8.3.js
generated
vendored
Normal file
9472
vendor/github.com/schollz/cowyo/static/js/jquery-1.8.3.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16027
vendor/github.com/schollz/cowyo/static/text/adjectives
generated
vendored
Normal file
16027
vendor/github.com/schollz/cowyo/static/text/adjectives
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
vendor/github.com/schollz/cowyo/static/text/adjectives.old
generated
vendored
Normal file
1
vendor/github.com/schollz/cowyo/static/text/adjectives.old
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
lulling, vile, foul, cheerful, messy, dreadful, uneven, stinky, young, sparkling, sweltering, verdant, hideous, friendly, blistering, rambunctious, carefree, fat, sloppy, gloomy, awful, anemic, minute, stiff, benevolent, ceaseless, large, quick, round, glassy, rusty, scarce, odd, shining, even, dowdy, solemn, scorching, brief, rotten, new, plush, cozy, meandering, apologetic, nimble, busy, strong, great, brilliant, piercing, creepy, miniature, narrow, whimsical, fantastic, cowardly, disgusting, marvelous, snug, stern, stingy, angry, spiky, cheeky, gorgeous, mysterious, flat, clever, charming, dismal, meek, somber, sour, thin, beautiful, stubborn, crazy, challenging, gaunt, salty, indifferent, huge, daring, awkward, picturesque, copious, glowing, truthful, rude, petite, cranky, ornery, brazen, modest, purring, filthy, rotund, short, splendid, hasty, deafening, crawling, furious, tall, mute, ghastly, still, arrogant, crabby, haughty, curly, voiceless, hot, courageous, late, microscopic, vast, stifling, good, disrespectful, bashful, moaning, towering, adventurous, idyllic, careless, shocking, erratic, heavy, square, hard, jagged, gullible, hushed, revolting, content, thrifty, sluggish, eternal, greedy, pleasant, small, demanding, greasy, enormous, hostile, terrible, chilly, speedy, massive, loud, puny, striking, clumsy, soaring, brave, fast, delicious, effortless, bland, thick, little, ancient, silent, wonderful, stuffed, grimy, bitter, muggy, shallow, ridiculous, absent-minded, fuzzy, peculiar, mangy, wide, kind, squeaky, screeching, silly, squealing, spoiled, gigantic, happy, steep, ingenious, modern, juicy, gentle, medium, brawny, curved, lumpy, afraid, amusing, thundering, cooing, oppressive, swollen, grave, sturdy, average, proud, rancid, absurd, entertaining, annoyed, fussy, precise, subtle, gilded, slow, delinquent, nervous, hopeful, rich, adequate, shrill, plump, freezing, nasty, endless, lavish, worried, courteous, bulky, fair, diminutive, groggy, miserable, horrid, crooked, monstrous, superb, contrary, lazy, fidgety, menacing, swift, stale, quarrelsome, quiet, askew, tough, simple, sweet, hardworking, frosty, whispering, famished, crispy, caring, capable, tiny, immense, startled, lovely, high-pitched, tasteless, decrepit, tense, lousy, straight, excited, ugly, stunning, parched, wild, ripe, lonely, optimistic, obnoxious, cavernous, different, harsh, creaky, grand, difficult, temporary, eccentric, muffled, alert, delicate, timid, infamous, enchanting, anxious, humble, edgy, severe, repulsive, desolate, sleepy, slimy, irritable, vigilant, generous, rapid, old-fashioned, hilly, easy, righteous, joyful, surprised, starving, big, early, compassionate, moody, perpetual, dishonest, serious, foolish, soft, old, scared, mighty, trendy, curious, hissing, savage, dense, steaming, broad, slick, creative, icy, adorable, slight, terrified, intense, noisy, cautious, sizzling, blithe, fluttering, faint, delighted, smelly, lively, frightened, gauzy, long, strict, bored, calm, melodic, spicy, relaxed, triangular, dull, wise, dangerous, smooth, cruel, creeping, dawdling, intimidating, exhausted, deep, tasty, obtuse, graceful, tranquil, raspy, selfish, sullen, malicious, ecstatic, wrinkly, opulent, polite, fetid, husky, prudent, skinny, tricky, impatient, loyal, fresh
|
1
vendor/github.com/schollz/cowyo/static/text/animals
generated
vendored
Normal file
1
vendor/github.com/schollz/cowyo/static/text/animals
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4902
vendor/github.com/schollz/cowyo/static/text/animals.all
generated
vendored
Normal file
4902
vendor/github.com/schollz/cowyo/static/text/animals.all
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
25
vendor/github.com/schollz/cowyo/static/text/howmany.py
generated
vendored
Executable file
25
vendor/github.com/schollz/cowyo/static/text/howmany.py
generated
vendored
Executable file
@ -0,0 +1,25 @@
|
||||
adjectives = {}
|
||||
with open('adjectives','r') as f:
|
||||
for line in f:
|
||||
word = line.strip().lower()
|
||||
if word[0] not in adjectives:
|
||||
adjectives[word[0]] = []
|
||||
adjectives[word[0]].append(word)
|
||||
|
||||
print(len(adjectives.keys()))
|
||||
|
||||
animals = {}
|
||||
for aword in open('animals','r').read().split(','):
|
||||
word = aword.strip().lower()
|
||||
if word[0] not in animals:
|
||||
animals[word[0]] = []
|
||||
animals[word[0]].append(word)
|
||||
|
||||
print(len(animals))
|
||||
|
||||
i = 0
|
||||
for key in adjectives.keys():
|
||||
if key in animals and key in adjectives:
|
||||
i = i + len(adjectives[key])*len(animals[key])
|
||||
|
||||
print(i)
|
4
vendor/github.com/schollz/cowyo/static/text/robots.txt
generated
vendored
Normal file
4
vendor/github.com/schollz/cowyo/static/text/robots.txt
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
Allow: /Help/view
|
||||
Allow: /sitemap.xml
|
9
vendor/github.com/schollz/cowyo/static/text/sitemap.xml
generated
vendored
Executable file
9
vendor/github.com/schollz/cowyo/static/text/sitemap.xml
generated
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url>
|
||||
<loc>https://awwkoala.com/Help/view</loc>
|
||||
<lastmod>2016-03-18</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
</urlset>
|
621
vendor/github.com/schollz/cowyo/templates/index.tmpl
generated
vendored
Executable file
621
vendor/github.com/schollz/cowyo/templates/index.tmpl
generated
vendored
Executable file
@ -0,0 +1,621 @@
|
||||
<!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">
|
||||
<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">
|
||||
|
||||
{{ if and .CustomCSS .ReadPage }}
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/custom.css">
|
||||
{{ else }}
|
||||
<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">
|
||||
<link rel="stylesheet" href="/static/css/highlight.css">
|
||||
<script src="/static/js/highlight.min.js"></script>
|
||||
<script type="text/javascript" src="/static/js/highlight.pack.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
{{ if .ListPage }}
|
||||
/* Required for lists */
|
||||
span { cursor: pointer; }
|
||||
{{ end }}
|
||||
body {
|
||||
background: #fff;
|
||||
}
|
||||
.success {
|
||||
color: #5cb85c;
|
||||
font-weight: bold;
|
||||
}
|
||||
.failure {
|
||||
color: #d9534f;
|
||||
font-weight: bold;
|
||||
}
|
||||
.pure-menu a {
|
||||
color: #777;
|
||||
}
|
||||
#wrap {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
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;
|
||||
top: 0;
|
||||
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 {
|
||||
padding-left:1.2em;
|
||||
padding-right:em;
|
||||
}
|
||||
}
|
||||
@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%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{{ end }}
|
||||
<title>{{ .Page }}</title>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<script type='text/javascript'>
|
||||
oulipo = false;
|
||||
//<![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() {
|
||||
$('#saveEditButton').removeClass()
|
||||
$('#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');
|
||||
if (oulipo == true) { $('#userInput').val($('#userInput').val().replace(/e/g,"")); }
|
||||
$('#saveEditButton').removeClass()
|
||||
$('#saveEditButton').text("Saving")
|
||||
upload();
|
||||
}, {{ .Debounce }}));
|
||||
|
||||
function upload() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/update',
|
||||
data: JSON.stringify({
|
||||
new_text: $('#userInput').val(),
|
||||
page: "{{ .Page }}"
|
||||
}),
|
||||
success: function(data) {
|
||||
$('#saveEditButton').removeClass()
|
||||
if (data.success == true) {
|
||||
$('#saveEditButton').addClass("success");
|
||||
} else {
|
||||
$('#saveEditButton').addClass("failure");
|
||||
}
|
||||
$('#saveEditButton').text(data.message);
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').removeClass()
|
||||
$('#saveEditButton').addClass("failure");
|
||||
$('#saveEditButton').text(error);
|
||||
},
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
|
||||
function primeForSelfDestruct() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prime',
|
||||
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);
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').removeClass()
|
||||
$('#saveEditButton').addClass("failure");
|
||||
$('#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) {
|
||||
$('#saveEditButton').removeClass()
|
||||
if (data.success == true) {
|
||||
$('#saveEditButton').addClass("success");
|
||||
} else {
|
||||
$('#saveEditButton').addClass("failure");
|
||||
}
|
||||
$('#saveEditButton').text(data.message);
|
||||
if (data.success == true && $('#lockPage').text() == "Lock") {
|
||||
window.location = "/{{ .Page }}/view";
|
||||
}
|
||||
if (data.success == true && $('#lockPage').text() == "Unlock") {
|
||||
window.location = "/{{ .Page }}/edit";
|
||||
}
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').removeClass()
|
||||
$('#saveEditButton').addClass("failure");
|
||||
$('#saveEditButton').text(error);
|
||||
},
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
|
||||
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'
|
||||
});
|
||||
}
|
||||
|
||||
function encryptPage(passphrase) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/encrypt',
|
||||
data: JSON.stringify({
|
||||
page: "{{ .Page }}",
|
||||
passphrase: passphrase
|
||||
}),
|
||||
success: function(data) {
|
||||
$('#saveEditButton').removeClass()
|
||||
if (data.success == true) {
|
||||
$('#saveEditButton').addClass("success");
|
||||
} else {
|
||||
$('#saveEditButton').addClass("failure");
|
||||
}
|
||||
$('#saveEditButton').text(data.message);
|
||||
if (data.success == true && $('#encryptPage').text() == "Encrypt") {
|
||||
window.location = "/{{ .Page }}/view";
|
||||
}
|
||||
if (data.success == true && $('#encryptPage').text() == "Decrypt") {
|
||||
window.location = "/{{ .Page }}/edit";
|
||||
}
|
||||
},
|
||||
error: function(xhr, error) {
|
||||
$('#saveEditButton').removeClass()
|
||||
$('#saveEditButton').addClass("failure");
|
||||
$('#saveEditButton').text(error);
|
||||
},
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
$('#saveEditButton').removeClass();
|
||||
$('#saveEditButton').addClass("failure");
|
||||
$('#saveEditButton').text(error);
|
||||
},
|
||||
contentType: "application/json",
|
||||
dataType: 'json'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$("#encryptPage").click(function(e) {
|
||||
e.preventDefault();
|
||||
var passphrase = prompt("Please enter a passphrase. Note: Encrypting will remove all previous history.", "");
|
||||
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) {
|
||||
if ($('#lockPage').text() == "Lock") {
|
||||
$('#saveEditButton').removeClass();
|
||||
$("#saveEditButton").text("Locking");
|
||||
} else {
|
||||
$('#saveEditButton').removeClass();
|
||||
$("#saveEditButton").text("Unlocking");
|
||||
}
|
||||
lockPage(passphrase);
|
||||
// POST encrypt page
|
||||
// reload page
|
||||
}
|
||||
});
|
||||
|
||||
$("#publishPage").click(function(e) {
|
||||
e.preventDefault();
|
||||
var message = " This will add your page to the sitemap.xml so it will be indexed by search engines.";
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
$("#clearOld").click(function(e) {
|
||||
e.preventDefault();
|
||||
var r = confirm("This will erase all cleared list items, are you sure you want to do that? (Versions will stay in history).");
|
||||
if (r == true) {
|
||||
clearOld()
|
||||
} else {
|
||||
x = "You pressed Cancel!";
|
||||
}
|
||||
});
|
||||
|
||||
$("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();
|
||||
}
|
||||
});
|
||||
|
||||
$('.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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}); //]]>
|
||||
|
||||
</script>
|
||||
<script>hljs.initHighlightingOnLoad();</script>
|
||||
|
||||
</head>
|
||||
<body id="pad">
|
||||
<article class="markdown-body">
|
||||
|
||||
{{ if .ReadPage }}
|
||||
<div id="wrap">
|
||||
<div id="rendered">
|
||||
{{ .RenderedPage }}
|
||||
</div>
|
||||
</div>
|
||||
{{ else }}
|
||||
|
||||
|
||||
<div class="pure-menu pure-menu-horizontal" id="menu">
|
||||
<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">
|
||||
<a href="#" id="menuLink1" class="pure-menu-link">{{ .Page }}</a>
|
||||
<ul class="pure-menu-children">
|
||||
{{ if .DiaryMode }}
|
||||
<li class="pure-menu-item"><a href="/{{ .Date }}/edit" class="pure-menu-link">New</a></li>
|
||||
{{ else }}
|
||||
<li class="pure-menu-item"><a href="/" class="pure-menu-link">New</a></li>
|
||||
{{ end }}
|
||||
<li class="pure-menu-item"><a href="https://github.com/schollz/cowyo" class="pure-menu-link">Source</a></li>
|
||||
{{ if .EditPage }}
|
||||
<li class="pure-menu-item"><a href="#" class="pure-menu-link" id="publishPage">
|
||||
{{- if .IsPublished -}}
|
||||
Unpublish
|
||||
{{- else -}}
|
||||
Publish
|
||||
{{- end -}}
|
||||
</a></li>
|
||||
{{ end }}
|
||||
<hr>
|
||||
{{ if (or (.IsLocked) (.IsEncrypted) )}}
|
||||
{{ else }}
|
||||
<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>
|
||||
<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>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</li>
|
||||
<!--
|
||||
<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 }}/read" class="pure-menu-link">Current</a>
|
||||
</li>
|
||||
{{ range .RecentlyEdited}}
|
||||
<li class="pure-menu-item"><a class="pure-menu-link" href="/{{.}}/read">{{.}}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
{{ if (or (.IsLocked) (.IsEncrypted) )}}
|
||||
{{ if .IsLocked }}
|
||||
<li class="pure-menu-item"><a href="#" class="pure-menu-link" id="lockPage">{{ if .IsLocked }}Unlock{{ else }}Lock{{end}}</a></li>
|
||||
<li class="pure-menu-item" class="pure-menu-link"><a href="#"><span id="saveEditButton"></span></a></li>
|
||||
{{ else }}
|
||||
<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" class="pure-menu-link"><a href="#"><span id="saveEditButton"></span></a></li>
|
||||
{{ end }}
|
||||
{{else}}
|
||||
{{ if .ListPage }}
|
||||
<li class="pure-menu-item {{ with .ListPage }}pure-menu-selected{{ end }}"><a href="#" class="pure-menu-link" id="clearOld">Clear done</a></li>
|
||||
{{ else }}
|
||||
<li class="pure-menu-item {{ with .ListPage }}pure-menu-selected{{ end }}"><a href="/{{ .Page }}/list" class="pure-menu-link">List</a></li>
|
||||
{{ end }}
|
||||
<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>
|
||||
{{end}}
|
||||
|
||||
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="wrap">
|
||||
{{ 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 }}
|
||||
<div id="rendered">
|
||||
{{ if .DontKnowPage }} <strong><center>{{ .Route }} not understood!</center></strong>{{ end }}
|
||||
{{ if .ViewPage }}{{ .RenderedPage }}
|
||||
{{ end }}
|
||||
{{ if .HistoryPage }}
|
||||
<h1>History</h1>
|
||||
<ul>
|
||||
{{range $i, $e := .Versions}}
|
||||
<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>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{ end }}
|
||||
{{ if .ListPage }}
|
||||
{{ range $index, $element := .ListItems }}
|
||||
{{ $element }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ 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}}
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
</article>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
221
vendor/github.com/schollz/cowyo/utils.go
generated
vendored
Normal file
221
vendor/github.com/schollz/cowyo/utils.go
generated
vendored
Normal file
@ -0,0 +1,221 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/base32"
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"math/rand"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/jcelliott/lumber"
|
||||
"github.com/microcosm-cc/bluemonday"
|
||||
"github.com/russross/blackfriday"
|
||||
"github.com/shurcooL/github_flavored_markdown"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
var animals []string
|
||||
var adjectives []string
|
||||
var aboutPageText string
|
||||
|
||||
var log *lumber.ConsoleLogger
|
||||
|
||||
func init() {
|
||||
rand.Seed(time.Now().Unix())
|
||||
animalsText, _ := Asset("static/text/animals")
|
||||
animals = strings.Split(string(animalsText), ",")
|
||||
adjectivesText, _ := Asset("static/text/adjectives")
|
||||
adjectives = strings.Split(string(adjectivesText), "\n")
|
||||
log = lumber.NewConsoleLogger(lumber.TRACE)
|
||||
}
|
||||
|
||||
func turnOffDebugger() {
|
||||
log = lumber.NewConsoleLogger(lumber.WARN)
|
||||
}
|
||||
|
||||
func randomAnimal() string {
|
||||
return strings.Replace(strings.Title(animals[rand.Intn(len(animals)-1)]), " ", "", -1)
|
||||
}
|
||||
|
||||
func randomAdjective() string {
|
||||
return strings.Replace(strings.Title(adjectives[rand.Intn(len(adjectives)-1)]), " ", "", -1)
|
||||
}
|
||||
|
||||
func randomAlliterateCombo() (combo string) {
|
||||
combo = ""
|
||||
// generate random alliteration thats not been used
|
||||
for {
|
||||
animal := randomAnimal()
|
||||
adjective := randomAdjective()
|
||||
if animal[0] == adjective[0] && len(animal)+len(adjective) < 18 { //&& stringInSlice(strings.ToLower(adjective+animal), takenNames) == false {
|
||||
combo = adjective + animal
|
||||
break
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// is there a string in a slice?
|
||||
func stringInSlice(s string, strings []string) bool {
|
||||
for _, k := range strings {
|
||||
if s == k {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// itob returns an 8-byte big endian representation of v.
|
||||
func itob(v int) []byte {
|
||||
b := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(b, uint64(v))
|
||||
return b
|
||||
}
|
||||
|
||||
func contentType(filename string) string {
|
||||
switch {
|
||||
case strings.Contains(filename, ".css"):
|
||||
return "text/css"
|
||||
case strings.Contains(filename, ".jpg"):
|
||||
return "image/jpeg"
|
||||
case strings.Contains(filename, ".png"):
|
||||
return "image/png"
|
||||
case strings.Contains(filename, ".js"):
|
||||
return "application/javascript"
|
||||
case strings.Contains(filename, ".xml"):
|
||||
return "application/xml"
|
||||
}
|
||||
return "text/html"
|
||||
}
|
||||
|
||||
func timeTrack(start time.Time, name string) {
|
||||
elapsed := time.Since(start)
|
||||
log.Debug("%s took %s", name, elapsed)
|
||||
}
|
||||
|
||||
var src = rand.NewSource(time.Now().UnixNano())
|
||||
|
||||
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
const (
|
||||
letterIdxBits = 6 // 6 bits to represent a letter index
|
||||
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
|
||||
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
|
||||
)
|
||||
|
||||
// RandStringBytesMaskImprSrc prints a random string
|
||||
func RandStringBytesMaskImprSrc(n int) string {
|
||||
b := make([]byte, n)
|
||||
// A src.Int63() generates 63 random bits, enough for letterIdxMax characters!
|
||||
for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
|
||||
if remain == 0 {
|
||||
cache, remain = src.Int63(), letterIdxMax
|
||||
}
|
||||
if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
|
||||
b[i] = letterBytes[idx]
|
||||
i--
|
||||
}
|
||||
cache >>= letterIdxBits
|
||||
remain--
|
||||
}
|
||||
|
||||
return string(b)
|
||||
}
|
||||
|
||||
// GetLocalIP returns the local ip address
|
||||
func GetLocalIP() string {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
bestIP := ""
|
||||
for _, address := range addrs {
|
||||
// check the address type and if it is not a loopback the display it
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
return ipnet.IP.String()
|
||||
}
|
||||
}
|
||||
}
|
||||
return bestIP
|
||||
}
|
||||
|
||||
// HashPassword generates a bcrypt hash of the password using work factor 14.
|
||||
// https://github.com/gtank/cryptopasta/blob/master/hash.go
|
||||
func HashPassword(password string) string {
|
||||
hash, _ := bcrypt.GenerateFromPassword([]byte(password), 14)
|
||||
return hex.EncodeToString(hash)
|
||||
}
|
||||
|
||||
// CheckPassword securely compares a bcrypt hashed password with its possible
|
||||
// plaintext equivalent. Returns nil on success, or an error on failure.
|
||||
// https://github.com/gtank/cryptopasta/blob/master/hash.go
|
||||
func CheckPasswordHash(password, hashedString string) error {
|
||||
hash, err := hex.DecodeString(hashedString)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return bcrypt.CompareHashAndPassword(hash, []byte(password))
|
||||
}
|
||||
|
||||
// exists returns whether the given file or directory exists or not
|
||||
func exists(path string) bool {
|
||||
_, err := os.Stat(path)
|
||||
if err == nil {
|
||||
return true
|
||||
}
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func MarkdownToHtml(s string) string {
|
||||
unsafe := blackfriday.MarkdownCommon([]byte(s))
|
||||
pClean := bluemonday.UGCPolicy()
|
||||
pClean.AllowElements("img")
|
||||
pClean.AllowAttrs("alt").OnElements("img")
|
||||
pClean.AllowAttrs("src").OnElements("img")
|
||||
pClean.AllowAttrs("class").OnElements("a")
|
||||
pClean.AllowAttrs("href").OnElements("a")
|
||||
pClean.AllowAttrs("id").OnElements("a")
|
||||
pClean.AllowDataURIImages()
|
||||
html := pClean.SanitizeBytes(unsafe)
|
||||
return string(html)
|
||||
}
|
||||
|
||||
func GithubMarkdownToHTML(s string) string {
|
||||
return string(github_flavored_markdown.Markdown([]byte(s)))
|
||||
}
|
||||
func encodeToBase32(s string) string {
|
||||
return base32.StdEncoding.EncodeToString([]byte(s))
|
||||
}
|
||||
|
||||
func decodeFromBase32(s string) (s2 string, err error) {
|
||||
bString, err := base32.StdEncoding.DecodeString(s)
|
||||
s2 = string(bString)
|
||||
return
|
||||
}
|
||||
|
||||
func reverseSliceInt64(s []int64) []int64 {
|
||||
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func reverseSliceString(s []string) []string {
|
||||
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
func reverseSliceInt(s []int) []int {
|
||||
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
return s
|
||||
}
|
34
vendor/github.com/schollz/cowyo/utils_test.go
generated
vendored
Executable file
34
vendor/github.com/schollz/cowyo/utils_test.go
generated
vendored
Executable file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkAlliterativeAnimal(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
randomAlliterateCombo()
|
||||
}
|
||||
}
|
||||
|
||||
func TestReverseList(t *testing.T) {
|
||||
s := []int64{1, 10, 2, 20}
|
||||
if reverseSliceInt64(s)[0] != 20 {
|
||||
t.Errorf("Could not reverse: %v", s)
|
||||
}
|
||||
s2 := []string{"a", "b", "d", "c"}
|
||||
if reverseSliceString(s2)[0] != "c" {
|
||||
t.Errorf("Could not reverse: %v", s2)
|
||||
}
|
||||
}
|
||||
func TestHashing(t *testing.T) {
|
||||
p := HashPassword("1234")
|
||||
log.Debug(p)
|
||||
err := CheckPasswordHash("1234", p)
|
||||
if err != nil {
|
||||
t.Errorf("Should be correct password")
|
||||
}
|
||||
err = CheckPasswordHash("1234lkjklj", p)
|
||||
if err == nil {
|
||||
t.Errorf("Should NOT be correct password")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user