summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--go.mod1
-rw-r--r--go.sum2
-rw-r--r--template/code.qtpl.go207
-rw-r--r--template/index.qtpl.go110
-rw-r--r--template/layout.qtpl.go104
5 files changed, 424 insertions, 0 deletions
diff --git a/go.mod b/go.mod
index 1cd1ad7..debb5aa 100644
--- a/go.mod
+++ b/go.mod
@@ -6,6 +6,7 @@ require (
github.com/fasthttp/router v0.5.2
github.com/go-redis/redis/v7 v7.0.0-beta.4
github.com/golang/protobuf v1.3.1 // indirect
+ github.com/klauspost/compress v1.9.2 // indirect
github.com/twmb/murmur3 v1.0.0
github.com/valyala/fasthttp v1.6.0
github.com/valyala/quicktemplate v1.4.1
diff --git a/go.sum b/go.sum
index 0fc0fac..a955a71 100644
--- a/go.sum
+++ b/go.sum
@@ -14,6 +14,8 @@ github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2KCcs=
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
+github.com/klauspost/compress v1.9.2 h1:LfVyl+ZlLlLDeQ/d2AqfGIIH4qEDu0Ed2S5GyhCWIWY=
+github.com/klauspost/compress v1.9.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
diff --git a/template/code.qtpl.go b/template/code.qtpl.go
new file mode 100644
index 0000000..2fa1401
--- /dev/null
+++ b/template/code.qtpl.go
@@ -0,0 +1,207 @@
+// Code generated by qtc from "code.qtpl". DO NOT EDIT.
+// See https://github.com/valyala/quicktemplate for details.
+
+// The code layout.
+
+//line template/code.qtpl:2
+package template
+
+//line template/code.qtpl:2
+import (
+ qtio422016 "io"
+
+ qt422016 "github.com/valyala/quicktemplate"
+)
+
+//line template/code.qtpl:2
+var (
+ _ = qtio422016.Copy
+ _ = qt422016.AcquireByteBuffer
+)
+
+//line template/code.qtpl:2
+func StreamCode(qw422016 *qt422016.Writer, lang, data string) {
+//line template/code.qtpl:2
+ qw422016.N().S(`
+ `)
+//line template/code.qtpl:3
+ streamlayout(qw422016, " ", code_scripts(lang), "", code_contents(lang, data), code_bodyscripts(lang))
+//line template/code.qtpl:3
+ qw422016.N().S(`
+`)
+//line template/code.qtpl:4
+}
+
+//line template/code.qtpl:4
+func WriteCode(qq422016 qtio422016.Writer, lang, data string) {
+//line template/code.qtpl:4
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line template/code.qtpl:4
+ StreamCode(qw422016, lang, data)
+//line template/code.qtpl:4
+ qt422016.ReleaseWriter(qw422016)
+//line template/code.qtpl:4
+}
+
+//line template/code.qtpl:4
+func Code(lang, data string) string {
+//line template/code.qtpl:4
+ qb422016 := qt422016.AcquireByteBuffer()
+//line template/code.qtpl:4
+ WriteCode(qb422016, lang, data)
+//line template/code.qtpl:4
+ qs422016 := string(qb422016.B)
+//line template/code.qtpl:4
+ qt422016.ReleaseByteBuffer(qb422016)
+//line template/code.qtpl:4
+ return qs422016
+//line template/code.qtpl:4
+}
+
+//line template/code.qtpl:7
+const prefix = "https://unpkg.com/prismjs"
+
+// The code scripts.
+
+//line template/code.qtpl:11
+func streamcode_scripts(qw422016 *qt422016.Writer, lang string) {
+//line template/code.qtpl:11
+ qw422016.N().S(`
+ <link rel='stylesheet' crossorigin='anonymous' href='`)
+//line template/code.qtpl:12
+ qw422016.E().S(prefix)
+//line template/code.qtpl:12
+ qw422016.N().S(`/themes/prism.css' />
+`)
+//line template/code.qtpl:13
+}
+
+//line template/code.qtpl:13
+func writecode_scripts(qq422016 qtio422016.Writer, lang string) {
+//line template/code.qtpl:13
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line template/code.qtpl:13
+ streamcode_scripts(qw422016, lang)
+//line template/code.qtpl:13
+ qt422016.ReleaseWriter(qw422016)
+//line template/code.qtpl:13
+}
+
+//line template/code.qtpl:13
+func code_scripts(lang string) string {
+//line template/code.qtpl:13
+ qb422016 := qt422016.AcquireByteBuffer()
+//line template/code.qtpl:13
+ writecode_scripts(qb422016, lang)
+//line template/code.qtpl:13
+ qs422016 := string(qb422016.B)
+//line template/code.qtpl:13
+ qt422016.ReleaseByteBuffer(qb422016)
+//line template/code.qtpl:13
+ return qs422016
+//line template/code.qtpl:13
+}
+
+// The code bodyscripts.
+
+//line template/code.qtpl:16
+func streamcode_bodyscripts(qw422016 *qt422016.Writer, lang string) {
+//line template/code.qtpl:16
+ qw422016.N().S(`
+ `)
+//line template/code.qtpl:17
+ qw422016.N().S(`<script src='`)
+//line template/code.qtpl:18
+ qw422016.E().S(prefix)
+//line template/code.qtpl:18
+ qw422016.N().S(`/prism.js'></script>`)
+//line template/code.qtpl:19
+ if lang != "" && lang != "none" {
+//line template/code.qtpl:19
+ qw422016.N().S(`<script src='`)
+//line template/code.qtpl:20
+ qw422016.E().S(prefix)
+//line template/code.qtpl:20
+ qw422016.N().S(`/components/prism-`)
+//line template/code.qtpl:20
+ qw422016.E().S(lang)
+//line template/code.qtpl:20
+ qw422016.N().S(`.js'></script>`)
+//line template/code.qtpl:21
+ }
+//line template/code.qtpl:22
+ qw422016.N().S(`
+`)
+//line template/code.qtpl:23
+}
+
+//line template/code.qtpl:23
+func writecode_bodyscripts(qq422016 qtio422016.Writer, lang string) {
+//line template/code.qtpl:23
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line template/code.qtpl:23
+ streamcode_bodyscripts(qw422016, lang)
+//line template/code.qtpl:23
+ qt422016.ReleaseWriter(qw422016)
+//line template/code.qtpl:23
+}
+
+//line template/code.qtpl:23
+func code_bodyscripts(lang string) string {
+//line template/code.qtpl:23
+ qb422016 := qt422016.AcquireByteBuffer()
+//line template/code.qtpl:23
+ writecode_bodyscripts(qb422016, lang)
+//line template/code.qtpl:23
+ qs422016 := string(qb422016.B)
+//line template/code.qtpl:23
+ qt422016.ReleaseByteBuffer(qb422016)
+//line template/code.qtpl:23
+ return qs422016
+//line template/code.qtpl:23
+}
+
+// The code contents.
+
+//line template/code.qtpl:26
+func streamcode_contents(qw422016 *qt422016.Writer, lang, data string) {
+//line template/code.qtpl:26
+ qw422016.N().S(`
+ <pre><code class='language-`)
+//line template/code.qtpl:27
+ qw422016.E().S(lang)
+//line template/code.qtpl:27
+ qw422016.N().S(`'>`)
+//line template/code.qtpl:27
+ qw422016.E().S(data)
+//line template/code.qtpl:27
+ qw422016.N().S(`</code></pre>
+`)
+//line template/code.qtpl:28
+}
+
+//line template/code.qtpl:28
+func writecode_contents(qq422016 qtio422016.Writer, lang, data string) {
+//line template/code.qtpl:28
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line template/code.qtpl:28
+ streamcode_contents(qw422016, lang, data)
+//line template/code.qtpl:28
+ qt422016.ReleaseWriter(qw422016)
+//line template/code.qtpl:28
+}
+
+//line template/code.qtpl:28
+func code_contents(lang, data string) string {
+//line template/code.qtpl:28
+ qb422016 := qt422016.AcquireByteBuffer()
+//line template/code.qtpl:28
+ writecode_contents(qb422016, lang, data)
+//line template/code.qtpl:28
+ qs422016 := string(qb422016.B)
+//line template/code.qtpl:28
+ qt422016.ReleaseByteBuffer(qb422016)
+//line template/code.qtpl:28
+ return qs422016
+//line template/code.qtpl:28
+}
diff --git a/template/index.qtpl.go b/template/index.qtpl.go
new file mode 100644
index 0000000..ad7b1df
--- /dev/null
+++ b/template/index.qtpl.go
@@ -0,0 +1,110 @@
+// Code generated by qtc from "index.qtpl". DO NOT EDIT.
+// See https://github.com/valyala/quicktemplate for details.
+
+// Index's contents.
+
+//line template/index.qtpl:2
+package template
+
+//line template/index.qtpl:2
+import (
+ qtio422016 "io"
+
+ qt422016 "github.com/valyala/quicktemplate"
+)
+
+//line template/index.qtpl:2
+var (
+ _ = qtio422016.Copy
+ _ = qt422016.AcquireByteBuffer
+)
+
+//line template/index.qtpl:2
+func streamindex_contents(qw422016 *qt422016.Writer) {
+//line template/index.qtpl:2
+ qw422016.N().S(`
+ `)
+//line template/index.qtpl:3
+ qw422016.N().S(`<h1>Burning Rubber Paste</h1><h2>Usage</h2><table border=1><thead><tr><th>Method - Endpoint</th><th>Effect</th></tr></thead><tbody><tr><td><pre><code>POST / data=foo</code></pre></td><td>Pastebin foo</td></tr><tr><td><pre><code>PUT /id data=foo</code></pre></td><td>Write foo into /id. Collisions disallowed. If a POST id coincides with your PUT content, it will be overwritten.</td></tr><tr><td><pre><code>GET /id</code></pre></td><td>Read paste with ID "id"</td></tr><tr><td><pre><code>GET /id/raw</code></pre></td><td>Get the raw contents of paste with ID "id"</td></tr><tr><td><pre><code>GET /id/lang</code></pre></td><td>Read paste with ID "id", and highlight it as "lang"</td></tr></tbody></table><h2>Examples</h2>`)
+//line template/index.qtpl:38
+ qw422016.N().S(`
+ <pre><code class='language-sh'>http -f https://brpaste.example.com data=@file.txt
+http -f https://brpaste.example.com data=abcd
+http -f PUT https://brpaste.example.com/myPaste data=contents
+http https://brpaste.example.com/some_id/raw
+xdg-open https://brpaste.example.com/some_id/cpp</code></pre>
+ `)
+//line template/index.qtpl:44
+ qw422016.N().S(`<h2>Paste from a browser</h2><form action='/' method='post'><textarea name='data' autocomplete='off' required autofocus cols='80' rows='27'></textarea><br><button type='submit'>Paste it!</button></form>`)
+//line template/index.qtpl:52
+ qw422016.N().S(`
+`)
+//line template/index.qtpl:53
+}
+
+//line template/index.qtpl:53
+func writeindex_contents(qq422016 qtio422016.Writer) {
+//line template/index.qtpl:53
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line template/index.qtpl:53
+ streamindex_contents(qw422016)
+//line template/index.qtpl:53
+ qt422016.ReleaseWriter(qw422016)
+//line template/index.qtpl:53
+}
+
+//line template/index.qtpl:53
+func index_contents() string {
+//line template/index.qtpl:53
+ qb422016 := qt422016.AcquireByteBuffer()
+//line template/index.qtpl:53
+ writeindex_contents(qb422016)
+//line template/index.qtpl:53
+ qs422016 := string(qb422016.B)
+//line template/index.qtpl:53
+ qt422016.ReleaseByteBuffer(qb422016)
+//line template/index.qtpl:53
+ return qs422016
+//line template/index.qtpl:53
+}
+
+// The index layout.
+
+//line template/index.qtpl:56
+func StreamIndex(qw422016 *qt422016.Writer) {
+//line template/index.qtpl:56
+ qw422016.N().S(`
+ `)
+//line template/index.qtpl:57
+ streamlayout(qw422016, "", "", "", index_contents(), "")
+//line template/index.qtpl:57
+ qw422016.N().S(`
+`)
+//line template/index.qtpl:58
+}
+
+//line template/index.qtpl:58
+func WriteIndex(qq422016 qtio422016.Writer) {
+//line template/index.qtpl:58
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line template/index.qtpl:58
+ StreamIndex(qw422016)
+//line template/index.qtpl:58
+ qt422016.ReleaseWriter(qw422016)
+//line template/index.qtpl:58
+}
+
+//line template/index.qtpl:58
+func Index() string {
+//line template/index.qtpl:58
+ qb422016 := qt422016.AcquireByteBuffer()
+//line template/index.qtpl:58
+ WriteIndex(qb422016)
+//line template/index.qtpl:58
+ qs422016 := string(qb422016.B)
+//line template/index.qtpl:58
+ qt422016.ReleaseByteBuffer(qb422016)
+//line template/index.qtpl:58
+ return qs422016
+//line template/index.qtpl:58
+}
diff --git a/template/layout.qtpl.go b/template/layout.qtpl.go
new file mode 100644
index 0000000..dc5e5d8
--- /dev/null
+++ b/template/layout.qtpl.go
@@ -0,0 +1,104 @@
+// Code generated by qtc from "layout.qtpl". DO NOT EDIT.
+// See https://github.com/valyala/quicktemplate for details.
+
+// The main layout function.
+
+//line template/layout.qtpl:2
+package template
+
+//line template/layout.qtpl:2
+import (
+ qtio422016 "io"
+
+ qt422016 "github.com/valyala/quicktemplate"
+)
+
+//line template/layout.qtpl:2
+var (
+ _ = qtio422016.Copy
+ _ = qt422016.AcquireByteBuffer
+)
+
+//line template/layout.qtpl:2
+func streamlayout(qw422016 *qt422016.Writer, css, scripts, title, contents, bodyscripts string) {
+//line template/layout.qtpl:2
+ qw422016.N().S(`
+ <!DOCTYPE html>
+ `)
+//line template/layout.qtpl:4
+ qw422016.N().S(`<html lang='en'><head><meta charset='utf-8' /><meta name='viewport' content='width=device-width, initial-scale=1' />`)
+//line template/layout.qtpl:10
+ if len(css) == 0 {
+//line template/layout.qtpl:10
+ qw422016.N().S(`<style>body {margin: 40px auto;max-width: 650px;line-height: 1.6;font-size: 18px;color: #444;padding: 0 10px;}h1, h2, h3 { line-length: 1.2; }td { text-align: left; }</style>`)
+//line template/layout.qtpl:23
+ } else {
+//line template/layout.qtpl:24
+ qw422016.N().S(css)
+//line template/layout.qtpl:25
+ }
+//line template/layout.qtpl:27
+ if len(scripts) != 0 {
+//line template/layout.qtpl:28
+ qw422016.N().S(scripts)
+//line template/layout.qtpl:29
+ }
+//line template/layout.qtpl:31
+ if len(title) == 0 {
+//line template/layout.qtpl:31
+ qw422016.N().S(`<title>Burning Rubber Paste</title>`)
+//line template/layout.qtpl:33
+ } else {
+//line template/layout.qtpl:34
+ qw422016.N().S(title)
+//line template/layout.qtpl:35
+ }
+//line template/layout.qtpl:35
+ qw422016.N().S(`</head><body><div id='main'>`)
+//line template/layout.qtpl:39
+ if len(contents) != 0 {
+//line template/layout.qtpl:40
+ qw422016.N().S(contents)
+//line template/layout.qtpl:41
+ }
+//line template/layout.qtpl:41
+ qw422016.N().S(`</div>`)
+//line template/layout.qtpl:43
+ if len(bodyscripts) != 0 {
+//line template/layout.qtpl:44
+ qw422016.N().S(bodyscripts)
+//line template/layout.qtpl:45
+ }
+//line template/layout.qtpl:45
+ qw422016.N().S(`</body></html>`)
+//line template/layout.qtpl:48
+ qw422016.N().S(`
+`)
+//line template/layout.qtpl:49
+}
+
+//line template/layout.qtpl:49
+func writelayout(qq422016 qtio422016.Writer, css, scripts, title, contents, bodyscripts string) {
+//line template/layout.qtpl:49
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line template/layout.qtpl:49
+ streamlayout(qw422016, css, scripts, title, contents, bodyscripts)
+//line template/layout.qtpl:49
+ qt422016.ReleaseWriter(qw422016)
+//line template/layout.qtpl:49
+}
+
+//line template/layout.qtpl:49
+func layout(css, scripts, title, contents, bodyscripts string) string {
+//line template/layout.qtpl:49
+ qb422016 := qt422016.AcquireByteBuffer()
+//line template/layout.qtpl:49
+ writelayout(qb422016, css, scripts, title, contents, bodyscripts)
+//line template/layout.qtpl:49
+ qs422016 := string(qb422016.B)
+//line template/layout.qtpl:49
+ qt422016.ReleaseByteBuffer(qb422016)
+//line template/layout.qtpl:49
+ return qs422016
+//line template/layout.qtpl:49
+}