remove /code

This commit is contained in:
Kay Faraday 2024-07-23 01:30:59 +00:00
parent 85823d3ade
commit 2644cc7f5a
3 changed files with 2 additions and 54 deletions

View File

@ -1,33 +0,0 @@
use std::fs::File;
use std::io;
use std::path::{Path, PathBuf};
use std::process::Command;
use zip::ZipWriter;
fn main() {
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let output = Command::new("cargo")
.args(["package", "--list", "--allow-dirty"])
.output()
.unwrap();
if !output.status.success() {
panic!("cargo package failed");
}
let mut writer = ZipWriter::new(File::create(out_dir.join("source.zip")).unwrap());
for path in String::from_utf8(output.stdout).unwrap().lines() {
if path == "Cargo.toml.orig" {
continue;
}
writer.start_file(path, Default::default()).unwrap();
io::copy(
&mut File::open(Path::new(env!("CARGO_MANIFEST_DIR")).join(path)).unwrap(),
&mut writer,
)
.unwrap();
}
writer.finish().unwrap();
}

View File

@ -28,7 +28,6 @@ fn rocket() -> _ {
"/", "/",
routes![ routes![
instance, instance,
trivial::code,
trivial::copy_js, trivial::copy_js,
trivial::css, trivial::css,
trivial::favicon_ico, trivial::favicon_ico,

View File

@ -3,9 +3,9 @@
use crate::Html; use crate::Html;
use askama::Template; use askama::Template;
use rocket::form::{Form, FromForm}; use rocket::form::{Form, FromForm};
use rocket::http::{Header, Status}; use rocket::http::Status;
use rocket::response::content::{RawCss, RawJavaScript}; use rocket::response::content::{RawCss, RawJavaScript};
use rocket::response::{status::NoContent, Redirect, Responder}; use rocket::response::{status::NoContent, Redirect};
use rocket::{get, post, uri}; use rocket::{get, post, uri};
#[derive(Template)] #[derive(Template)]
@ -33,24 +33,6 @@ pub(crate) fn instance_form(form: Form<InstanceForm<'_>>) -> Redirect {
))) )))
} }
#[derive(Responder)]
#[response(content_type = "application/zip")]
pub(crate) struct Code {
zip: &'static [u8],
disposition: Header<'static>,
}
#[get("/code")]
pub(crate) fn code() -> Code {
Code {
zip: include_bytes!(concat!(env!("OUT_DIR"), "/source.zip")),
disposition: Header::new(
"content-disposition",
r#"attachment; filename="emojos.in.zip""#,
),
}
}
#[get("/static/site.css")] #[get("/static/site.css")]
pub(crate) fn css() -> RawCss<&'static [u8]> { pub(crate) fn css() -> RawCss<&'static [u8]> {
RawCss(include_bytes!("site.css")) RawCss(include_bytes!("site.css"))