commit 4785bb6afa4ba2735d9cbd1ffbd71aa58eb16eba Author: Jenga Phoenix Date: Mon Feb 11 00:14:30 2019 -0600 Init and scaffolding diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..05f2d4c --- /dev/null +++ b/README.txt @@ -0,0 +1,43 @@ +=============================================================================== +BLAGOBLAG Simple blogsphere-ish system +=============================================================================== + +Blagoblag is a pretty simple system that'd be perfectly at home in the +blogosphere.[1] + +TL;DR, registered users can create date-stamped posts. Someone can browse +posts by date (from all users) in a format resembling a “newsletter,” or +by user. +Users can create comments on any post after filling out a simple CAPTCHA. + +Y'know, stuff along those lines. + +[1] https://xkcd.com/181/ + + + +---------------------------------------- +PRE-REQUISITES +---------------------------------------- + * PHP 7.0 + * Webserver with CGI enabled + * A paper-clip and soldering-iron + * Also a lighter + + + +---------------------------------------- +INSTALLATION +---------------------------------------- +Drop Blagoblag in any directory on your webserver, then create an SQL +database for Blagoblag. Make sure to make a "config.ini" file (from +"config.ini.example")-- at the minimum, you need to configure the SQL +connection settings. + + + +---------------------------------------- +BORING STUFF +---------------------------------------- +License is AGPLv3, copyleft. +TL;DR, do whatever, but share the source-code. :) diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1698897 --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ "require": + { + "twig/twig": "1.*" + } +} diff --git a/docs/database_spec.txt b/docs/database_spec.txt new file mode 100644 index 0000000..c862314 --- /dev/null +++ b/docs/database_spec.txt @@ -0,0 +1,24 @@ +=============================================================================== +DATABASE SPEC +=============================================================================== + +We use `dbi4php` (/lib/ext/dbi4php/) for database access, so that we don't +have to rely on a specific DB. + +Anything supported by DBI (MySQL, MS SQL, Oracles, PostgreSQL, ODBC, Interbase, +SQLite, IBM DB2) will work just fine. + +The database name will be fetched from the "config.ini" file-- and a table +will be automatically created as necessary. + +The tables used by Blagoblag are: + + posts (title varchar(200), date datetime, author smallint, + text longtext) + + authors (id smallint primary key, username varchar(20), + password_hash varchar(30), full_name varchar(50)) + + comments (id smallint primary key, displayname varchar(20), + text shorttext, date datetime) + diff --git a/docs/directory_structure.txt b/docs/directory_structure.txt new file mode 100644 index 0000000..97607e1 --- /dev/null +++ b/docs/directory_structure.txt @@ -0,0 +1,43 @@ +=============================================================================== +DIRECTORY STRUCTURE +=============================================================================== + +The structure of this repo is like this: + + /res/ + Contains publicly-accessible resources (CSS, etc), + and themes. + /res/img/ + Contains uploaded images. + /res/themes/ + Contains all themes (collections of CSS, images, and + templates). + /res/themes/default/ + The theme we're gonna develop and use. + /res/themes/default/css/ + CSS for the default theme. + /res/themes/default/templates/ + Templates for the default theme (our HTML). + + -------------------- + + /lib/ + Contains PHP files that should be included into every + PHP file. + /lib/ext/ + Contains external PHP libraries. + + -------------------- + + /public/ + The webroot. + Contains small, bare PHP files that render webpages. + Any requests for "/public/res/" will be rediricted by + the webserver to "/res/". + /public/*/private/ + PHP files for processing input (I.E., user submits + a blog)-- everything in */private/ should redirect + to something in a corresponding */results/ file. + /public/*/results/ + PHP files for displaying results of processed input + (I.E., "wow, that's an error" or "hooray, it worked") diff --git a/docs/frontend.txt b/docs/frontend.txt new file mode 100644 index 0000000..f09d402 --- /dev/null +++ b/docs/frontend.txt @@ -0,0 +1,23 @@ +=============================================================================== +FRONT-END +=============================================================================== +There are 6 different pages/views we need to work on: + + * INDEX/OVERVIEW + A page for showing a general overview of the site-- newest + posts overall. + * USER + A page dedicated to a given user, with their name, biography, + (maybe a picture? <3) and some of their recent psots. + * POST + A page dedicated to displaying a single article. Should list + the author, date, and text. Y'know, jazz like that. + * ABOUT + An about page, that talks about what this thing is. + + * NAVBAR + A top-bar/side-bar for navigation that will be shown on every + page in the site. + * FOOTER + A bottom-bar/footer that has whatever legal/boring/contact-us + stuff we want to put in it. diff --git a/docs/php_cheatsheet.txt b/docs/php_cheatsheet.txt new file mode 100644 index 0000000..113dd09 --- /dev/null +++ b/docs/php_cheatsheet.txt @@ -0,0 +1,114 @@ +=============================================================================== +A PHP CHEAT-SHEET +=============================================================================== + +---------------------------------------- +SYNTAX +---------------------------------------- +All PHP code must be between "": + + +Every statement ends with a semicolon, all function arguments +are seperated by commas, etc. + + +---------------------------------------- +OPERATORS +---------------------------------------- +Normal stuff (like +, -, etc.), but *also*: + . concatenation (mainly for strings, like "a" . "b" ... "ab") + ++ increment (add one, I.E. 1++ ... 2) + -- decrement (subtract one, I.E. 2-- ... 1) + + +---------------------------------------- +COMPARISON OPERATORS +---------------------------------------- + == equal (same data) + === identical (same type + data) + != not-equal (different data) + !== not-identicial (different type or data) + < less-than + > greater-than + <= less-than or equal-to + >= greater-than or equal-to + ?? null coalescing (choose first variable that's non-null, + from left to right) + +---------------------------------------- +VARIABLES +---------------------------------------- +All variables start like "$". Assignment is like this: + + $variable = "value"; + + +---------------------------------------- +FUNCTIONS +---------------------------------------- +Make a function like a lot of languages: + + function FUNCTION_NAME($ARGUMENT, $ARGUMENT) { + BLAH BLAH BLAH; + return BLAH; + } + +... replace FUNCTION_NAME with the name, $ARGUMENT with a variable name, +etc. etc. + +If you want an argument to be optional, assign it a default value, like: + + function FUNCTION_NAME($ARGUMENT = "default", $ARGUMENT = 2) { + + +---------------------------------------- +ARRAYS +---------------------------------------- +Make an array with + + array(KEY=>VALUE, KEY=>VALUE); + +VARIABLE can be a string or a number. + +Get an array value like + + $array[KEY] + + +---------------------------------------- +GLOBAL VARIABLES +---------------------------------------- +There are some important global variables-- + + $GET Hosts all GET data. + $POST All POST data + $SERVER SERVER data + $GLOBALS Contains all global vars. + +They're all arrays. +Variables are local to their function-- and often, global variables from +certain functions won't be accessible in the global scope of another. + +To reliably access (inter-file) globals, access them like values in an +array of $GLOBALS + + $GLOBALS[KEY] + + +---------------------------------------- +ETC. +---------------------------------------- +Really, most of PHP is really similar to other languages. +You should be able to read it pretty easily-- if there's something +you don't quite get, you can use the Wikibook + + https://en.wikibooks.org/wiki/PHP_Programming/ + +For quick reference. And for function definitions/examples, check the +PHP documentation + + https://secure.php.net/docs.php + +Also Google loves you <3 diff --git a/docs/twig.txt b/docs/twig.txt new file mode 100644 index 0000000..1b42309 --- /dev/null +++ b/docs/twig.txt @@ -0,0 +1,18 @@ +=============================================================================== +TWIG TEMPLATING SYSTEM +=============================================================================== +Twig is a system for writing HTML "templates"-- HTML snippets that can have +variable names in it, which PHP will interpret and replace with the values. + +We're gonna be using Twig, since it's really useful. + +If you're front-end, writing HTML, look at `./twig_example.html` for a general +example of how you'll use Twig. +You can alo read `https://twig.symfony.com/doc/2.x/templates.html` if you want +more in-depth documentation, but you probably don't need it. + +If you're back-end, writing PHP, look at +`https://twig.symfony.com/doc/2.x/api.html`. + + +Look at `variables.txt` for a list of the variables we'll be using. diff --git a/docs/twig_example.html b/docs/twig_example.html new file mode 100644 index 0000000..4e9f09a --- /dev/null +++ b/docs/twig_example.html @@ -0,0 +1,27 @@ + + + Twig Example + + + + + + +

My name is {{ name }}

+ + + +

List of animals:

+ + + + + diff --git a/docs/variables.txt b/docs/variables.txt new file mode 100644 index 0000000..55fa139 --- /dev/null +++ b/docs/variables.txt @@ -0,0 +1,83 @@ +=============================================================================== +VARIABLE LIST +=============================================================================== + +GLOBAL +---------------------------------------- +There are a few variables that will always be avaiable to use-- these are what +you can use in any page's template: + + * users[number] + A numbered array of all users that can create posts + * user['name']['string'] + An array indexed by a username (string), with a + sub-list containing data on a user. 'string' can be + one of the following: + * 'full_name' + * 'bio' + * 'email' + * 'posts' + 'posts' is special, because it actually will be another + array that lists the post IDs of a users posts in + order of newest to oldest. + So for Andre's latest post: + user['andre']['posts'][0] + For his second-newest: + user['andre']['posts'][1] + For Andre's full name: + user['andre']['full_name'] + * posts[number] + A list of post IDs, in order from newest to oldest. + So the newest post ID would be posts[0]. + * post[number]['string'] + All blogpost data will be stored in this array-- the + number is the ID (number assigned to a post when + created) and 'string' is one of the following: + * 'title' + * 'date' + * 'author' + * 'text' + For example, to get the title of post #345: + post[345]['title'] + and it's text: + post[345]['text'] + So on and so forth. + +Example: + To get the text of the newest post by Kaleb, do: + post[user['kaleb']['posts'][0]]['text'] + + Since userposts[] lists a user's posts in ascending order, the newest + is '0', and since user['kaleb']['posts'][0] would contain the ID of his + newest post, we just use that as the post ID, and boom. + + + +LOCAL +---------------------------------------- +These are variables that can only be used in specific contexts, on a per-page +basis. + +USER +-------------------- + * username + The user's username + * full_name + The user's fullname + * bio + The user's bio + * email + The user's email + * posts + A list of the user's posts (IDs) from newest to oldest + +POST +-------------------- + * author + The post's author (username) + * date + The post's publishing date + * id + The post's id + * text + The post's text diff --git a/public_html/index.php b/public_html/index.php new file mode 100644 index 0000000..75ed9b6 --- /dev/null +++ b/public_html/index.php @@ -0,0 +1 @@ +Placeholder. diff --git a/res/themes/default/css/about.css b/res/themes/default/css/about.css new file mode 100644 index 0000000..a711918 --- /dev/null +++ b/res/themes/default/css/about.css @@ -0,0 +1 @@ +/* This is the CSS file for the about page *only* */ diff --git a/res/themes/default/css/footer.css b/res/themes/default/css/footer.css new file mode 100644 index 0000000..f59afed --- /dev/null +++ b/res/themes/default/css/footer.css @@ -0,0 +1 @@ +/* This is the CSS file for the footer *only* */ diff --git a/res/themes/default/css/index.css b/res/themes/default/css/index.css new file mode 100644 index 0000000..adb9a89 --- /dev/null +++ b/res/themes/default/css/index.css @@ -0,0 +1 @@ +/* This is the CSS file for the index page *only* */ diff --git a/res/themes/default/css/navbar.css b/res/themes/default/css/navbar.css new file mode 100644 index 0000000..82937da --- /dev/null +++ b/res/themes/default/css/navbar.css @@ -0,0 +1 @@ +/* This is the CSS file for the navbar *only* */ diff --git a/res/themes/default/css/post.css b/res/themes/default/css/post.css new file mode 100644 index 0000000..1d82875 --- /dev/null +++ b/res/themes/default/css/post.css @@ -0,0 +1 @@ +/* This is the CSS file for the post page *only* */ diff --git a/res/themes/default/css/user.css b/res/themes/default/css/user.css new file mode 100644 index 0000000..adb9a89 --- /dev/null +++ b/res/themes/default/css/user.css @@ -0,0 +1 @@ +/* This is the CSS file for the index page *only* */ diff --git a/res/themes/default/html/about.twig.html b/res/themes/default/html/about.twig.html new file mode 100644 index 0000000..a38b28d --- /dev/null +++ b/res/themes/default/html/about.twig.html @@ -0,0 +1,10 @@ + + + + + + Index + + + + + + + + + Index + + + + + + + + + Index + + + + + + + + + Index + + + + + + + + + Index + + + + + + + + + Index + + + +