aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorXe Iaso <me@christine.website>2022-09-21 02:31:43 +0000
committerXe Iaso <me@christine.website>2022-09-21 02:31:43 +0000
commit49c62851137d2757d6e8019636c908b4612f61d1 (patch)
tree141577daeb9f3e89def22fa930ea4fcbf3622813 /src
parent292c43392102cde951d345cf012e0231826877a5 (diff)
downloadxesite-49c62851137d2757d6e8019636c908b4612f61d1.tar.xz
xesite-49c62851137d2757d6e8019636c908b4612f61d1.zip
purge cloudflare
Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'src')
-rw-r--r--src/app/mod.rs6
-rw-r--r--src/app/poke.rs48
-rw-r--r--src/post/mod.rs11
3 files changed, 6 insertions, 59 deletions
diff --git a/src/app/mod.rs b/src/app/mod.rs
index 9a331a4..73320e1 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -68,9 +68,9 @@ pub async fn init(cfg: PathBuf) -> Result<State> {
cfg.clone().mi_token.clone(),
crate::APPLICATION_NAME.to_string(),
)?;
- let blog = crate::post::load(cfg.clone(), "blog").await?;
- let gallery = crate::post::load(cfg.clone(), "gallery").await?;
- let talks = crate::post::load(cfg.clone(), "talks").await?;
+ let blog = crate::post::load("blog").await?;
+ let gallery = crate::post::load("gallery").await?;
+ let talks = crate::post::load("talks").await?;
let mut everything: Vec<Post> = vec![];
{
diff --git a/src/app/poke.rs b/src/app/poke.rs
index ef5f882..404b14d 100644
--- a/src/app/poke.rs
+++ b/src/app/poke.rs
@@ -7,18 +7,9 @@ pub async fn the_cloud() -> Result<()> {
info!("waiting for things to settle");
delay_for(Duration::from_secs(10)).await;
- info!("purging cloudflare cache");
- cloudflare().await?;
-
- info!("waiting for the cloudflare cache to purge globally");
- delay_for(Duration::from_secs(45)).await;
-
info!("poking mi");
mi().await?;
- info!("poking bing");
- bing().await?;
-
info!("poking google");
google().await?;
@@ -26,19 +17,6 @@ pub async fn the_cloud() -> Result<()> {
}
#[instrument(err)]
-async fn bing() -> Result<()> {
- let cli = reqwest::Client::new();
- cli.get("https://www.bing.com/ping")
- .query(&[("sitemap", "https://xeiaso.net/sitemap.xml")])
- .header("User-Agent", crate::APPLICATION_NAME)
- .send()
- .await?
- .error_for_status()?;
-
- Ok(())
-}
-
-#[instrument(err)]
async fn google() -> Result<()> {
let cli = reqwest::Client::new();
cli.get("https://www.google.com/ping")
@@ -52,32 +30,6 @@ async fn google() -> Result<()> {
}
#[instrument(err)]
-async fn cloudflare() -> Result<()> {
- let cli = cfcache::Client::new(env::var("CF_TOKEN")?, env::var("CF_ZONE_ID")?)?;
- cli.purge(
- vec![
- "https://xeiaso.net/sitemap.xml",
- "https://xeiaso.net",
- "https://xeiaso.net/blog",
- "https://xeiaso.net/blog.atom",
- "https://xeiaso.net/blog.json",
- "https://xeiaso.net/blog.rss",
- "https://xeiaso.net/gallery",
- "https://xeiaso.net/talks",
- "https://xeiaso.net/resume",
- "https://xeiaso.net/signalboost",
- "https://xeiaso.net/feeds",
- ]
- .into_iter()
- .map(|i| i.to_string())
- .collect(),
- )
- .await?;
-
- Ok(())
-}
-
-#[instrument(err)]
async fn mi() -> Result<()> {
let cli = mi::Client::new(env::var("MI_TOKEN")?, crate::APPLICATION_NAME.to_string())?;
cli.refresh().await?;
diff --git a/src/post/mod.rs b/src/post/mod.rs
index 263471d..0ad5cc0 100644
--- a/src/post/mod.rs
+++ b/src/post/mod.rs
@@ -83,12 +83,7 @@ impl Post {
}
}
-async fn read_post(
- cfg: Arc<Config>,
- dir: &str,
- fname: PathBuf,
- cli: &Option<mi::Client>,
-) -> Result<Post> {
+async fn read_post(dir: &str, fname: PathBuf, cli: &Option<mi::Client>) -> Result<Post> {
debug!(
"loading {}",
fname.clone().into_os_string().into_string().unwrap()
@@ -151,7 +146,7 @@ async fn read_post(
})
}
-pub async fn load(cfg: Arc<Config>, dir: &str) -> Result<Vec<Post>> {
+pub async fn load(dir: &str) -> Result<Vec<Post>> {
let cli = match std::env::var("MI_TOKEN") {
Ok(token) => mi::Client::new(token.to_string(), crate::APPLICATION_NAME.to_string()).ok(),
Err(_) => None,
@@ -159,7 +154,7 @@ pub async fn load(cfg: Arc<Config>, dir: &str) -> Result<Vec<Post>> {
let futs = glob(&format!("{}/*.markdown", dir))?
.filter_map(Result::ok)
- .map(|fname| read_post(cfg.clone(), dir, fname, cli.borrow()));
+ .map(|fname| read_post(dir, fname, cli.borrow()));
let mut result: Vec<Post> = futures::future::join_all(futs)
.await