Add README, fix #2

This commit is contained in:
Max Nuding 2023-04-02 13:19:42 +02:00
parent 81f40101be
commit 8a37738ca3
Signed by: phlaym
GPG Key ID: A06651BAB6777237

View File

@ -1,38 +1,42 @@
# create-svelte
# Moshing Mammut
Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
The fine folks on the [metalhead.club Mastodon Server](https://metalhead.club) occasionally share like to share
what they're currently listening to.
Having a quick overview over what is being posted can be a great way to discover new music!
## Creating a project
# Technical Notes
If you're seeing this, you've probably already done this step. Congrats!
This is fairly simple from a technical point of view! metalhead.club's local timeline is being watched using the
Mastodon Streaming API over a Websocket. Every time a new post arrives, it is checked if it contains any music by
checking included hashtags and URLs. A list of tags and URLs can be found in [the configuration](.env.EXAMPLE).
Additionally, lins to YouTube are queried, if they are music or other videos using the YouTube API.
```bash
# create a new project in the current directory
npm create svelte@latest
If a post passes this check it is saved to a SQLite database.
# create a new project in my-app
npm create svelte@latest my-app
```
The UI is built using [SvelteKit](https://kit.svelte.dev). The initial page is rendered on the server, and works even
without Javascript. If Javascript is enabled, new posts are fetched every 10 seconds, but there are plans to switch
to Websockets instead. See #10.
## Developing
# The ~~Mastodon~~ Elephant in the Room
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
> So, are you just going to save other peoples posts into your own database?
```bash
npm run dev
I'm afraid so, and I'm not particularly happy about this. I've thought about how to do it without and it doesn't look
good.
# or start the server and open the app in a new browser tab
npm run dev -- --open
```
My initial plan was to search for posts and work with the search results, however
Mastodon doesn't offer full text search, so this would be limited to work with hashtags.
I can see that there are plenty of posts using only descriptions and links without a corresponding hashtag that would
be missed. This isn't a great solution.
## Building
Another idea was to store only URLs of posts and resolve the content and account information live.
This would be better, but I'm *still* storing post information while also slowing the app down and introduce more code
complexity. I'm willing to make this change if people prefer this though.
To create a production version of your app:
Additionally, I ended up adding a few things which turned out to be not needed:
The `tags` table (tags are included in the post's content and I don't do anything separately with tags) and
`accounts.username` and `accounts.avatar_static`. I will keep these in until the initial wave of feedback arrives, and
remove it if no new features required them.
```bash
npm run build
```
I'll gladly accept any help in coming up with a good solution which doesn't need to store anything at all!
You can preview the production build with `npm run preview`.
> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.