CoastalCommits Pastes is a fork of Drift, a self-hostable Gist and paste service. Built with Next.js 13 and React Server Components. https://pastes.coastalcommits.com
Find a file
2023-07-21 21:35:36 -07:00
.github chore(deps): update actions/checkout action to v3 (#92) 2022-04-12 13:39:45 -07:00
.vscode bump deps 2023-01-28 21:58:21 -08:00
public some file cleanup, add api/og function 2023-01-23 21:05:17 -08:00
src Fix file link color in post list 2023-07-21 21:35:36 -07:00
tools Slight shell script improvements 2023-02-26 01:21:08 -08:00
types chore: linting 2023-02-26 15:22:05 -08:00
.env.default feat: add keycloak login (#139) 2023-03-28 00:37:27 -07:00
.eslintrc.json /new page responsiveness 2023-07-20 20:48:02 -07:00
.gitignore remove @vercel/og, use bundled package 2023-05-20 15:47:37 -07:00
.prettierrc Shadify (#150) 2023-07-20 18:04:47 -07:00
components.json Shadify (#150) 2023-07-20 18:04:47 -07:00
CONTRIBUTING.md Create CONTRIBUTING.md 2022-03-12 19:45:25 -08:00
docker-compose.yml cleaned up multi-service compose (#75) 2022-04-13 15:31:38 -07:00
jest.config.js Add some (WIP) tests 2023-02-26 14:44:32 -08:00
LICENSE Create LICENSE 2022-03-12 15:03:17 -08:00
next-env.d.ts Bump next.js and related deps 2023-02-21 23:20:10 -08:00
next.config.mjs Shadify (#150) 2023-07-20 18:04:47 -07:00
package.json Shadify (#150) 2023-07-20 18:04:47 -07:00
pnpm-lock.yaml Bump word-wrap from 1.2.3 to 1.2.4 (#151) 2023-07-20 19:13:41 -07:00
postcss.config.js Shadify (#150) 2023-07-20 18:04:47 -07:00
README.md Shadify (#150) 2023-07-20 18:04:47 -07:00
renovate.json server: lint, renovate: weekly updates 2022-04-14 14:58:56 -07:00
tailwind.config.js Shadify (#150) 2023-07-20 18:04:47 -07:00
tsconfig.json Add some (WIP) tests 2023-02-26 14:44:32 -08:00

Drift

Note: This branch is where all work is being done to refactor to the Next.js 13 app directory and React Server Components.

Drift is a self-hostable Gist clone. It's in beta, but is completely functional.

You can try a demo at https://drift.lol. The demo is built on main but has no database, so files and accounts can be wiped at any time.

If you want to contribute, need support, or want to stay updated, you can join the IRC channel at #drift on irc.libera.chat or reach me on twitter. If you don't have an IRC client yet, you can use a webclient here.

Drift is built with Next.js 13, React Server Components, shadcn/ui, and Prisma.


Contents:

Setup

Development

In the root directory, run pnpm i. If you need pnpm, you can download it here. You can run pnpm dev in client for file watching and live reloading.

To work with prisma, you can use pnpm prisma or pnpm exec prisma to interact with the database.

Production

pnpm build will produce production code. pnpm start will start the Next.js server.

Environment Variables

You can change these to your liking.

.env:

  • DRIFT_URL: the URL of the drift instance.
  • DATABASE_URL: the URL to connect to your postgres instance. For example, postgresql://user:password@localhost:5432/drift.
  • WELCOME_CONTENT: a markdown string that's rendered on the home page
  • WELCOME_TITLE: the file title for the post on the homepage.
  • ENABLE_ADMIN: the first account created is an administrator account
  • REGISTRATION_PASSWORD: the password required to register an account. If not set, no password is required.
  • NODE_ENV: defaults to development, can be production

Auth environment variables

Note: Only credential auth currently supports the registration password, so if you want to secure registration, you must use only credential auth.

  • GITHUB_CLIENT_ID: the client ID for GitHub OAuth.
  • GITHUB_CLIENT_SECRET: the client secret for GitHub OAuth.
  • NEXTAUTH_URL: the URL of the drift instance. Not required if hosting on Vercel.
  • CREDENTIAL_AUTH: whether to allow username/password authentication. Defaults to true.

Running with pm2

It's easy to start Drift using pm2. First, add the .env file with your values (see the above section for the required options).

Then, use the following command to start the server:

  • pnpm build && pm2 start pnpm --name drift --interpreter bash -- start

Refer to pm2's docs or pm2 help for more information.

Running with Docker

Running with systemd

NOTE: We assume that you know how to enable user lingering if you don't want to use the systemd unit as root

  • As root

    • Place the following systemd unit in /etc/systemd/system and name it drift.service
    • Replace any occurrence of $USERNAME with the shell username of the user that will be running the Drift server
    ##########
    # Drift Systemd Unit (Global)
    ##########
    [Unit]
    Description=Drift Server (Global)
    After=default.target
    
    [Service]
    User=$USERNAME
    Group=$USERNAME
    Type=simple
    WorkingDirectory=/home/$USERNAME/Drift
    ExecStart=/usr/bin/pnpm start
    Restart=on-failure
    
    [Install]
    WantedBy=default.target
    
  • As a nomal user

    • Place the following systemd unit inside /home/user/.config/systemd/user and name it drift_user.service
    • Replace any occurrence of $USERNAME with the shell username of the user that will be running the Drift server
    ##########
    # Drift Systemd Unit (User)
    ##########
    [Unit]
    Description=Drift Server (User)
    After=default.target
    
    [Service]
    Type=simple
    WorkingDirectory=/home/$USERNAME/Drift
    ExecStart=/usr/bin/pnpm start
    Restart=on-failure
    
    [Install]
    WantedBy=default.target
    

Current status

Drift is a work in progress. Below is a (rough) list of completed and envisioned features. If you want to help address any of them, please let me know regardless of your experience and I'll be happy to assist.

  • Next.js 13 app directory
  • creating and sharing private, public, password-protected, and unlisted posts
    • syntax highlighting
    • expiring posts
  • responsive UI
  • user auth
    • SSO via HTTP header (Issue: #11)
    • SSO via GitHub OAuth
  • downloading files (individually and entire posts)
  • password protected posts
  • postgres database
  • administrator account / settings
  • docker-compose (PRs: #13, #75)
    • publish docker builds
  • user settings
  • works enough with JavaScript disabled
  • in-depth documentation
  • customizable homepage, so the demo can exist as-is but other instances can be built from the same source. Environment variable for the file contents?
  • fleshed out API
  • Swappable database backends
  • More OAuth providers