Skip to content

Commit

Permalink
Replaced "pasta" on all user-facing places with "upload"
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
szabodanika committed Jul 11, 2023
1 parent a46312b commit 4a7360b
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 66 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions src/endpoints/auth_pasta.rs → src/endpoints/auth_upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();

Expand All @@ -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(),
Expand All @@ -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 {
Expand All @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/endpoints/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
8 changes: 1 addition & 7 deletions src/endpoints/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
),
Expand Down
8 changes: 4 additions & 4 deletions src/endpoints/pastalist.rs → src/endpoints/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
}
Expand Down
10 changes: 5 additions & 5 deletions src/endpoints/pasta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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(""))
}
Expand Down Expand Up @@ -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}")]
Expand Down Expand Up @@ -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> {
Expand Down
4 changes: 2 additions & 2 deletions src/endpoints/qr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
};

Expand Down
16 changes: 3 additions & 13 deletions src/endpoints/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
}
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
),
Expand Down
30 changes: 15 additions & 15 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions templates/admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ <h3>Uploads</h3>
<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()}}
Expand Down Expand Up @@ -200,7 +200,7 @@ <h3>URL Redirects</h3>
<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()}}
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion templates/edit.html
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
3 changes: 1 addition & 2 deletions templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
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;
Expand Down
6 changes: 3 additions & 3 deletions templates/pastalist.html → templates/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ <h3>Uploads</h3>
<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>
Expand Down Expand Up @@ -125,7 +125,7 @@ <h3>URL Redirects</h3>
<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() == "" %}
Expand Down
4 changes: 2 additions & 2 deletions templates/qr.html
Original file line number Diff line number Diff line change
@@ -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>


Expand All @@ -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 %}
Expand Down
4 changes: 2 additions & 2 deletions templates/pasta.html → templates/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -148,7 +148,7 @@
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();
Expand Down

0 comments on commit 4a7360b

Please sign in to comment.