mirror of
https://github.com/szabodanika/microbin
synced 2024-11-10 03:34:17 +00:00
Replaced "pasta" on all user-facing places with "upload"
- We understand what a pasta is, but let's avoid the situation when you send a link to your mom that ends with microbin.eu/pasta/dog-bat-cat and they misunderstand it. - Also replaced /pastalist with just /list - Internally kept "pasta" instead of "upload" to confuse everyone adopting MicroBin after v2
This commit is contained in:
parent
a46312bf62
commit
4a7360b90e
17 changed files with 49 additions and 66 deletions
|
@ -8,7 +8,7 @@ description = "Simple, performant, configurable, entirely self-contained Pastebi
|
|||
readme = "README.md"
|
||||
homepage = "https://microbin.eu"
|
||||
repository = "https://github.com/szabodanika/microbin"
|
||||
keywords = ["pastebin", "pastabin", "microbin", "actix", "selfhosted"]
|
||||
keywords = ["pastebin", "filesharing", "microbin", "actix", "selfhosted"]
|
||||
categories = ["pastebins"]
|
||||
|
||||
[dependencies]
|
||||
|
|
|
@ -44,7 +44,7 @@ On our website [microbin.eu](https://microbin.eu) you will find the following:
|
|||
- Raw text serving (eg. `server.com/raw/pig-dog-cat`)
|
||||
- QR code support
|
||||
- URL shortening and redirection
|
||||
- Animal names instead of random numbers for pasta identifiers (64 animals)
|
||||
- Animal names instead of random numbers for upload identifiers (64 animals)
|
||||
- SQLite and JSON database support
|
||||
- Private and public, editable and uneditable, automatically and never expiring uploads
|
||||
- Automatic dark mode and custom styling support with very little CSS and only vanilla JS (see [`water.css`](https://github.com/kognise/water.css))
|
||||
|
|
|
@ -8,7 +8,7 @@ use actix_web::{get, web, HttpResponse};
|
|||
use askama::Template;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "auth_pasta.html")]
|
||||
#[template(path = "auth_upload.html")]
|
||||
struct AuthPasta<'a> {
|
||||
args: &'a Args,
|
||||
id: String,
|
||||
|
@ -19,7 +19,7 @@ struct AuthPasta<'a> {
|
|||
}
|
||||
|
||||
#[get("/auth/{id}")]
|
||||
pub async fn auth_pasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||
pub async fn auth_upload(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||
// get access to the pasta collection
|
||||
let mut pastas = data.pastas.lock().unwrap();
|
||||
|
||||
|
@ -40,7 +40,7 @@ pub async fn auth_pasta(data: web::Data<AppState>, id: web::Path<String>) -> Htt
|
|||
status: String::from(""),
|
||||
encrypted_key: pasta.encrypted_key.to_owned().unwrap_or_default(),
|
||||
encrypt_client: pasta.encrypt_client,
|
||||
path: String::from("pasta"),
|
||||
path: String::from("upload"),
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
|
@ -54,7 +54,7 @@ pub async fn auth_pasta(data: web::Data<AppState>, id: web::Path<String>) -> Htt
|
|||
}
|
||||
|
||||
#[get("/auth/{id}/{status}")]
|
||||
pub async fn auth_pasta_with_status(
|
||||
pub async fn auth_upload_with_status(
|
||||
data: web::Data<AppState>,
|
||||
param: web::Path<(String, String)>,
|
||||
) -> HttpResponse {
|
||||
|
@ -80,7 +80,7 @@ pub async fn auth_pasta_with_status(
|
|||
status,
|
||||
encrypted_key: pasta.encrypted_key.to_owned().unwrap_or_default(),
|
||||
encrypt_client: pasta.encrypt_client,
|
||||
path: String::from("pasta"),
|
||||
path: String::from("upload"),
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
|
@ -326,7 +326,7 @@ pub async fn create(
|
|||
Ok(HttpResponse::Found()
|
||||
.append_header((
|
||||
"Location",
|
||||
format!("{}/pasta/{}", ARGS.public_path_as_str(), slug),
|
||||
format!("{}/upload/{}", ARGS.public_path_as_str(), slug),
|
||||
))
|
||||
.finish())
|
||||
}
|
||||
|
|
|
@ -304,12 +304,6 @@ pub async fn post_edit(
|
|||
id: web::Path<String>,
|
||||
mut payload: Multipart,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
if ARGS.readonly {
|
||||
return Ok(HttpResponse::Found()
|
||||
.append_header(("Location", format!("{}/", ARGS.public_path_as_str())))
|
||||
.finish());
|
||||
}
|
||||
|
||||
let id = if ARGS.hash_ids {
|
||||
hashid_to_u64(&id).unwrap_or(0)
|
||||
} else {
|
||||
|
@ -372,7 +366,7 @@ pub async fn post_edit(
|
|||
.append_header((
|
||||
"Location",
|
||||
format!(
|
||||
"{}/pasta/{}",
|
||||
"{}/upload/{}",
|
||||
ARGS.public_path_as_str(),
|
||||
pastas[i].id_as_animals()
|
||||
),
|
||||
|
|
|
@ -7,13 +7,13 @@ use crate::util::misc::remove_expired;
|
|||
use crate::AppState;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "pastalist.html")]
|
||||
struct PastaListTemplate<'a> {
|
||||
#[template(path = "list.html")]
|
||||
struct ListTemplate<'a> {
|
||||
pastas: &'a Vec<Pasta>,
|
||||
args: &'a Args,
|
||||
}
|
||||
|
||||
#[get("/pastalist")]
|
||||
#[get("/list")]
|
||||
pub async fn list(data: web::Data<AppState>) -> HttpResponse {
|
||||
if ARGS.no_listing {
|
||||
return HttpResponse::Found()
|
||||
|
@ -29,7 +29,7 @@ pub async fn list(data: web::Data<AppState>) -> HttpResponse {
|
|||
pastas.sort_by(|a, b| b.created.cmp(&a.created));
|
||||
|
||||
HttpResponse::Ok().content_type("text/html").body(
|
||||
PastaListTemplate {
|
||||
ListTemplate {
|
||||
pastas: &pastas,
|
||||
args: &ARGS,
|
||||
}
|
|
@ -14,7 +14,7 @@ use magic_crypt::{new_magic_crypt, MagicCryptTrait};
|
|||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "pasta.html", escape = "none")]
|
||||
#[template(path = "upload.html", escape = "none")]
|
||||
struct PastaTemplate<'a> {
|
||||
pasta: &'a Pasta,
|
||||
args: &'a Args,
|
||||
|
@ -121,7 +121,7 @@ fn pastaresponse(
|
|||
.body(ErrorTemplate { args: &ARGS }.render().unwrap())
|
||||
}
|
||||
|
||||
#[post("/pasta/{id}")]
|
||||
#[post("/upload/{id}")]
|
||||
pub async fn postpasta(
|
||||
data: web::Data<AppState>,
|
||||
id: web::Path<String>,
|
||||
|
@ -159,7 +159,7 @@ pub async fn postshortpasta(
|
|||
Ok(pastaresponse(data, id, password))
|
||||
}
|
||||
|
||||
#[get("/pasta/{id}")]
|
||||
#[get("/upload/{id}")]
|
||||
pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||
pastaresponse(data, id, String::from(""))
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ pub async fn getrawpasta(
|
|||
// otherwise send pasta not found error as raw text
|
||||
Ok(HttpResponse::NotFound()
|
||||
.content_type("text/html")
|
||||
.body(String::from("Pasta not found! :-(")))
|
||||
.body(String::from("Upload not found! :-(")))
|
||||
}
|
||||
|
||||
#[post("/raw/{id}")]
|
||||
|
@ -421,7 +421,7 @@ pub async fn postrawpasta(
|
|||
// otherwise send pasta not found error as raw text
|
||||
Ok(HttpResponse::NotFound()
|
||||
.content_type("text/html")
|
||||
.body(String::from("Pasta not found! :-(")))
|
||||
.body(String::from("Upload not found! :-(")))
|
||||
}
|
||||
|
||||
fn decrypt(text_str: &str, key_str: &str) -> Result<String, magic_crypt::MagicCryptError> {
|
||||
|
|
|
@ -42,13 +42,13 @@ pub async fn getqr(data: web::Data<AppState>, id: web::Path<String>) -> HttpResp
|
|||
}
|
||||
|
||||
if found {
|
||||
// generate the QR code as an SVG - if its a file or text pastas, this will point to the /pasta endpoint, otherwise to the /url endpoint, essentially directly taking the user to the url stored in the pasta
|
||||
// generate the QR code as an SVG - if its a file or text pastas, this will point to the /upload endpoint, otherwise to the /url endpoint, essentially directly taking the user to the url stored in the pasta
|
||||
let svg: String = match pastas[index].pasta_type.as_str() {
|
||||
"url" => misc::string_to_qr_svg(
|
||||
format!("{}/url/{}", &ARGS.public_path_as_str(), &id).as_str(),
|
||||
),
|
||||
_ => misc::string_to_qr_svg(
|
||||
format!("{}/pasta/{}", &ARGS.public_path_as_str(), &id).as_str(),
|
||||
format!("{}/upload/{}", &ARGS.public_path_as_str(), &id).as_str(),
|
||||
),
|
||||
};
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ use std::fs;
|
|||
|
||||
#[get("/remove/{id}")]
|
||||
pub async fn remove(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||
|
||||
let mut pastas = data.pastas.lock().unwrap();
|
||||
|
||||
let id = if ARGS.hash_ids {
|
||||
|
@ -67,10 +66,7 @@ pub async fn remove(data: web::Data<AppState>, id: web::Path<String>) -> HttpRes
|
|||
delete(Some(&pastas), Some(id));
|
||||
|
||||
return HttpResponse::Found()
|
||||
.append_header((
|
||||
"Location",
|
||||
format!("{}/pastalist", ARGS.public_path_as_str()),
|
||||
))
|
||||
.append_header(("Location", format!("{}/list", ARGS.public_path_as_str())))
|
||||
.finish();
|
||||
}
|
||||
}
|
||||
|
@ -88,12 +84,6 @@ pub async fn post_remove(
|
|||
id: web::Path<String>,
|
||||
mut payload: Multipart,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
if ARGS.readonly {
|
||||
return Ok(HttpResponse::Found()
|
||||
.append_header(("Location", format!("{}/", ARGS.public_path_as_str())))
|
||||
.finish());
|
||||
}
|
||||
|
||||
let id = if ARGS.hash_ids {
|
||||
hashid_to_u64(&id).unwrap_or(0)
|
||||
} else {
|
||||
|
@ -153,7 +143,7 @@ pub async fn post_remove(
|
|||
return Ok(HttpResponse::Found()
|
||||
.append_header((
|
||||
"Location",
|
||||
format!("{}/pastalist", ARGS.public_path_as_str()),
|
||||
format!("{}/list", ARGS.public_path_as_str()),
|
||||
))
|
||||
.finish());
|
||||
} else {
|
||||
|
@ -178,7 +168,7 @@ pub async fn post_remove(
|
|||
.append_header((
|
||||
"Location",
|
||||
format!(
|
||||
"{}/pasta/{}",
|
||||
"{}/upload/{}",
|
||||
ARGS.public_path_as_str(),
|
||||
pastas[i].id_as_animals()
|
||||
),
|
||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -2,8 +2,8 @@ extern crate core;
|
|||
|
||||
use crate::args::ARGS;
|
||||
use crate::endpoints::{
|
||||
admin, auth_admin, auth_pasta, create, edit, errors, file, guide, pasta as pasta_endpoint,
|
||||
pastalist, qr, remove, static_resources,
|
||||
admin, auth_admin, auth_upload, create, edit, errors, file, guide, list,
|
||||
pasta as pasta_endpoint, qr, remove, static_resources,
|
||||
};
|
||||
use crate::pasta::Pasta;
|
||||
use crate::util::db::read_all;
|
||||
|
@ -37,14 +37,14 @@ pub mod util {
|
|||
pub mod endpoints {
|
||||
pub mod admin;
|
||||
pub mod auth_admin;
|
||||
pub mod auth_pasta;
|
||||
pub mod auth_upload;
|
||||
pub mod create;
|
||||
pub mod edit;
|
||||
pub mod errors;
|
||||
pub mod file;
|
||||
pub mod guide;
|
||||
pub mod list;
|
||||
pub mod pasta;
|
||||
pub mod pastalist;
|
||||
pub mod qr;
|
||||
pub mod remove;
|
||||
pub mod static_resources;
|
||||
|
@ -105,17 +105,17 @@ async fn main() -> std::io::Result<()> {
|
|||
.service(create::index)
|
||||
.service(guide::guide)
|
||||
.service(auth_admin::auth_admin)
|
||||
.service(auth_pasta::auth_file_with_status)
|
||||
.service(auth_upload::auth_file_with_status)
|
||||
.service(auth_admin::auth_admin_with_status)
|
||||
.service(auth_pasta::auth_pasta_with_status)
|
||||
.service(auth_pasta::auth_raw_pasta_with_status)
|
||||
.service(auth_pasta::auth_edit_private_with_status)
|
||||
.service(auth_pasta::auth_remove_private_with_status)
|
||||
.service(auth_pasta::auth_file)
|
||||
.service(auth_pasta::auth_pasta)
|
||||
.service(auth_pasta::auth_raw_pasta)
|
||||
.service(auth_pasta::auth_edit_private)
|
||||
.service(auth_pasta::auth_remove_private)
|
||||
.service(auth_upload::auth_upload_with_status)
|
||||
.service(auth_upload::auth_raw_pasta_with_status)
|
||||
.service(auth_upload::auth_edit_private_with_status)
|
||||
.service(auth_upload::auth_remove_private_with_status)
|
||||
.service(auth_upload::auth_file)
|
||||
.service(auth_upload::auth_upload)
|
||||
.service(auth_upload::auth_raw_pasta)
|
||||
.service(auth_upload::auth_edit_private)
|
||||
.service(auth_upload::auth_remove_private)
|
||||
.service(pasta_endpoint::getpasta)
|
||||
.service(pasta_endpoint::postpasta)
|
||||
.service(pasta_endpoint::getshortpasta)
|
||||
|
@ -140,7 +140,7 @@ async fn main() -> std::io::Result<()> {
|
|||
.wrap(middleware::Logger::default())
|
||||
.service(remove::remove)
|
||||
.service(remove::post_remove)
|
||||
.service(pastalist::list)
|
||||
.service(list::list)
|
||||
.service(create::index_with_status)
|
||||
.wrap(Condition::new(
|
||||
ARGS.auth_basic_username.is_some()
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
<tr>
|
||||
<td>
|
||||
<a
|
||||
href="{{ args.public_path_as_str()}}/pasta/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
href="{{ args.public_path_as_str()}}/upload/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.created_as_string()}}
|
||||
|
@ -200,7 +200,7 @@
|
|||
<tr>
|
||||
<td>
|
||||
<a
|
||||
href="{{ args.public_path_as_str()}}/pasta/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
href="{{ args.public_path_as_str()}}/upload/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{pasta.created_as_string()}}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% include "header.html" %}
|
||||
<form action="/{{ path }}/{{ pasta.id_as_animals() }}" method="POST" enctype="multipart/form-data">
|
||||
<h4>
|
||||
Editing pasta '{{ pasta.id_as_animals() }}'
|
||||
Editing upload '{{ pasta.id_as_animals() }}'
|
||||
</h4>
|
||||
<label>Content</label>
|
||||
<br>
|
||||
|
|
|
@ -48,8 +48,7 @@ padding-right:0.5rem; line-height: 1.5; font-size: 1.1em; padding-top: 2rem;">
|
|||
margin-left: 0.5rem">New</a>
|
||||
|
||||
{% if !args.no_listing %}
|
||||
<a href="{{ args.public_path_as_str() }}/pastalist"
|
||||
style="margin-right: 0.5rem; margin-left: 0.5rem">List</a>
|
||||
<a href="{{ args.public_path_as_str() }}/list" style="margin-right: 0.5rem; margin-left: 0.5rem">List</a>
|
||||
{%- endif %}
|
||||
|
||||
<a href="{{ args.public_path_as_str() }}/guide" style="margin-right: 0.5rem;
|
||||
|
|
|
@ -42,13 +42,13 @@
|
|||
<tr>
|
||||
<td>
|
||||
<a
|
||||
href="{{ args.public_path_as_str()}}/pasta/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
href="{{ args.public_path_as_str()}}/upload/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if args.public_path_as_str() != "" %}
|
||||
{% if args.short_path_as_str() == "" %}
|
||||
<a style="margin-right:1rem; cursor: pointer;" class="copy-button" null
|
||||
data-url="{{ args.public_path_as_str()}}/pasta/{{pasta.id_as_animals()}}">Copy</a>
|
||||
data-url="{{ args.public_path_as_str()}}/upload/{{pasta.id_as_animals()}}">Copy</a>
|
||||
{% else %}
|
||||
<a style="margin-right:1rem; cursor: pointer;" class="copy-button" data-url="{{ args.short_path_as_str()
|
||||
}}/p/{{pasta.id_as_animals()}}">Copy</a>
|
||||
|
@ -125,7 +125,7 @@
|
|||
<tr>
|
||||
<td>
|
||||
<a
|
||||
href="{{ args.public_path_as_str() }}/pasta/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
href="{{ args.public_path_as_str() }}/upload/{{pasta.id_as_animals()}}">{{pasta.id_as_animals()}}</a>
|
||||
</td>
|
||||
<td>
|
||||
{% if args.short_path_as_str() == "" %}
|
|
@ -1,7 +1,7 @@
|
|||
{% include "header.html" %}
|
||||
|
||||
<div style="float: left">
|
||||
<a href="{{ args.public_path_as_str() }}/pasta/{{pasta.id_as_animals()}}">Back to Pasta</a>
|
||||
<a href="{{ args.public_path_as_str() }}/upload/{{pasta.id_as_animals()}}">Back to Upload</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
|||
{{qr}}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ args.public_path_as_str() }}/pasta/{{pasta.id_as_animals()}}">
|
||||
<a href="{{ args.public_path_as_str() }}/upload/{{pasta.id_as_animals()}}">
|
||||
{{qr}}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
</div>
|
||||
<div style="float: right">
|
||||
<a style="margin-right: 0.5rem"
|
||||
href="{{ args.public_path_as_str() }}/pasta/{{pasta.id_as_animals()}}"><i>{{pasta.id_as_animals()}}</i></a>
|
||||
href="{{ args.public_path_as_str() }}/upload/{{pasta.id_as_animals()}}"><i>{{pasta.id_as_animals()}}</i></a>
|
||||
{% if args.public_path_as_str() != "" %}
|
||||
<button id="copy-url-button" class="small-button" style="margin-right: 0">
|
||||
Copy URL
|
||||
|
@ -148,7 +148,7 @@ pasta.file_embeddable() && !pasta.encrypt_client %}
|
|||
const copyRedirectBtn = document.getElementById("copy-redirect-button")
|
||||
var content = `{{ pasta.content_escaped() }}`
|
||||
const contentElement = document.getElementById("code");
|
||||
const url = (`{{ args.short_path_as_str()}}` === "") ? `{{ args.public_path_as_str() }}/pasta/{{pasta.id_as_animals()}}` : `{{ args.short_path_as_str()}}/p/{{pasta.id_as_animals()}}`
|
||||
const url = (`{{ args.short_path_as_str()}}` === "") ? `{{ args.public_path_as_str() }}/upload/{{pasta.id_as_animals()}}` : `{{ args.short_path_as_str()}}/p/{{pasta.id_as_animals()}}`
|
||||
const redirect_url = (`{{ args.short_path_as_str()}}` === "") ? `{{ args.public_path_as_str() }}/url/{{pasta.id_as_animals()}}` : `{{ args.short_path_as_str()}}/u/{{pasta.id_as_animals()}}`
|
||||
|
||||
const te = new TextEncoder();
|
Loading…
Reference in a new issue