More reorganization
This commit is contained in:
75
scripts/create_db.sql
Normal file
75
scripts/create_db.sql
Normal file
@ -0,0 +1,75 @@
|
||||
DROP TABLE IF EXISTS articles_tags;
|
||||
DROP TABLE IF EXISTS articles_contributors;
|
||||
DROP TABLE IF EXISTS articles_authors;
|
||||
DROP TABLE IF EXISTS tags;
|
||||
DROP TABLE IF EXISTS articles;
|
||||
DROP TABLE IF EXISTS issues;
|
||||
DROP TABLE IF EXISTS users;
|
||||
|
||||
CREATE TABLE users (
|
||||
id INT AUTO_INCREMENT,
|
||||
username VARCHAR(255) NOT NULL UNIQUE,
|
||||
password VARCHAR(60) NOT NULL,
|
||||
first_name VARCHAR(255) NOT NULL,
|
||||
last_name VARCHAR(255) NOT NULL,
|
||||
email VARCHAR(255) NOT NULL,
|
||||
profile_pic_link VARCHAR(255),
|
||||
role INT NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE issues (
|
||||
id INT AUTO_INCREMENT,
|
||||
published BOOL NOT NULL,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE articles (
|
||||
id INT AUTO_INCREMENT,
|
||||
title VARCHAR(255) NOT NULL,
|
||||
created TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
banner_link VARCHAR(255),
|
||||
summary TEXT NOT NULL,
|
||||
published BOOL NOT NULL,
|
||||
rejected BOOL NOT NULL,
|
||||
creator_id INT NOT NULL,
|
||||
issue_id INT NOT NULL,
|
||||
edited_id INT NOT NULL,
|
||||
clicks INT NOT NULL,
|
||||
is_in_issue BOOL NOT NULL,
|
||||
auto_generated BOOL NOT NULL,
|
||||
uuid VARCHAR(36) NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (creator_id) REFERENCES users (id),
|
||||
FOREIGN KEY (issue_id) REFERENCES issues (id)
|
||||
);
|
||||
|
||||
CREATE TABLE tags (
|
||||
id INT AUTO_INCREMENT,
|
||||
name VARCHAR(50) NOT NULL UNIQUE,
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
CREATE TABLE articles_authors (
|
||||
article_id INT NOT NULL,
|
||||
author_id INT NOT NULL,
|
||||
PRIMARY KEY (article_id, author_id),
|
||||
FOREIGN KEY (article_id) REFERENCES articles (id),
|
||||
FOREIGN KEY (author_id) REFERENCES users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE articles_contributors (
|
||||
article_id INT NOT NULL,
|
||||
contributor_id INT NOT NULL,
|
||||
PRIMARY KEY (article_id, contributor_id),
|
||||
FOREIGN KEY (article_id) REFERENCES articles (id),
|
||||
FOREIGN KEY (contributor_id) REFERENCES users (id)
|
||||
);
|
||||
|
||||
CREATE TABLE articles_tags (
|
||||
article_id INT NOT NULL,
|
||||
tag_id INT NOT NULL,
|
||||
PRIMARY KEY (article_id, tag_id),
|
||||
FOREIGN KEY (article_id) REFERENCES articles (id),
|
||||
FOREIGN KEY (tag_id) REFERENCES tags (id)
|
||||
);
|
33
scripts/create_toc.lua
Normal file
33
scripts/create_toc.lua
Normal file
@ -0,0 +1,33 @@
|
||||
-- Helper function: remove all image inlines from a list of inlines.
|
||||
local function remove_images(inlines)
|
||||
local result = {}
|
||||
for _, item in ipairs(inlines) do
|
||||
if item.t ~= "Image" then
|
||||
table.insert(result, item)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
-- Build a bullet list representing the table of contents.
|
||||
local function build_toc(doc)
|
||||
local toc_items = {}
|
||||
for _, block in ipairs(doc.blocks) do
|
||||
if block.t == "Header" then
|
||||
local clean_inlines = remove_images(block.content)
|
||||
local header_text = pandoc.utils.stringify(clean_inlines)
|
||||
if header_text ~= "" then
|
||||
local link = pandoc.Link(clean_inlines, "#" .. block.identifier)
|
||||
table.insert(toc_items, { link })
|
||||
end
|
||||
end
|
||||
end
|
||||
return pandoc.BulletList(toc_items)
|
||||
end
|
||||
|
||||
-- The Pandoc function runs after the document is fully constructed.
|
||||
function Pandoc(doc)
|
||||
local toc = build_toc(doc)
|
||||
table.insert(doc.blocks, 1, toc) -- Insert the TOC at the very beginning of the document.
|
||||
return doc
|
||||
end
|
Reference in New Issue
Block a user