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
39 changes: 8 additions & 31 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,32 +123,10 @@ standardize code changes as much as possible and with as little friction for you
as we can add. If you have concerns or suggestions about specific settings, you
are welcome to open a GitHub Issue to discuss.

### Using Glitch

Glitch is an online community for creative coding. Its free hosting allows for
the "remixing" of projects, including directly from GitHub repos, and is
therefore useful for standing up ActivityPub servers that are instantly
available at unique hostnames on the internet. You can go to this URL:

https://glitch.new/github.com/ckolderup/postmarks

to spin up a new project that uses the current `main` branch of the Postmarks
repo. You'll be in a web-based IDE that auto-builds the project as you make
changes. If you're not logged in to Glitch, the project will be archived after
five days. You can create an account or log in to associate the project with
the account. You can read more about Glitch's hosting offerings on its
[documentation](https://help.glitch.com).

_(Disclosure: Postmarks maintainer Casey Kolderup has worked on Glitch from 2021
up to the time of this writing; no one at Glitch or its parent company requested
that Casey promote Glitch in the process of working on or talking about
Postmarks.)_

### Changing port

You can set the env var `PORT` to any valid number to make Postmarks bind to
that port. By default, Postmarks uses port 3000. (Don't do this if you're
developing on Glitch!)
that port. By default, Postmarks uses port 3000.

### Logging persistence

Expand All @@ -157,7 +135,7 @@ to your .env file. This will cause all incoming requests to append to
`request_log.txt` in your project root directory.

> [!WARNING]
> If you are running on a container with limited storage (e.g. Glitch), you
> If you are running on a container with limited storage, you
> should not leave this enabled, or you'll eventually run out of space as
> ActivityPub messages get logged. This is intended for debugging.

Expand All @@ -166,13 +144,12 @@ to your .env file. This will cause all incoming requests to append to
Postmarks aims to be interoperable with other Fediverse apps where it makes
sense to do so; one of the most common and obvious applications of that concept
is in working with Mastodon. If you plan on manually QAing changes to Postmarks
you may want to set up a pair of testing surfaces, one being a persistent Glitch
app running Postmarks, the other an account on a public Mastodon instance. You
may want this account to be locked and separate from any existing presence you
have on Mastodon and associated Fediverse microblogging networks. Many Mastodon
instances offer free accounts; you can take a look at
[Join Mastodon](https://joinmastodon.org) to see who is offering open signups
at this time.
you may want to set up a pair of testing surfaces, one being a Postmarks instance
running the latest public release of the software and the other an account on a public
Mastodon instance. You may want this account to be locked and separate from any existing
presence you have on Mastodon and associated Fediverse microblogging networks. Many Mastodon
instances offer free accounts; you can take a look at [Join Mastodon](https://joinmastodon.org)
to see who is offering open signups at this time.

### Bookmark data sets

Expand Down
30 changes: 7 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,20 @@ Check the setup below to understand how to do that!

To set your app up:

If you're using Glitch:

- Rename your project immediately in the project settings, if you intend to be called something else. This determines the domain that your site lives at, which also determines the second half of your `@username@project-name.glitch.me` identity on the fediverse. NOTE: If you change this later, you will break the connection any existing followers have to your site, they'll have to re-follow the account on its new domain (and depending on the software they're following from, may even prevent them from unfollowing the old URL 😱)
- In your `.env` editor, create a key `ADMIN_KEY` and give it a text string as a value. This is your "password" when your browser prompts you, so make it as secure as you need to protect your data.
- Add another key to your .env called `SESSION_SECRET` and generate a random string for its value. This is your [session secret](http://expressjs.com/en/resources/middleware/session.html#secret), used to generate the hashed version of your session that gets encoded with the cookies used to store your login. If you make this string too easily guessable, you make it easier for someone to hijack your session and gain unauthorized login. Also, if you ever change this string, it will invalidate all existing cookies.
- If you've got a custom domain in front of your Glitch project, add a key to your .env called `PUBLIC_BASE_URL` with the value set to the hostname (the part after the https://) at which you want the project to be accessible.
- Edit the contents of `account.json.example` to set your `@username`, display name, bio, and avatar. (If you don't set a username, your default actor name will be 'bookmarks', so people will find you on the fediverse `@bookmarks@project-name.glitch.me`.)
- THEN: either rename `account.json.example` to `account.json`, or copy the contents into a new file called `account.json`. Whatever `username` you have in this file when the project first starts you'll need to retain or else you'll break your followers' connection to this account.

Otherwise:
- Create a `.env` file in the root of the project.
- Add the line `PUBLIC_BASE_URL=<hostname>` to your .env where \<hostname\> is the hostname of your instance.
- Add the line `ADMIN_KEY=<key>` to your .env where \<key\> is the password you'll enter when the browser prompts you, and another line for `SESSION_SECRET=<secret>` where \<secret\> is a random string used when hashing your session for use in a secure cookie.
- Make a file called `account.json` in the project root. Copy the contents of `account.json.example` into it and edit the values to set your `@username`, display name, bio, and avatar. (If you don't set a username, your default actor name will be 'bookmarks', so people will find you on the fediverse `@bookmarks@project-name.glitch.me`.)

If you're using Glitch, you should be done!
- Make a file called `account.json` in the project root. Copy the contents of `account.json.example` into it and edit the values to set your `@username`, display name, bio, and avatar.
- If you don't set a username, your default actor name will be 'bookmarks', so people will find you on the fediverse `@bookmarks@<hostname>`.
- You should update the avatar field in order to not hotlink to another server-- the value must be an absolute URL. If you change out the hostname and leave the existing filename, you will link to a statically hosted image on your server that was downloaded along with the rest of the Postmarks repo.

If you are using Docker compose you can run `docker compose up` or `docker-compose up` (depending on the version of Docker you are using) and Postmarks should be running. You can access it at http://localhost:3000
If you are using Docker compose you can run `docker compose up` or `docker-compose up` (depending on the version of Docker you are using) and Postmarks should be running. Otherwise, run `npm run start` on the command line. You can also use `npm run start` in any kind of app/container-management tool or SaaS provider that lets you define an entrypoint.

Otherwise, run `npm run start` via whatever mechanism you choose to use to host this website.
By default, Postmarks runs on port 3000. You can change this with a `PORT=<number>` entry in your .env. If you're running Postmarks behind a reverse proxy, configure it to send traffic from your Postmarks hostname to this port.

Click on the **Admin** link in the footer, and enter the password (whatever you set ADMIN_KEY to in the .env).
At this point, you should be able to load Postmarks in your browser using the hostname you configured. If you don't have a proxy to direct from the hostname, you'll need to add the port to the URL. In basic local development mode it should be available at http://localhost:3000 .

You should be logged in, at which point you can configure various settings, import bookmarks, and use the "Add" links in the header and footer (as well as the bookmarklet, available in the Admin section) to save new bookmarks.
Once you're looking at the web interface in your browser, click on the **Admin** link in the footer, and enter the password (whatever you set ADMIN_KEY to in the .env). You should be logged in, at which point you can configure various settings, import bookmarks, and use the "Add" links in the header and footer (as well as the bookmarklet, available in the Admin section) to save new bookmarks.

## Mastodon Verification

Expand All @@ -57,9 +47,3 @@ as how to submit your changes for review.
- Much of the original form of the site's frontend is lifted from the starter projects available on [Glitch](https://glitch.com). Thank you to all the people who have contributed to those projects over the years!
- Much of the original backend of the site is based off of Darius Kazemi's [express-activitypub](https://github.com/dariusk/express-activitypub) repo. I made a point not to just clone his repo from the start, but then ended up retyping most of it as I learned how things work. While some pieces have been upgraded, much of Darius' work creates the foundation for Postmarks' ActivityPub functionality.

## We built this with Glitch!

[Glitch](https://glitch.com) is a friendly community where millions of people come together to build web apps and websites.

- Need more help? [Check out the Help Center](https://help.glitch.com/) for answers to any common questions.
- Ready to make it official? [Become a paid Glitch member](https://glitch.com/pricing) to boost your app with private sharing, more storage and memory, domains and more.
2 changes: 1 addition & 1 deletion account.json.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"username": "bookmarks",
"avatar": "https://cdn.glitch.global/8eaf209c-2fa9-4353-9b99-e8d8f3a5f8d4/postmarks-logo-white-small.png?v=1693610556689",
"avatar": "https://sharepostmarks.org/postmarks-logo-white-small.png",
"displayName": "Postmarks",
"description": "An ActivityPub bookmarking and sharing site built with Postmarks"
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"license": "MIT",
"keywords": [
"node",
"glitch",
"sqlite",
"fediverse",
"express",
Expand Down
Binary file added public/postmarks-logo-white-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ const hbs = create({
searchUrl() {
return `https://${app.get('domain')}/opensearch.xml`;
},
glitchProjectName() {
return process.env.PROJECT_DOMAIN;
},
section(name, options) {
if (!this._sections) this._sections = {};
this._sections[name] = options.fn(this);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/admin/following.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
type="text"
id="actor"
name="actor"
placeholder="@updates@postmarks.glitch.me"
placeholder="@updates@sharepostmarks.org"
/>
</div>
<div class="form-group">
Expand Down
4 changes: 0 additions & 4 deletions src/pages/layouts/main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@
<a class="btn--github" href="https://github.com/ckolderup/postmarks" target="_blank">
<img src="/github-icon.svg" alt="GitHub logo">
</a>
<a class="btn--remix" target="_top" href="https://glitch.new/github.com/ckolderup/postmarks">
<img src="/glitch-logo.svg" alt="Glitch logo">
Remix on Glitch
</a>
</div>
</footer>
{{{_sections.script}}}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/activitypub/nodeinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ router.get('/', async (req, res) => {
name: instanceType,
version: instanceVersion,
repository: 'https://github.com/ckolderup/postmarks',
homepage: 'https://postmarks.glitch.me',
homepage: 'https://sharepostmarks.org',
},
protocols: ['activitypub'],
services: {
Expand Down
5 changes: 1 addition & 4 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ export const domain = (() => {
if (process.env.PUBLIC_BASE_URL) {
return process.env.PUBLIC_BASE_URL;
}
if (process.env.PROJECT_DOMAIN) {
return `${process.env.PROJECT_DOMAIN}.glitch.me`;
}

console.log("didn't find a PUBLIC_BASE_URL or PROJECT_DOMAIN in env, assuming localhost");
console.log("didn't find a PUBLIC_BASE_URL in env, assuming localhost");
return 'localhost';
})();

Expand Down