rebrand + added dockerfile agian

This commit is contained in:
Schrottkatze 2023-03-05 15:21:12 +01:00
parent d1c583d4b0
commit e4575d7d6e
11 changed files with 901 additions and 81 deletions

58
Cargo.lock generated
View file

@ -1159,6 +1159,35 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "karton"
version = "2.0.0"
dependencies = [
"actix-files",
"actix-multipart",
"actix-web",
"actix-web-httpauth",
"askama",
"askama-filters",
"bytesize",
"chrono",
"clap",
"env_logger",
"futures",
"harsh",
"lazy_static",
"linkify",
"log",
"mime_guess",
"qrcode-generator",
"rand",
"rust-embed",
"sanitize-filename",
"serde",
"serde_json",
"syntect",
]
[[package]]
name = "language-tags"
version = "0.3.2"
@ -1281,35 +1310,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "microbin"
version = "2.0.0"
dependencies = [
"actix-files",
"actix-multipart",
"actix-web",
"actix-web-httpauth",
"askama",
"askama-filters",
"bytesize",
"chrono",
"clap",
"env_logger",
"futures",
"harsh",
"lazy_static",
"linkify",
"log",
"mime_guess",
"qrcode-generator",
"rand",
"rust-embed",
"sanitize-filename",
"serde",
"serde_json",
"syntect",
]
[[package]]
name = "mime"
version = "0.3.16"

View file

@ -1,14 +1,14 @@
[package]
name = "microbin"
name = "karton"
version = "2.0.0"
edition = "2021"
authors = ["Daniel Szabo <daniel.szabo99@outlook.com>", "Jade <jade@schrottkatze.de>"]
authors = ["Jade <jade@schrottkatze.de>", "Daniel Szabo <daniel.szabo99@outlook.com>"]
license = "BSD-3-Clause"
description = "Simple, performant, configurable, entirely self-contained Pastebin and URL shortener."
readme = "README.md"
homepage = "https://gitlab.com/obsidianical/microbin"
repository = "https://gitlab.com/obsidianical/microbin"
keywords = ["pastebin", "pastabin", "microbin", "actix", "selfhosted"]
keywords = ["pastebin", "pastabin", "karton", "microbin", "actix", "selfhosted"]
categories = ["pastebins"]
[dependencies]

37
Dockerfile Normal file
View file

@ -0,0 +1,37 @@
FROM rust:latest as build
WORKDIR /app
COPY . .
RUN \
DEBIAN_FRONTEND=noninteractive \
apt-get update &&\
apt-get -y install ca-certificates tzdata &&\
CARGO_NET_GIT_FETCH_WITH_CLI=true \
cargo build --release
# https://hub.docker.com/r/bitnami/minideb
FROM bitnami/minideb:latest
# microbin will be in /app
WORKDIR /app
# copy time zone info
COPY --from=build \
/usr/share/zoneinfo \
/usr/share/zoneinfo
COPY --from=build \
/etc/ssl/certs/ca-certificates.crt \
/etc/ssl/certs/ca-certificates.crt
# copy built executable
COPY --from=build \
/app/target/release/microbin \
/usr/bin/microbin
# Expose webport used for the webserver to the docker runtime
EXPOSE 8080
ENTRYPOINT ["karton"]

View file

@ -17,133 +17,133 @@ pub struct Args {
/// If unset, HTTP authentication stays disabled.
///
/// WARNING: people opening pastas will have to authenticate too.
#[clap(long, env = "MICROBIN_AUTH_USERNAME")]
#[clap(long, env = "KARTON_AUTH_USERNAME")]
pub auth_username: Option<String>,
/// Set a password for HTTP authentication.
/// If unset, HTTP authentication will not require a password.
/// If `auth_username` is unset, this option will not have any effect.
#[clap(long, env = "MICROBIN_AUTH_PASSWORD")]
#[clap(long, env = "KARTON_AUTH_PASSWORD")]
pub auth_password: Option<String>,
/// Enable the option to make pastas editable.
#[clap(long, env = "MICROBIN_EDITABLE")]
#[clap(long, env = "KARTON_EDITABLE")]
pub editable: bool,
/// The text displayed in the browser navigation bar.
#[clap(long, env = "MICROBIN_TITLE", default_value = " MicroBin")]
#[clap(long, env = "KARTON_TITLE", default_value = " Karton")]
pub title: String,
/// The web interfaces' footer text.
#[clap(long, env = "MICROBIN_FOOTER_TEXT")]
#[clap(long, env = "KARTON_FOOTER_TEXT")]
pub footer_text: Option<String>,
/// Hide the footer of the web interface.
#[clap(long, env = "MICROBIN_HIDE_FOOTER")]
#[clap(long, env = "KARTON_HIDE_FOOTER")]
pub hide_footer: bool,
/// Hide the header of the web interface.
#[clap(long, env = "MICROBIN_HIDE_HEADER")]
#[clap(long, env = "KARTON_HIDE_HEADER")]
pub hide_header: bool,
/// Hide the logo in the header.
#[clap(long, env = "MICROBIN_HIDE_LOGO")]
#[clap(long, env = "KARTON_HIDE_LOGO")]
pub hide_logo: bool,
/// Disable the listing page.
#[clap(long, env = "MICROBIN_NO_LISTING")]
#[clap(long, env = "KARTON_NO_LISTING")]
pub no_listing: bool,
/// Enable syntax highlighting in pastas.
#[clap(long, env = "MICROBIN_HIGHLIGHTSYNTAX")]
#[clap(long, env = "KARTON_HIGHLIGHTSYNTAX")]
pub highlightsyntax: bool,
/// The port to which to bind the server.
#[clap(short, long, env = "MICROBIN_PORT", default_value_t = 8080)]
#[clap(short, long, env = "KARTON_PORT", default_value_t = 8080)]
pub port: u16,
/// The IP adress to bind the server to.
#[clap(short, long, env="MICROBIN_BIND", default_value_t = IpAddr::from([0, 0, 0, 0]))]
#[clap(short, long, env="KARTON_BIND", default_value_t = IpAddr::from([0, 0, 0, 0]))]
pub bind: IpAddr,
/// Enable the option to create private pastas.
#[clap(long, env = "MICROBIN_PRIVATE")]
#[clap(long, env = "KARTON_PRIVATE")]
pub private: bool,
/// Disables most css, apart form some inline styles.
#[clap(long, env = "MICROBIN_PURE_HTML")]
#[clap(long, env = "KARTON_PURE_HTML")]
pub pure_html: bool,
/// The servers public path, making it possible to run microbin behind a reverse proxy subpath.
#[clap(long, env="MICROBIN_PUBLIC_PATH", default_value_t = PublicUrl(String::from("")))]
/// The servers public path, making it possible to run Karton behind a reverse proxy subpath.
#[clap(long, env="KARTON_PUBLIC_PATH", default_value_t = PublicUrl(String::from("")))]
pub public_path: PublicUrl,
/// Enable creation of QR codes of pastas. Requires `public_path` to be set.
#[clap(long, env = "MICROBIN_QR")]
#[clap(long, env = "KARTON_QR")]
pub qr: bool,
/// Disable adding/removing/editing pastas.
#[clap(long, env = "MICROBIN_READONLY")]
#[clap(long, env = "KARTON_READONLY")]
pub readonly: bool,
/// The amount of worker threads that the server is allowed to have.
#[clap(short, long, env = "MICROBIN_THREADS", default_value_t = 1)]
#[clap(short, long, env = "KARTON_THREADS", default_value_t = 1)]
pub threads: u8,
/// Sets a time value for the garbage collector. Pastas that aren't accessed for the given
/// amount of days will be deleted. Set to 0 to disable garbage collection.
#[clap(short, long, env = "MICROBIN_GC_DAYS", default_value_t = 90)]
#[clap(short, long, env = "KARTON_GC_DAYS", default_value_t = 90)]
pub gc_days: u16,
/// Enable the option to delete after a given amount of reads.
#[clap(long, env = "MICROBIN_ENABLE_BURN_AFTER")]
#[clap(long, env = "KARTON_ENABLE_BURN_AFTER")]
pub enable_burn_after: bool,
/// The default amount of reads for the self-delete mechanism.
#[clap(short, long, env = "MICROBIN_DEFAULT_BURN_AFTER", default_value_t = 0)]
#[clap(short, long, env = "KARTON_DEFAULT_BURN_AFTER", default_value_t = 0)]
pub default_burn_after: u16,
/// Changes the UIs maximum width from 720 pixels to 1080.
#[clap(long, env = "MICROBIN_WIDE")]
#[clap(long, env = "KARTON_WIDE")]
pub wide: bool,
/// Disable "Never" expiry setting.
#[clap(long, env = "MICROBIN_NO_ETERNAL_PASTA")]
#[clap(long, env = "KARTON_NO_ETERNAL_PASTA")]
pub no_eternal_pasta: bool,
/// Set the default expiry time value.
#[clap(long, env = "MICROBIN_DEFAULT_EXPIRY", default_value = "24hour")]
#[clap(long, env = "KARTON_DEFAULT_EXPIRY", default_value = "24hour")]
pub default_expiry: String,
/// Disable file uploading.
#[clap(short, long, env = "MICROBIN_NO_FILE_UPLOAD")]
#[clap(short, long, env = "KARTON_NO_FILE_UPLOAD")]
pub no_file_upload: bool,
// TODO: replace with simple path.
/// Replace built-in CSS file with a CSS file provided by the linked URL.
#[clap(long, env = "MICROBIN_CUSTOM_CSS")]
#[clap(long, env = "KARTON_CUSTOM_CSS")]
pub custom_css: Option<String>,
/// Replace built-in animal names file with custom names file for pasta links.
/// The file must be newline seperated.
#[clap(long, env = "MICROBIN_CUSTOM_NAMES")]
#[clap(long, env = "KARTON_CUSTOM_NAMES")]
pub custom_names: Option<PathBuf>,
/// Enable the use of Hash IDs for shorter URLs instead of animal names.
#[clap(long, env = "MICROBIN_HASH_IDS")]
#[clap(long, env = "KARTON_HASH_IDS")]
pub hash_ids: bool,
/// Endpoint for /url/
#[clap(long, env = "MICROBIN_URL_EP", default_value = "url" )]
#[clap(long, env = "KARTON_URL_EP", default_value = "url" )]
pub url_endpoint: String,
/// Endpoint for /pasta/
#[clap(long, env = "MICROBIN_PASTA_EP", default_value = "pasta" )]
#[clap(long, env = "KARTON_PASTA_EP", default_value = "pasta" )]
pub pasta_endpoint: String,
/// Endpoint for /raw/
#[clap(long, env = "MICROBIN_RAW_EP", default_value = "raw" )]
#[clap(long, env = "KARTON_RAW_EP", default_value = "raw" )]
pub raw_endpoint: String,
}

View file

@ -1,5 +1,81 @@
<svg width="63" height="73" viewBox="0 0 63 73" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0.806818 72.1932L12.7045 0.636362H25.0455L19.9659 30.9773C19.6023 33.3409 19.7955 35.4205 20.5455 37.2159C21.3182 38.9886 22.5682 40.3864 24.2955 41.4091C26.0227 42.4091 28.1364 42.9091 30.6364 42.9091C33.1591 42.9091 35.4432 42.4091 37.4886 41.4091C39.5568 40.3864 41.2614 38.9886 42.6023 37.2159C43.9432 35.4205 44.7955 33.3409 45.1591 30.9773L50.2386 0.636362H62.6136L53.8864 53H41.8864L43.2159 45.4318H42.8068C41.1932 47.8409 39.1591 49.7159 36.7045 51.0568C34.25 52.375 31.6477 53.0341 28.8977 53.0341C26.2386 53.0341 23.8864 52.375 21.8409 51.0568C19.8182 49.7159 18.4205 47.8409 17.6477 45.4318H17.2386L12.7727 72.1932H0.806818Z" fill="#868686"/>
<path d="M0.806818 72.1932L12.7045 0.636362H25.0455L19.9659 30.9773C19.6023 33.3409 19.7955 35.4205 20.5455 37.2159C21.3182 38.9886 22.5682 40.3864 24.2955 41.4091C26.0227 42.4091 28.1364 42.9091 30.6364 42.9091C33.1591 42.9091 35.4432 42.4091 37.4886 41.4091C39.5568 40.3864 41.2614 38.9886 42.6023 37.2159C43.9432 35.4205 44.7955 33.3409 45.1591 30.9773L50.2386 0.636362H62.6136L53.8864 53H41.8864L43.2159 45.4318H42.8068C41.1932 47.8409 39.1591 49.7159 36.7045 51.0568C34.25 52.375 31.6477 53.0341 28.8977 53.0341C26.2386 53.0341 23.8864 52.375 21.8409 51.0568C19.8182 49.7159 18.4205 47.8409 17.6477 45.4318H17.2386L12.7727 72.1932H0.806818Z" fill="#868686"/>
<path d="M0.806818 72.1932L12.7045 0.636362H25.0455L19.9659 30.9773C19.6023 33.3409 19.7955 35.4205 20.5455 37.2159C21.3182 38.9886 22.5682 40.3864 24.2955 41.4091C26.0227 42.4091 28.1364 42.9091 30.6364 42.9091C33.1591 42.9091 35.4432 42.4091 37.4886 41.4091C39.5568 40.3864 41.2614 38.9886 42.6023 37.2159C43.9432 35.4205 44.7955 33.3409 45.1591 30.9773L50.2386 0.636362H62.6136L53.8864 53H41.8864L43.2159 45.4318H42.8068C41.1932 47.8409 39.1591 49.7159 36.7045 51.0568C34.25 52.375 31.6477 53.0341 28.8977 53.0341C26.2386 53.0341 23.8864 52.375 21.8409 51.0568C19.8182 49.7159 18.4205 47.8409 17.6477 45.4318H17.2386L12.7727 72.1932H0.806818Z" fill="#868686"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="31.999998"
height="31.999998"
viewBox="0 0 8.4666661 8.4666661"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="logo.svg"
inkscape:export-filename="logo.png"
inkscape:export-xdpi="384"
inkscape:export-ydpi="384"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#4a4a55"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
showgrid="true"
inkscape:zoom="19.556004"
inkscape:cx="6.0339524"
inkscape:cy="16.721207"
inkscape:window-width="2560"
inkscape:window-height="1036"
inkscape:window-x="0"
inkscape:window-y="44"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid182"
visible="true" />
</sodipodi:namedview>
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g14438"
inkscape:label="Box">
<path
style="color:#000000;fill:#f7f7ff;-inkscape-stroke:none"
d="M 1.984375,3.8066406 V 6.2207031 L 4.2324219,7.34375 4.2929687,7.3144531 6.4824219,6.2207031 V 3.8066406 l -2.25,1.125 z m 0.2636719,0.4296875 1.984375,0.9921875 1.984375,-0.9921875 V 6.0566406 L 4.2324219,7.0488281 2.2480469,6.0566406 Z"
id="path2056" />
<path
id="path3512"
style="color:#000000;fill:#f7f7ff;fill-opacity:1;-inkscape-stroke:none"
d="M 4.3651082,5.3087199 4.2322998,5.3748657 4.1015584,5.3097534 v 1.5260051 l 0.1328085,0.066663 0.1307413,-0.065629 z" />
</g>
<g
id="g18197"
inkscape:label="Cat"
style="display:inline">
<path
id="path14440"
style="color:#000000;display:inline;fill:#f7f7ff;fill-opacity:1;-inkscape-stroke:none"
d="M 4.6663818,2.8716593 4.3862956,3.0959351 h 0.045475 L 5.4063883,3.291272 5.709729,4.0462646 5.9464071,3.9279256 5.5996582,3.058728 Z M 2.6199951,2.9434896 2.4618652,3.8989868 2.7088786,4.0230103 2.8571899,3.1331421 Z" />
<path
style="color:#000000;fill:#f7f7ff;-inkscape-stroke:none"
d="m 2.1308594,1.0234375 0.2773437,1.109375 v 0.4707031 l 1.1894532,0.953125 0.083984,-0.066406 1.1074219,-0.8867188 V 2.1328125 L 5.0664062,1.0234375 3.9902344,1.5605469 H 3.2070313 Z M 2.5273438,1.5175781 3.1445313,1.8261719 H 4.0527344 L 4.6699219,1.5175781 4.5234375,2.0996094 V 2.4765625 L 3.5976563,3.2167969 2.671875,2.4765625 V 2.0996094 Z"
id="path14903" />
</g>
<path
id="path22977"
style="color:#000000;fill:#f7f7ff;fill-opacity:1;-inkscape-stroke:none"
d="M 5.94434,3.5646403 6.0657796,3.8684977 6.3086589,3.7470581 Z m -3.5723918,0.074414 -0.2149739,0.1074869 0.181901,0.090951 z"
sodipodi:nodetypes="cccccccc" />
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

81
templates/assets/logo.svg Normal file
View file

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="32"
height="32"
viewBox="0 0 8.4666666 8.4666666"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="microbin-logo.svg"
inkscape:export-filename="microbin-logo-exp.svg"
inkscape:export-xdpi="144"
inkscape:export-ydpi="144"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#4a4a55"
bordercolor="#eeeeee"
borderopacity="1"
inkscape:showpageshadow="0"
inkscape:pageopacity="0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#505050"
inkscape:document-units="mm"
showgrid="true"
inkscape:zoom="19.556004"
inkscape:cx="6.0339524"
inkscape:cy="16.721207"
inkscape:window-width="2560"
inkscape:window-height="1036"
inkscape:window-x="0"
inkscape:window-y="44"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid182"
visible="true" />
</sodipodi:namedview>
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g14438"
inkscape:label="Box">
<path
style="color:#000000;fill:#f7f7ff;-inkscape-stroke:none"
d="M 1.984375,3.8066406 V 6.2207031 L 4.2324219,7.34375 4.2929687,7.3144531 6.4824219,6.2207031 V 3.8066406 l -2.25,1.125 z m 0.2636719,0.4296875 1.984375,0.9921875 1.984375,-0.9921875 V 6.0566406 L 4.2324219,7.0488281 2.2480469,6.0566406 Z"
id="path2056" />
<path
id="path3512"
style="color:#000000;fill:#f7f7ff;-inkscape-stroke:none;fill-opacity:1"
d="M 4.3651082 5.3087199 L 4.2322998 5.3748657 L 4.1015584 5.3097534 L 4.1015584 6.8357585 L 4.2343669 6.9024211 L 4.3651082 6.836792 L 4.3651082 5.3087199 z " />
</g>
<g
id="g18197"
inkscape:label="Cat"
style="display:inline">
<path
id="path14440"
style="color:#000000;display:inline;fill:#f7f7ff;-inkscape-stroke:none;fill-opacity:1"
d="M 4.6663818,2.8716593 4.3862956,3.0959351 h 0.045475 L 5.4063883,3.291272 5.709729,4.0462646 5.9464071,3.9279256 5.5996582,3.058728 Z M 2.6199951,2.9434896 2.4618652,3.8989868 2.7088786,4.0230103 2.8571899,3.1331421 Z" />
<path
style="color:#000000;fill:#f7f7ff;-inkscape-stroke:none"
d="m 2.1308594,1.0234375 0.2773437,1.109375 v 0.4707031 l 1.1894532,0.953125 0.083984,-0.066406 1.1074219,-0.8867188 V 2.1328125 L 5.0664062,1.0234375 3.9902344,1.5605469 H 3.2070313 Z M 2.5273438,1.5175781 3.1445313,1.8261719 H 4.0527344 L 4.6699219,1.5175781 4.5234375,2.0996094 V 2.4765625 L 3.5976563,3.2167969 2.671875,2.4765625 V 2.0996094 Z"
id="path14903" />
</g>
<path
id="path22977"
style="color:#000000;fill:#f7f7ff;-inkscape-stroke:none;fill-opacity:1"
d="M 5.94434,3.5646403 6.0657796,3.8684977 6.3086589,3.7470581 Z m -3.5723918,0.074414 -0.2149739,0.1074869 0.181901,0.090951 z"
sodipodi:nodetypes="cccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.3 KiB

File diff suppressed because one or more lines are too long

View file

@ -3,7 +3,7 @@
<hr>
<p style="font-size: smaller">
{% if args.footer_text.as_ref().is_none() %}
<a href="https://microbin.eu">MicroBin</a> by Dániel Szabó and the FOSS Community.
<b>Karton</b> by Schrottkatze, based on <a href="https://microbin.eu">MicroBin</a> by Dániel Szabó and the FOSS Community.
Let's keep the Web <b>compact</b>, <b>accessible</b> and <b>humane</b>!
{%- else %}
{{ args.footer_text.as_ref().unwrap() }}

View file

@ -44,15 +44,13 @@
<b style="margin-right: 0.5rem">
{% if !args.hide_logo %}
<a href="{{ args.public_path }}/">
<img
width=26
style="margin-bottom: -6px; margin-right: 0.5rem;"
src="{{ args.public_path }}/static/logo.png"
>
</a>
<a href="{{ args.public_path }}/"><img
width=48
style="margin-bottom: -12px;"
src="{{ args.public_path }}/static/logo.png"
></a>
{%- endif %}
MicroBin
{{ args.title }}
</b>
<a href="{{ args.public_path }}/" style="margin-right: 0.5rem; margin-left: 0.5rem">New

View file

@ -179,11 +179,14 @@
{% endif %}
{% if args.readonly %}
<b>
<input style="width: 140px; float: right; background-color: #0076d18f;" disabled type="submit"
<!--<input style="width: 140px; float: right; background-color: #0076d18f;" disabled type="submit"-->
<!--value="Read Only" /></b>-->
<input style="width: 140px; float: right" disabled type="submit"
value="Read Only" /></b>
{%- else %}
<b>
<input style="width: 140px; float: right; background-color: #0076d18f;" type="submit" value="Save" />
<!--<input style="width: 140px; float: right; background-color: #0076d18f;" type="submit" value="Save" />-->
<input style="width: 140px; float: right" type="submit" value="Save" />
</b>
{%- endif %}
</div>
@ -246,4 +249,4 @@
}
</style>
{% include "footer.html" %}
{% include "footer.html" %}