Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@ jobs:
node-version: 20
cache: pnpm

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Install wasm-bindgen
uses: taiki-e/install-action@v2
with:
tool: wasm-bindgen@0.2.130

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run Vitest
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,6 @@ dist

# vscode junk

.lh
.lh
# wasm-bindgen output of wasm/, built by `pnpm build:wasm`
src/wasm
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ You need to generate a matrix id, using the algorithm as shown above.

`GET /_soliditas/preview_url?url=[url]` answers in the shape of the Matrix `/preview_url` endpoint. Missing `og:` tags are filled from `twitter:` tags, `<title>`, `<meta name="description">` and oEmbed. Twitter/X links are read from the [FxTwitter API](https://github.com/FxEmbed/FxEmbed), Reddit and TikTok titles from their oEmbed endpoints, Tumblr posts without an image get the [fxtumblr](https://github.com/knuxify/fxtumblr) render, and Misskey-family notes show their images from the ActivityPub object unless marked sensitive, instead of the author's avatar.

The scraper is the Rust crate `sable-link-preview`, which the Sable client also runs natively. `wasm/` compiles it for the worker, and `pnpm build:wasm` (run before `test`, `dev` and `deploy`) needs Rust with the `wasm32-unknown-unknown` target and `wasm-bindgen-cli` 0.2.130.

`og:image` is returned as `mxc://[servername]/og_[base64url of the image url]`. When a post has more than one image, `com.sable.images` lists up to ten of them as `{ url, width, height }`, and `og:image` stays the single image other clients show (the FxTwitter mosaic for tweets).

## License
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"version": "0.0.0",
"private": true,
"scripts": {
"build:wasm": "cargo build --manifest-path wasm/Cargo.toml --release --target wasm32-unknown-unknown && wasm-bindgen --target web --out-dir src/wasm wasm/target/wasm32-unknown-unknown/release/soliditas_wasm.wasm",
"deploy": "wrangler deploy",
"dev": "wrangler dev",
"start": "wrangler dev",
"pretest": "pnpm build:wasm",
"test": "vitest",
"cf-typegen": "wrangler types"
},
Expand Down
7 changes: 6 additions & 1 deletion src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@ export interface Env {
HOSTNAME?: string;
SERVERNAME?: string;
PORT?: number;
}
}

declare module '*.wasm' {
const module: WebAssembly.Module;
export default module;
}
Loading
Loading