paste-free.openapps.xyz

Source

This app’s code and revision history are public. Download a copy or explore the files below.

Public
The app’s code and revision history are public.
Owned app · rev 01fdb2b1f66e
Run it yourself
Take the whole tree and run it on your own machine. The download needs no account. Cloning needs a sign-in.
Download .zip
bounded clone 6eca480d6447d873e2e5eed9
A copy you download is not bounded. The guarantees this app runs under - declared egress, proven invariants, writes that fail closed - live in the runtime serving this page, not in the files. What you get is auditable source you can read and run, with no runtime guarantees attached.
← All files
src/main.tsx
// Paste's entry. "/" keeps the static landing and mounts the editor and "Your pastes" into it;
// "/<id>" shows a paste, "/<id>/admin" its admin page, and "/<id>/raw" hands over to the API's plain text.
import { lazy, Suspense } from "react";
import { createRoot } from "react-dom/client";
import { usePath } from "./lib/router";
import { SERVED_API } from "./lib/app";
import { Toaster } from "./ui";
import { Editor, YourPastes } from "./Editor";
import { ViewPage } from "./View";
import { AdminSkeleton } from "./Skeletons";
import "./styles.css";

const AdminPage = lazy(() => import("./Admin"));
// Must match the inline script at the top of index.html.
const ROUTE = /^\/([A-Za-z0-9]{12})(?:\/(admin|raw))?\/?$/;

function setNoIndex(on: boolean) {
  let meta = document.querySelector<HTMLMetaElement>('meta[name="robots"]');
  if (on && !meta) document.head.append(Object.assign(document.createElement("meta"), { name: "robots", content: "noindex" }));
  if (!on) meta?.remove();
}

function App() {
  const path = usePath();
  const route = path.match(ROUTE);
  if (route?.[2] === "raw") {
    location.replace(`${SERVED_API}/pastes/${route[1]}/raw`);
    return null;
  }
  document.documentElement.classList.toggle("app-route", Boolean(route));
  document.body.classList.toggle("app-mode", Boolean(route));
  setNoIndex(Boolean(route));
  if (!route) document.title = "Paste: free Pastebin alternative with no ads and no daily paste limit | OpenApps";
  return (
    <>
      {route?.[2] === "admin" ? (
        <Suspense fallback={<AdminSkeleton />}>
          <AdminPage key={route[1]} id={route[1]} />
        </Suspense>
      ) : route ? <ViewPage key={route[1]} id={route[1]} /> : null}
      <Toaster />
    </>
  );
}

createRoot(document.getElementById("app")!).render(<App />);
createRoot(document.getElementById("create")!).render(<Editor />);
createRoot(document.getElementById("mine")!).render(<YourPastes />);

Change history

Quality pass: password lock, year expiry, line links, text/plain API
01fdb2b1f6 · 4 hours ago
Bounded source sync
fe5788c2d2 · 1 day ago
Bounded source sync
ac6f7dbc95 · 1 day ago
Bounded source sync
0a45926293 · 1 day ago