From 6f37abd11c1337454169f1fdd9396b26e18571f1 Mon Sep 17 00:00:00 2001
From: Jenga Phoenix
Date: Mon, 18 Feb 2019 23:24:07 -0600
Subject: [PATCH] Way too much for a single commit...
---
about.php | 3 +-
admin/index.php | 4 +-
admin/private/user_create.php | 44 ++--
admin/private/user_destroy.php | 6 +-
index.php | 3 +-
new/post/index.php | 20 ++
new/post/private/post_create.php | 38 ++++
post.php | 25 +-
res/lib/array.php | 3 +-
res/lib/blagoblag.php | 13 +-
res/lib/db.php | 91 +++++++-
res/lib/load.php | 15 +-
res/lib/post.php | 122 ++++++++++
res/lib/sterilize.php | 88 +++++++-
res/lib/user.php | 8 +-
res/themes/default/css/global.css | 213 ++++++++++++++++++
res/themes/default/html/admin_index.twig.html | 3 +-
res/themes/default/html/head.twig.html | 26 ++-
res/themes/default/html/index.twig.html | 13 +-
res/themes/default/html/meta_post_card.html | 10 +
.../default/html/new_post_index.twig.html | 28 +++
res/themes/default/html/post.twig.html | 19 +-
res/themes/default/html/user.twig.html | 20 +-
user.php | 31 ++-
24 files changed, 751 insertions(+), 95 deletions(-)
create mode 100644 new/post/index.php
create mode 100644 new/post/private/post_create.php
create mode 100644 res/lib/post.php
create mode 100644 res/themes/default/css/global.css
create mode 100644 res/themes/default/html/meta_post_card.html
create mode 100644 res/themes/default/html/new_post_index.twig.html
diff --git a/about.php b/about.php
index e3b2426..682cef0 100644
--- a/about.php
+++ b/about.php
@@ -10,10 +10,11 @@
$depth = "";
$title = "About";
+$mark = "about";
include "res/lib/load.php";
// ------------------------------------
-display_page("about.twig.html", $depth, $title);
+display_page($mark, $depth, $title);
?>
diff --git a/admin/index.php b/admin/index.php
index dcdc550..c8703a6 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -10,10 +10,12 @@
$title = "Control Panel";
$depth = "../";
+$mark = "admin_index";
include "../res/lib/load.php";
// --------------------------------------
-display_page("admin_index.twig.html", $depth, $title);
+display_page($mark, $depth, $title);
+echo profanity_sharpie("fuck you bitch ass shit");
?>
diff --git a/admin/private/user_create.php b/admin/private/user_create.php
index e45326e..8746ac0 100644
--- a/admin/private/user_create.php
+++ b/admin/private/user_create.php
@@ -11,42 +11,34 @@
$depth = "../../";
include "../../res/lib/load.php";
-$auth_user = $_POST['auth_user'];
-$auth_pass = $_POST['auth_pass'];
-$auth_user_id = user_name_to_id($auth_user);
+$auth_user = scrub($_POST['auth_user']);
+$auth_pass = scrub($_POST['auth_pass']);
+$auth_id = user_name_to_id($auth_user);
-$id = intval($_POST['id']);
-$name = $_POST['name'];
-$full_name = $_POST['full_name'];
-$bio = $_POST['bio'];
-$email = $_POST['email'];
-$url = $_POST['url'];
-$password = $_POST['password'];
-$login = $_POST['login'];
-$password = password_hash($password, PASSWORD_BCRYPT, array('cost' => 11));
+$name = scrub($_POST['name']);
+$full = scrub($_POST['full_name']);
+$bio = scrub($_POST['bio']);
+$email = scrub($_POST['email']);
+$url = scrub($_POST['url']);
+$pass = scrub($_POST['password']);
+$login = scrub($_POST['login']);
// -------------------------------------
-auth_enforce($auth_user_id, $auth_pass,
+auth_enforce($auth_id, $auth_pass,
array("wizard", "archmage"), "make accounts");
-$invalid = input_enforce(array($id, $name, $full_name, $bio, $email, $url,
- $password, $login),
- array("ID", "Username", "Full name", "Biography", "E-mail",
+input_enforce(array($name, $full, $bio, $email, $url, $pass,
+ $login),
+ array("Username", "Full name", "Biography", "E-mail",
"URL", "Password", "Login class"),
- array("free_user_id", "free_user_name", "string", "string",
- "email", "url", "ne_string",
- array("spectator", "wizard", "archmage",
- "contributor")));
-
-if (!empty($invalid)) {
- input_error("Some input is invalid: " . comma_sep($invalid));
-}
+ array("free_user_name", "string", "string",
+ "email", "url", "ne_string",
+ array("spectator", "wizard", "archmage", "contributor")));
// -------------------------------------
-user_create($id, $name, $password, $login,
- $full_name, $email, $url, $bio);
+user_create($name, $pass, $login, $full, $email, $url, $bio);
root_redirect("user.php?name=" . $name);
diff --git a/admin/private/user_destroy.php b/admin/private/user_destroy.php
index fc957b4..6c7ab6d 100644
--- a/admin/private/user_destroy.php
+++ b/admin/private/user_destroy.php
@@ -22,11 +22,7 @@ $id = intval($_POST['id']);
auth_enforce($auth_user_id, $auth_pass,
array("wizard", "archmage"), "destroy users");
-$invalid = input_enforce(array($id), array("ID"), array("user_id"));
-
-if (!empty($invalid)) {
- input_error("Some input is invalid: " . comma_sep($invalid));
-}
+input_enforce(array($id), array("ID"), array("user_id"));
// -------------------------------------
diff --git a/index.php b/index.php
index e3294cf..72f9a4f 100644
--- a/index.php
+++ b/index.php
@@ -10,10 +10,11 @@
$depth = "";
$title = "";
+$mark = "index";
include "res/lib/load.php";
// -------------------------------------
-display_page("index.twig.html", $depth, $title);
+display_page($mark, $depth, $title);
?>
diff --git a/new/post/index.php b/new/post/index.php
new file mode 100644
index 0000000..5eddb3a
--- /dev/null
+++ b/new/post/index.php
@@ -0,0 +1,20 @@
+
diff --git a/new/post/private/post_create.php b/new/post/private/post_create.php
new file mode 100644
index 0000000..396f858
--- /dev/null
+++ b/new/post/private/post_create.php
@@ -0,0 +1,38 @@
+
diff --git a/post.php b/post.php
index 00f51e5..0240dd4 100644
--- a/post.php
+++ b/post.php
@@ -10,20 +10,31 @@
$depth = "";
$title = "";
+$mark = "post";
include "res/lib/load.php";
// -------------------------------------
-$id = $_GET['id'];
-$text = post_text($id);
-$author = post_author($id);
-$date = post_data($id);
+$id = $_GET['id'] ?? post_name_to_id($_GET['name']);
+$name = post_title($id);
-$local_exports = array('id' => $id, 'text' => $text, 'author' => $author,
- 'data' => $data);
+// --------------------------------------
+
+$text = markdown(post_text($id));
+$date = post_date($id);
+$data = post_data($id);
+
+$user_id = post_author($id);
+$username = user_name($user_id);
+$full_name = user_full_name($user_id);
+
+$local_exports = array('id' => $id, 'text' => $text, 'username' => $username,
+ 'user_id' => $user_id, 'full_name' => $full_name,
+ 'data' => $data, 'title' => $name,
+ 'date' => $date);
// -------------------------------------
-display_page("post.twig.html", $depth, $title, $local_exports);
+display_page($mark, $depth, $title, $local_exports);
?>
diff --git a/res/lib/array.php b/res/lib/array.php
index ef0a123..711522c 100644
--- a/res/lib/array.php
+++ b/res/lib/array.php
@@ -33,9 +33,10 @@ function comma_sep($array, $seperator=", ") {
// STRING STRING [ARRAY] --> ARRAY
// Return exports for Twig-- with the required global & local exports,
// along with any optional local ones.
-function make_exports($depth, $title, $local = array()) {
+function make_exports($depth, $title, $mark, $local = array()) {
$exports = $GLOBALS['twig_exports'];
+ $exports['mark'] = $mark;
$exports['depth'] = $depth;
$exports['title'] = $title;
diff --git a/res/lib/blagoblag.php b/res/lib/blagoblag.php
index bf7cdc8..4a4a550 100644
--- a/res/lib/blagoblag.php
+++ b/res/lib/blagoblag.php
@@ -12,12 +12,15 @@
// STRING STRING STRING [ARRAY] --> BOOLEAN
// Render and display a page, based on it's template-path, title, relative
// depth, and an optional array of more Twig variable exports.
-function display_page($template, $depth, $title, $local_exports=array()) {
+function display_page($mark, $depth, $title, $local_exports=array()) {
echo $GLOBALS['twig']->render("head.twig.html",
- make_exports($depth, $title, $local_exports));
- echo $GLOBALS['twig']->render($template,
- make_exports($depth, $title, $local_exports));
+ make_exports($depth, $title, $mark,
+ $local_exports));
+ echo $GLOBALS['twig']->render($mark . ".twig.html",
+ make_exports($depth, $title, $mark,
+ $local_exports));
echo $GLOBALS['twig']->render("foot.twig.html",
- make_exports($depth, $title, $local_exports));
+ make_exports($depth, $title, $mark,
+ $local_exports));
return true;
}
diff --git a/res/lib/db.php b/res/lib/db.php
index 80713ac..6d735cf 100644
--- a/res/lib/db.php
+++ b/res/lib/db.php
@@ -1,7 +1,7 @@
ARRAY
// Return all values of a specific column
-function db_get_columns($table, $column) {
- $result = db_cmd("select " . $column . " from " . $table);
+function db_get_columns($table, $column,
+ $order = null, $ordered = null, $max = null) {
+
+ $command = "select " . $column . " from " . $table;
+
+ if (is_string($ordered)) {
+ $command = $command . " order by " . $ordered . " " . $order;
+ } else {
+ $command = $command . " order by " . $column . " " . $order;
+ }
+
+ if (is_int($max)) {
+ $command = $command . " limit 0," . $max;
+ }
+
+ $command = $command . ";";
+
+ // -----------------
+
+ $result = db_cmd($command);
$result_nest = function($array) {
return $array[0];
@@ -76,7 +102,7 @@ function db_get_columns($table, $column) {
} else {
return $result;
}
-}
+}
// STRING STRING VARYING --> ARRAY
// Return all rows that have an 'identifier' column set to given value
@@ -92,6 +118,21 @@ function db_get_cell($table, $identifier, $value, $cell) {
return db_get_rows($table, $identifier, $value)[0][$cell];
}
+// !!!
+// !!! ['id'] is used instead of $cell !!!
+// STRING STRING VARYING STRING --> ARRAY
+// Return the value of a specific column in a given row, identified by an
+// 'identifier' column set to the given value
+function db_get_cells($table, $identifier, $value, $cell) {
+ $id_pop = function ($row, $cell) {
+ return $row['id'];
+ };
+
+ $rows = db_get_rows($table, $identifier, $value);
+
+ return array_map($id_pop, $rows, $cell);
+}
+
// --------------------------------------
// STRING STRING VARYING STRING VARYING --> NIL
@@ -107,14 +148,42 @@ function db_set_cell($table, $identifier, $value, $cell, $new_value) {
// -------------------------------------
+// STRING STRING --> VARYING
+// Return the 'biggest' value in a column, as dictated by 'desc' ordering
+function db_get_biggest($table, $column) {
+ return db_get_columns($table, $column, "desc")[0];
+}
+
+// STRING STRING --> VARYING
+// Return the 'smallest' value in a column, as dictated by 'asc' ordering
+function db_get_smallest($table, $column) {
+ return db_get_columns($table, $column, "asc")[0];
+}
+
+// -------------------------------------
+
+// STRING STRING --> INTEGER
+// When passed a column of numbers, it'll increment the biggest number. Good
+// for creating IDs. If there aren't any numbers in the column, it'll choose 1.
+function db_new_id($table, $column) {
+ $biggest = db_get_biggest($table, $column);
+
+ if (is_nan($biggest)) {
+ return 1;
+ } else {
+ return $biggest + 1;
+ }
+}
+
+// -------------------------------------
+
// STRING ARRAY ARRAY --> BOOLEAN
// Create a table with given values to given columns.
// First array is a list of columns (as would be provided to SQL), and the
// second is the list of values (as would follow " values " in SQL)
function db_insert_row($table, $variables, $values) {
- $variables = comma_sep($variables);
- $values = comma_sep(strings_wrap($values));
-
+ $variables = comma_sep($variables, ", ");
+ $values = comma_sep(strings_wrap($values), ", ");
return db_cmd("insert into " . $table
. " (". $variables .")"
diff --git a/res/lib/load.php b/res/lib/load.php
index 897836a..471469a 100644
--- a/res/lib/load.php
+++ b/res/lib/load.php
@@ -28,11 +28,12 @@ include(root("res/lib/error.php"));
include(root("res/lib/sterilize.php"));
include(root("res/lib/db.php"));
include(root("res/lib/url.php"));
+include(root("res/lib/post.php"));
include(root("res/lib/blagoblag.php"));
$loader= new Twig_Loader_Filesystem(root("res/themes/default/html"));
$twig = new Twig_Environment($loader, ['cache' =>
- root('cache/')]);
+ root('cache/'), 'autoescape' => false]);
@@ -49,17 +50,17 @@ $push_user_data = function($user_id) {
array_map($push_user_data, $users);
-// global $posts; $posts = post_ids();
-// global $post; $post = array();
-// $post = array_map(post_data, $posts);
+global $posts; $posts = post_ids_recent();
+global $post; $post = array();
+$post = array_map("post_data", $posts);
// -----------------
global $twig_exports;
$twig_exports = array('theme' => $GLOBALS['theme'],
'users' => $GLOBALS['users'],
- 'user' => $GLOBALS['user']);
- //'posts' => $GLOBALS['posts'],
- //'post' => $GLOBALS['post']);
+ 'user' => $GLOBALS['user'],
+ 'posts' => $GLOBALS['posts'],
+ 'post' => $GLOBALS['post']);
?>
diff --git a/res/lib/post.php b/res/lib/post.php
new file mode 100644
index 0000000..0ad9e5d
--- /dev/null
+++ b/res/lib/post.php
@@ -0,0 +1,122 @@
+ VARYING
+// Return the value of a given user's row
+function post_get($id, $variable) {
+ return db_get_cell("posts", "id", $id, $variable);
+}
+
+// NUMBER STRING VARYING --> NIL
+// Set the value of a given user's cell
+function post_set($id, $variable, $new_value) {
+ return db_set_cell("posts", "id", $id, $variable, $new_value);
+}
+
+// -------------------------------------
+
+
+// NUMBER STRING STRING [STRING STRING STRING STRING STRING] --> BOOLEAN
+// Create a user of the given specification.
+function post_create($title, $author, $desc, $text) {
+ $id = db_new_id("posts", "id");
+
+ return db_insert_row("posts",
+ array("id", "user", "description", "date",
+ "text", "title"),
+ array($id, $author, $desc,
+ date("Y-m-d H:i:s"), $text, $title));
+}
+
+// NUMBER --> BOOLEAN
+// Delete a user by their ID.
+function post_delete($id) {
+ return db_cmd("delete from posts where id = " . $id);
+}
+
+
+// -------------------------------------
+
+
+function post_name_to_id($name) {
+ return db_get_cell("posts", "title", string_wrap($name), "id");
+}
+
+// NUMBER --> STRING
+// Return a post's title from ID
+function post_title($id) {
+ return post_get($id, "title");
+}
+
+// NUMBER --> STRING
+// Return a post's description from ID
+function post_description($id) {
+ return post_get($id, "description");
+}
+
+// NUMBER --> STRING
+// Return a post's date from ID
+function post_date($id) {
+ return post_get($id, "date");
+}
+
+
+// NUMBER --> STRING
+// Return the author's user ID from post ID
+function post_author($id) {
+ return post_get($id, "user");
+}
+
+// NUMBER --> STRING
+// Return the post's text from post ID
+function post_text($id) {
+ return post_get($id, "text");
+}
+
+
+// -------------------------------------
+
+
+// NUMBER --> ARRAY
+// Fetch an array of a post's IDs
+function post_ids() {
+ return db_get_columns("posts", "id", "desc", "date");
+}
+
+
+// -------------------------------------
+
+
+// NUMBER --> ARRAY
+// Fetch an array of a post's IDs
+function post_ids_recent() {
+ return db_get_columns("posts", "id", "desc", "date", 25);
+}
+
+
+// -------------------------------------
+
+
+
+// NUMBER --> ARRAY
+// Return an array filled with all of a user's relevant data.
+function post_data($id) {
+ return array('title' => post_title($id),
+ 'date' => post_date($id),
+ 'author' => post_author($id),
+ 'text' => post_text($id),
+ 'desc' => post_description($id));
+}
+
+
+?>
diff --git a/res/lib/sterilize.php b/res/lib/sterilize.php
index 1208544..aba197e 100644
--- a/res/lib/sterilize.php
+++ b/res/lib/sterilize.php
@@ -69,8 +69,11 @@ function input_enforce($values, $names, $types) {
$i++;
}
+ if (!empty($stack)) {
+ input_error("Some input is invalid: " . comma_sep($stack));
+ }
- return $stack;
+ return true;
}
@@ -89,6 +92,22 @@ function is_url($string) {
return filter_var($string, FILTER_VALIDATE_URL);
}
+// STRING --> BOOLEAN
+// Return whether or not a string is a tweet (<250 chars)
+function is_tweet($string) {
+ if (strlen($string) <= 250 && !empty($string)) {
+ return true;
+ } else {return false; }
+}
+
+// STRING --> BOOLEAN
+// Return whether or not a string is a title (<50 chars)
+function is_title($string) {
+ if (strlen($string) <= 50 && !empty($string)) {
+ return true;
+ } else {return false; }
+}
+
// VARYING --> BOOLEAN
// Return whether or not a given value is a non-empty string
function is_ne_string($value) {
@@ -138,7 +157,74 @@ function is_free_user_id($id) {
}
+function bleep_word($word, $replacement) {
+ $word = str_replace("a", $replacement, $word);
+ $word = str_replace("e", $replacement, $word);
+ $word = str_replace("i", $replacement, $word);
+ $word = str_replace("o", $replacement, $word);
+ $word = str_replace("u", $replacement, $word);
+ $word = str_replace("y", $replacement, $word);
+
+ return $word;
+}
+
+// STRING --> STRING
+// you know how people'll write nasty stuff on bathroom stalls?
+// this is like taking a sharpie and bleeping all that out
+function profanity_sharpie($string) {
+ $string = str_ireplace(" ass ", bleep_word(" ass ", "♥"),
+ $string);
+ $string = str_ireplace(" asses ", bleep_word(" asses ", "♥"),
+ $string);
+ $string = str_ireplace("fuck", bleep_word("fuck", "♥"), $string);
+ $string = str_ireplace("bitch", bleep_word("bitch", "♥"),
+ $string);
+ $string = str_ireplace("dick", bleep_word("dick", "♥"), $string);
+ $string = str_ireplace("cunt", bleep_word("cunt", "♥"), $string);
+
+ $string = str_ireplace("shit", bleep_word("shit", "☆"), $string);
+ $string = str_ireplace("bitch", bleep_word("bitch", "☆"),
+ $string);
+
+ $string = \ConsoleTVs\Profanity\Builder::blocker($string)->filter();
+
+ return $string;
+}
+
+
// -------------------------------------
+// STRING --> STRING
+// Agressively sanitize a string -- alias for rub_a_dub_dub()
+function scrub($string) {
+ return rub_a_dub_dub($string);
+}
+
+// STRING --> STRING
+// don't forget your rubber duck <3
+function rub_a_dub_dub($string) {
+ $string = htmlentities($string, ENT_QUOTES, "UTF-8", false);
+ $string = profanity_sharpie($string);
+ return $string;
+}
+
+// STRING --> STRING
+// Agressively sanitize a string -- alias for rub_a_dub_dub()
+function unscrub($string) {
+ return html_entity_decode($string, ENT_QUOTES);
+}
+
+
+// -------------------------------------
+
+function markdown($string) {
+ $parsedown = new Parsedown();
+ return $parsedown->text($string);
+}
+
+function markdown_inline($string) {
+ $parsedown = new Parsedown();
+ return $parsedown->line($string);
+}
?>
diff --git a/res/lib/user.php b/res/lib/user.php
index fe65fce..eb72f5f 100644
--- a/res/lib/user.php
+++ b/res/lib/user.php
@@ -28,9 +28,13 @@ function user_set($id, $variable, $new_value) {
// NUMBER STRING STRING [STRING STRING STRING STRING STRING] --> BOOLEAN
// Create a user of the given specification.
-function user_create($id, $name, $password, $class="Spectator",
+function user_create($name, $password, $class="spectator",
$full_name=NULL, $email=NULL, $url=NULL, $bio=NULL) {
+ $id = db_new_id("lusers", "id");
+ $password = password_hash($password, PASSWORD_BCRYPT,
+ array('cost' => 11));
+
return db_insert_row("lusers",
array("id", "username", "hash", "class",
"full_name", "email", "website", "biography"),
@@ -116,7 +120,7 @@ function user_ids() {
// NUMBER --> ARRAY
// Fetch an array of a user's posts (by ID)
function user_posts($id) {
- return db_get_cell("posts", "user", $id, "id");
+ return db_get_cells("posts", "user", $id, array('id'));
}
diff --git a/res/themes/default/css/global.css b/res/themes/default/css/global.css
new file mode 100644
index 0000000..85c73fe
--- /dev/null
+++ b/res/themes/default/css/global.css
@@ -0,0 +1,213 @@
+/*PEN STYLES*/
+
+* {
+ box-sizing: border-box;
+}
+
+.postbox {
+ height: 500px;
+}
+
+
+body {
+ background: #f1f1f1;
+ margin: 2rem;
+}
+
+$color_white: #fff;
+$color_prime: #5ad67d;
+$color_grey: #e2e2e2;
+$color_grey_dark: #a2a2a2;
+
+.blog-card {
+ display: flex;
+ flex-direction: column;
+ margin: 1rem auto;
+ box-shadow: 0 3px 7px -1px rgba(#000, .1);
+ margin-bottom: 1.6%;
+ background: $color_white;
+ line-height: 1.4;
+ font-family: sans-serif;
+ border-radius: 5px;
+ overflow: hidden;
+ z-index: 0;
+ a {
+ color: inherit;
+ &:hover {
+ color: $color_prime;
+ }
+ }
+ &:hover {
+ .photo {
+ transform: scale(1.3) rotate(3deg);
+ }
+ }
+ .meta {
+ position: relative;
+ z-index: 0;
+ height: 200px;
+ }
+ .photo {
+ position: absolute;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ background-size: cover;
+ background-position: center;
+ transition: transform .2s;
+ }
+ .details,
+ .details ul {
+ margin: auto;
+ padding: 0;
+ list-style: none;
+ }
+
+ .details {
+ position: absolute;
+ top: 0;
+ bottom: 0;
+ left: -100%;
+ margin: auto;
+ transition: left .2s;
+ background: rgba(#000, .6);
+ color: $color_white;
+ padding: 10px;
+ width: 100%;
+ font-size: .9rem;
+ a {
+ text-decoration: dotted underline
+ }
+ ul li {
+ display: inline-block;
+ }
+ .author:before {
+ font-family: FontAwesome;
+ margin-right: 10px;
+ content: "\f007";
+ }
+
+ .date:before {
+ font-family: FontAwesome;
+ margin-right: 10px;
+ content: "\f133";
+ }
+
+ .tags {
+ ul:before {
+ font-family: FontAwesome;
+ content: "\f02b";
+ margin-right: 10px;
+ }
+ li {
+ margin-right: 2px;
+ &:first-child {
+ margin-left: -4px;
+ }
+ }
+ }
+ }
+ .description {
+ padding: 1rem;
+ background: $color_white;
+ position: relative;
+ z-index: 1;
+ h1,
+ h2 {
+ font-family: Poppins, sans-serif;
+ }
+ h1 {
+ line-height: 1;
+ margin: 0;
+ font-size: 1.7rem;
+ }
+ h2 {
+ font-size: 1rem;
+ font-weight: 300;
+ text-transform: uppercase;
+ color: $color_grey_dark;
+ margin-top: 5px;
+ }
+ .read-more {
+ text-align: right;
+ a {
+ color: $color_prime;
+ display: inline-block;
+ position: relative;
+ &:after {
+ content: "\f061";
+ font-family: FontAwesome;
+ margin-left: -10px;
+ opacity: 0;
+ vertical-align: middle;
+ transition: margin .3s, opacity .3s;
+ }
+
+ &:hover:after {
+ margin-left: 5px;
+ opacity: 1;
+ }
+ }
+ }
+ }
+ p {
+ position: relative;
+ margin: 1rem 0 0;
+ &:first-of-type {
+ margin-top: 1.25rem;
+ &:before {
+ content: "";
+ position: absolute;
+ height: 5px;
+ background: $color_prime;
+ width: 35px;
+ top: -0.75rem;
+ border-radius: 3px;
+ }
+ }
+ }
+ &:hover {
+ .details {
+ left: 0%;
+ }
+ }
+
+
+ @media (min-width: 640px) {
+ flex-direction: row;
+ max-width: 700px;
+ .meta {
+ flex-basis: 40%;
+ height: auto;
+ }
+ .description {
+ flex-basis: 60%;
+ &:before {
+ transform: skewX(-3deg);
+ content: "";
+ background: #fff;
+ width: 30px;
+ position: absolute;
+ left: -10px;
+ top: 0;
+ bottom: 0;
+ z-index: -1;
+ }
+ }
+ &.alt {
+ flex-direction: row-reverse;
+ .description {
+ &:before {
+ left: inherit;
+ right: -10px;
+ transform: skew(3deg)
+ }
+ }
+ .details {
+ padding-left: 25px;
+ }
+ }
+ }
+}
+
diff --git a/res/themes/default/html/admin_index.twig.html b/res/themes/default/html/admin_index.twig.html
index 33e57b4..c945b89 100644
--- a/res/themes/default/html/admin_index.twig.html
+++ b/res/themes/default/html/admin_index.twig.html
@@ -6,13 +6,12 @@
-
+
-
diff --git a/res/themes/default/html/head.twig.html b/res/themes/default/html/head.twig.html
index 2889f26..583b258 100644
--- a/res/themes/default/html/head.twig.html
+++ b/res/themes/default/html/head.twig.html
@@ -1,11 +1,29 @@
-
-
+
+
+
Index
-
+
+
diff --git a/res/themes/default/html/index.twig.html b/res/themes/default/html/index.twig.html
index 5935977..dc3c88a 100644
--- a/res/themes/default/html/index.twig.html
+++ b/res/themes/default/html/index.twig.html
@@ -1 +1,12 @@
- {{ animal }}s are SUPER RAD.
+{% for post_id in posts %}
+ {% set post_author = post[post_id]['author'] %}
+ {% set post_username = user[post_author]['name'] %}
+ {% set post_full_name = user[post_author]['full_name'] %}
+
+ {% set post_title = post[post_id]['title'] %}
+ {% set post_date = post[post_id]['date'] %}
+ {% set post_desc = post[post_id]['desc'] %}
+
+ {{ include('meta_post_card.html') }}
+{% endfor %}
+
diff --git a/res/themes/default/html/meta_post_card.html b/res/themes/default/html/meta_post_card.html
new file mode 100644
index 0000000..8874041
--- /dev/null
+++ b/res/themes/default/html/meta_post_card.html
@@ -0,0 +1,10 @@
+
diff --git a/res/themes/default/html/new_post_index.twig.html b/res/themes/default/html/new_post_index.twig.html
new file mode 100644
index 0000000..c9b7344
--- /dev/null
+++ b/res/themes/default/html/new_post_index.twig.html
@@ -0,0 +1,28 @@
+
diff --git a/res/themes/default/html/post.twig.html b/res/themes/default/html/post.twig.html
index 5af0238..d373c06 100644
--- a/res/themes/default/html/post.twig.html
+++ b/res/themes/default/html/post.twig.html
@@ -1,10 +1,9 @@
-
-
-
-
-
- Index
-
-
-
-{{ title }}
+
+
+{{ date }}
+{{ text }}
diff --git a/res/themes/default/html/user.twig.html b/res/themes/default/html/user.twig.html
index 932a5ed..056e01f 100644
--- a/res/themes/default/html/user.twig.html
+++ b/res/themes/default/html/user.twig.html
@@ -1,7 +1,17 @@
{{ full_name }}
-{{ username }}
-{{ email }}
-{{ url }}
+{{ website }} <{{ email }}>
+({{ name }})
{{ bio }}
-
+
+
+{% for post_id in user_posts %}
+ {% set post_id = post_id %}
+ {% set post_username = name %}
+ {% set post_user_id = id %}
+ {% set post_full_name = full_name %}
+ {% set post_title = user_post[post_id]['title'] %}
+ {% set post_date = user_post[post_id]['date'] %}
+ {% set post_desc = user_post[post_id]['desc'] %}
+
+ {{ include('meta_post_card.html') }}
+{% endfor %}
diff --git a/user.php b/user.php
index 1fc93bd..c6f4136 100644
--- a/user.php
+++ b/user.php
@@ -10,6 +10,8 @@
$depth = "";
+$mark = "user";
+$title = "Death";
include "res/lib/load.php";
// -------------------------------------
@@ -26,14 +28,33 @@ if (empty($name)) {
general_error("It looks like that isn't a real user...");
}
-// ------------------------------------
+// -------------------------------------
-$local_exports = array('full_name' => user_full_name($id), 'name' => $name,
- 'bio' => user_biography($id), 'email' =>
- user_email($id), 'website' => user_website($id));
+global $user_posts; $user_posts = user_posts($id);
+global $user_post; $user_post = array();
+
+// this is used to make associative array for a user's posts, based on
+// both post ID and post title
+$push_post_data = function($post_id) {
+ $title = post_title($post_id);
+ $GLOBALS['user_post'][$post_id] = post_data($post_id);
+ $GLOBALS['user_post'][$title] = post_data($post_id);
+ };
+
+array_map($push_post_data, $user_posts);
+
+// -----------------
+
+$local_exports = array('id' => $id, 'full_name' => unscrub(user_full_name($id)),
+ 'name' => $name,
+ 'bio' => unscrub(user_biography($id)),
+ 'email' => user_email($id),
+ 'website' => user_website($id),
+ 'user_posts' => $user_posts,
+ 'user_post' => $user_post);
// -------------------------------------
-display_page("user.twig.html", $depth, $title, $local_exports);
+display_page($mark, $depth, $title, $local_exports);
?>