mirror of
https://github.com/zyllian/webdog.git
synced 2025-05-09 18:16:40 -07:00
Switch to stable toolchain
This commit is contained in:
parent
41268039de
commit
e91bbc38c5
5 changed files with 31 additions and 45 deletions
6
.github/workflows/main.yml
vendored
6
.github/workflows/main.yml
vendored
|
@ -27,12 +27,6 @@ jobs:
|
||||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install nightly
|
|
||||||
uses: actions-rs/toolchain@v1
|
|
||||||
with:
|
|
||||||
toolchain: nightly
|
|
||||||
override: true
|
|
||||||
|
|
||||||
# Runs a single command using the runners shell
|
# Runs a single command using the runners shell
|
||||||
- name: Build site
|
- name: Build site
|
||||||
run: |
|
run: |
|
||||||
|
|
2
rust-toolchain.toml
Normal file
2
rust-toolchain.toml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[toolchain]
|
||||||
|
channel = "stable"
|
|
@ -57,9 +57,7 @@ impl<'a> SiteBuilder<'a> {
|
||||||
/// Prepares the site builder for use.
|
/// Prepares the site builder for use.
|
||||||
pub fn prepare(mut self) -> anyhow::Result<Self> {
|
pub fn prepare(mut self) -> anyhow::Result<Self> {
|
||||||
let build_static_path = self.build_path.join(STATIC_PATH);
|
let build_static_path = self.build_path.join(STATIC_PATH);
|
||||||
if std::fs::try_exists(&self.build_path)
|
if self.build_path.exists() {
|
||||||
.context("Failed check if build directory exists")?
|
|
||||||
{
|
|
||||||
if build_static_path.exists() {
|
if build_static_path.exists() {
|
||||||
std::fs::remove_dir_all(&build_static_path)
|
std::fs::remove_dir_all(&build_static_path)
|
||||||
.context("Failed to remove old static directory")?;
|
.context("Failed to remove old static directory")?;
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
#![feature(path_try_exists)]
|
|
||||||
#![feature(async_closure)]
|
|
||||||
|
|
||||||
mod builder;
|
mod builder;
|
||||||
#[cfg(feature = "serve")]
|
#[cfg(feature = "serve")]
|
||||||
pub mod serving;
|
pub mod serving;
|
||||||
|
|
|
@ -231,45 +231,40 @@ impl Site {
|
||||||
.or(warp::any().and(warp::get()).and(
|
.or(warp::any().and(warp::get()).and(
|
||||||
warp::path::full()
|
warp::path::full()
|
||||||
.and(with_build_path(build_path.clone()))
|
.and(with_build_path(build_path.clone()))
|
||||||
.and_then(
|
.and_then(move |path: FullPath, build_path: PathBuf| async move {
|
||||||
async move |path: FullPath,
|
// Serve static files
|
||||||
build_path: PathBuf|
|
let p = &path.as_str()[1..];
|
||||||
-> Result<Response, warp::Rejection> {
|
|
||||||
// Serve static files
|
|
||||||
let p = &path.as_str()[1..];
|
|
||||||
|
|
||||||
if p == "static/_dev.js" {
|
if p == "static/_dev.js" {
|
||||||
let res =
|
let res = Response::new(include_str!("./refresh_websocket.js").into());
|
||||||
Response::new(include_str!("./refresh_websocket.js").into());
|
return Ok(res);
|
||||||
return Ok(res);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let mut p = build_path.join(p);
|
let mut p = build_path.join(p);
|
||||||
|
|
||||||
if !p.exists() {
|
if !p.exists() {
|
||||||
p = p.with_extension("html");
|
p = p.with_extension("html");
|
||||||
}
|
}
|
||||||
if p.is_dir() {
|
if p.is_dir() {
|
||||||
p = p.join("index.html");
|
p = p.join("index.html");
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.exists() {
|
if p.exists() {
|
||||||
let mut res = Response::new("".into());
|
let mut res = Response::new("".into());
|
||||||
match std::fs::read_to_string(&p) {
|
match std::fs::read_to_string(&p) {
|
||||||
Ok(body) => {
|
Ok(body) => {
|
||||||
*res.body_mut() = body.into();
|
*res.body_mut() = body.into();
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("{}", e);
|
eprintln!("{}", e);
|
||||||
*res.body_mut() = format!("Failed to load: {}", e).into();
|
*res.body_mut() = format!("Failed to load: {}", e).into();
|
||||||
*res.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
*res.status_mut() = StatusCode::INTERNAL_SERVER_ERROR;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Ok(res);
|
|
||||||
}
|
}
|
||||||
Err(warp::reject())
|
return Ok(res);
|
||||||
},
|
}
|
||||||
),
|
Err(warp::reject())
|
||||||
|
}),
|
||||||
))
|
))
|
||||||
.or(warp::any()
|
.or(warp::any()
|
||||||
.and(warp::path::full())
|
.and(warp::path::full())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue