Archived
1
0
Disbranĉigi 0

Init and scaffolding

This commit is contained in:
Jenga Phoenix 2019-02-11 00:14:30 -06:00
commit 4785bb6afa
22 changed files with 447 additions and 0 deletions

43
README.txt Normal file
View File

@ -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. :)

5
composer.json Normal file
View File

@ -0,0 +1,5 @@
{ "require":
{
"twig/twig": "1.*"
}
}

24
docs/database_spec.txt Normal file
View File

@ -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)

View File

@ -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")

23
docs/frontend.txt Normal file
View File

@ -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.

114
docs/php_cheatsheet.txt Normal file
View File

@ -0,0 +1,114 @@
===============================================================================
A PHP CHEAT-SHEET
===============================================================================
----------------------------------------
SYNTAX
----------------------------------------
All PHP code must be between "<?php" and "?>":
<?php
echo "Like this.";
?>
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

18
docs/twig.txt Normal file
View File

@ -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.

27
docs/twig_example.html Normal file
View File

@ -0,0 +1,27 @@
<html>
<head>
<title>Twig Example</title>
</head>
<body>
<!-- Variable names put between {{ ... }} will turn into the value
when interpreted by the server. -->
<!-- If the variable "name" is set in the PHP code, then this will
print out that string: -->
<p>My name is {{ name }}</p>
<!-- List items can be read like {{ list[n] }} -->
<p>List of animals:</p>
<ul>
{{ animals[0] }}
{{ animals[1] }}
{{ animals[2] }}
{{ animals[3] }}
{{ animals[4] }}
</ul>
<!-- That should be all you need to know! -->
</body>
</html>

83
docs/variables.txt Normal file
View File

@ -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

1
public_html/index.php Normal file
View File

@ -0,0 +1 @@
Placeholder.

View File

@ -0,0 +1 @@
/* This is the CSS file for the about page *only* */

View File

@ -0,0 +1 @@
/* This is the CSS file for the footer *only* */

View File

@ -0,0 +1 @@
/* This is the CSS file for the index page *only* */

View File

@ -0,0 +1 @@
/* This is the CSS file for the navbar *only* */

View File

@ -0,0 +1 @@
/* This is the CSS file for the post page *only* */

View File

@ -0,0 +1 @@
/* This is the CSS file for the index page *only* */

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../css/global.css">
<link rel="stylesheet" type="text/css" href="../css/about.css">
<title>Index</title>
</head>
<body>
</body>
</html

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../css/global.css">
<link rel="stylesheet" type="text/css" href="../css/footer.css">
<title>Index</title>
</head>
<body>
</body>
</html

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../css/global.css">
<link rel="stylesheet" type="text/css" href="../css/index.css">
<title>Index</title>
</head>
<body>
</body>
</html

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../css/global.css">
<link rel="stylesheet" type="text/css" href="../css/navbar.css">
<title>Index</title>
</head>
<body>
</body>
</html

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../css/global.css">
<link rel="stylesheet" type="text/css" href="../css/post.css">
<title>Index</title>
</head>
<body>
</body>
</html

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="../css/global.css">
<link rel="stylesheet" type="text/css" href="../css/user.css">
<title>Index</title>
</head>
<body>
</body>
</html