Skip to content

Commit

Permalink
remove svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Oct 14, 2024
1 parent a340576 commit 0f7d1a8
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 103 deletions.
13 changes: 3 additions & 10 deletions buildscript.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import esbuild from "esbuild";
import sveltePlugin from "esbuild-svelte";
import sveltePreprocess from "svelte-preprocess";

esbuild
.build({
entryPoints: ["src/app.ts"],
mainFields: ["svelte", "browser", "module", "main"],
entryPoints: ["src/app.js"],
mainFields: ["browser", "module", "main"],
bundle: true,
minify: true,
minify: false,
format: "esm",
outfile: "build/bundle.js",
plugins: [
sveltePlugin({
preprocess: sveltePreprocess()
})
],
logLevel: "info",
})
.catch((error, location) => {
Expand Down
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
{
"type": "module",
"main": "index.tsx",
"name": "mastodon-bookmark-rss",
"version": "0.1.0",
"description": "An app to subscribe to your Mastodon bookmarks via RSS",
"repository": "git@github.com:untitaker/mastodon-bookmark-rss.git",
"author": "Markus Unterwaditzer <markus-honeypot@unterwaditzer.net>",
"license": "MIT",
"dependencies": {
"@tsconfig/svelte": "^3.0.0",
"esbuild": "^0.17.2",
"esbuild-svelte": "^0.7.3",
"purecss": "^3.0.0",
"svelte": "^3.55.1",
"svelte-check": "^3.0.3",
"svelte-preprocess": "^5.0.1"
"purecss": "^3.0.0"
},
"scripts": {
"build": "node buildscript.js",
"typecheck": "svelte-check",
"dev": "find src/ | entr -sr 'npm run build && cargo run'",
"fmt": "prettier --write src/ && cargo fmt"
},
"devDependencies": {
"prettier": "^2.8.3",
"prettier-plugin-svelte": "^2.9.0"
"prettier": "^2.8.3"
},
"volta": {
"node": "21.0.0",
Expand Down
81 changes: 71 additions & 10 deletions src/app.ts → src/app.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// this will cause esbuild to also create src/bundle.css
import "./app.css";

import App from "./svelte/App.svelte";

const OAUTH_CLIENT_NAME = "Mastodon Bookmark RSS";
const OAUTH_SCOPES = "read:bookmarks";
const SERVICE_BASE_URL = `${window.location.origin}${window.location.pathname}`;

const launchLogin = async (baseUrl: string) => {
const launchLogin = async (baseUrl) => {
window.localStorage.setItem("baseUrl", baseUrl);

const params = new FormData();
Expand Down Expand Up @@ -75,10 +73,73 @@ const getFeedUrl = async () => {
return `${SERVICE_BASE_URL}feed?host=${baseUrl}&token=${accessToken}`;
};

new App({
target: document.getElementById("app-root"),
props: {
launchLogin,
feedUrlPromise: getFeedUrl(),
},
});
(async () => {
const appRoot = document.getElementById("app-root");
appRoot.innerText = "loading...";
const feedUrl = await getFeedUrl();
if (!feedUrl) {
appRoot.innerHTML = `
<form class="pure-form pure-form-stacked" onsubmit="submitLoginForm()">
<fieldset>
<label for="host">Your instance</label>
<input
type="text"
id="host"
class="pure-input-1"
required
name="host"
placeholder="e.g. mastodon.social"
title="Something that looks like a hostname"
/>
</fieldset>
<input
type="submit"
class="pure-button pure-button-primary"
value="Get RSS feed"
/>
</form>
`;

document.querySelector("form").onsubmit = (e) => {
launchLogin(e.target.host.value);
e.preventDefault();
};
} else {
appRoot.innerHTML = `
<div>
<p class="green">Subscribe to the following URL in your feed reader. Anybody who knows this
URL can read your bookmarks!</p>
<form class="pure-form pure-form-stacked">
<fieldset>
<input type="text" class="pure-input-1" readOnly />
<label for="form-client-link">Optional: Add an "Open In" link to bookmarks</label>
<select onchange="changeClient()">
<option value="none" selected>None</option>
<option value="host">Your Mastodon Host</option>
<option value="elk">Elk</option>
<option value="elkcanary">Elk Canary</option>
<option value="phanpy">Phanpy</option>
<option value="phanpydev">Phanpy Dev</option>
<option value="trunks">Trunks</option>
<option value="ivory">Ivory</option>
</select>
</fieldset>
</form>
</div>
`;

const changeClient = (client) => {
const result = document.querySelector("input");
result.value = `${
client === "none" ? feedUrl : `${feedUrl}&client=${client}`
}`;
};

document.querySelector("select").onchange = (e) => {
changeClient(e.target.value);
};

changeClient("none");
}
})();
11 changes: 5 additions & 6 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ <h2 class="content-head is-center">About this service</h2>

<ul>
<li>
This service does not store your bookmarks. All needed credentials
are encoded in the RSS feed's URL.
This service does not store your bookmarks. All needed credentials are
encoded in the RSS feed's URL.
</li>

<li>
Expand All @@ -59,10 +59,9 @@ <h2 class="content-head is-center">About this service</h2>
</li>

<li>
This service enforces some basic rate limits. Any
reasonable RSS feed reader should not run into them.
Please don't poll your RSS feed more often than you
actually need, this relieves this service and your
This service enforces some basic rate limits. Any reasonable RSS feed
reader should not run into them. Please don't poll your RSS feed more
often than you actually need, this relieves this service and your
Mastodon server.
</li>
</ul>
Expand Down
67 changes: 0 additions & 67 deletions src/svelte/App.svelte

This file was deleted.

0 comments on commit 0f7d1a8

Please sign in to comment.