Add default theme and other fixes

This commit is contained in:
Pòsweg 2020-05-30 22:23:04 +02:00
parent 19e477b35b
commit 903d00da39
20 changed files with 347 additions and 11 deletions

View File

@ -29,6 +29,7 @@ if(!$db->querySingle("SELECT EXISTS(SELECT * FROM users where id = 0);")){
}
if($_SESSION["login"] === true){
echo("<div id='header'>");
echo("<a href='/'>LibreCat</a>");
echo(" | ");
$user = $db->query("SELECT * FROM users WHERE id = ".$_SESSION["uid"].";")->fetchArray(SQLITE3_ASSOC);
@ -42,8 +43,10 @@ if($_SESSION["login"] === true){
echo(" | ");
echo("<a href='/logout.php'>logout</a>");
}
echo("</div>");
}
else{
echo("<div id='header'>");
echo("<a href='/'>LibreCat</a>");
echo(" | ");
if($fancy_urls){
@ -52,6 +55,7 @@ else{
else{
echo("<a href='/login.php'>Login</a>");
}
echo("</div>");
//header("Location: /login.php"); die();
}
?>

5
include/main.php Normal file
View File

@ -0,0 +1,5 @@
<?php
include("settings.php");
?>

View File

@ -5,5 +5,6 @@
// with this as false
$fancy_urls = true;
$theme_name = "minimalpunk";
?>

View File

@ -1,5 +1,7 @@
<?php
session_start();
include("include/settings.php");
$db = new SQLite3('ask.db');
$logErrorMsg = "";
@ -68,6 +70,7 @@ if(isset($_POST["reg"])){
<!DOCTYPE html>
<html>
<head>
<?php include("themes/$theme_name/login.php"); ?>
<meta http-equiv="content-type" content="text/html;chartset=utf8"/>
<title>Login</title>
</head>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 KiB

View File

@ -0,0 +1,7 @@
<?php
$color_main = "#353942";
$color_bg = "#282b32";
$color_2 = "#464c58";
$color_3 = "#5a6271";
?>

View File

@ -0,0 +1,4 @@
<?php
$color_main = "#353942";
$color_bg = "#282b32";
?>

View File

@ -0,0 +1,33 @@
<?php include("../colors.php"); ?>
@font-face{
font-family: liberation-sans;
src: url(/themes/minimalpunk/assets/liberation-sans-Regular.ttf) format("truetype");
}
@font-face{
font-family: liberation-sans;
font-weight: bold;
src: url(/themes/minimalpunk/assets/liberation-sans-Bold.ttf) format("truetype");
}
body{
font-family: liberation-sans;
background-color: <?= $color_bg ?>;
color: white;
}
a{
color: white;
}
input{
background-color: <?= $color_3 ?>;
color: white;
border: none;
padding: 10px 20px;
}
body{
background-image: url("/themes/minimalpunk/assets/logo_1000px.png"):
background-size: 100px 100px;
}

View File

@ -0,0 +1,48 @@
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}

View File

@ -0,0 +1,104 @@
<?php include("../colors.php"); ?>
#parent-container{
width: 80%;
margin: 50px auto 30px;
/*background-color: <?= $color_main ?>;*/
}
#header{
text-align: right;
padding: 20px;
background-color: <?= $color_main ?>;
}
.columns-container{
display: flex;
}
.column{
flex: 25%;
}
.question-container{
flex: 75%;
}
/* user profile styling */
#user-container{
/*background-color: black;*/
text-align: center;
background-color: <?= $color_3 ?>;
padding: 30px;
margin: 0px;
}
#user-name{
font-size: 30px;
font-weight: bold;
margin-bottom: 20px;
}
#user-bio{
}
/* Form column */
.form-column{
background-color: <?= $color_2 ?>;
padding: 10px;
overflow: hidden;
}
.form-column textarea{
width: 100%;
height: 80px;
margin-bottom: 10px;
}
.form-column input[type="submit"]{
margin: 10px;
float: right;
}
.form-column input[type="submit"]:hover{
background-color: <?= $color_main ?>
}
/* Questions */
.question-container{
padding: 10px;
background-color: <?= $color_main ?>;
}
.question{
margin: 20px;
margin-bottom: 10px;
}
.question-username{
font-size: 20px;
font-weight: bold;
padding-bottom: 15px;
text-decoration: none;
}
.question-text{
margin-bottom: 15px;
}
.question-date{
float: right;
margin-bottom: 20px;
}
.answer{
clear: both;
padding: 10px;
margin-left: 40px;
background-color: <?= $color_2 ?>;
}
.answer-date{
margin-top: 20px;
}
/* Footer */
#footer{
padding: 10px;
/*background-color: <?= $color_3 ?>;*/
text-align: center;
margin-bottom: 30px;
}
@media screen and (max-width: 800px){
.columns-container{
display: block;
}
}

View File

@ -0,0 +1,84 @@
<?php include("../colors.php"); ?>
65;6002;1cbody{
background-color: <?= $color_bg ?>;
}
#parent-container{
width: 80%;
margin: 50px auto;
/*background-color: <?= $color_main ?>;*/
}
#header{
text-align: right;
padding: 20px;
background-color: <?= $color_main ?>;
}
.columns-container{
display: flex;
}
.column{
flex: 25%;
}
.question-container{
flex: 75%;
}
/* user profile styling */
#user-container{
/*background-color: black;*/
text-align: center;
background-color: <?= $color_3 ?>;
padding: 30px;
margin: 0px;
}
#user-name{
font-size: 30px;
font-weight: bold;
margin-bottom: 20px;
}
#user-bio{
}
/* Form column */
.form-column{
background-color: <?= $color_2 ?>;
padding: 10px;
}
.form-column textarea{
width: 100%;
height: 80px;
}
/* Questions */
.question-container{
padding: 10px;
background-color: <?= $color_main ?>;
}
.question{
margin: 20px;
margin-bottom: 10px;
}
.question-username{
font-size: 20px;
font-weight: bold;
padding-bottom: 15px;
text-decoration: none;
}
.question-text{
margin-bottom: 15px;
}
.question-date{
float: right;
}
.answer{
padding: 10px;
margin-top: 15px;
margin-left: 40px;
}
/* Footer */
#footer{
background-color: <?= $color_bg ?>;
}

View File

@ -0,0 +1,3 @@
<?php
include("main.php");
?>

View File

@ -0,0 +1,6 @@
<?php
echo('<link rel="stylesheet" type="text/css" href="/themes/minimalpunk/css/reset.css">');
echo('<link rel="stylesheet" type="text/css" href="/themes/minimalpunk/css/main.css.php">');
echo('<link rel="shortcut icon" type="image/png" href="/themes/minimalpunk/assets/favicon.png"/>');
echo('<meta name="viewport" content="width=device-width, initial-scale=1.0">');
?>

View File

@ -0,0 +1,4 @@
<?php
include("main.php");
echo('<link rel="stylesheet" type="text/css" href="/themes/minimalpunk/css/user.css.php">');
?>

View File

@ -1,6 +1,8 @@
<?php
session_start();
include("include/settings.php");
$db = new SQLite3('ask.db');
$p_user = $db->query("SELECT * FROM users WHERE username = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC);
@ -18,33 +20,46 @@ if(isset($_SESSION["uid"])){
<html>
<head>
<?php include("themes/$theme_name/user.php"); ?>
<title><?= $p_user["username"] ?> | LibreCat</title>
</head>
<body>
<?php // print_profile($p_user); ?>
<?php include("include/header.php"); ?>
<h2><?= $p_user["username"] ?></h2>
<p><?= $p_user["bio"] ?></p>
<div id="parent-container">
<div id="user-container">
<p id="user-name"><?= $p_user["username"] ?></p>
<p class="user-bio"><?php
// if($p_user["bio"]) echo($p_user["bio"]);
// else echo("This is a sample bio, please change me, this is just to test the layout.");
?></p>
<?php
if($is_current_user){
echo("<br/>");
if($fancy_urls)
echo("<a href='/config/profile'>config</a>");
else
echo("<a href='/config.php?q=profile'>config</a>");
}
?>
</div>
<div class="columns-container">
<div class="column form-column">
<form name="input" action="/action/publish-question.php" method="post">
<textarea placeholder="Ask me anything!" id="post-text" name="post-text"></textarea>
<br/>
<input type="hidden" name="uid" value="<?= $p_user["id"] ?>"/>
<p><input type="checkbox" <?php if(!isset($_SESSION["uid"])) echo("checked disabled"); ?> name="anon"/> Post anonymously</p>
<?php if(isset($errorMsg)) echo "<p>$errorMsg</p>\n"; ?>
<input type="submit" name="post-submit"/>
<input type="submit" value="Ask" name="post-submit"/>
</form>
</div>
<div class="question-container column">
<?php
$u_prep = $db->prepare("SELECT * FROM users WHERE id = :id");
$qs = $db->query("SELECT * FROM questions WHERE user = '" . $p_user["id"] . "' LIMIT 0, 10;");
$qs = $db->query("SELECT * FROM questions WHERE user = '" . $p_user["id"] . "' ORDER BY id DESC LIMIT 0, 10;");
$time = new DateTime("@0");
while($current = $qs->fetchArray(SQLITE3_ASSOC)){
@ -52,10 +67,12 @@ if(isset($_SESSION["uid"])){
$u_prep->bindValue(":id", $current["by"], SQLITE3_INTEGER);
$q_user = $u_prep->execute()->fetchArray(SQLITE3_ASSOC);
if($q_user["id"] == 0) echo("<h3>" . $q_user["name"] ."</h3>");
else if($fancy_urls) echo("<a href='/user/" . $q_user["name"] . "'><h3>" . $q_user["name"] ."</h3></a>\n");
else echo("<a href='/user.php?q=" . $q_user["name"] . "'><h3>" . $q_user["name"] ."</h3></a>\n");
echo("\t<p>". $current["question"] ."<p>\n");
echo("<div class='question'>");
if($q_user["id"] == 0) echo("<p class='question-username'>" . $q_user["name"] ."</p>");
else if($fancy_urls) echo("<p class='question-username'><a href='/user/" . $q_user["name"] . "'>" . $q_user["name"] ."</a></p>\n");
else echo("<p class='question-username'><a href='/user.php?q=" . $q_user["name"] . "'>" . $q_user["name"] ."</a></p>\n");
echo("\t<p class='question-text'>". $current["question"] ."</p>\n");
if($is_current_user){
echo("\t<a href='/action/reply.php?q=".$current["id"]."'>reply</a> ");
@ -65,15 +82,28 @@ if(isset($_SESSION["uid"])){
// Time
$time->settimestamp($current["q_date"]);
echo($time->format("y-m-d h:i:s"));
echo("<p class='question-date'>" . $time->format("y-m-d h:i:s") . "</p>");
if($current["answer"]){
echo("<p>" . $current["answer"] . "</p>");
echo("<div class='answer'>");
echo("<p class='answer-text'>" . $current["answer"] . "</p>");
$time->settimestamp($current["a_date"]);
echo($time->format("y-m-d h:i:s"));
echo("<p class='answer-date'>" . $time->format("y-m-d h:i:s") . "</p>");
echo("</div>");
}
echo("\n\n");
echo("</div>");
}
?>
</div>
</div>
</div>
<div id="footer">
<p>
Powered by Librecat, under the GPL3 license.
Source code: <a href="https://git.posweg.es/posweg/librecat">https://git.posweg.es/posweg/librecat</a>
</p>
</div>
</body>
</html>