Getting ready for 1.2.0 release: many smaller requests implemented
- Implements #7 - Implements #42 and therefore #64 - Improved #53 - Implements #59 - Implements #61 - Implements #63 - Implements #80 - Implements #84 - Added Info page - Removed Help page - Bumped version number to 1.2.0 - Fixed a bug where wide mode was still 720px wide - Created FUNDING.yml - Reorganised arguments in README.MD and documented new options - Updated SECURITY.MD - Added display of last read time and read count - Increased default width to 800px to make UI less cluttered - Reorganised index page - New, better attach file button I want to spend some time testing these changes and let everyone have a look at them before tagging and releasing new artifacts.
This commit is contained in:
parent
769901c895
commit
44b55ae08e
22 changed files with 977 additions and 327 deletions
4
.github/workflows/FUNDING.yml
vendored
Normal file
4
.github/workflows/FUNDING.yml
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: szabodanika
|
||||||
|
ko_fi: dani_sz
|
334
Cargo.lock
generated
334
Cargo.lock
generated
|
@ -401,6 +401,12 @@ dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bit_field"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "1.3.2"
|
version = "1.3.2"
|
||||||
|
@ -455,6 +461,18 @@ version = "3.11.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytemuck"
|
||||||
|
version = "1.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2f5715e491b5a1598fc2bef5a606847b5dc1d48ea625bd3c02c00de8285591da"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
|
@ -558,6 +576,12 @@ dependencies = [
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "color_quant"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "convert_case"
|
name = "convert_case"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
|
@ -599,6 +623,55 @@ dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-channel"
|
||||||
|
version = "0.5.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-deque"
|
||||||
|
version = "0.8.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-epoch",
|
||||||
|
"crossbeam-utils",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-epoch"
|
||||||
|
version = "0.9.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"cfg-if",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"memoffset",
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crossbeam-utils"
|
||||||
|
version = "0.8.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "crunchy"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crypto-common"
|
name = "crypto-common"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
|
@ -676,6 +749,12 @@ dependencies = [
|
||||||
"crypto-common",
|
"crypto-common",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "either"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "encoding_rs"
|
name = "encoding_rs"
|
||||||
version = "0.8.31"
|
version = "0.8.31"
|
||||||
|
@ -698,6 +777,21 @@ dependencies = [
|
||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "exr"
|
||||||
|
version = "1.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8eb5f255b5980bb0c8cf676b675d1a99be40f316881444f44e0462eaf5df5ded"
|
||||||
|
dependencies = [
|
||||||
|
"bit_field",
|
||||||
|
"flume",
|
||||||
|
"half",
|
||||||
|
"lebe",
|
||||||
|
"miniz_oxide 0.6.2",
|
||||||
|
"smallvec",
|
||||||
|
"threadpool",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.24"
|
version = "1.0.24"
|
||||||
|
@ -705,7 +799,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
|
checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide 0.5.4",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flume"
|
||||||
|
version = "0.10.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
|
"nanorand",
|
||||||
|
"pin-project",
|
||||||
|
"spin",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -835,8 +942,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
"js-sys",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gif"
|
||||||
|
version = "0.11.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3edd93c6756b4dfaf2709eafcc345ba2636565295c198a9cfbf75fa5e3e00b06"
|
||||||
|
dependencies = [
|
||||||
|
"color_quant",
|
||||||
|
"weezl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -858,6 +977,15 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "half"
|
||||||
|
version = "2.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ad6a9459c9c30b177b925162351f97e7d967c7ea8bab3b8352805327daf45554"
|
||||||
|
dependencies = [
|
||||||
|
"crunchy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.12.3"
|
version = "0.12.3"
|
||||||
|
@ -879,6 +1007,15 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "html-escape"
|
||||||
|
version = "0.2.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b8e7479fa1ef38eb49fb6a42c426be515df2d063f06cb8efd3e50af073dbc26c"
|
||||||
|
dependencies = [
|
||||||
|
"utf8-width",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "http"
|
name = "http"
|
||||||
version = "0.2.8"
|
version = "0.2.8"
|
||||||
|
@ -954,6 +1091,25 @@ dependencies = [
|
||||||
"unicode-normalization",
|
"unicode-normalization",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "image"
|
||||||
|
version = "0.24.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd8e4fb07cf672b1642304e731ef8a6a4c7891d67bb4fd4f5ce58cd6ed86803c"
|
||||||
|
dependencies = [
|
||||||
|
"bytemuck",
|
||||||
|
"byteorder",
|
||||||
|
"color_quant",
|
||||||
|
"exr",
|
||||||
|
"gif",
|
||||||
|
"jpeg-decoder",
|
||||||
|
"num-rational",
|
||||||
|
"num-traits",
|
||||||
|
"png",
|
||||||
|
"scoped_threadpool",
|
||||||
|
"tiff",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "1.9.1"
|
version = "1.9.1"
|
||||||
|
@ -979,6 +1135,15 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "jpeg-decoder"
|
||||||
|
version = "0.2.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9478aa10f73e7528198d75109c8be5cd7d15fb530238040148d5f9a22d4c5b3b"
|
||||||
|
dependencies = [
|
||||||
|
"rayon",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.60"
|
version = "0.3.60"
|
||||||
|
@ -1000,6 +1165,12 @@ version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lebe"
|
||||||
|
version = "0.5.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lexical-core"
|
name = "lexical-core"
|
||||||
version = "0.7.6"
|
version = "0.7.6"
|
||||||
|
@ -1095,9 +1266,18 @@ version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "memoffset"
|
||||||
|
version = "0.6.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "microbin"
|
name = "microbin"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
|
@ -1113,6 +1293,7 @@ dependencies = [
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"linkify",
|
"linkify",
|
||||||
"log",
|
"log",
|
||||||
|
"qrcode-generator",
|
||||||
"rand",
|
"rand",
|
||||||
"sanitize-filename",
|
"sanitize-filename",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -1145,6 +1326,15 @@ dependencies = [
|
||||||
"adler",
|
"adler",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.6.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa"
|
||||||
|
dependencies = [
|
||||||
|
"adler",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
|
@ -1157,6 +1347,15 @@ dependencies = [
|
||||||
"windows-sys",
|
"windows-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nanorand"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nom"
|
name = "nom"
|
||||||
version = "6.1.2"
|
version = "6.1.2"
|
||||||
|
@ -1180,6 +1379,17 @@ dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-rational"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"num-integer",
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.15"
|
version = "0.2.15"
|
||||||
|
@ -1277,6 +1487,26 @@ version = "2.2.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
|
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc"
|
||||||
|
dependencies = [
|
||||||
|
"pin-project-internal",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "pin-project-internal"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.9"
|
version = "0.2.9"
|
||||||
|
@ -1309,6 +1539,18 @@ dependencies = [
|
||||||
"xml-rs",
|
"xml-rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "png"
|
||||||
|
version = "0.17.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f0e7f4c94ec26ff209cee506314212639d6c91b80afb82984819fafce9df01c"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"crc32fast",
|
||||||
|
"flate2",
|
||||||
|
"miniz_oxide 0.5.4",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
@ -1348,6 +1590,23 @@ dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qrcode-generator"
|
||||||
|
version = "4.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "501c33c9127afb867693646b38817bf63a9a756d4b66aefbc5c0d7e5e8c3125a"
|
||||||
|
dependencies = [
|
||||||
|
"html-escape",
|
||||||
|
"image",
|
||||||
|
"qrcodegen",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "qrcodegen"
|
||||||
|
version = "1.8.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4339fc7a1021c9c1621d87f5e3505f2805c8c105420ba2f2a4df86814590c142"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.21"
|
version = "1.0.21"
|
||||||
|
@ -1393,6 +1652,30 @@ dependencies = [
|
||||||
"getrandom",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon"
|
||||||
|
version = "1.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
"crossbeam-deque",
|
||||||
|
"either",
|
||||||
|
"rayon-core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rayon-core"
|
||||||
|
version = "1.9.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f"
|
||||||
|
dependencies = [
|
||||||
|
"crossbeam-channel",
|
||||||
|
"crossbeam-deque",
|
||||||
|
"crossbeam-utils",
|
||||||
|
"num_cpus",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
@ -1459,6 +1742,12 @@ dependencies = [
|
||||||
"regex",
|
"regex",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scoped_threadpool"
|
||||||
|
version = "0.1.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -1565,6 +1854,15 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "spin"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09"
|
||||||
|
dependencies = [
|
||||||
|
"lock_api",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "static_assertions"
|
name = "static_assertions"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
@ -1652,6 +1950,26 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "threadpool"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
|
||||||
|
dependencies = [
|
||||||
|
"num_cpus",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tiff"
|
||||||
|
version = "0.7.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7259662e32d1e219321eb309d5f9d898b779769d81b76e762c07c8e5d38fcb65"
|
||||||
|
dependencies = [
|
||||||
|
"flate2",
|
||||||
|
"jpeg-decoder",
|
||||||
|
"weezl",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.1.44"
|
version = "0.1.44"
|
||||||
|
@ -1838,6 +2156,12 @@ dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "utf8-width"
|
||||||
|
version = "0.1.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5190c9442dcdaf0ddd50f37420417d219ae5261bbf5db120d0f9bab996c9cba1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
version = "0.9.4"
|
version = "0.9.4"
|
||||||
|
@ -1921,6 +2245,12 @@ version = "0.2.83"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "weezl"
|
||||||
|
version = "0.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "microbin"
|
name = "microbin"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Daniel Szabo <daniel.szabo99@outlook.com>"]
|
authors = ["Daniel Szabo <daniel.szabo99@outlook.com>"]
|
||||||
license = "BSD-3-Clause"
|
license = "BSD-3-Clause"
|
||||||
|
@ -31,6 +31,7 @@ env_logger = "0.9.0"
|
||||||
actix-web-httpauth = "0.6.0"
|
actix-web-httpauth = "0.6.0"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
syntect = "5.0"
|
syntect = "5.0"
|
||||||
|
qrcode-generator = "4.1.6"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
|
47
README.MD
47
README.MD
|
@ -255,6 +255,24 @@ Require username for HTTP Basic Authentication when visiting the service. If `--
|
||||||
|
|
||||||
Require password for HTTP Basic Authentication when visiting the service. Will not have any affect unless `--auth-username` is also set. If `--auth-username` is set but `--auth-password ` is not, just leave the password field empty when logging in. You can also just go to https://username:password@yourserver.net or https://username@yourserver.net if password is not set instead of typing into the password prompt.
|
Require password for HTTP Basic Authentication when visiting the service. Will not have any affect unless `--auth-username` is also set. If `--auth-username` is set but `--auth-password ` is not, just leave the password field empty when logging in. You can also just go to https://username:password@yourserver.net or https://username@yourserver.net if password is not set instead of typing into the password prompt.
|
||||||
|
|
||||||
|
### -b, --bind [ADDRESS]
|
||||||
|
|
||||||
|
Default value: `0.0.0.0`
|
||||||
|
|
||||||
|
Sets the bind address for the server will be listening on. Both ipv4 and ipv6 are supported.
|
||||||
|
|
||||||
|
### --default-expiry [EXPIRY]
|
||||||
|
|
||||||
|
Default value: `24hour`
|
||||||
|
|
||||||
|
Selects the default expiry time in the dropdown list.
|
||||||
|
|
||||||
|
Options: `1min`, `10min`, `1hour`, `24hour` and `1week`
|
||||||
|
|
||||||
|
### --no-eternal-pasta
|
||||||
|
|
||||||
|
Disables the option to create never expiring pastas.
|
||||||
|
|
||||||
### --editable
|
### --editable
|
||||||
|
|
||||||
Enables editable pastas. You will still be able to make finalised pastas but there will be an extra checkbox to make your new pasta editable from the pasta list or the pasta view page.
|
Enables editable pastas. You will still be able to make finalised pastas but there will be an extra checkbox to make your new pasta editable from the pasta list or the pasta view page.
|
||||||
|
@ -293,21 +311,26 @@ Default value: 8080
|
||||||
|
|
||||||
Sets the port for the server will be listening on.
|
Sets the port for the server will be listening on.
|
||||||
|
|
||||||
|
### --public-path [PUBLIC_PATH]
|
||||||
|
|
||||||
### -b, --bind [ADDRESS]
|
Add the given public path prefix to all urls.
|
||||||
|
|
||||||
Default value: 0.0.0.0
|
The URL copy feature will only copy the entire URL if this is provided. Otherwise only the path (eg. `/url/dog-cat-bat`) will be copied to your clipboard!
|
||||||
|
|
||||||
Sets the bind address for the server will be listening on. Both ipv4 and ipv6 are supported.
|
This allows you to host MicroBin behind a reverse proxy on a subpath.
|
||||||
|
Note that MicroBin itself still expects all routes to be as without this option, and thus is unsuited
|
||||||
|
if you are running MicroBin directly.
|
||||||
|
|
||||||
### --private
|
Example: `--public-path https://myserver.com` or `--public-path http://localhost:8080`
|
||||||
|
|
||||||
Enables private pastas. Adds a new checkbox to make your pasta private, which then won't show up on the pastalist page. With the URL to your pasta, it will still be accessible.
|
|
||||||
|
|
||||||
### --pure-html
|
### --pure-html
|
||||||
|
|
||||||
Disables main CSS styling, just uses a few in-line stylings for the layout. With this option you will lose dark-mode support.
|
Disables main CSS styling, just uses a few in-line stylings for the layout. With this option you will lose dark-mode support.
|
||||||
|
|
||||||
|
### --private
|
||||||
|
|
||||||
|
Enables private pastas. Adds a new checkbox to make your pasta private, which then won't show up on the pastalist page. With the URL to your pasta, it will still be accessible.
|
||||||
|
|
||||||
### --readonly
|
### --readonly
|
||||||
|
|
||||||
Disables adding/editing/removing pastas entirely.
|
Disables adding/editing/removing pastas entirely.
|
||||||
|
@ -330,18 +353,6 @@ Displays your MicroBin's version information.
|
||||||
|
|
||||||
Changes the maximum width of the UI from 720 pixels to 1080 pixels.
|
Changes the maximum width of the UI from 720 pixels to 1080 pixels.
|
||||||
|
|
||||||
### --public-path [PUBLIC_PATH]
|
|
||||||
|
|
||||||
Add the given public path prefix to all urls.
|
|
||||||
|
|
||||||
The URL copy feature will only copy the entire URL if this is provided. Otherwise only the path (eg. `/url/dog-cat-bat`) will be copied to your clipboard!
|
|
||||||
|
|
||||||
This allows you to host MicroBin behind a reverse proxy on a subpath.
|
|
||||||
Note that MicroBin itself still expects all routes to be as without this option, and thus is unsuited
|
|
||||||
if you are running MicroBin directly.
|
|
||||||
|
|
||||||
Example: `--public-path https://myserver.com` or `--public-path http://localhost:8080`
|
|
||||||
|
|
||||||
#### Example Usage (caddy)
|
#### Example Usage (caddy)
|
||||||
|
|
||||||
An example of running MicroBin behind the reverse proxy `caddy` on the path `/paste` (using systemd)
|
An example of running MicroBin behind the reverse proxy `caddy` on the path `/paste` (using systemd)
|
||||||
|
|
13
SECURITY.md
13
SECURITY.md
|
@ -1,19 +1,12 @@
|
||||||
# Security Policy
|
# Security Policy
|
||||||
|
|
||||||
## Supported Versions
|
## Version Support
|
||||||
|
|
||||||
Use this section to tell people about which versions of your project are
|
Currently we only have capacity to support the latest version of MicroBin. We recommend that you always update to the newest one and check our pages regularly for announcements.
|
||||||
currently being supported with security updates.
|
|
||||||
|
|
||||||
| Version | Supported |
|
|
||||||
| ------- | ------------------ |
|
|
||||||
| 1.1.* | :white_check_mark: |
|
|
||||||
| < 1.1.0 | :x: |
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
Security vulnerabilities can be reported directly to
|
Security vulnerabilities can be reported directly to the developer/maintainer at d@szab.eu.
|
||||||
the developer/maintainer at d@szab.eu.
|
|
||||||
|
|
||||||
Sensitive information may be GPG encrypted with my public key available at
|
Sensitive information may be GPG encrypted with my public key available at
|
||||||
https://szab.eu/assets/files/daniel-szabo-pub.asc.
|
https://szab.eu/assets/files/daniel-szabo-pub.asc.
|
||||||
|
|
21
src/args.rs
21
src/args.rs
|
@ -63,11 +63,32 @@ pub struct Args {
|
||||||
#[clap(short, long, env = "MICROBIN_THREADS", default_value_t = 1)]
|
#[clap(short, long, env = "MICROBIN_THREADS", default_value_t = 1)]
|
||||||
pub threads: u8,
|
pub threads: u8,
|
||||||
|
|
||||||
|
#[clap(short, long, env = "MICROBIN_GC_DAYS", default_value_t = 90)]
|
||||||
|
pub gc_days: u16,
|
||||||
|
|
||||||
|
#[clap(long, env = "MICROBIN_ENABLE_BURN_AFTER")]
|
||||||
|
pub enable_burn_after: bool,
|
||||||
|
|
||||||
|
#[clap(short, long, env = "MICROBIN_DEFAULT_BURN_AFTER", default_value_t = 0)]
|
||||||
|
pub default_burn_after: u16,
|
||||||
|
|
||||||
#[clap(long, env = "MICROBIN_WIDE")]
|
#[clap(long, env = "MICROBIN_WIDE")]
|
||||||
pub wide: bool,
|
pub wide: bool,
|
||||||
|
|
||||||
|
#[clap(long, env = "MICROBIN_QR")]
|
||||||
|
pub qr: bool,
|
||||||
|
|
||||||
|
#[clap(long, env = "MICROBIN_NO_ETERNAL_PASTA")]
|
||||||
|
pub no_eternal_pasta: bool,
|
||||||
|
|
||||||
|
#[clap(long, env = "MICROBIN_DEFAULT_EXPIRY", default_value = "24hour")]
|
||||||
|
pub default_expiry: String,
|
||||||
|
|
||||||
#[clap(short, long, env = "MICROBIN_NO_FILE_UPLOAD")]
|
#[clap(short, long, env = "MICROBIN_NO_FILE_UPLOAD")]
|
||||||
pub no_file_upload: bool,
|
pub no_file_upload: bool,
|
||||||
|
|
||||||
|
#[clap(long, env = "MICROBIN_CUSTOM_CSS")]
|
||||||
|
pub custom_css: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -54,6 +54,9 @@ pub async fn create(
|
||||||
private: false,
|
private: false,
|
||||||
editable: false,
|
editable: false,
|
||||||
created: timenow,
|
created: timenow,
|
||||||
|
read_count: 0,
|
||||||
|
burn_after_reads: 0,
|
||||||
|
last_read: timenow,
|
||||||
pasta_type: String::from(""),
|
pasta_type: String::from(""),
|
||||||
expiration: 0,
|
expiration: 0,
|
||||||
};
|
};
|
||||||
|
@ -78,9 +81,34 @@ pub async fn create(
|
||||||
"1hour" => timenow + 60 * 60,
|
"1hour" => timenow + 60 * 60,
|
||||||
"24hour" => timenow + 60 * 60 * 24,
|
"24hour" => timenow + 60 * 60 * 24,
|
||||||
"1week" => timenow + 60 * 60 * 24 * 7,
|
"1week" => timenow + 60 * 60 * 24 * 7,
|
||||||
"never" => 0,
|
"never" => {
|
||||||
|
if ARGS.no_eternal_pasta {
|
||||||
|
timenow + 60 * 60 * 24 * 7
|
||||||
|
} else {
|
||||||
|
0
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
log::error!("{}", "Unexpected expiration time!");
|
log::error!("{}", "Unexpected expiration time!");
|
||||||
|
timenow + 60 * 60 * 24 * 7
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
"burn_after" => {
|
||||||
|
while let Some(chunk) = field.try_next().await? {
|
||||||
|
new_pasta.burn_after_reads = match std::str::from_utf8(&chunk).unwrap() {
|
||||||
|
// give an extra read because the user will be redirected to the pasta page automatically
|
||||||
|
"1" => 2,
|
||||||
|
"10" => 10,
|
||||||
|
"100" => 100,
|
||||||
|
"1000" => 1000,
|
||||||
|
"10000" => 10000,
|
||||||
|
"0" => 0,
|
||||||
|
_ => {
|
||||||
|
log::error!("{}", "Unexpected burn after value!");
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -126,7 +154,10 @@ pub async fn create(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::fs::create_dir_all(format!("./pasta_data/public/{}", &new_pasta.id_as_animals()))
|
std::fs::create_dir_all(format!(
|
||||||
|
"./pasta_data/public/{}",
|
||||||
|
&new_pasta.id_as_animals()
|
||||||
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let filepath = format!(
|
let filepath = format!(
|
||||||
|
@ -158,6 +189,9 @@ pub async fn create(
|
||||||
save_to_file(&pastas);
|
save_to_file(&pastas);
|
||||||
|
|
||||||
Ok(HttpResponse::Found()
|
Ok(HttpResponse::Found()
|
||||||
.append_header(("Location", format!("{}/pasta/{}", ARGS.public_path, to_animal_names(id))))
|
.append_header((
|
||||||
|
"Location",
|
||||||
|
format!("{}/pasta/{}", ARGS.public_path, to_animal_names(id)),
|
||||||
|
))
|
||||||
.finish())
|
.finish())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
use crate::args::{Args, ARGS};
|
|
||||||
use actix_web::{get, HttpResponse};
|
|
||||||
use askama::Template;
|
|
||||||
use std::marker::PhantomData;
|
|
||||||
|
|
||||||
#[derive(Template)]
|
|
||||||
#[template(path = "help.html")]
|
|
||||||
struct Help<'a> {
|
|
||||||
args: &'a Args,
|
|
||||||
_marker: PhantomData<&'a ()>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[get("/help")]
|
|
||||||
pub async fn help() -> HttpResponse {
|
|
||||||
HttpResponse::Ok().content_type("text/html").body(
|
|
||||||
Help {
|
|
||||||
args: &ARGS,
|
|
||||||
_marker: Default::default(),
|
|
||||||
}
|
|
||||||
.render()
|
|
||||||
.unwrap(),
|
|
||||||
)
|
|
||||||
}
|
|
42
src/endpoints/info.rs
Normal file
42
src/endpoints/info.rs
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
use crate::args::{Args, ARGS};
|
||||||
|
use crate::pasta::Pasta;
|
||||||
|
use crate::AppState;
|
||||||
|
use actix_web::{get, web, HttpResponse};
|
||||||
|
use askama::Template;
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "info.html")]
|
||||||
|
struct Info<'a> {
|
||||||
|
args: &'a Args,
|
||||||
|
pastas: &'a Vec<Pasta>,
|
||||||
|
status: &'a String,
|
||||||
|
version_string: &'a String,
|
||||||
|
message: &'a String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/info")]
|
||||||
|
pub async fn info(data: web::Data<AppState>) -> HttpResponse {
|
||||||
|
// get access to the pasta collection
|
||||||
|
let mut pastas = data.pastas.lock().unwrap();
|
||||||
|
|
||||||
|
// todo status report more sophisticated
|
||||||
|
let mut status = "OK";
|
||||||
|
let mut message = "";
|
||||||
|
|
||||||
|
if ARGS.public_path.to_string() == "" {
|
||||||
|
status = "WARNING";
|
||||||
|
message = "Warning: No public URL set with --public-path parameter. QR code and URL Copying functions have been disabled"
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpResponse::Ok().content_type("text/html").body(
|
||||||
|
Info {
|
||||||
|
args: &ARGS,
|
||||||
|
pastas: &pastas,
|
||||||
|
status: &String::from(status),
|
||||||
|
version_string: &String::from("1.2.0-20221029"),
|
||||||
|
message: &String::from(message),
|
||||||
|
}
|
||||||
|
.render()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
}
|
|
@ -1,12 +1,14 @@
|
||||||
use actix_web::{get, web, HttpResponse};
|
|
||||||
use askama::Template;
|
|
||||||
|
|
||||||
use crate::args::{Args, ARGS};
|
use crate::args::{Args, ARGS};
|
||||||
|
use crate::dbio::save_to_file;
|
||||||
use crate::endpoints::errors::ErrorTemplate;
|
use crate::endpoints::errors::ErrorTemplate;
|
||||||
use crate::pasta::Pasta;
|
use crate::pasta::Pasta;
|
||||||
use crate::util::animalnumbers::to_u64;
|
use crate::util::animalnumbers::to_u64;
|
||||||
use crate::util::misc::remove_expired;
|
use crate::util::misc::remove_expired;
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
|
use actix_web::rt::time;
|
||||||
|
use actix_web::{get, web, HttpResponse};
|
||||||
|
use askama::Template;
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "pasta.html", escape = "none")]
|
#[template(path = "pasta.html", escape = "none")]
|
||||||
|
@ -17,27 +19,60 @@ struct PastaTemplate<'a> {
|
||||||
|
|
||||||
#[get("/pasta/{id}")]
|
#[get("/pasta/{id}")]
|
||||||
pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||||
|
// get access to the pasta collection
|
||||||
let mut pastas = data.pastas.lock().unwrap();
|
let mut pastas = data.pastas.lock().unwrap();
|
||||||
|
|
||||||
|
// get the u64 id from the animal names in the path
|
||||||
let id = to_u64(&*id.into_inner()).unwrap_or(0);
|
let id = to_u64(&*id.into_inner()).unwrap_or(0);
|
||||||
|
|
||||||
println!("{}", id);
|
// remove expired pastas (including this one if needed)
|
||||||
|
|
||||||
remove_expired(&mut pastas);
|
remove_expired(&mut pastas);
|
||||||
|
|
||||||
for pasta in pastas.iter() {
|
// find the index of the pasta in the collection based on u64 id
|
||||||
|
let mut index: usize = 0;
|
||||||
|
let mut found: bool = false;
|
||||||
|
for (i, pasta) in pastas.iter().enumerate() {
|
||||||
if pasta.id == id {
|
if pasta.id == id {
|
||||||
return HttpResponse::Ok().content_type("text/html").body(
|
index = i;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found {
|
||||||
|
// increment read count
|
||||||
|
pastas[index].read_count = pastas[index].read_count + 1;
|
||||||
|
|
||||||
|
// save the updated read count
|
||||||
|
save_to_file(&pastas);
|
||||||
|
|
||||||
|
// serve pasta in template
|
||||||
|
let response = HttpResponse::Ok().content_type("text/html").body(
|
||||||
PastaTemplate {
|
PastaTemplate {
|
||||||
pasta: &pasta,
|
pasta: &pastas[index],
|
||||||
args: &ARGS,
|
args: &ARGS,
|
||||||
}
|
}
|
||||||
.render()
|
.render()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// get current unix time in seconds
|
||||||
|
let timenow: i64 = match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||||
|
Ok(n) => n.as_secs(),
|
||||||
|
Err(_) => {
|
||||||
|
log::error!("SystemTime before UNIX EPOCH!");
|
||||||
|
0
|
||||||
}
|
}
|
||||||
|
} as i64;
|
||||||
|
|
||||||
|
// update last read time
|
||||||
|
pastas[index].last_read = timenow;
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// otherwise
|
||||||
|
// send pasta not found error
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
.body(ErrorTemplate { args: &ARGS }.render().unwrap())
|
.body(ErrorTemplate { args: &ARGS }.render().unwrap())
|
||||||
|
@ -45,26 +80,62 @@ pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpR
|
||||||
|
|
||||||
#[get("/url/{id}")]
|
#[get("/url/{id}")]
|
||||||
pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||||
|
// get access to the pasta collection
|
||||||
let mut pastas = data.pastas.lock().unwrap();
|
let mut pastas = data.pastas.lock().unwrap();
|
||||||
|
|
||||||
|
// get the u64 id from the animal names in the path
|
||||||
let id = to_u64(&*id.into_inner()).unwrap_or(0);
|
let id = to_u64(&*id.into_inner()).unwrap_or(0);
|
||||||
|
|
||||||
|
// remove expired pastas (including this one if needed)
|
||||||
remove_expired(&mut pastas);
|
remove_expired(&mut pastas);
|
||||||
|
|
||||||
for pasta in pastas.iter() {
|
// find the index of the pasta in the collection based on u64 id
|
||||||
|
let mut index: usize = 0;
|
||||||
|
let mut found: bool = false;
|
||||||
|
for (i, pasta) in pastas.iter().enumerate() {
|
||||||
if pasta.id == id {
|
if pasta.id == id {
|
||||||
if pasta.pasta_type == "url" {
|
index = i;
|
||||||
return HttpResponse::Found()
|
found = true;
|
||||||
.append_header(("Location", String::from(&pasta.content)))
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if found {
|
||||||
|
// increment read count
|
||||||
|
pastas[index].read_count = pastas[index].read_count + 1;
|
||||||
|
|
||||||
|
// save the updated read count
|
||||||
|
save_to_file(&pastas);
|
||||||
|
|
||||||
|
// send redirect if it's a url pasta
|
||||||
|
if pastas[index].pasta_type == "url" {
|
||||||
|
let response = HttpResponse::Found()
|
||||||
|
.append_header(("Location", String::from(&pastas[index].content)))
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
|
// get current unix time in seconds
|
||||||
|
let timenow: i64 = match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||||
|
Ok(n) => n.as_secs(),
|
||||||
|
Err(_) => {
|
||||||
|
log::error!("SystemTime before UNIX EPOCH!");
|
||||||
|
0
|
||||||
|
}
|
||||||
|
} as i64;
|
||||||
|
|
||||||
|
// update last read time
|
||||||
|
pastas[index].last_read = timenow;
|
||||||
|
|
||||||
|
return response;
|
||||||
|
// send error if we're trying to open a non-url pasta as a redirect
|
||||||
} else {
|
} else {
|
||||||
return HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
.body(ErrorTemplate { args: &ARGS }.render().unwrap());
|
.body(ErrorTemplate { args: &ARGS }.render().unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// otherwise
|
||||||
|
// send pasta not found error
|
||||||
HttpResponse::Ok()
|
HttpResponse::Ok()
|
||||||
.content_type("text/html")
|
.content_type("text/html")
|
||||||
.body(ErrorTemplate { args: &ARGS }.render().unwrap())
|
.body(ErrorTemplate { args: &ARGS }.render().unwrap())
|
||||||
|
@ -72,17 +143,50 @@ pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> Ht
|
||||||
|
|
||||||
#[get("/raw/{id}")]
|
#[get("/raw/{id}")]
|
||||||
pub async fn getrawpasta(data: web::Data<AppState>, id: web::Path<String>) -> String {
|
pub async fn getrawpasta(data: web::Data<AppState>, id: web::Path<String>) -> String {
|
||||||
|
// get access to the pasta collection
|
||||||
let mut pastas = data.pastas.lock().unwrap();
|
let mut pastas = data.pastas.lock().unwrap();
|
||||||
|
|
||||||
|
// get the u64 id from the animal names in the path
|
||||||
let id = to_u64(&*id.into_inner()).unwrap_or(0);
|
let id = to_u64(&*id.into_inner()).unwrap_or(0);
|
||||||
|
|
||||||
|
// remove expired pastas (including this one if needed)
|
||||||
remove_expired(&mut pastas);
|
remove_expired(&mut pastas);
|
||||||
|
|
||||||
for pasta in pastas.iter() {
|
// find the index of the pasta in the collection based on u64 id
|
||||||
|
let mut index: usize = 0;
|
||||||
|
let mut found: bool = false;
|
||||||
|
for (i, pasta) in pastas.iter().enumerate() {
|
||||||
if pasta.id == id {
|
if pasta.id == id {
|
||||||
return pasta.content.to_owned();
|
index = i;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if found {
|
||||||
|
// increment read count
|
||||||
|
pastas[index].read_count = pastas[index].read_count + 1;
|
||||||
|
|
||||||
|
// get current unix time in seconds
|
||||||
|
let timenow: i64 = match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||||
|
Ok(n) => n.as_secs(),
|
||||||
|
Err(_) => {
|
||||||
|
log::error!("SystemTime before UNIX EPOCH!");
|
||||||
|
0
|
||||||
|
}
|
||||||
|
} as i64;
|
||||||
|
|
||||||
|
// update last read time
|
||||||
|
pastas[index].last_read = timenow;
|
||||||
|
|
||||||
|
// save the updated read count
|
||||||
|
save_to_file(&pastas);
|
||||||
|
|
||||||
|
// send raw content of pasta
|
||||||
|
return pastas[index].content.to_owned();
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise
|
||||||
|
// send pasta not found error as raw text
|
||||||
String::from("Pasta not found! :-(")
|
String::from("Pasta not found! :-(")
|
||||||
}
|
}
|
||||||
|
|
34
src/endpoints/qr.rs
Normal file
34
src/endpoints/qr.rs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
use crate::args::{Args, ARGS};
|
||||||
|
use crate::pasta::Pasta;
|
||||||
|
use crate::util::misc::{self, remove_expired};
|
||||||
|
use crate::AppState;
|
||||||
|
use actix_web::{get, web, HttpResponse};
|
||||||
|
use askama::Template;
|
||||||
|
use qrcode_generator::QrCodeEcc;
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "qr.html", escape = "none")]
|
||||||
|
struct QRTemplate<'a> {
|
||||||
|
qr: &'a String,
|
||||||
|
args: &'a Args,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/qr/{id}")]
|
||||||
|
pub async fn getqr(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||||
|
// find the index of the pasta in the collection based on u64 id
|
||||||
|
|
||||||
|
let svg: String = misc::string_to_qr_svg(
|
||||||
|
format!("{}/pasta/{}", &ARGS.public_path, &*id.into_inner()).as_str(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// serve qr code in template
|
||||||
|
HttpResponse::Ok().content_type("text/html").body(
|
||||||
|
QRTemplate {
|
||||||
|
qr: &svg,
|
||||||
|
args: &ARGS,
|
||||||
|
}
|
||||||
|
.render()
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
}
|
18
src/main.rs
18
src/main.rs
|
@ -2,7 +2,7 @@ extern crate core;
|
||||||
|
|
||||||
use crate::args::ARGS;
|
use crate::args::ARGS;
|
||||||
use crate::endpoints::{
|
use crate::endpoints::{
|
||||||
create, edit, errors, help, pasta as pasta_endpoint, pastalist, remove, static_resources,
|
create, edit, errors, info, pasta as pasta_endpoint, pastalist, qr, remove, static_resources,
|
||||||
};
|
};
|
||||||
use crate::pasta::Pasta;
|
use crate::pasta::Pasta;
|
||||||
use crate::util::dbio;
|
use crate::util::dbio;
|
||||||
|
@ -31,9 +31,10 @@ pub mod endpoints {
|
||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod edit;
|
pub mod edit;
|
||||||
pub mod errors;
|
pub mod errors;
|
||||||
pub mod help;
|
pub mod info;
|
||||||
pub mod pasta;
|
pub mod pasta;
|
||||||
pub mod pastalist;
|
pub mod pastalist;
|
||||||
|
pub mod qr;
|
||||||
pub mod remove;
|
pub mod remove;
|
||||||
pub mod static_resources;
|
pub mod static_resources;
|
||||||
}
|
}
|
||||||
|
@ -66,8 +67,14 @@ async fn main() -> std::io::Result<()> {
|
||||||
match fs::create_dir_all("./pasta_data/public") {
|
match fs::create_dir_all("./pasta_data/public") {
|
||||||
Ok(dir) => dir,
|
Ok(dir) => dir,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
log::error!("Couldn't create data directory ./pasta_data/public/: {:?}", error);
|
log::error!(
|
||||||
panic!("Couldn't create data directory ./pasta_data/public/: {:?}", error);
|
"Couldn't create data directory ./pasta_data/public/: {:?}",
|
||||||
|
error
|
||||||
|
);
|
||||||
|
panic!(
|
||||||
|
"Couldn't create data directory ./pasta_data/public/: {:?}",
|
||||||
|
error
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,13 +87,14 @@ async fn main() -> std::io::Result<()> {
|
||||||
.app_data(data.clone())
|
.app_data(data.clone())
|
||||||
.wrap(middleware::NormalizePath::trim())
|
.wrap(middleware::NormalizePath::trim())
|
||||||
.service(create::index)
|
.service(create::index)
|
||||||
.service(help::help)
|
.service(info::info)
|
||||||
.service(pasta_endpoint::getpasta)
|
.service(pasta_endpoint::getpasta)
|
||||||
.service(pasta_endpoint::getrawpasta)
|
.service(pasta_endpoint::getrawpasta)
|
||||||
.service(pasta_endpoint::redirecturl)
|
.service(pasta_endpoint::redirecturl)
|
||||||
.service(edit::get_edit)
|
.service(edit::get_edit)
|
||||||
.service(edit::post_edit)
|
.service(edit::post_edit)
|
||||||
.service(static_resources::static_resources)
|
.service(static_resources::static_resources)
|
||||||
|
.service(qr::getqr)
|
||||||
.service(actix_files::Files::new("/file", "./pasta_data/public/"))
|
.service(actix_files::Files::new("/file", "./pasta_data/public/"))
|
||||||
.service(web::resource("/upload").route(web::post().to(create::create)))
|
.service(web::resource("/upload").route(web::post().to(create::create)))
|
||||||
.default_service(web::route().to(errors::not_found))
|
.default_service(web::route().to(errors::not_found))
|
||||||
|
|
56
src/pasta.rs
56
src/pasta.rs
|
@ -3,6 +3,7 @@ use chrono::{Datelike, Local, TimeZone, Timelike};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use crate::util::animalnumbers::to_animal_names;
|
use crate::util::animalnumbers::to_animal_names;
|
||||||
use crate::util::syntaxhighlighter::html_highlight;
|
use crate::util::syntaxhighlighter::html_highlight;
|
||||||
|
@ -39,6 +40,9 @@ pub struct Pasta {
|
||||||
pub editable: bool,
|
pub editable: bool,
|
||||||
pub created: i64,
|
pub created: i64,
|
||||||
pub expiration: i64,
|
pub expiration: i64,
|
||||||
|
pub last_read: i64,
|
||||||
|
pub read_count: u64,
|
||||||
|
pub burn_after_reads: u64,
|
||||||
pub pasta_type: String,
|
pub pasta_type: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,6 +77,58 @@ impl Pasta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn last_read_time_ago_as_string(&self) -> String {
|
||||||
|
// get current unix time in seconds
|
||||||
|
let timenow: i64 = match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||||
|
Ok(n) => n.as_secs(),
|
||||||
|
Err(_) => {
|
||||||
|
log::error!("SystemTime before UNIX EPOCH!");
|
||||||
|
0
|
||||||
|
}
|
||||||
|
} as i64;
|
||||||
|
|
||||||
|
// get seconds since last read and convert it to days
|
||||||
|
let days = ((timenow - self.last_read) / 86400) as u16;
|
||||||
|
if days > 1 {
|
||||||
|
return format!("{} days ago", days);
|
||||||
|
};
|
||||||
|
|
||||||
|
// it's less than 1 day, let's do hours then
|
||||||
|
let hours = ((timenow - self.last_read) / 3600) as u16;
|
||||||
|
if hours > 1 {
|
||||||
|
return format!("{} hours ago", hours);
|
||||||
|
};
|
||||||
|
|
||||||
|
// it's less than 1 hour, let's do minutes then
|
||||||
|
let minutes = ((timenow - self.last_read) / 60) as u16;
|
||||||
|
if minutes > 1 {
|
||||||
|
return format!("{} minutes ago", minutes);
|
||||||
|
};
|
||||||
|
|
||||||
|
// it's less than 1 minute, let's do seconds then
|
||||||
|
let seconds = (timenow - self.last_read) as u16;
|
||||||
|
if seconds > 1 {
|
||||||
|
return format!("{} seconds ago", seconds);
|
||||||
|
};
|
||||||
|
|
||||||
|
// it's less than 1 second?????
|
||||||
|
return String::from("just now");
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn last_read_days_ago(&self) -> u16 {
|
||||||
|
// get current unix time in seconds
|
||||||
|
let timenow: i64 = match SystemTime::now().duration_since(UNIX_EPOCH) {
|
||||||
|
Ok(n) => n.as_secs(),
|
||||||
|
Err(_) => {
|
||||||
|
log::error!("SystemTime before UNIX EPOCH!");
|
||||||
|
0
|
||||||
|
}
|
||||||
|
} as i64;
|
||||||
|
|
||||||
|
// get seconds since last read and convert it to days
|
||||||
|
return ((timenow - self.last_read) / 86400) as u16;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn content_syntax_highlighted(&self) -> String {
|
pub fn content_syntax_highlighted(&self) -> String {
|
||||||
html_highlight(&self.content, &self.extension)
|
html_highlight(&self.content, &self.extension)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
|
use crate::args::ARGS;
|
||||||
use linkify::{LinkFinder, LinkKind};
|
use linkify::{LinkFinder, LinkKind};
|
||||||
|
use qrcode_generator::QrCodeEcc;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use crate::{dbio, Pasta};
|
use crate::{dbio, Pasta};
|
||||||
|
@ -16,8 +18,16 @@ pub fn remove_expired(pastas: &mut Vec<Pasta>) {
|
||||||
} as i64;
|
} as i64;
|
||||||
|
|
||||||
pastas.retain(|p| {
|
pastas.retain(|p| {
|
||||||
|
// keep if:
|
||||||
// expiration is `never` or not reached
|
// expiration is `never` or not reached
|
||||||
if p.expiration == 0 || p.expiration > timenow {
|
// AND
|
||||||
|
// read count is less than burn limit, or no limit set
|
||||||
|
// AND
|
||||||
|
// has been read in the last N days where N is the arg --gc-days OR N is 0 (no GC)
|
||||||
|
if (p.expiration == 0 || p.expiration > timenow)
|
||||||
|
&& (p.read_count < p.burn_after_reads || p.burn_after_reads == 0)
|
||||||
|
&& (p.last_read_days_ago() < ARGS.gc_days || ARGS.gc_days == 0)
|
||||||
|
{
|
||||||
// keep
|
// keep
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,6 +55,10 @@ pub fn remove_expired(pastas: &mut Vec<Pasta>) {
|
||||||
dbio::save_to_file(pastas);
|
dbio::save_to_file(pastas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn string_to_qr_svg(str: &str) -> String {
|
||||||
|
qrcode_generator::to_svg_to_string(str, QrCodeEcc::Low, 512, None::<&str>).unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_valid_url(url: &str) -> bool {
|
pub fn is_valid_url(url: &str) -> bool {
|
||||||
let finder = LinkFinder::new();
|
let finder = LinkFinder::new();
|
||||||
let spans: Vec<_> = finder.spans(url).collect();
|
let spans: Vec<_> = finder.spans(url).collect();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<b>Not Found</b>
|
<b>Not Found</b>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
<a href="{{ args.public_path }}/" > Go Home</a>
|
<a href="{{ args.public_path }}/"> Go Home</a>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
{% include "footer.html" %}
|
{% include "footer.html" %}
|
|
@ -12,13 +12,18 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
||||||
{% if !args.pure_html %}
|
{% if !args.pure_html %}
|
||||||
|
{% if args.custom_css.as_ref().is_none() %}
|
||||||
<link rel="stylesheet" href="{{ args.public_path }}/static/water.css">
|
<link rel="stylesheet" href="{{ args.public_path }}/static/water.css">
|
||||||
|
{%- else %}
|
||||||
|
<link rel="stylesheet" href="{{ args.custom_css.as_ref().unwrap() }}">
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
{% if args.wide %}
|
{% if args.wide %}
|
||||||
|
|
||||||
<body style="
|
<body style="
|
||||||
max-width: 720px;
|
max-width: 1080px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding-left:0.5rem;
|
padding-left:0.5rem;
|
||||||
padding-right:0.5rem;
|
padding-right:0.5rem;
|
||||||
|
@ -28,7 +33,7 @@
|
||||||
{%- else %}
|
{%- else %}
|
||||||
|
|
||||||
<body style="
|
<body style="
|
||||||
max-width: 720px;
|
max-width: 800px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding-left:0.5rem;
|
padding-left:0.5rem;
|
||||||
padding-right:0.5rem;
|
padding-right:0.5rem;
|
||||||
|
@ -53,11 +58,12 @@
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
</b>
|
</b>
|
||||||
|
|
||||||
<a href="{{ args.public_path }}/" style="margin-right: 0.5rem; margin-left: 0.5rem">New Pasta</a>
|
<a href="{{ args.public_path }}/" style="margin-right: 0.5rem; margin-left: 0.5rem">New
|
||||||
|
Pasta</a>
|
||||||
|
|
||||||
<a href="{{ args.public_path }}/pastalist" style="margin-right: 0.5rem; margin-left: 0.5rem">Pasta List</a>
|
<a href="{{ args.public_path }}/pastalist" style="margin-right: 0.5rem; margin-left: 0.5rem">Pasta List</a>
|
||||||
|
|
||||||
<a href="{{ args.public_path }}/help" style="margin-right: 0.5rem; margin-left: 0.5rem">Help</a>
|
<a href="{{ args.public_path }}/info" style="margin-right: 0.5rem; margin-left: 0.5rem">Info</a>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
|
|
@ -1,160 +0,0 @@
|
||||||
{% include "header.html" %}
|
|
||||||
|
|
||||||
|
|
||||||
<h2 id="welcome-to-the-microbin-wiki-">Welcome to MicroBin!</h2>
|
|
||||||
<p>This page contains help regarding the installation, configuration and use of MicroBin. If you have questions that are not answered here, head to our <a href="https://github.com/szabodanika/microbin">GitHub repository</a>.</p>
|
|
||||||
<h2 id="1-usage">1 Usage</h2>
|
|
||||||
<h3 id="what-is-a-pasta-anyway-">What is a "pasta" anyway?</h3>
|
|
||||||
<p>In microbin, a pasta can be:</p>
|
|
||||||
<ul>
|
|
||||||
<li>A text that you want to paste from one machine to another, eg. some code</li>
|
|
||||||
<li>A file that you want to share, eg. a video that is too large for Discord, a zip with a code project in it or an image</li>
|
|
||||||
<li>A URL redirect</li>
|
|
||||||
</ul>
|
|
||||||
<h3 id="when-is-microbin-useful-">When is MicroBin useful?</h3>
|
|
||||||
<p>You can use MicroBin</p>
|
|
||||||
<ul>
|
|
||||||
<li>As a URL shortener/redirect service,</li>
|
|
||||||
<li>To send long texts to other people,</li>
|
|
||||||
<li>To send large files to other people,</li>
|
|
||||||
<li>To serve content on the web, eg. configuration files for testing, images, or any other file content using the Raw functionality,</li>
|
|
||||||
<li>To move files between your desktop and a server you access from the console,</li>
|
|
||||||
<li>As a "postbox" service where people can upload their files or texts, but they cannot see or remove what others sent you - just disable the pastalist page</li>
|
|
||||||
<li>To take notes! Simply create an editable pasta.</li>
|
|
||||||
</ul>
|
|
||||||
<p>...and many other things, why not get creative?</p>
|
|
||||||
<h3 id="creating-a-pasta">Creating a Pasta</h3>
|
|
||||||
<p>Navigate to the root of your server, for example <a href="https://microbin.myserver.com/">https://microbin.myserver.com/</a>. This should show you a form where you will at the very least see an expiration selector, a file attachment input, a content text field and a green save button. Depending on your configuration there miight also be a syntax highlight selector, an editable checkbox and a private ceckbox.</p>
|
|
||||||
<p>Use the expiration dropdown to choose how long you want your pasta to exist. When the selected time has expired, it will be removed from the server. The content can be any text, including plain text, code, html, even a URL. A URL is a special case, because when you open the pasta again, it will redirect you to that URL instead of showing it as a text. Entering content is optional, and so is the file attachment. If you want, you can even submit a pasta completely empty.</p>
|
|
||||||
<p>You will be redirected to the URL of the pasta, which will end with a few animal names. If you remember those animals, you can simply type them in on another machine and open your pasta elsewhere.</p>
|
|
||||||
<p>If you have editable pastas enabled and you check the editable checkbox, then later on there will be an option to change the text content of your pasta. Selecting the private checkbox will simply prevent your pasta to show up on the pasta list page, if that is enabled.</p>
|
|
||||||
<p>If you have syntax higlighting enabled, then select your language from the dropdown, or leave it as none if you just want to upload plain with no highlighting.</p>
|
|
||||||
<h3 id="listing-pastas">Listing Pastas</h3>
|
|
||||||
<p>If you have pasta listing enabled, then there is a pasta list option in the navigation bar, which will list all the pastas on the server in two groups: regular pastas and URL redirects (pastas containing nothing but a URL). If you have private pastas enabled, they will not show up here at all.</p>
|
|
||||||
<p>From the pasta list page, you will be able to view individual pastas by clicking on their animal identifiers on the lest, view their raw contrent by clicking on the Raw button, remove them, and if you have editable pastas enabled, then open them in edit view.</p>
|
|
||||||
<h3 id="use-microbin-from-the-console-with-curl">Use MicroBin from the console with cURL</h3>
|
|
||||||
<p>Simple text Pasta: <code>curl -d "expiration=10min&content=This is a test pasta" -X POST https://microbin.myserver.com/create</code></p>
|
|
||||||
<p>File contents: <code>curl -d "expiration=10min&content=$( < mypastafile.txt )" -X POST https://microbin.myserver.com/create</code></p>
|
|
||||||
<p>Available expiration options:
|
|
||||||
<code>1min</code>, <code>10min</code>, <code>1hour</code>, <code>24hour</code>, <code>1week</code>, <code>never</code></p>
|
|
||||||
<p>Use cURL to read the pasta: <code>curl https://microbin.myserver.com/rawpasta/fish-pony-crow</code>,</p>
|
|
||||||
<p>or to download the pasta: <code>curl https://microbin.myserver.com/rawpasta/fish-pony-crow > output.txt</code> (use /file instead of /rawpasta to download attached file).</p>
|
|
||||||
<h2 id="2-installation">2 Installation</h2>
|
|
||||||
<h3 id="from-cargo">From Cargo</h3>
|
|
||||||
<p>Install from Cargo:</p>
|
|
||||||
<p><code>cargo install microbin</code></p>
|
|
||||||
<p>Remember, MicroBin will create your database and file storage wherever you execute it. I recommend that you create a folder for it first and execute it there:</p>
|
|
||||||
<p><code>mkdir ~/microbin/</code></p>
|
|
||||||
<p><code>cd ~/microbin/</code></p>
|
|
||||||
<p><code>microbin --port 8080 --highlightsyntax --editable</code></p>
|
|
||||||
<h3 id="building-microbin">Building MicroBin</h3>
|
|
||||||
<p>Simply clone the repository, build it with <code>cargo build --release</code> and run the <code>microbin</code> executable in the created <code>target/release/</code> directory. It will start on port 8080. You can change the port with <code>-p</code> or <code>--port</code> CL arguments. For other arguments see <a href="https://github.com/szabodanika/microbin/wiki">the Wiki</a>.</p>
|
|
||||||
<pre><code>git clone https:<span class="hljs-comment">//github.com/szabodanika/microbin.git</span>
|
|
||||||
cd microbin
|
|
||||||
cargo build --<span class="hljs-built_in">release</span>
|
|
||||||
./target/<span class="hljs-built_in">release</span>/microbin -p <span class="hljs-number">80</span>
|
|
||||||
</code></pre><h3 id="microbin-as-a-service">MicroBin as a service</h3>
|
|
||||||
<p>To install it as a service on your Linux machine, create a file called <code>/etc/systemd/system/microbin.service</code>, paste this into it with the <code>[username]</code> and <code>[path to installation directory]</code> replaced with the actual values. If you installed MicroBin from Cargo, your executable will be in your system's Cargo directory, e.g. <code>/Users/daniel/.cargo/bin/microbin</code>.</p>
|
|
||||||
<pre><code><span class="hljs-section">[Unit]</span>
|
|
||||||
<span class="hljs-attr">Description</span>=MicroBin
|
|
||||||
<span class="hljs-attr">After</span>=network.target
|
|
||||||
<span class="hljs-section">
|
|
||||||
[Service]</span>
|
|
||||||
<span class="hljs-attr">Type</span>=simple
|
|
||||||
<span class="hljs-attr">Restart</span>=always
|
|
||||||
<span class="hljs-attr">User</span>=[username]
|
|
||||||
<span class="hljs-attr">RootDirectory</span>=/
|
|
||||||
<span class="hljs-attr">WorkingDirectory</span>=[path to installation directory]
|
|
||||||
<span class="hljs-attr">ExecStart</span>=[path to installation directory]/target/release/microbin
|
|
||||||
<span class="hljs-section">
|
|
||||||
[Install]</span>
|
|
||||||
<span class="hljs-attr">WantedBy</span>=multi-user.target
|
|
||||||
</code></pre><p>Here is my <code>microbin.service</code> for example, with some optional arguments:</p>
|
|
||||||
<pre><code><span class="hljs-section">[Unit]</span>
|
|
||||||
<span class="hljs-attr">Description</span>=MicroBin
|
|
||||||
<span class="hljs-attr">After</span>=network.target
|
|
||||||
<span class="hljs-section">
|
|
||||||
[Service]</span>
|
|
||||||
<span class="hljs-attr">Type</span>=simple
|
|
||||||
<span class="hljs-attr">Restart</span>=always
|
|
||||||
<span class="hljs-attr">User</span>=ubuntu
|
|
||||||
<span class="hljs-attr">RootDirectory</span>=/
|
|
||||||
|
|
||||||
<span class="hljs-comment"># This is the directory where I want to run microbin. It will store all the pastas here.</span>
|
|
||||||
<span class="hljs-attr">WorkingDirectory</span>=/home/ubuntu/server/microbin
|
|
||||||
|
|
||||||
<span class="hljs-comment"># This is the location of my executable - I also have 2 optional features enabled</span>
|
|
||||||
<span class="hljs-attr">ExecStart</span>=/home/ubuntu/server/microbin/target/release/microbin --editable --linenumbers --highlightsyntax
|
|
||||||
|
|
||||||
<span class="hljs-comment"># I keep my installation in the home directory, so I need to add this</span>
|
|
||||||
<span class="hljs-attr">ProtectHome</span>=<span class="hljs-literal">off</span>
|
|
||||||
<span class="hljs-section">
|
|
||||||
[Install]</span>
|
|
||||||
<span class="hljs-attr">WantedBy</span>=multi-user.target
|
|
||||||
</code></pre><p>Then start the service with <code>systemctl start microbin</code> and enable it on boot with <code>systemctl enable microbin</code>. To update your MicroBin, simply update or clone the repository again, build it again, and then restart the service with <code>systemctl restart microbin</code>. An update will never affect your existing pastas, unless there is a breaking change in the data model (in which case MicroBin just won't be able to import your DB), which will always be mentioned explicitly.</p>
|
|
||||||
<h3 id="nginx-configuration">NGINX configuration</h3>
|
|
||||||
<pre><code><span class="hljs-section">server</span> {
|
|
||||||
<span class="hljs-comment"># I have HTTPS enabled using certbot - you can use HTTP of course if you want!</span>
|
|
||||||
<span class="hljs-attribute">listen</span> <span class="hljs-number">443</span> ssl; <span class="hljs-comment"># managed by Certbot</span>
|
|
||||||
|
|
||||||
<span class="hljs-attribute">server_name</span> microbin.myserver.com;
|
|
||||||
|
|
||||||
<span class="hljs-attribute">location</span> / {
|
|
||||||
<span class="hljs-comment"># Make sure to change the port if you are not running MicroBin at 8080!</span>
|
|
||||||
<span class="hljs-attribute">proxy_pass</span> http://127.0.0.1:8080<span class="hljs-variable">$request_uri</span>;
|
|
||||||
<span class="hljs-attribute">proxy_set_header</span> Host <span class="hljs-variable">$host</span>;
|
|
||||||
<span class="hljs-attribute">proxy_set_header</span> X-Forwarded-Proto <span class="hljs-variable">$scheme</span>;
|
|
||||||
<span class="hljs-attribute">proxy_set_header</span> X-Real-IP <span class="hljs-variable">$remote_addr</span>;
|
|
||||||
<span class="hljs-attribute">proxy_set_header</span> X-Forwarded-For <span class="hljs-variable">$proxy_add_x_forwarded_for</span>;
|
|
||||||
}
|
|
||||||
|
|
||||||
<span class="hljs-comment"># Limit content size - I have 1GB because my MicroBin server is private, no one else will use it.</span>
|
|
||||||
<span class="hljs-attribute">client_max_body_size</span> <span class="hljs-number">1024M</span>;
|
|
||||||
|
|
||||||
<span class="hljs-attribute">ssl_certificate</span> /etc/letsencrypt/live/microbin.myserver.com/fullchain.pem; <span class="hljs-comment"># managed by Certbot</span>
|
|
||||||
<span class="hljs-attribute">ssl_certificate_key</span> /etc/letsencrypt/live/microbin.myserver.com/privkey.pem; <span class="hljs-comment"># managed by Certbot</span>
|
|
||||||
<span class="hljs-attribute">include</span> /etc/letsencrypt/options-ssl-nginx.conf; <span class="hljs-comment"># managed by Certbot</span>
|
|
||||||
<span class="hljs-attribute">ssl_dhparam</span> /etc/letsencrypt/ssl-dhparams.pem; <span class="hljs-comment"># managed by Certbot</span>
|
|
||||||
}
|
|
||||||
</code></pre><h2 id="3-command-line-arguments">3 Command Line Arguments</h2>
|
|
||||||
<p>There is an ever expanding list of customisations built into MicroBin so you can use it the way you want. Instead of a configuration file, we simply use arguments that you pass to the executable, making the workflow even simpler. Read the following options and if you cannot find what you need, you can always open an issue at our GitHub repository and request a new feature!</p>
|
|
||||||
<h3 id="-auth-username-auth_username-">--auth-username [AUTH_USERNAME]</h3>
|
|
||||||
<p>Require username for HTTP Basic Authentication when visiting the service. If <code>--auth-username</code> is set but <code>--auth-password</code> is not, just leave the password field empty when logging in. You can also just go to <a href="https://username:password@yourserver.net">https://username:password@yourserver.net</a> or <a href="https://username@yourserver.net">https://username@yourserver.net</a> if password is not set instead of typing into the password</p>
|
|
||||||
<h3 id="-auth-password-auth_password-">--auth-password [AUTH_PASSWORD]</h3>
|
|
||||||
<p>Require password for HTTP Basic Authentication when visiting the service. Will not have any affect unless <code>--auth-username</code> is also set. If <code>--auth-username</code> is set but <code>--auth-password</code> is not, just leave the password field empty when logging in. You can also just go to <a href="https://username:password@yourserver.net">https://username:password@yourserver.net</a> or <a href="https://username@yourserver.net">https://username@yourserver.net</a> if password is not set instead of typing into the password prompt.</p>
|
|
||||||
<h3 id="-editable">--editable</h3>
|
|
||||||
<p>Enables editable pastas. You will still be able to make finalised pastas but there will be an extra checkbox to make your new pasta editable from the pasta list or the pasta view page.</p>
|
|
||||||
<h3 id="-footer_text-text-">--footer_text [TEXT]</h3>
|
|
||||||
<p>Replaces the default footer text with your own. If you want to hide the footer, use --hide-footer instead.</p>
|
|
||||||
<h3 id="-h-help">-h, --help</h3>
|
|
||||||
<p>Show all commands in the terminal.</p>
|
|
||||||
<h3 id="-hide-footer">--hide-footer</h3>
|
|
||||||
<p>Hides the footer on every page.</p>
|
|
||||||
<h3 id="-hide-header">--hide-header</h3>
|
|
||||||
<p>Hides the navigation bar on every page.</p>
|
|
||||||
<h3 id="-hide-logo">--hide-logo</h3>
|
|
||||||
<p>Hides the MicroBin logo from the navigation bar on every page.</p>
|
|
||||||
<h3 id="-no-listing">--no-listing</h3>
|
|
||||||
<p>Disables the /pastalist endpoint, essentially making all pastas private.</p>
|
|
||||||
<h3 id="-highlightsyntax">--highlightsyntax</h3>
|
|
||||||
<p>Enables syntax highlighting support. When creating a new pasta, a new dropdown selector will be added where you can select your pasta's syntax, or just leave it empty for no highlighting.</p>
|
|
||||||
<h3 id="-p-port-port-">-p, --port [PORT]</h3>
|
|
||||||
<p>Default value: 8080</p>
|
|
||||||
<p>Sets the port for the server will be listening on.</p>
|
|
||||||
<h3 id="-private">--private</h3>
|
|
||||||
<p>Enables private pastas. Adds a new checkbox to make your pasta private, which then won't show up on the pastalist page. With the URL to your pasta, it will still be accessible.</p>
|
|
||||||
<h3 id="-pure-html">--pure-html</h3>
|
|
||||||
<p>Disables main CSS styling, just uses a few in-line stylings for the layout. With this option you will lose dark-mode support.</p>
|
|
||||||
<h3 id="-readonly">--readonly</h3>
|
|
||||||
<p>Disables adding/editing/removing pastas entirely.</p>
|
|
||||||
<h3 id="-title-title-">--title [TITLE]</h3>
|
|
||||||
<p>Replaces "MicroBin" with your title of choice in the navigation bar.</p>
|
|
||||||
<h3 id="-t-threads-threads-">-t, --threads [THREADS]</h3>
|
|
||||||
<p>Default value: 1</p>
|
|
||||||
<p>Number of workers MicroBin is allowed to have. Increase this to the number of CPU cores you have if you want to go beast mode, but for personal use one worker is enough.</p>
|
|
||||||
<h3 id="-v-version">-V, --version</h3>
|
|
||||||
<p>Displays your MicroBin's version information.</p>
|
|
||||||
<h3 id="-wide">--wide</h3>
|
|
||||||
<p>Changes the maximum width of the UI from 720 pixels to 1080 pixels.</p>
|
|
||||||
|
|
||||||
{% include "footer.html" %}
|
|
|
@ -1,26 +1,108 @@
|
||||||
{% include "header.html" %}
|
{% include "header.html" %}
|
||||||
|
|
||||||
<form action="upload" method="POST" enctype="multipart/form-data">
|
<form action="upload" method="POST" enctype="multipart/form-data">
|
||||||
<br>
|
<br>
|
||||||
<div style="display: grid;
|
<div id="settings">
|
||||||
grid-gap: 4px;
|
|
||||||
grid-template-columns: repeat(auto-fit, 234px);
|
|
||||||
grid-template-rows: repeat(1, 100px); ">
|
|
||||||
<div>
|
<div>
|
||||||
<label for="expiration">Expiration</label><br>
|
<label for="expiration">Expiration</label><br>
|
||||||
<select style="width: 100%;" name="expiration" id="expiration">
|
<select style="width: 100%;" name="expiration" id="expiration">
|
||||||
<optgroup label="Expire">
|
<optgroup label="Expire after">
|
||||||
<option value="1min">1 minute</option>
|
{% if args.default_expiry == "1min" %}
|
||||||
<option value="10min">10 minutes</option>
|
<option selected value="1min">
|
||||||
<option value="1hour">1 hour</option>
|
{%- else %}
|
||||||
<option selected value="24hour">24 hours</option>
|
<option value="1min">
|
||||||
<option value="1week">1 week</option>
|
{%- endif %}
|
||||||
|
1 minute
|
||||||
|
</option>
|
||||||
|
{% if args.default_expiry == "10min" %}
|
||||||
|
<option selected value="10min">
|
||||||
|
{%- else %}
|
||||||
|
<option value="10min">
|
||||||
|
{%- endif %}
|
||||||
|
10 minutes
|
||||||
|
</option>
|
||||||
|
{% if args.default_expiry == "1hour" %}
|
||||||
|
<option selected value="1hour">
|
||||||
|
{%- else %}
|
||||||
|
<option value="1hour">
|
||||||
|
{%- endif %}
|
||||||
|
1 hour
|
||||||
|
</option>
|
||||||
|
{% if args.default_expiry == "24hour" %}
|
||||||
|
<option selected value="24hour">
|
||||||
|
{%- else %}
|
||||||
|
<option value="24hour">
|
||||||
|
{%- endif %}
|
||||||
|
24 hours
|
||||||
|
</option>
|
||||||
|
{% if args.default_expiry == "1week" %}
|
||||||
|
<option selected value="1week">
|
||||||
|
{%- else %}
|
||||||
|
<option value="1week">
|
||||||
|
{%- endif %}
|
||||||
|
1 week
|
||||||
|
</option>
|
||||||
</optgroup>
|
</optgroup>
|
||||||
|
{% if !args.no_eternal_pasta %}
|
||||||
<option value="never">Never Expire</option>
|
<option value="never">Never Expire</option>
|
||||||
|
{%- endif %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
{% if args.enable_burn_after %}
|
||||||
|
<div>
|
||||||
|
<label for="expiration">Burn After</label><br>
|
||||||
|
<select style="width: 100%;" name="burn_after" id="burn_after">
|
||||||
|
<optgroup label="Burn after">
|
||||||
|
{% if args.default_burn_after == 1 %}
|
||||||
|
<option selected value="1">
|
||||||
|
{%- else %}
|
||||||
|
<option value="1">
|
||||||
|
{%- endif %}
|
||||||
|
First Read
|
||||||
|
</option>
|
||||||
|
{% if args.default_burn_after == 10 %}
|
||||||
|
<option selected value="10">
|
||||||
|
{%- else %}
|
||||||
|
<option value="10">
|
||||||
|
{%- endif %}
|
||||||
|
10th Read
|
||||||
|
</option>
|
||||||
|
{% if args.default_burn_after == 100 %}
|
||||||
|
<option selected value="100">
|
||||||
|
{%- else %}
|
||||||
|
<option value="100">
|
||||||
|
{%- endif %}
|
||||||
|
100th Read
|
||||||
|
</option>
|
||||||
|
{% if args.default_burn_after == 1000 %}
|
||||||
|
<option selected value="1000">
|
||||||
|
{%- else %}
|
||||||
|
<option value="1000">
|
||||||
|
{%- endif %}
|
||||||
|
1000th Read
|
||||||
|
</option>
|
||||||
|
{% if args.default_burn_after == 10000 %}
|
||||||
|
<option selected value="10000">
|
||||||
|
{%- else %}
|
||||||
|
<option value="10000">
|
||||||
|
{%- endif %}
|
||||||
|
10000th Read
|
||||||
|
</option>
|
||||||
|
</optgroup>
|
||||||
|
{% if args.default_burn_after == 0 %}
|
||||||
|
<option selected value="0">
|
||||||
|
{%- else %}
|
||||||
|
<option value="0">
|
||||||
|
{%- endif %}
|
||||||
|
No Limit
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{% if args.highlightsyntax %}
|
{% if args.highlightsyntax %}
|
||||||
<div>
|
<div>
|
||||||
<label for="syntax-highlight">Syntax Highlighting</label><br>
|
<label for="syntax-highlight">Syntax</label><br>
|
||||||
<select style="width: 100%;" name="syntax-highlight" id="syntax-highlight">
|
<select style="width: 100%;" name="syntax-highlight" id="syntax-highlight">
|
||||||
<option value="none">None</option>
|
<option value="none">None</option>
|
||||||
<optgroup label="Source Code">
|
<optgroup label="Source Code">
|
||||||
|
@ -59,24 +141,10 @@
|
||||||
<input type="hidden" name="syntax-highlight" value="none">
|
<input type="hidden" name="syntax-highlight" value="none">
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{% if !args.no_file_upload %}
|
|
||||||
<div>
|
<div>
|
||||||
<label>File attachment</label>
|
{% if args.editable || args.private %}
|
||||||
<br>
|
<label>Other</label>
|
||||||
<div id="input-bg">
|
{%- endif %}
|
||||||
<input style="width: 100%;" type="file" id="file" name="file">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
<label>Content</label>
|
|
||||||
<br>
|
|
||||||
<textarea style="width: 100%; min-height: 100px" name="content" autofocus></textarea>
|
|
||||||
<br>
|
|
||||||
<div style="display: grid;
|
|
||||||
grid-gap: 4px;
|
|
||||||
grid-template-columns: repeat(auto-fit, 120px);
|
|
||||||
grid-template-rows: repeat(1, 50px); ">
|
|
||||||
{% if args.editable %}
|
{% if args.editable %}
|
||||||
<div>
|
<div>
|
||||||
<input type="checkbox" id="editable" name="editable" value="editable">
|
<input type="checkbox" id="editable" name="editable" value="editable">
|
||||||
|
@ -91,6 +159,20 @@
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<label>Content</label>
|
||||||
|
<br>
|
||||||
|
<textarea style="width: 100%; min-height: 100px" name="content" autofocus></textarea>
|
||||||
|
{% if !args.no_file_upload %}
|
||||||
|
<div>
|
||||||
|
<label for="file" id="attach-file-button-label"><a role="button" id="attach-file-button">Attach File</a></label>
|
||||||
|
<br>
|
||||||
|
<input type="file" id="file" name="file" />
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% if args.readonly %}
|
{% if args.readonly %}
|
||||||
<input style="width: 140px; background-color: limegreen" disabled type="submit" value="Read Only" />
|
<input style="width: 140px; background-color: limegreen" disabled type="submit" value="Read Only" />
|
||||||
{%- else %}
|
{%- else %}
|
||||||
|
@ -101,23 +183,40 @@
|
||||||
<br>
|
<br>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const hiddenFileButton = document.getElementById('file');
|
||||||
|
const attachFileButton = document.getElementById('attach-file-button');
|
||||||
|
|
||||||
|
hiddenFileButton.addEventListener('change', function () {
|
||||||
|
attachFileButton.textContent = "Attached: " + this.files[0].name;
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
input::file-selector-button {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#settings {
|
||||||
|
display: grid;
|
||||||
|
grid-gap: 4px;
|
||||||
|
grid-template-columns: repeat(auto-fit, 150px);
|
||||||
|
grid-template-rows: repeat(1, 90px);
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
height: 3rem;
|
height: 3rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
#file {
|
#attach-file-button-label {
|
||||||
/* max-height: 22px; */
|
padding-top: 1rem;
|
||||||
padding-top: 7px;
|
padding-bottom: 1rem;
|
||||||
padding-bottom: 13px;
|
cursor: pointer;
|
||||||
background: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#input-bg {
|
#file {
|
||||||
background: var(--background);
|
display: none;
|
||||||
overflow: hidden;
|
|
||||||
height: 3rem;
|
|
||||||
border-radius: 6px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
42
templates/info.html
Normal file
42
templates/info.html
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{% include "header.html" %}
|
||||||
|
|
||||||
|
<h2>Welcome to MicroBin</h2>
|
||||||
|
<div style="height: 200px;">
|
||||||
|
<div style="float: left">
|
||||||
|
<h4>Links</h4>
|
||||||
|
<a href="https://docs.microbin.eu" style="margin-right: 1rem">Documentation and Help</a>
|
||||||
|
<br>
|
||||||
|
<a href="https://github.com/szabodanika/microbin" style="margin-right: 1rem">Source Code</a>
|
||||||
|
<br>
|
||||||
|
<a href="https://github.com/szabodanika/microbin/issues" style="margin-right: 1rem">Feedback</a>
|
||||||
|
<br>
|
||||||
|
<a href="microbin.eu/sponsor">Sponsor</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div style="float: right">
|
||||||
|
<h4>Info</h4>
|
||||||
|
<table style="width: 400px">
|
||||||
|
<tr>
|
||||||
|
<td><b>Version</b></td>
|
||||||
|
<td>{{version_string}} </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Status</b></td>
|
||||||
|
<td>{{status}} </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><b>Pastas</b></td>
|
||||||
|
<td>{{pastas.len()}} </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if message != "" %}
|
||||||
|
<h4>Messages</h4>
|
||||||
|
<p>{{message}}</p>
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
{% include "footer.html" %}
|
|
@ -1,26 +1,39 @@
|
||||||
{% include "header.html" %}
|
{% include "header.html" %}
|
||||||
<div style="float: left">
|
<div style="float: left">
|
||||||
<a style="margin-right: 0.5rem" href="{{ args.public_path }}/raw/{{pasta.id_as_animals()}}">Raw Text Content</a>
|
{% if pasta.content != "No Text Content" %}
|
||||||
{% if pasta.file.is_some() %}
|
<button id="copy-text-button" class="copy-text-button" style="margin-right: 0.5rem">
|
||||||
<a style="margin-right: 0.5rem; margin-left: 0.5rem"
|
Copy Text
|
||||||
href="{{ args.public_path }}/file/{{pasta.id_as_animals()}}/{{pasta.file.as_ref().unwrap().name()}}">
|
</button>
|
||||||
Attached file'{{pasta.file.as_ref().unwrap().name()}}' [{{pasta.file.as_ref().unwrap().size}}]
|
<a style="margin-right: 1rem" href="{{ args.public_path }}/raw/{{pasta.id_as_animals()}}">Raw Text
|
||||||
</a>
|
Content</a>
|
||||||
|
{%- endif %}
|
||||||
|
{% if args.qr && args.public_path.to_string() != "" %}
|
||||||
|
<a style="margin-right: 1rem" href="{{ args.public_path }}/qr/{{pasta.id_as_animals()}}">QR</a>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{% if pasta.editable %}
|
{% if pasta.editable %}
|
||||||
<a style="margin-right: 0.5rem; margin-left: 0.5rem"
|
<a style="margin-right: 1rem" href="{{ args.public_path }}/edit/{{pasta.id_as_animals()}}">Edit</a>
|
||||||
href="{{ args.public_path }}/edit/{{pasta.id_as_animals()}}">Edit</a>
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
<a style="margin-right: 0.5rem; margin-left: 0.5rem"
|
<a style="margin-right: 1rem" href="{{ args.public_path }}/remove/{{pasta.id_as_animals()}}">Remove</a>
|
||||||
href="{{ args.public_path }}/remove/{{pasta.id_as_animals()}}">Remove</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div style="float: right">
|
<div style="float: right">
|
||||||
<a href="{{ args.public_path }}/pasta/{{pasta.id_as_animals()}}"><i>{{pasta.id_as_animals()}}</i></a>
|
<a style="margin-right: 0.5rem"
|
||||||
<button id="copy-button" class="copy-button">
|
href="{{ args.public_path }}/pasta/{{pasta.id_as_animals()}}"><i>{{pasta.id_as_animals()}}</i></a>
|
||||||
Copy
|
{% if args.public_path.to_string() != "" %}
|
||||||
|
<button id="copy-url-button" class="copy-url-button" style="margin-right: 0">
|
||||||
|
Copy URL
|
||||||
</button>
|
</button>
|
||||||
|
{%- endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% if pasta.file.is_some() %}
|
||||||
<br>
|
<br>
|
||||||
|
<br>
|
||||||
|
<a href="{{ args.public_path }}/file/{{pasta.id_as_animals()}}/{{pasta.file.as_ref().unwrap().name()}}" download>
|
||||||
|
Download attached file: '{{pasta.file.as_ref().unwrap().name()}}' [{{pasta.file.as_ref().unwrap().size}}]
|
||||||
|
</a>
|
||||||
|
{%- endif %}
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
{% if pasta.content != "No Text Content" %}
|
||||||
<div class="code-container">
|
<div class="code-container">
|
||||||
<div style="clear: both;">
|
<div style="clear: both;">
|
||||||
{% if args.highlightsyntax %}
|
{% if args.highlightsyntax %}
|
||||||
|
@ -30,16 +43,33 @@
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{%- endif %}
|
||||||
|
<div>
|
||||||
|
<p style="font-size: small">Read {{pasta.read_count}} times, last {{pasta.last_read_time_ago_as_string()}}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const btn = document.getElementById("copy-button")
|
const copyURLBtn = document.getElementById("copy-url-button")
|
||||||
|
const copyTextBtn = document.getElementById("copy-text-button")
|
||||||
const content = `{{ pasta.content_escaped() }}`
|
const content = `{{ pasta.content_escaped() }}`
|
||||||
|
const url = `{{ args.public_path }}/pasta/{{pasta.id_as_animals()}}`
|
||||||
|
|
||||||
btn.addEventListener("click", () => {
|
copyURLBtn.addEventListener("click", () => {
|
||||||
navigator.clipboard.writeText(content)
|
navigator.clipboard.writeText(url)
|
||||||
btn.innerHTML = "Copied"
|
copyURLBtn.innerHTML = "Copied"
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
btn.innerHTML = "Copy"
|
copyURLBtn.innerHTML = "Copy URL"
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
|
||||||
|
copyTextBtn.addEventListener("click", () => {
|
||||||
|
navigator.clipboard.writeText(content)
|
||||||
|
copyTextBtn.innerHTML = "Copied"
|
||||||
|
setTimeout(() => {
|
||||||
|
copyTextBtn.innerHTML = "Copy Text"
|
||||||
}, 1000)
|
}, 1000)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -82,14 +112,11 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.copy-button {
|
.copy-text-button,
|
||||||
|
.copy-url-button {
|
||||||
font-size: small;
|
font-size: small;
|
||||||
background-color: var(--links);
|
|
||||||
color: var(--background-body);
|
|
||||||
margin-right: 0.5rem;
|
|
||||||
margin-left: 0.5rem;
|
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
width: 4rem;
|
width: 6rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
{{pasta.expiration_as_string()}}
|
{{pasta.expiration_as_string()}}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a style="margin-right:1rem" id="copy-button"
|
<a style="margin-right:1rem; cursor: pointer;" id="copy-button"
|
||||||
data-url="{{ args.public_path }}/url/{{pasta.id_as_animals()}}">Copy</a>
|
data-url="{{ args.public_path }}/url/{{pasta.id_as_animals()}}">Copy</a>
|
||||||
{% if pasta.editable %}
|
{% if pasta.editable %}
|
||||||
<a style="margin-right:1rem" href="{{ args.public_path }}/edit/{{pasta.id_as_animals()}}">Edit</a>
|
<a style="margin-right:1rem" href="{{ args.public_path }}/edit/{{pasta.id_as_animals()}}">Edit</a>
|
||||||
|
|
7
templates/qr.html
Normal file
7
templates/qr.html
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{% include "header.html" %}
|
||||||
|
|
||||||
|
<div style="text-align: center">
|
||||||
|
{{qr}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% include "footer.html" %}
|
Loading…
Reference in a new issue