Merge branch 'master' into public-path
This commit is contained in:
commit
43061699f5
11 changed files with 102 additions and 14 deletions
|
@ -65,6 +65,9 @@ pub struct Args {
|
|||
|
||||
#[clap(long, env="MICROBIN_WIDE")]
|
||||
pub wide: bool,
|
||||
|
||||
#[clap(short, long, env="MICROBIN_NO_FILE_UPLOAD")]
|
||||
pub no_file_upload: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
|
@ -83,4 +86,3 @@ impl FromStr for PublicUrl {
|
|||
let uri = s.strip_suffix('/').unwrap_or(s).to_owned();
|
||||
Ok(PublicUrl(uri))
|
||||
}
|
||||
}
|
|
@ -106,6 +106,10 @@ pub async fn create(
|
|||
continue;
|
||||
}
|
||||
"file" => {
|
||||
if ARGS.no_file_upload {
|
||||
continue;
|
||||
}
|
||||
|
||||
let path = field.content_disposition().get_filename();
|
||||
|
||||
let path = match path {
|
||||
|
|
|
@ -8,6 +8,12 @@ struct WaterCSS<'a> {
|
|||
_marker: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "favicon.svg", escape = "none")]
|
||||
struct Favicon<'a> {
|
||||
_marker: PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
#[get("/static/{resource}")]
|
||||
pub async fn static_resources(resource_id: web::Path<String>) -> HttpResponse {
|
||||
match resource_id.into_inner().as_str() {
|
||||
|
@ -18,6 +24,13 @@ pub async fn static_resources(resource_id: web::Path<String>) -> HttpResponse {
|
|||
.render()
|
||||
.unwrap(),
|
||||
),
|
||||
"favicon.svg" => HttpResponse::Ok().content_type("image/svg+xml").body(
|
||||
Favicon {
|
||||
_marker: Default::default(),
|
||||
}
|
||||
.render()
|
||||
.unwrap(),
|
||||
),
|
||||
_ => HttpResponse::NotFound().content_type("text/html").finish(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@ impl Pasta {
|
|||
pub fn content_not_highlighted(&self) -> String {
|
||||
html_highlight(&self.content, "txt")
|
||||
}
|
||||
|
||||
pub fn content_escaped(&self) -> String {
|
||||
self.content.replace("`", "\\`").replace("$", "\\$")
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Pasta {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue