mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 02:41:35 +01:00
Add theme toggle for templates
This commit is contained in:
@@ -37,8 +37,7 @@ CREATE TABLE internal.website (
|
||||
is_published BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CLOCK_TIMESTAMP(),
|
||||
last_modified_at TIMESTAMPTZ NOT NULL DEFAULT CLOCK_TIMESTAMP(),
|
||||
last_modified_by UUID REFERENCES internal.user (id) ON DELETE SET NULL,
|
||||
title_search TSVECTOR GENERATED ALWAYS AS (TO_TSVECTOR('english', title)) STORED
|
||||
last_modified_by UUID REFERENCES internal.user (id) ON DELETE SET NULL
|
||||
);
|
||||
|
||||
CREATE TABLE internal.media (
|
||||
@@ -107,7 +106,6 @@ CREATE TABLE internal.article (
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CLOCK_TIMESTAMP(),
|
||||
last_modified_at TIMESTAMPTZ NOT NULL DEFAULT CLOCK_TIMESTAMP(),
|
||||
last_modified_by UUID REFERENCES internal.user (id) ON DELETE SET NULL,
|
||||
title_description_search TSVECTOR GENERATED ALWAYS AS (TO_TSVECTOR('english', COALESCE(title, '') || ' ' || COALESCE(meta_description, ''))) STORED,
|
||||
UNIQUE (website_id, category, article_weight)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
-- migrate:up
|
||||
CREATE FUNCTION pgrst_watch ()
|
||||
CREATE FUNCTION internal.pgrst_watch ()
|
||||
RETURNS EVENT_TRIGGER
|
||||
AS $$
|
||||
BEGIN
|
||||
@@ -10,10 +10,10 @@ $$
|
||||
LANGUAGE plpgsql;
|
||||
|
||||
CREATE EVENT TRIGGER pgrst_watch ON ddl_command_end
|
||||
EXECUTE FUNCTION pgrst_watch ();
|
||||
EXECUTE FUNCTION internal.pgrst_watch ();
|
||||
|
||||
-- migrate:down
|
||||
DROP EVENT TRIGGER pgrst_watch;
|
||||
|
||||
DROP FUNCTION pgrst_watch ();
|
||||
DROP FUNCTION internal.pgrst_watch ();
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ CREATE FUNCTION internal.user_role (username TEXT, pass TEXT, OUT role_name NAME
|
||||
AS $$
|
||||
BEGIN
|
||||
SELECT
|
||||
ROLE INTO role_name
|
||||
u.role INTO role_name
|
||||
FROM
|
||||
internal.user AS u
|
||||
WHERE
|
||||
@@ -111,7 +111,7 @@ AS $$
|
||||
DECLARE
|
||||
_role NAME;
|
||||
_user_id UUID;
|
||||
_exp INTEGER;
|
||||
_exp INTEGER := EXTRACT(EPOCH FROM CLOCK_TIMESTAMP())::INTEGER + 86400;
|
||||
BEGIN
|
||||
SELECT
|
||||
internal.user_role (login.username, login.pass) INTO _role;
|
||||
@@ -120,12 +120,11 @@ BEGIN
|
||||
USING message = 'Invalid username or password';
|
||||
ELSE
|
||||
SELECT
|
||||
id INTO _user_id
|
||||
u.id INTO _user_id
|
||||
FROM
|
||||
internal.user AS u
|
||||
WHERE
|
||||
u.username = login.username;
|
||||
_exp := EXTRACT(EPOCH FROM CLOCK_TIMESTAMP())::INTEGER + 86400;
|
||||
SELECT
|
||||
SIGN(JSON_BUILD_OBJECT('role', _role, 'user_id', _user_id, 'username', login.username, 'exp', _exp), CURRENT_SETTING('app.jwt_secret')) INTO token;
|
||||
END IF;
|
||||
|
||||
@@ -99,17 +99,7 @@ BEGIN
|
||||
INSERT INTO internal.home (website_id, main_content)
|
||||
VALUES (_website_id, '## About
|
||||
|
||||
archtika is a FLOSS, modern, performant and lightweight CMS (Content Mangement System) in the form of a web application. It allows you to easily create, manage and publish minimal, responsive and SEO friendly blogging and documentation websites with official, professionally designed templates.
|
||||
|
||||
It is also possible to add contributors to your sites, which is very useful for larger projects where, for example, several people are constantly working on the documentation.
|
||||
|
||||
## How it works
|
||||
|
||||
For the backend, PostgreSQL is used in combination with PostgREST to create a RESTful API. JSON web tokens along with row-level security control authentication and authorisation flows.
|
||||
|
||||
The web application uses SvelteKit with SSR (Server Side Rendering) and Svelte version 5, currently in beta.
|
||||
|
||||
NGINX is used to deploy the websites, serving the static site files from the `/var/www/archtika-websites` directory. The static files can be found in this directory via the path `<user_id>/<website_id>`, which is dynamically created by the web application.');
|
||||
archtika is a FLOSS, modern, performant and lightweight CMS (Content Mangement System) in the form of a web application. It allows you to easily create, manage and publish minimal, responsive and SEO friendly blogging and documentation websites with official, professionally designed templates. It is also possible to add contributors to your sites, which is very useful for larger projects where, for example, several people are constantly working on the documentation.');
|
||||
INSERT INTO internal.footer (website_id, additional_text)
|
||||
VALUES (_website_id, 'archtika is a free, open, modern, performant and lightweight CMS');
|
||||
website_id := _website_id;
|
||||
|
||||
@@ -7,11 +7,11 @@ DECLARE
|
||||
BEGIN
|
||||
IF (NOT EXISTS (
|
||||
SELECT
|
||||
id
|
||||
u.id
|
||||
FROM
|
||||
internal.user
|
||||
internal.user AS u
|
||||
WHERE
|
||||
id = _user_id)) THEN
|
||||
u.id = _user_id)) THEN
|
||||
RETURN COALESCE(NEW, OLD);
|
||||
END IF;
|
||||
IF TG_OP != 'DELETE' THEN
|
||||
|
||||
@@ -21,7 +21,7 @@ BEGIN
|
||||
SELECT
|
||||
UNNEST(_allowed_mimetypes))) THEN
|
||||
RAISE invalid_parameter_value
|
||||
USING message = 'Invalid MIME type. Allowed types are: png, jpg, webp';
|
||||
USING message = 'Invalid MIME type. Allowed types are: png, jpg, webp, avif, gif, svg';
|
||||
ELSIF OCTET_LENGTH($1) > _max_file_size THEN
|
||||
RAISE program_limit_exceeded
|
||||
USING message = FORMAT('File size exceeds the maximum limit of %s MB', _max_file_size / (1024 * 1024));
|
||||
@@ -56,7 +56,7 @@ BEGIN
|
||||
SELECT
|
||||
m.blob
|
||||
FROM
|
||||
internal.media m
|
||||
internal.media AS m
|
||||
WHERE
|
||||
m.id = retrieve_file.id INTO _blob;
|
||||
IF FOUND THEN
|
||||
|
||||
@@ -22,11 +22,11 @@ DECLARE
|
||||
BEGIN
|
||||
IF (NOT EXISTS (
|
||||
SELECT
|
||||
id
|
||||
u.id
|
||||
FROM
|
||||
internal.user
|
||||
internal.user AS u
|
||||
WHERE
|
||||
id = _user_id) OR (to_jsonb (OLD.*) - 'last_modified_at' - 'last_modified_by') = (to_jsonb (NEW.*) - 'last_modified_at' - 'last_modified_by')) THEN
|
||||
u.id = _user_id) OR (to_jsonb (OLD.*) - 'last_modified_at' - 'last_modified_by') = (to_jsonb (NEW.*) - 'last_modified_at' - 'last_modified_by')) THEN
|
||||
RETURN NULL;
|
||||
END IF;
|
||||
IF TG_TABLE_NAME = 'website' THEN
|
||||
@@ -40,21 +40,21 @@ BEGIN
|
||||
ELSIF (TG_OP = 'UPDATE'
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
id
|
||||
w.id
|
||||
FROM
|
||||
internal.website
|
||||
internal.website AS w
|
||||
WHERE
|
||||
id = _website_id)) THEN
|
||||
w.id = _website_id)) THEN
|
||||
INSERT INTO internal.change_log (website_id, table_name, operation, old_value, new_value)
|
||||
VALUES (_website_id, TG_TABLE_NAME, TG_OP, HSTORE (OLD) - HSTORE (NEW), HSTORE (NEW) - HSTORE (OLD));
|
||||
ELSIF (TG_OP = 'DELETE'
|
||||
AND EXISTS (
|
||||
SELECT
|
||||
id
|
||||
w.id
|
||||
FROM
|
||||
internal.website
|
||||
internal.website AS w
|
||||
WHERE
|
||||
id = _website_id)) THEN
|
||||
w.id = _website_id)) THEN
|
||||
INSERT INTO internal.change_log (website_id, table_name, operation, old_value)
|
||||
VALUES (_website_id, TG_TABLE_NAME, TG_OP, HSTORE (OLD));
|
||||
END IF;
|
||||
|
||||
Reference in New Issue
Block a user