Browse code

Init and scaffolding

Jenga Phoenix authored on 2019-02-11 06:14:30
Showing 22 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+===============================================================================
2
+BLAGOBLAG                                          Simple blogsphere-ish system
3
+===============================================================================
4
+
5
+Blagoblag is a pretty simple system that'd be perfectly at home in the
6
+blogosphere.[1]
7
+
8
+TL;DR, registered users can create date-stamped posts. Someone can browse
9
+posts by date (from all users) in a format resembling a “newsletter,” or
10
+by user.
11
+Users can create comments on any post after filling out a simple CAPTCHA.
12
+
13
+Y'know, stuff along those lines.
14
+
15
+[1] https://xkcd.com/181/
16
+
17
+
18
+
19
+----------------------------------------
20
+PRE-REQUISITES
21
+----------------------------------------
22
+	* PHP 7.0
23
+	* Webserver with CGI enabled
24
+	* A paper-clip and soldering-iron
25
+	* Also a lighter
26
+
27
+
28
+
29
+----------------------------------------
30
+INSTALLATION
31
+----------------------------------------
32
+Drop Blagoblag in any directory on your webserver, then create an SQL
33
+database for Blagoblag. Make sure to make a "config.ini" file (from 
34
+"config.ini.example")-- at the minimum, you need to configure the SQL
35
+connection settings.
36
+
37
+
38
+
39
+----------------------------------------
40
+BORING STUFF
41
+----------------------------------------
42
+License is AGPLv3, copyleft.
43
+TL;DR, do whatever, but share the source-code. :)
0 44
new file mode 100644
... ...
@@ -0,0 +1,5 @@
1
+{ "require":
2
+	{
3
+		"twig/twig": "1.*"
4
+	}
5
+}
0 6
new file mode 100644
... ...
@@ -0,0 +1,24 @@
1
+===============================================================================
2
+DATABASE SPEC
3
+===============================================================================
4
+
5
+We use `dbi4php` (/lib/ext/dbi4php/) for database access, so that we don't
6
+have to rely on a specific DB.
7
+
8
+Anything supported by DBI (MySQL, MS SQL, Oracles, PostgreSQL, ODBC, Interbase,
9
+SQLite, IBM DB2) will work just fine.
10
+
11
+The database name will be fetched from the "config.ini" file-- and a table
12
+will be automatically created as necessary.
13
+
14
+The tables used by Blagoblag are:
15
+
16
+	posts (title varchar(200), date datetime, author smallint,
17
+		text longtext)
18
+
19
+	authors (id smallint primary key, username varchar(20),
20
+		password_hash varchar(30), full_name varchar(50))
21
+
22
+	comments (id smallint primary key, displayname varchar(20),
23
+		text shorttext, date datetime)
24
+
0 25
new file mode 100644
... ...
@@ -0,0 +1,43 @@
1
+===============================================================================
2
+DIRECTORY STRUCTURE
3
+===============================================================================
4
+
5
+The structure of this repo is like this:
6
+
7
+	/res/
8
+			Contains publicly-accessible resources (CSS, etc),
9
+			and themes.
10
+	/res/img/
11
+			Contains uploaded images.
12
+	/res/themes/
13
+			Contains all themes (collections of CSS, images, and
14
+			templates).
15
+	/res/themes/default/
16
+			The theme we're gonna develop and use.
17
+	/res/themes/default/css/
18
+			CSS for the default theme.
19
+	/res/themes/default/templates/
20
+			Templates for the default theme (our HTML).
21
+
22
+	--------------------
23
+
24
+	/lib/
25
+			Contains PHP files that should be included into every
26
+			PHP file.
27
+	/lib/ext/
28
+			Contains external PHP libraries.
29
+
30
+	--------------------
31
+
32
+	/public/
33
+			The webroot.
34
+			Contains small, bare PHP files that render webpages.
35
+			Any requests for "/public/res/" will be rediricted by
36
+			the webserver to "/res/".
37
+	/public/*/private/
38
+			PHP files for processing input (I.E., user submits
39
+			a blog)-- everything in */private/ should redirect
40
+			to something in a corresponding */results/ file.
41
+	/public/*/results/
42
+			PHP files for displaying results of processed input
43
+			(I.E., "wow, that's an error" or "hooray, it worked")
0 44
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+===============================================================================
2
+FRONT-END
3
+===============================================================================
4
+There are 6 different pages/views we need to work on:
5
+
6
+	* INDEX/OVERVIEW
7
+		A page for showing a general overview of the site-- newest
8
+		posts overall.
9
+	* USER
10
+		A page dedicated to a given user, with their name, biography,
11
+		(maybe a picture? <3) and some of their recent psots.
12
+	* POST
13
+		A page dedicated to displaying a single article. Should list
14
+		the author, date, and text. Y'know, jazz like that.
15
+	* ABOUT
16
+		An about page, that talks about what this thing is.
17
+
18
+	* NAVBAR
19
+		A top-bar/side-bar for navigation that will be shown on every
20
+		page in the site.
21
+	* FOOTER
22
+		A bottom-bar/footer that has whatever legal/boring/contact-us
23
+		stuff we want to put in it.
0 24
new file mode 100644
... ...
@@ -0,0 +1,114 @@
1
+===============================================================================
2
+A PHP CHEAT-SHEET
3
+===============================================================================
4
+
5
+----------------------------------------
6
+SYNTAX
7
+----------------------------------------
8
+All PHP code must be between "<?php" and "?>":
9
+	<?php
10
+		echo "Like this.";
11
+	?>
12
+
13
+Every statement ends with a semicolon, all function arguments
14
+are seperated by commas, etc.
15
+
16
+
17
+----------------------------------------
18
+OPERATORS
19
+----------------------------------------
20
+Normal stuff (like +, -, etc.), but *also*:
21
+	.	concatenation (mainly for strings, like "a" . "b" ... "ab")
22
+	++	increment (add one, I.E. 1++ ... 2)
23
+	--	decrement (subtract one, I.E. 2-- ... 1)
24
+
25
+
26
+----------------------------------------
27
+COMPARISON OPERATORS
28
+----------------------------------------
29
+	==	equal (same data)
30
+	===	identical (same type + data)
31
+	!=	not-equal (different data)
32
+	!==	not-identicial (different type or data)
33
+	<	less-than
34
+	>	greater-than
35
+	<=	less-than or equal-to
36
+	>=	greater-than or equal-to
37
+	??	null coalescing (choose first variable that's non-null,
38
+		from left to right)
39
+
40
+----------------------------------------
41
+VARIABLES
42
+----------------------------------------
43
+All variables start like "$". Assignment is like this:
44
+
45
+	$variable = "value";
46
+
47
+
48
+----------------------------------------
49
+FUNCTIONS
50
+----------------------------------------
51
+Make a function like a lot of languages:
52
+
53
+	function FUNCTION_NAME($ARGUMENT, $ARGUMENT) {
54
+		BLAH BLAH BLAH;
55
+		return BLAH;
56
+	}
57
+
58
+... replace FUNCTION_NAME with the name, $ARGUMENT with a variable name,
59
+etc. etc.
60
+
61
+If you want an argument to be optional, assign it a default value, like:
62
+
63
+	function FUNCTION_NAME($ARGUMENT = "default", $ARGUMENT = 2) {
64
+
65
+
66
+----------------------------------------
67
+ARRAYS
68
+----------------------------------------
69
+Make an array with 
70
+
71
+	array(KEY=>VALUE, KEY=>VALUE);
72
+
73
+VARIABLE can be a string or a number.
74
+
75
+Get an array value like
76
+
77
+	$array[KEY]
78
+
79
+
80
+----------------------------------------
81
+GLOBAL VARIABLES
82
+----------------------------------------
83
+There are some important global variables--
84
+
85
+	$GET    	Hosts all GET data.
86
+	$POST   	All POST data
87
+	$SERVER  	SERVER data
88
+	$GLOBALS	Contains all global vars.
89
+
90
+They're all arrays.
91
+Variables are local to their function-- and often, global variables from
92
+certain functions won't be accessible in the global scope of another.
93
+
94
+To reliably access (inter-file) globals, access them like values in an
95
+array of $GLOBALS
96
+
97
+	$GLOBALS[KEY]
98
+
99
+
100
+----------------------------------------
101
+ETC.
102
+----------------------------------------
103
+Really, most of PHP is really similar to other languages.
104
+You should be able to read it pretty easily-- if there's something
105
+you don't quite get, you can use the Wikibook
106
+
107
+	https://en.wikibooks.org/wiki/PHP_Programming/
108
+
109
+For quick reference. And for function definitions/examples, check the
110
+PHP documentation
111
+
112
+	https://secure.php.net/docs.php
113
+
114
+Also Google loves you <3
0 115
new file mode 100644
... ...
@@ -0,0 +1,18 @@
1
+===============================================================================
2
+TWIG TEMPLATING SYSTEM
3
+===============================================================================
4
+Twig is a system for writing HTML "templates"-- HTML snippets that can have
5
+variable names in it, which PHP will interpret and replace with the values.
6
+
7
+We're gonna be using Twig, since it's really useful.
8
+
9
+If you're front-end, writing HTML, look at `./twig_example.html` for a general
10
+example of how you'll use Twig.
11
+You can alo read `https://twig.symfony.com/doc/2.x/templates.html` if you want
12
+more in-depth documentation, but you probably don't need it.
13
+
14
+If you're back-end, writing PHP, look at
15
+`https://twig.symfony.com/doc/2.x/api.html`.
16
+
17
+
18
+Look at `variables.txt` for a list of the variables we'll be using.
0 19
new file mode 100644
... ...
@@ -0,0 +1,27 @@
1
+<html>
2
+<head>
3
+	<title>Twig Example</title>
4
+</head>
5
+<body>
6
+
7
+	<!-- Variable names put between {{ ... }} will turn into the value
8
+	     when interpreted by the server. -->
9
+
10
+	<!-- If the variable "name" is set in the PHP code, then this will
11
+	     print out that string: -->
12
+	<p>My name is {{ name }}</p>
13
+
14
+
15
+	<!-- List items can be read like {{ list[n] }} -->
16
+	<p>List of animals:</p>
17
+	<ul>
18
+		{{ animals[0] }}
19
+		{{ animals[1] }}
20
+		{{ animals[2] }}
21
+		{{ animals[3] }}
22
+		{{ animals[4] }}
23
+	</ul>
24
+
25
+	<!-- That should be all you need to know! -->
26
+</body>
27
+</html>
0 28
new file mode 100644
... ...
@@ -0,0 +1,83 @@
1
+===============================================================================
2
+VARIABLE LIST
3
+===============================================================================
4
+
5
+GLOBAL
6
+----------------------------------------
7
+There are a few variables that will always be avaiable to use-- these are what
8
+you can use in any page's template:
9
+
10
+	* users[number]
11
+			A numbered array of all users that can create posts
12
+	* user['name']['string']
13
+			An array indexed by a username (string), with a
14
+			sub-list containing data on a user. 'string' can be
15
+			one of the following:
16
+				* 'full_name'
17
+				* 'bio'
18
+				* 'email'
19
+				* 'posts'
20
+			'posts' is special, because it actually will be another
21
+			array that lists the post IDs of a users posts in
22
+			order of newest to oldest.
23
+			So for Andre's latest post:
24
+				user['andre']['posts'][0]
25
+			For his second-newest: 
26
+				user['andre']['posts'][1]
27
+			For Andre's full name:
28
+				user['andre']['full_name']
29
+	* posts[number]
30
+			A list of post IDs, in order from newest to oldest.
31
+			So the newest post ID would be posts[0].
32
+	* post[number]['string']
33
+			All blogpost data will be stored in this array-- the
34
+			number is the ID (number assigned to a post when
35
+			created) and 'string' is one of the following:
36
+				* 'title'
37
+				* 'date'
38
+				* 'author'
39
+				* 'text'
40
+			For example, to get the title of post #345:
41
+				post[345]['title']
42
+			and it's text:
43
+				post[345]['text']
44
+			So on and so forth.
45
+
46
+Example:
47
+	To get the text of the newest post by Kaleb, do:
48
+		post[user['kaleb']['posts'][0]]['text']
49
+
50
+	Since userposts[] lists a user's posts in ascending order, the newest
51
+	is '0', and since user['kaleb']['posts'][0] would contain the ID of his
52
+	newest post, we just use that as the post ID, and boom.
53
+
54
+
55
+
56
+LOCAL
57
+----------------------------------------
58
+These are variables that can only be used in specific contexts, on a per-page
59
+basis.
60
+
61
+USER
62
+--------------------
63
+	* username
64
+		The user's username
65
+	* full_name
66
+		The user's fullname
67
+	* bio
68
+		The user's bio
69
+	* email
70
+		The user's email
71
+	* posts
72
+		A list of the user's posts (IDs) from newest to oldest
73
+
74
+POST
75
+--------------------
76
+	* author
77
+		The post's author (username)
78
+	* date
79
+		The post's publishing date
80
+	* id
81
+		The post's id
82
+	* text
83
+		The post's text
0 84
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+Placeholder.
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+/* This is the CSS file for the about page *only* */
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+/* This is the CSS file for the footer *only* */
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+/* This is the CSS file for the index page *only* */
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+/* This is the CSS file for the navbar *only* */
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+/* This is the CSS file for the post page *only* */
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+/* This is the CSS file for the index page *only* */
0 2
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+	<link rel="stylesheet" type="text/css" href="../css/global.css">
5
+	<link rel="stylesheet" type="text/css" href="../css/about.css">
6
+	<title>Index</title>
7
+</head>
8
+<body>
9
+</body>
10
+</html
0 11
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+	<link rel="stylesheet" type="text/css" href="../css/global.css">
5
+	<link rel="stylesheet" type="text/css" href="../css/footer.css">
6
+	<title>Index</title>
7
+</head>
8
+<body>
9
+</body>
10
+</html
0 11
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+	<link rel="stylesheet" type="text/css" href="../css/global.css">
5
+	<link rel="stylesheet" type="text/css" href="../css/index.css">
6
+	<title>Index</title>
7
+</head>
8
+<body>
9
+</body>
10
+</html
0 11
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+	<link rel="stylesheet" type="text/css" href="../css/global.css">
5
+	<link rel="stylesheet" type="text/css" href="../css/navbar.css">
6
+	<title>Index</title>
7
+</head>
8
+<body>
9
+</body>
10
+</html
0 11
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+	<link rel="stylesheet" type="text/css" href="../css/global.css">
5
+	<link rel="stylesheet" type="text/css" href="../css/post.css">
6
+	<title>Index</title>
7
+</head>
8
+<body>
9
+</body>
10
+</html
0 11
new file mode 100644
... ...
@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+	<link rel="stylesheet" type="text/css" href="../css/global.css">
5
+	<link rel="stylesheet" type="text/css" href="../css/user.css">
6
+	<title>Index</title>
7
+</head>
8
+<body>
9
+</body>
10
+</html