Skip to content

Commit

Permalink
Merge branch 'release/1.0.0-beta.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
nekofar committed Oct 13, 2023
2 parents e0a1eb8 + 7138a31 commit 475a565
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
override: true

- name: Deploy to Workers
uses: cloudflare/wrangler-action@v3.2.0
uses: cloudflare/wrangler-action@v3.3.1
with:
accountId: ${{ secrets.CF_ACCOUNT_ID }}
apiToken: ${{ secrets.CF_API_TOKEN }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [1.0.0-beta.2] - 2023-10-13

### Features

- Add unique color to each platform`s og image

## [1.0.0-alpha.7] - 2023-10-05

### Refactor
Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "lilnouns-click"
version = "1.0.0-beta.1"
version = "1.0.0-beta.2"
authors = ["Milad Nekofar <milad@nekofar.com>"]
edition = "2021"
description = "A Nounish URL shortener for LilNouns DAO."
Expand All @@ -21,9 +21,9 @@ html-escape = { version = "0.2.13", default-features = false }
html-minifier = { version = "4.0.0", default-features = false }
log = { version = "0.4.20", features = [] }
percent-encoding = "2.3.0"
regex = "1.9.6"
regex = "1.10.0"
reqwest = "0.11.22"
serde = { version = "1.0.188", features = ["derive"] }
serde = { version = "1.0.189", features = ["derive"] }
sqids = "0.3.0"
unidecode = "0.3.0"
url = "2.4.1"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"dev": "wrangler dev"
},
"devDependencies": {
"wrangler": "3.10.1"
"wrangler": "3.13.1"
}
}
50 changes: 25 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ pub async fn handle_og_image<D>(_req: Request, ctx: RouteContext<D>) -> worker::
let image = match (community, platform) {
(Some(LilNouns), Some(Ethereum)) => {
let (title, description) = fetch_lil_nouns_data(&ctx.env, numbers[2]).await?;
create_og_image(&title, &description)
create_og_image(&title, &description, "7CC4F2")
}
(Some(LilNouns), Some(PropLot)) => {
let (title, description) = fetch_prop_lot_data(&ctx.env, numbers[2]).await?;
create_og_image(&title, &description)
create_og_image(&title, &description, "8C8D92")
}
(Some(LilNouns), Some(MetaGov)) => {
let (title, description) = fetch_meta_gov_data(&ctx.env, numbers[2]).await?;
create_og_image(&title, &description)
create_og_image(&title, &description, "EFC950")
}
_ => String::new(),
};
Expand Down
5 changes: 3 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ pub fn truncate_and_clean_string(input: &str, limit: usize) -> String {
}
}

pub fn create_og_image(title: &str, description: &str) -> String {
pub fn create_og_image(title: &str, description: &str, background_color: &str) -> String {
let non_alpha_numeric = Regex::new("[^a-zA-Z0-9 .]").unwrap();

let title = non_alpha_numeric.replace_all(title, "");
let description = non_alpha_numeric.replace_all(description, "");
let background_color = format!("/b_rgb:{}", background_color);

let cloudinary_id = "nekofar";
let cloudinary_url = format!("https://res.cloudinary.com/{}/image/upload", cloudinary_id);
Expand All @@ -74,7 +75,7 @@ pub fn create_og_image(title: &str, description: &str) -> String {

let parts = vec![
&cloudinary_url,
"/b_rgb:7CC4F2",
&background_color,
"/c_scale,h_630,w_1200",
"/l_lil_noun_logo/c_scale,w_300/e_screen,fl_layer_apply,g_north,y_100",
&title_encoded,
Expand Down

0 comments on commit 475a565

Please sign in to comment.