From a88458b6c86d9b3e3f867730d39faa2abff2b646 Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 10 Feb 2016 21:22:21 -0500 Subject: [PATCH] Added Admin to readme Former-commit-id: 32c29fa2c9ae356c906a56c42599216a098fd917 [formerly 1094cb4faa2aa742dbef3477531d82e42a35ac27] [formerly 983165937d8bb743af4ae98293728a48bc6017c6 [formerly 1216c77c1a68a1a206d656a49c0848bfde738e7b [formerly 8bfcc08381788ec64c29e47590122ae18d19ade4]]] Former-commit-id: f2b61169a064af5a501ca408a82c67b27424fe17 [formerly 26597ad59097a8e6dc8be59ab4dbd7cb8b1e37c7] Former-commit-id: 56c18ea099014e16a0b4736e27fbcd6c152e2eb0 Former-commit-id: a273cc0f6c6d1ce4172a1baa88c8cf7952a41af3 --- README.md | 6 +++--- main.go | 2 ++ utils.go | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6ede8ca..63430d2 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ This is a self-contained wiki webserver that makes sharing easy and _fast_. You can make any page you want, and any page is editable by anyone. Pages load instantly for editing, and have special rendering for whether you want to view as a web page or view as list. # Features -## Just type. -To jot a note, simply load the page at [`/`](http://AwwKoala.com/) and just start typing. No need to press edit, the browser will already be focused on the text. No need to press save - it will automatically save when you stop writing. The URL at [`/`](http://AwwKoala.com/) will redirect to an easy-to-remember name that you can use to reload the page at anytime, anywhere. But, you can also use any URL you want, e.g. [`/AnythingYouWant`](http://AwwKoala.com/AnythingYouWant). +## Simplicity +The philosophy here is to *just type*. To jot a note, simply load the page at [`/`](http://AwwKoala.com/) and just start typing. No need to press edit, the browser will already be focused on the text. No need to press save - it will automatically save when you stop writing. The URL at [`/`](http://AwwKoala.com/) will redirect to an easy-to-remember name that you can use to reload the page at anytime, anywhere. But, you can also use any URL you want, e.g. [`/AnythingYouWant`](http://AwwKoala.com/AnythingYouWant). ## Views All pages can be rendered into HTML by adding `/view`. For example, the page [`/AnythingYouWant`](http://AwwKoala.com/AnythingYouWant) is rendered at [`/AnythingYouWant/view`](http://AwwKoala.com/AnythingYouWant/view). You can write in HTML or [Markdown](https://daringfireball.net/projects/markdown/) for page rendering. To quickly link to `/view` pages, just use `[[AnythingYouWnat]]`. Math is supported with [Katex](https://github.com/Khan/KaTeX) using `$\frac{1}{2}$` for inline equations and `$$\frac{1}{2}$$` for regular equations. @@ -23,7 +23,7 @@ All previous versions of all notes are stored and can be accessed by adding `?ve Quickly transition between Edit/View/List by using `Ctl+Shift+E` to Edit, `Ctl+Shift+Z` to View, and `Ctl+Shift+L` to Listify. -## Admin +## Admin controls The Admin can view/delete all the documents by setting the `-a YourAdminKey` when starting the program. Then the admin has access to the `/ls/YourAdminKey` to view and delete any of the pages. diff --git a/main.go b/main.go index c9556ee..34ffc93 100644 --- a/main.go +++ b/main.go @@ -68,6 +68,8 @@ Options:`) p := WikiData{"about", "", []string{}, []string{}} p.save(string(aboutFile)) + fmt.Println(RandStringBytesMaskImprSrc(10)) + // var q WikiData // q.load("about") // fmt.Println(getImportantVersions(q)) diff --git a/utils.go b/utils.go index 9d4b56a..f12fa3c 100644 --- a/utils.go +++ b/utils.go @@ -150,3 +150,30 @@ func rebuildTextsToDiffN(p WikiData, n int) string { } return "ERROR" } + +var src = rand.NewSource(time.Now().UnixNano()) + +const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +const ( + letterIdxBits = 6 // 6 bits to represent a letter index + letterIdxMask = 1<= 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) +}