mirror of
https://github.com/hannobraun/Fornjot
synced 2025-03-01 02:25:59 +00:00
Add support for generating sponsor update post
This commit is contained in:
parent
5efcd16b12
commit
29d0c5ac18
@ -14,6 +14,7 @@ impl Args {
|
|||||||
#[derive(clap::Subcommand)]
|
#[derive(clap::Subcommand)]
|
||||||
pub enum Blog {
|
pub enum Blog {
|
||||||
Release,
|
Release,
|
||||||
|
SponsorUpdate,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Parser)]
|
#[derive(clap::Parser)]
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
mod release;
|
mod release;
|
||||||
|
mod sponsors;
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
pub use self::release::create_release_announcement;
|
pub use self::{
|
||||||
|
release::create_release_announcement, sponsors::create_sponsor_update,
|
||||||
|
};
|
||||||
|
58
tools/automator/src/blog/sponsors.rs
Normal file
58
tools/automator/src/blog/sponsors.rs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
use std::fmt::Write;
|
||||||
|
|
||||||
|
use tokio::{fs::File, io::AsyncWriteExt};
|
||||||
|
|
||||||
|
use super::util;
|
||||||
|
|
||||||
|
pub async fn create_sponsor_update() -> anyhow::Result<()> {
|
||||||
|
let month = util::now_ym();
|
||||||
|
let date = util::now_ymd();
|
||||||
|
|
||||||
|
let mut file = util::create_blog_post_file("sponsors", &month).await?;
|
||||||
|
generate_update(date, month, &mut file).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn generate_update(
|
||||||
|
date: String,
|
||||||
|
month: String,
|
||||||
|
file: &mut File,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let mut buf = String::new();
|
||||||
|
write!(
|
||||||
|
buf,
|
||||||
|
"\
|
||||||
|
+++
|
||||||
|
title = \"Sponsor Update - {month}\"
|
||||||
|
date = {date}
|
||||||
|
|
||||||
|
# Uncomment to generate the HTML for the email newsletter.
|
||||||
|
# template = \"newsletter/email.html\"
|
||||||
|
+++
|
||||||
|
|
||||||
|
Hey folks!
|
||||||
|
|
||||||
|
I just sent out the new sponsor update! Topics this month include:
|
||||||
|
|
||||||
|
- **TASK: Summarize sponsor update.**
|
||||||
|
|
||||||
|
If you want to receive monthly behind-the-scenes updates too, why not support Fornjot by [becoming a sponsor](https://github.com/sponsors/hannobraun)? You can start with as little as $2 a month. More substantial contributions are also welcome, of course 😁
|
||||||
|
|
||||||
|
I dedicate a substantial chunk of my week to working on Fornjot. Your contribution can help make that more sustainable.
|
||||||
|
|
||||||
|
|
||||||
|
### Not receiving these updates?
|
||||||
|
|
||||||
|
I've been sending out an update every month since February 2022. If you are a sponsor and haven't received those updates, maybe you are not opted in? Update your sponsorship over at GitHub, and make sure you check `Receive email updates from hannobraun`. Also make sure to check the spam folder in your email client.
|
||||||
|
|
||||||
|
If you still haven't received an update, [please contact me](mailto:hanno@braun-odw.eu). I'm happy to send you a copy directly.
|
||||||
|
|
||||||
|
I'm sorry for any inconvenience! Unfortunately, GitHub gives me no control over, or insight into, who is receiving those updates.
|
||||||
|
"
|
||||||
|
)?;
|
||||||
|
|
||||||
|
file.write_all(buf.as_bytes()).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
@ -4,6 +4,11 @@ use anyhow::Context;
|
|||||||
use chrono::{Datelike, Utc};
|
use chrono::{Datelike, Utc};
|
||||||
use tokio::fs::{self, File};
|
use tokio::fs::{self, File};
|
||||||
|
|
||||||
|
pub fn now_ym() -> String {
|
||||||
|
let now = Utc::now();
|
||||||
|
format!("{}-{:02}", now.year(), now.month())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn now_ymd() -> String {
|
pub fn now_ymd() -> String {
|
||||||
let now = Utc::now();
|
let now = Utc::now();
|
||||||
format!("{}-{:02}-{:02}", now.year(), now.month(), now.day())
|
format!("{}-{:02}-{:02}", now.year(), now.month(), now.day())
|
||||||
|
@ -20,6 +20,11 @@ pub async fn run() -> anyhow::Result<()> {
|
|||||||
.await
|
.await
|
||||||
.context("Failed to create release announcement")?;
|
.context("Failed to create release announcement")?;
|
||||||
}
|
}
|
||||||
|
Args::Blog(Blog::SponsorUpdate) => {
|
||||||
|
blog::create_sponsor_update()
|
||||||
|
.await
|
||||||
|
.context("Failed to create sponsor update")?;
|
||||||
|
}
|
||||||
Args::Sponsors(args) => {
|
Args::Sponsors(args) => {
|
||||||
let min_dollars = 8;
|
let min_dollars = 8;
|
||||||
let sponsors = Sponsors::query(&octocrab)
|
let sponsors = Sponsors::query(&octocrab)
|
||||||
|
Loading…
Reference in New Issue
Block a user