now-updater/README.md

80 lines
3.2 KiB
Markdown
Raw Normal View History

2025-12-18 01:57:14 +00:00
# now-updater
Update your Now page, automatically
2025-12-18 16:28:31 +00:00
[**Demo**](https://melanie.lol/now)
2025-12-18 01:57:14 +00:00
## How It Works
2025-12-18 16:28:31 +00:00
You define a connection and a URL in the `config.js` file so that it looks for a Markdown link with the URL and replaces the text with the connection's value.
For example:
```markdown
- {blog} [tktk](https://melkat.blog)
```
Becomes:
```markdown
- {blog} [My Latest Post](https://melkat.blog)
```
To keep this going automatically, we use a Forgejo Action runner configured to run every three hours.
While it does run every three hours, it only updates your now page when there has been a change.
2025-12-18 01:57:14 +00:00
## Getting Started
2025-12-18 16:28:31 +00:00
1. Fork this repo, and go to theTRAKT_SLURM _Settings_ tab, select _Actions_ and go to _Variables_
2. Create a variable `OMGLOL_USERNAME` and set it to your omg.lol username. So for me, it's `melanie`
- This is where you store nonsensitive variables. Currently this is only used for your omg.lol username.
3. Also in _Settings_ under _Actions_, select _Secrets_
4. Create a secret `OMGLOL_KEY` and set it to your omg.lol API key
- This is where you will define any sensitive keys, for example I use `TRAKT_SLURM` to store my _SLURM_ key. You only need this if you want to use the Trakt integration.
5. Once you are ready, you can enable the Forgejo Action by going to the fork's settings page. From the sidebar, go to Units and then Overview. This will take you to a page where you can enable actions.
- Check the box next to `Actions` and don't forget to click save.
2025-12-18 16:28:31 +00:00
If you're running this locally, you may also want to copy the `.env.example` to `.env` and store those values there too. The `.env` file is git ignored for a reason, so be sure not to commit it.
## Configuring
Configuring is all done within the `config.js` in the `items` array.
For example, to get the latest post from my blog's JSON feed.
```js
{
id: 'blog',
regex: markdownLinkRegex('melkat.blog'),
getLatest: async () =>
getJsonFeedItemTitle('https://melkat.blog/feed.json'),
},
```
- `id`: Used for logs
- `regex`: The regex used for finding the markdown link to replace the link text of
- `getLatest`: an async function to fetch the data and return a string used to be the new link text
### Available Functions
#### Basics
- `getJsonFeedItemContent(JSONFEED_URL)`: For getting the `content_html` of a JSON feed item and when available the item's `image`
- `getJsonFeedItemTitle(JSONFEED_URL)`: For getting the `title` of a JSON feed item and when available the item's `image`
- `getRSSItemTitle(RSS_URL)`: For getting the `title` of a RSS feed item
#### Service Specific
- `getLetterboxdActivity(LETTERBOXD_USERNAME)`: For getting the latest item from your Letterboxd RSS feed and the image from the description
- `getMalojaScrobble(MALOJA_URL)`: For getting the latest scrobble artist and track title
- `getTraktEpisode(TRAKT_USERNAME, TRAKT_ID)`: For getting the latest watched TV episode's show name, season and episode number, episode title, and episode image
2025-12-18 01:57:14 +00:00
2025-12-18 16:28:31 +00:00
## Support
2025-12-18 01:57:14 +00:00
2025-12-18 16:28:31 +00:00
Got a question? Reach out to me on Mastodon, [@zicklepop@nyan.lol](https://nyan.lol/@zicklepop) and I will do my best.
2025-12-18 01:57:14 +00:00
2025-12-18 16:28:31 +00:00
Did you find this useful? Donate to [Trans Lifeline](https://translifeline.org) or [The Trevor Project](https://thetrevorproject.org).