diff --git a/articles.php b/articles.php new file mode 100644 index 0000000..a1e2e1c --- /dev/null +++ b/articles.php @@ -0,0 +1,28 @@ + diff --git a/components/head.php b/components/head.php index fe942c9..751dbdb 100644 --- a/components/head.php +++ b/components/head.php @@ -3,8 +3,21 @@ - - + + + '; +} elseif ($_SESSION['theme'] == 'light') { + echo ' + + '; +} +?> + + + diff --git a/components/nav.php b/components/nav.php new file mode 100644 index 0000000..b7c872a --- /dev/null +++ b/components/nav.php @@ -0,0 +1,28 @@ + +
+ +
+'; + +$theme_toggle = ''; +if ($_SESSION['theme'] == 'dark') + $theme_toggle = 'light'; +else + $theme_toggle = 'dark'; + +$nav .= ' + +
+
+ +'; + +echo $nav; diff --git a/article.php b/compose.php similarity index 78% rename from article.php rename to compose.php index 0aec9e4..da33b09 100644 --- a/article.php +++ b/compose.php @@ -1,10 +1,7 @@ text($markdown); + $html = '
'; + $html .= $parsedown->text($markdown); + $html .= '
'; return $html; } @@ -24,17 +50,20 @@ function article_page_from_markdown($article_id) */ function article_card($article_id) { - $article_query = 'SELECT * FROM articles WHERE article_id = ' . $article_id . ';'; + $article_query = 'SELECT * FROM article WHERE article_id = ' . $article_id . ';'; $article = query_db_one_result($article_query); $article_tags_query = 'SELECT tag FROM article_tags INNER JOIN tags ON article_tags.tag_id = tags.tag_id WHERE article_id = ' . $article_id . ';'; $tags_results = query_db_one_or_more_results($article_tags_query); - $tags_html = '
'; + $tags_html = ''; + if ($tags_results != null) { + $tags_html .= '
'; - while ($row = mysqli_fetch_array($tags_results)) - $tags_html .= '#' . $row['tag'] . ''; + while ($row = mysqli_fetch_array($tags_results)) + $tags_html .= '#' . $row['tag'] . ''; - $tags_html .= '
'; + $tags_html .= '
'; + } $author_query = 'SELECT username, profile_picture FROM user WHERE user_id = ' . $article['author_id'] . ';'; $author = query_db_one_result($author_query); @@ -56,7 +85,7 @@ function article_card($article_id)

' . $article['excerpt'] . '

- Read More + Read More
' . $tags_html . '
diff --git a/functions/init.php b/functions/init.php index cd22382..989d46c 100644 --- a/functions/init.php +++ b/functions/init.php @@ -1,4 +1,5 @@ safeLoad(); // Set SESSION variable. -$_SESSION['initialized'] = true; +if (!isset($_SESSION['initialized'])) { + $_SESSION['initialized'] = true; + $_SESSION['theme'] = 'dark'; +} + +if ($_SESSION['initialized'] && isset($_POST['theme'])) { + $_SESSION['theme'] = $_POST['theme']; + unset($_POST['theme']); +} diff --git a/index.php b/index.php index 22e0a92..c9257f4 100644 --- a/index.php +++ b/index.php @@ -8,7 +8,4 @@ require_once 'functions/functions.php'; include_once 'components/head.php'; -include_once 'functions/article_functions.php'; -echo article_card(1); - include_once 'components/foot.php'; diff --git a/resources/HackNerdFont-Bold.ttf b/resources/HackNerdFont-Bold.ttf new file mode 100644 index 0000000..7b73ac5 Binary files /dev/null and b/resources/HackNerdFont-Bold.ttf differ diff --git a/resources/HackNerdFont-BoldItalic.ttf b/resources/HackNerdFont-BoldItalic.ttf new file mode 100644 index 0000000..06375dd Binary files /dev/null and b/resources/HackNerdFont-BoldItalic.ttf differ diff --git a/resources/HackNerdFont-Italic.ttf b/resources/HackNerdFont-Italic.ttf new file mode 100644 index 0000000..39009f9 Binary files /dev/null and b/resources/HackNerdFont-Italic.ttf differ diff --git a/resources/HackNerdFont-Regular.ttf b/resources/HackNerdFont-Regular.ttf new file mode 100644 index 0000000..f397f20 Binary files /dev/null and b/resources/HackNerdFont-Regular.ttf differ diff --git a/resources/HackNerdFontMono-Bold.ttf b/resources/HackNerdFontMono-Bold.ttf new file mode 100644 index 0000000..1e9e746 Binary files /dev/null and b/resources/HackNerdFontMono-Bold.ttf differ diff --git a/resources/HackNerdFontMono-BoldItalic.ttf b/resources/HackNerdFontMono-BoldItalic.ttf new file mode 100644 index 0000000..f4fc85f Binary files /dev/null and b/resources/HackNerdFontMono-BoldItalic.ttf differ diff --git a/resources/HackNerdFontMono-Italic.ttf b/resources/HackNerdFontMono-Italic.ttf new file mode 100644 index 0000000..29fbdf4 Binary files /dev/null and b/resources/HackNerdFontMono-Italic.ttf differ diff --git a/resources/HackNerdFontMono-Regular.ttf b/resources/HackNerdFontMono-Regular.ttf new file mode 100644 index 0000000..c43eee0 Binary files /dev/null and b/resources/HackNerdFontMono-Regular.ttf differ diff --git a/resources/HackNerdFontPropo-Bold.ttf b/resources/HackNerdFontPropo-Bold.ttf new file mode 100644 index 0000000..379e8e2 Binary files /dev/null and b/resources/HackNerdFontPropo-Bold.ttf differ diff --git a/resources/HackNerdFontPropo-BoldItalic.ttf b/resources/HackNerdFontPropo-BoldItalic.ttf new file mode 100644 index 0000000..893546a Binary files /dev/null and b/resources/HackNerdFontPropo-BoldItalic.ttf differ diff --git a/resources/HackNerdFontPropo-Italic.ttf b/resources/HackNerdFontPropo-Italic.ttf new file mode 100644 index 0000000..353cf94 Binary files /dev/null and b/resources/HackNerdFontPropo-Italic.ttf differ diff --git a/resources/HackNerdFontPropo-Regular.ttf b/resources/HackNerdFontPropo-Regular.ttf new file mode 100644 index 0000000..d8fc76d Binary files /dev/null and b/resources/HackNerdFontPropo-Regular.ttf differ diff --git a/resources/LICENSE.md b/resources/LICENSE.md new file mode 100644 index 0000000..08927e5 --- /dev/null +++ b/resources/LICENSE.md @@ -0,0 +1,45 @@ +The work in the Hack project is Copyright 2018 Source Foundry Authors and licensed under the MIT License + +The work in the DejaVu project was committed to the public domain. + +Bitstream Vera Sans Mono Copyright 2003 Bitstream Inc. and licensed under the Bitstream Vera License with Reserved Font Names "Bitstream" and "Vera" + +### MIT License + +Copyright (c) 2018 Source Foundry Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +### BITSTREAM VERA LICENSE + +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions: + +The above copyright and trademark notices and this permission notice shall be included in all copies of one or more of the Font Software typefaces. + +The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing either the words "Bitstream" or the word "Vera". + +This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "Bitstream Vera" names. + +The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE. + +Except as contained in this notice, the names of Gnome, the Gnome Foundation, and Bitstream Inc., shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Font Software without prior written authorization from the Gnome Foundation or Bitstream Inc., respectively. For further information, contact: fonts at gnome dot org. diff --git a/resources/README.md b/resources/README.md new file mode 100644 index 0000000..d5bd32b --- /dev/null +++ b/resources/README.md @@ -0,0 +1,48 @@ +# Nerd Fonts + +This is an archived font from the Nerd Fonts release v3.3.0. + +For more information see: +* https://github.com/ryanoasis/nerd-fonts/ +* https://github.com/ryanoasis/nerd-fonts/releases/latest/ + +# Hack + +A typeface designed for source code. + +For more information have a look at the upstream website: https://github.com/source-foundry/Hack + +Version: 3.003 + +## Which font? + +### TL;DR + +* Pick your font family: + * If you are limited to monospaced fonts (because of your terminal, etc) then pick a font with `Nerd Font Mono` (or `NFM`). + * If you want to have bigger icons (usually around 1.5 normal letters wide) pick a font without `Mono` i.e. `Nerd Font` (or `NF`). Most terminals support this, but ymmv. + * If you work in a proportional context (GUI elements or edit a presentation etc) pick a font with `Nerd Font Propo` (or `NFP`). + +### Ligatures + +Ligatures are generally preserved in the patched fonts. +Nerd Fonts `v2.0.0` had no ligatures in the `Nerd Font Mono` fonts, this has been dropped with `v2.1.0`. +If you have a ligature-aware terminal and don't want ligatures you can (usually) disable them in the terminal settings. + +### Explanation + +Once you narrow down your font choice of family (`Droid Sans`, `Inconsolata`, etc) and style (`bold`, `italic`, etc) you have 2 main choices: + +#### `Option 1: Download already patched font` + + * For a stable version download a font package from the [release page](https://github.com/ryanoasis/nerd-fonts/releases) + * Or download the development version from the folders here + +#### `Option 2: Patch your own font` + + * Patch your own variations with the various options provided by the font patcher (i.e. not include all symbols for smaller font size) + +For more information see: [The FAQ](https://github.com/ryanoasis/nerd-fonts/wiki/FAQ-and-Troubleshooting#which-font) + +[SIL-RFN]:http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web_fonts_and_RFNs#14cbfd4a + diff --git a/scripts/init.sql b/scripts/init.sql index 3b03797..73b1dac 100644 --- a/scripts/init.sql +++ b/scripts/init.sql @@ -6,17 +6,11 @@ CREATE TABLE roles ( role VARCHAR(16) NOT NULL ); -INSERT INTO roles (role) - VALUES ('owner'), ('admin'), ('contributor'), ('reader'); - CREATE TABLE tags ( tag_id INT PRIMARY KEY AUTO_INCREMENT, tag VARCHAR(16) NOT NULL ); -INSERT INTO tags (tag) - VALUES ('linux'), ('web-dev'), ('raspberry-pi'), ('self-hosting'); - CREATE TABLE user ( user_id INT PRIMARY KEY, username VARCHAR(32) NOT NULL UNIQUE, @@ -30,11 +24,10 @@ CREATE TABLE user ( FOREIGN KEY (role_id) REFERENCES roles (role_id) ); -CREATE TABLE articles ( +CREATE TABLE article ( article_id INT PRIMARY KEY AUTO_INCREMENT, author_id INT NOT NULL, - markdown_file_path VARCHAR(256) NOT NULL UNIQUE, - title VARCHAR(64) NOT NULL, + title VARCHAR(26) NOT NULL, slug VARCHAR(32), read_count INT DEFAULT 0, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, @@ -46,9 +39,27 @@ CREATE TABLE articles ( ); CREATE TABLE article_tags ( - article_id INT NOT NULL, - tag_id INT NOT NULL, - PRIMARY KEY (article_id, tag_id), - FOREIGN KEY (article_id) REFERENCES articles(article_id), - FOREIGN KEY (tag_id) REFERENCES tags(tag_id) + article_id INT NOT NULL, + tag_id INT NOT NULL, + PRIMARY KEY (article_id, tag_id), + FOREIGN KEY (article_id) REFERENCES article(article_id), + FOREIGN KEY (tag_id) REFERENCES tags(tag_id) ); + +INSERT INTO roles (role) + VALUES ('owner'), ('admin'), ('contributor'), ('reader'); + +INSERT INTO tags (tag) + VALUES ('linux'), ('web-dev'), ('raspberry-pi'), ('self-hosting'), ('devlog'), ('testing'); + +INSERT INTO user (user_id, username, email, password_hash, role_id, profile_picture) + VALUES (2025, 'quaxlyqueen', 'me@joshashton.dev', 'changeme', 1, '2025.jpg'); + +INSERT INTO article (author_id, title, excerpt, published_at) + VALUES (2025, 'Building vintagecoding.net', 'This site is intended to be a platform for exposing, celebrating, and sharing the style of Vintage Coding. Topics from hardware to software and kernel to web, this site aims to cover it all.', CURRENT_TIMESTAMP); + +INSERT INTO article (author_id, title, excerpt, published_at) + VALUES (2025, 'Testing vintagecoding.net', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas a mauris sit amet dui pellentesque sodales. Pellentesque non viverra leo, et congue metus.', CURRENT_TIMESTAMP); + +INSERT INTO article_tags (article_id, tag_id) VALUES (1, 2), (1, 4), (1, 5); +INSERT INTO article_tags (article_id, tag_id) VALUES (2, 2), (2, 6);