1
0
Fork 0
mirror of https://github.com/kou029w/quot.git synced 2025-01-31 14:28:06 +00:00

Compare commits

..

No commits in common. "f29cc8e838ef3c9bbe769743cbf7ecf9c92143ee" and "b725b250d332ff1649e49a927dde33e73ea04fbe" have entirely different histories.

9 changed files with 24 additions and 76 deletions

View file

@ -1,5 +1,5 @@
:root { :root {
font-size: 14px; font-size: 12px;
--nc-font-sans: sans-serif; --nc-font-sans: sans-serif;
--nc-font-mono: monospace; --nc-font-mono: monospace;
--nc-lk-1: #1875d1; --nc-lk-1: #1875d1;
@ -9,13 +9,11 @@
} }
body { body {
padding-inline: 0.75rem; padding-inline: 1rem;
max-inline-size: 80rem; max-inline-size: 80rem;
} }
header { header {
padding-block: 1.25rem;
margin-bottom: 0.75rem;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-evenly; justify-content: space-evenly;
@ -23,7 +21,6 @@ header {
header h1 { header h1 {
margin: 0; margin: 0;
font-size: 1.85rem;
} }
header h1 > :is(a, a:hover) { header h1 > :is(a, a:hover) {
@ -31,8 +28,7 @@ header h1 > :is(a, a:hover) {
} }
header nav > * { header nav > * {
margin: 0.75rem; font-size: 1.55rem;
font-size: 1.25rem;
} }
a[href^="/"] { a[href^="/"] {

View file

@ -2,13 +2,11 @@ import "./app.css";
import { createSignal } from "solid-js"; import { createSignal } from "solid-js";
import Index from "./pages/index"; import Index from "./pages/index";
import Page from "./pages/page"; import Page from "./pages/page";
import Random from "./pages/random";
import random from "./helpers/random"; import random from "./helpers/random";
import { decodeJwt } from "jose"; import { decodeJwt } from "jose";
const routes = { const routes = {
"/": Index, "/": Index,
"/random": Random,
}; };
async function updateUser(jwt: string): Promise<boolean> { async function updateUser(jwt: string): Promise<boolean> {
@ -72,7 +70,6 @@ export default () => {
</h1> </h1>
<nav> <nav>
<a href={authenticated ? "/new" : "/login"}>📄</a> <a href={authenticated ? "/new" : "/login"}>📄</a>
<a href="/random">🔀</a>
</nav> </nav>
</header> </header>
{routes[pathname()] ?? ( {routes[pathname()] ?? (

View file

@ -1,7 +1,6 @@
.card { .card {
margin: unset; margin: unset;
padding: 0.25rem 0.75rem; padding: 1rem;
font-size: 0.75rem;
aspect-ratio: 1; aspect-ratio: 1;
box-sizing: border-box; box-sizing: border-box;
overflow: hidden; overflow: hidden;
@ -14,7 +13,6 @@
} }
.card h2 { .card h2 {
margin: unset;
padding: unset; padding: unset;
font-size: unset; font-size: unset;
} }

View file

@ -1,7 +1,7 @@
.cards { .cards {
display: grid; display: grid;
gap: 0.75rem; gap: 1rem;
grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
} }
.cards > a:hover::after { .cards > a:hover::after {

View file

@ -1,6 +1,5 @@
.editor { .editor {
padding: 0.75rem; padding: 1rem;
font-size: 1rem;
box-sizing: border-box; box-sizing: border-box;
background-color: var(--nc-bg-2); background-color: var(--nc-bg-2);
color: var(--nc-tx-2); color: var(--nc-tx-2);
@ -12,7 +11,7 @@
.editor :is(h1, h2, h3, h4, h5, h6) { .editor :is(h1, h2, h3, h4, h5, h6) {
padding: unset; padding: unset;
font-size: 1.25rem; font-size: unset;
} }
.editor p { .editor p {

View file

@ -75,9 +75,7 @@ export default (props: {
return `${" ".repeat(indent)}${line.getTextContent()}`; return `${" ".repeat(indent)}${line.getTextContent()}`;
}); });
const text = [title, ...lines].join("\n"); const text = [title, ...lines].join("\n");
if (props.text !== text) { props.onUpdatePage({ id: props.id, title, text });
props.onUpdatePage({ id: props.id, title, text });
}
}) })
) )
); );

View file

@ -1,21 +0,0 @@
import { createEffect, createResource } from "solid-js";
import type Pages from "../../protocol/pages";
import random from "../helpers/random";
async function randomPage(): Promise<Pages.ResponsePage> {
const jwt = window.localStorage.getItem("jwt");
const res = await fetch(
`${import.meta.env.QUOT_API_ENDPOINT}/pages?order=random&limit=1`,
{ headers: jwt ? { authorization: `Bearer ${jwt}` } : {} }
);
const data = (await res.json()) as Pages.Response;
return data[0]!;
}
export default () => {
const [page] = createResource(random(), randomPage);
createEffect(() => {
if (!page.loading) window.location.replace(`/${page()!.id.toString(16)}`);
});
return null;
};

View file

@ -1,7 +0,0 @@
-- migrate:up
CREATE FUNCTION random(pages) RETURNS DOUBLE PRECISION LANGUAGE SQL AS $$
SELECT random();
$$;
-- migrate:down
DROP FUNCTION random(pages);

View file

@ -9,6 +9,20 @@ SET xmloption = content;
SET client_min_messages = warning; SET client_min_messages = warning;
SET row_security = off; SET row_security = off;
--
-- Name: update_timestamp(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated = CURRENT_TIMESTAMP;
RETURN NEW;
END
$$;
SET default_tablespace = ''; SET default_tablespace = '';
SET default_table_access_method = heap; SET default_table_access_method = heap;
@ -28,31 +42,6 @@ CREATE TABLE public.pages (
); );
--
-- Name: random(public.pages); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.random(public.pages) RETURNS double precision
LANGUAGE sql
AS $$
SELECT random();
$$;
--
-- Name: update_timestamp(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.update_timestamp() RETURNS trigger
LANGUAGE plpgsql
AS $$
BEGIN
NEW.updated = CURRENT_TIMESTAMP;
RETURN NEW;
END
$$;
-- --
-- Name: pages_id_seq; Type: SEQUENCE; Schema: public; Owner: - -- Name: pages_id_seq; Type: SEQUENCE; Schema: public; Owner: -
-- --
@ -197,5 +186,4 @@ CREATE POLICY users_policy ON public.users USING ((id = ((current_setting('reque
-- --
INSERT INTO public.schema_migrations (version) VALUES INSERT INTO public.schema_migrations (version) VALUES
('0'), ('0');
('20220907130637');