changeset 75:b12491ceabfd

pasterd: begin of custom theme
author David Demelier <markand@malikania.fr>
date Wed, 15 Mar 2023 20:15:00 +0100
parents 67b3d13a5035
children 9643962908ab
files html/header.html html/new.html html/paste.html html/search.html page-index.c page-new.c page-paste.c page-search.c page-static.c page.c themes/default/sourcecodepro.ttf themes/default/style.css themes/default/titilliumweb.ttf
diffstat 13 files changed, 163 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/html/header.html	Wed Mar 15 19:34:00 2023 +0100
+++ b/html/header.html	Wed Mar 15 20:15:00 2023 +0100
@@ -3,6 +3,7 @@
 	<head>
 		<meta charset="UTF-8">
 		<meta name="viewport" content="width=device-width, initial-scale=1">
+		<link rel="stylesheet" href="/static/style.css">
 		<title>{{title}}</title>
 	</head>
 
--- a/html/new.html	Wed Mar 15 19:34:00 2023 +0100
+++ b/html/new.html	Wed Mar 15 20:15:00 2023 +0100
@@ -3,17 +3,17 @@
 			<form action="/new" method="post">
 				<table>
 					<tr>
-						<td>Title</td>
+						<td class="label">Title</td>
 						<td><input name="title" type="text" placeholder="Untitled" value="{{title}}" /></td>
 					</tr>
 
 					<tr>
-						<td>Author</td>
+						<td class="label">Author</td>
 						<td><input name="author" type="text" placeholder="Anonymous" /></td>
 					</tr>
 
 					<tr>
-						<td>Language</td>
+						<td class="label">Language</td>
 						<td>
 							<select name="language">
 								{{#languages}}
@@ -24,7 +24,7 @@
 					</tr>
 
 					<tr>
-						<td>Expires in</td>
+						<td class="label">Expires in</td>
 						<td>
 							<select name="duration">
 								{{#durations}}
@@ -35,11 +35,12 @@
 					</tr>
 
 					<tr>
-						<td>Private</td>
+						<td class="label">Private</td>
 						<td><input type="checkbox" name="private" checked></input></td>
 					</tr>
 				</table>
 
 				<textarea id="code" class="textarea" placeholder="What do you want to share?" rows="10" name="code">{{code}}</textarea>
-				<button>Submit</button>
+				<br>
+				<input class="submit" type="submit" value="paste" />
 			</form>
--- a/html/paste.html	Wed Mar 15 19:34:00 2023 +0100
+++ b/html/paste.html	Wed Mar 15 20:15:00 2023 +0100
@@ -1,5 +1,6 @@
-	<h2>Actions</h2>
-	<ul>
+	<h1>Paste {{title}}</h1>
+
+	<ul id="paste-menu">
 		<li><a href="/fork/{{id}}">Fork</a></li>
 		<li><a href="/download/{{id}}">Download</a></li>
 	</ul>
@@ -7,31 +8,31 @@
 	<table>
 		<tbody>
 			<tr>
-				<td>Identifier</td>
+				<td class="label">Identifier</td>
 				<td>{{id}}</td>
 			</tr>
 			<tr>
-				<td>Title</td>
+				<td class="label">Title</td>
 				<td>{{title}}</td>
 			</tr>
 			<tr>
-				<td>Author</td>
+				<td class="label">Author</td>
 				<td>{{author}}</td>
 			</tr>
 			<tr>
-				<td>Language</td>
+				<td class="label">Language</td>
 				<td>{{language}}</td>
 			</tr>
 			<tr>
-				<td>Date</td>
+				<td class="label">Date</td>
 				<td>{{date}}</td>
 			</tr>
 			<tr>
-				<td>Public</td>
+				<td class="label">Public</td>
 				<td>{{public}}</td>
 			</tr>
 			<tr>
-				<td>Expires in</td>
+				<td class="label">Expires in</td>
 				<td>{{expiration}}</td>
 			</tr>
 		</tbody>
--- a/html/search.html	Wed Mar 15 19:34:00 2023 +0100
+++ b/html/search.html	Wed Mar 15 20:15:00 2023 +0100
@@ -22,5 +22,5 @@
 			</tr>
 		</table>
 
-		<button>Submit</button>
+		<input class="submit" type="submit" value="Search" />
 	</form>
--- a/page-index.c	Wed Mar 15 19:34:00 2023 +0100
+++ b/page-index.c	Wed Mar 15 20:15:00 2023 +0100
@@ -79,7 +79,7 @@
 create_doc(const struct paste *pastes, size_t pastesz)
 {
 	return json_pack("{ss so}",
-		"pagetitle",    "sci -- recent pastes",
+		"pagetitle",    "paster -- recent pastes",
 		"pastes",       create_pastes(pastes, pastesz)
 	);
 }
--- a/page-new.c	Wed Mar 15 19:34:00 2023 +0100
+++ b/page-new.c	Wed Mar 15 20:15:00 2023 +0100
@@ -161,7 +161,7 @@
 		paste = &paste_default;
 
 	page(req, KHTTP_200, html_new, json_pack("{ss ss so so ss}",
-		"pagetitle",    "sci -- new",
+		"pagetitle",    "paster -- create new paste",
 		"title",        paste->title,
 		"languages",    create_languages(paste),
 		"durations",    create_durations(),
--- a/page-paste.c	Wed Mar 15 19:34:00 2023 +0100
+++ b/page-paste.c	Wed Mar 15 20:15:00 2023 +0100
@@ -42,13 +42,13 @@
 static inline json_t *
 create_pagetitle(const struct paste *paste)
 {
-	return json_sprintf("sci -- %s", paste->title);
+	return json_sprintf("paster -- %s", paste->title);
 }
 
 static inline json_t *
 create_paste(const struct paste *paste)
 {
-	return json_pack("{so ss ss ss ss ss so so}",
+	return json_pack("{so ss ss ss ss ss ss so so}",
 		"pagetitle",    create_pagetitle(paste),
 		"id",           paste->id,
 		"title",        paste->title,
@@ -57,7 +57,7 @@
 		"code",         paste->code,
 		"public",       paste->visible ? "Yes" : "No",
 		"date",         create_date(paste),
-		"expliration",  create_expiration(paste)
+		"expiration",   create_expiration(paste)
 	);
 }
 
--- a/page-search.c	Wed Mar 15 19:34:00 2023 +0100
+++ b/page-search.c	Wed Mar 15 20:15:00 2023 +0100
@@ -2,11 +2,11 @@
  * page-search.c -- page /search
  *
  * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
- * 
+ *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@@ -34,7 +34,7 @@
 	json_t *array = json_array();
 
 	for (size_t i = 0; i < languagesz; ++i)
-		json_array_append_new(array, json_pack("{ss ss}", "value", languages[i]));
+		json_array_append_new(array, json_pack("{ss}", "value", languages[i]));
 
 	return array;
 }
--- a/page-static.c	Wed Mar 15 19:34:00 2023 +0100
+++ b/page-static.c	Wed Mar 15 20:15:00 2023 +0100
@@ -2,11 +2,11 @@
  * page-static.c -- page /static
  *
  * Copyright (c) 2020-2023 David Demelier <markand@malikania.fr>
- * 
+ *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
  * copyright notice and this permission notice appear in all copies.
- * 
+ *
  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@@ -33,7 +33,8 @@
 	struct stat st;
 	char path[PATH_MAX];
 
-	snprintf(path, sizeof (path), "%s%s", config.themedir, req->fullpath);
+	/* Skip /static part that we don't want in the theme directory. */
+	snprintf(path, sizeof (path), "%s%s", config.themedir, req->fullpath + 7);
 
 	if (stat(path, &st) < 0)
 		page_status(req, KHTTP_404);
--- a/page.c	Wed Mar 15 19:34:00 2023 +0100
+++ b/page.c	Wed Mar 15 20:15:00 2023 +0100
@@ -21,6 +21,7 @@
 
 #include <mustach-jansson.h>
 
+#include "config.h"
 #include "page.h"
 #include "util.h"
 
Binary file themes/default/sourcecodepro.ttf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/default/style.css	Wed Mar 15 20:15:00 2023 +0100
@@ -0,0 +1,131 @@
+@font-face {
+	font-family: titilliumweb;
+	src: url(/static/titilliumweb.ttf);
+}
+
+@font-face {
+	font-family: sourcecodepro;
+	src: url(/static/sourcecodepro.ttf);
+}
+
+* {
+	margin: 0;
+	padding: 0;
+	font-family: titilliumweb;
+	color: #212121;
+}
+
+:root {
+	--main-color1: #254E70;
+	--main-color2: #37718E;
+	--main-color3: #8EE3EF;
+	--main-color4: #AEF3E7;
+	--main-color5: #C33C54;
+}
+
+a {
+	color: var(--main-color1);
+}
+
+a:hover {
+	color: var(--main-color2);
+}
+
+pre, code {
+	padding-left: 0.5em;
+	padding-right: 0.5em;
+	background-color: gainsboro;
+	border-radius: 4px;
+	font-family: sourcecodepro;
+	letter-spacing: 0;
+	padding: 0.15em 0.25em 0.15em 0.25em;
+	color: #000000;
+}
+
+pre {
+	margin-top: 0.5em;
+	margin-bottom: 0.5em;
+	border-left: 4px solid var(--main-color1);
+	box-shadow: #d9d9d9 0px 1px 4px;
+}
+
+#nav-links {
+	background-color: var(--main-color1);
+	list-style-type: none;
+	display: flex;
+}
+
+#nav .nav-link-brand {
+	font-weight: bold;
+}
+
+#nav a {
+	text-decoration: none;
+	color: #ffffff;
+	font-size: large;
+	display: block;
+	padding: 1em;
+}
+
+#nav a:hover {
+	background-color: var(--main-color2);
+}
+
+#container {
+	max-width: 768px;
+	margin: 0 auto;
+	margin-top: 1em;
+	padding: 1em;
+}
+
+/*
+ * Style for items on /paste.
+ */
+
+#paste-menu {
+	list-style-type: none;
+	margin-top: 0.5em;
+	margin-bottom: 0.5em;
+}
+
+#paste-menu li {
+	display: inline-block;
+	background-color: var(--main-color2);
+	border-radius: 2px;
+}
+
+#paste-menu a {
+	color: #ffffff;
+	text-decoration: none;
+	padding: 0.5em;
+}
+
+#code {
+	max-width: 768px;
+	width: 100%;
+}
+
+.submit {
+	background-color: var(--main-color2);
+	color: #ffffff;
+	border: 0;
+	border-radius: 2px;
+	padding: 0.5em;
+	font-size: medium;
+}
+
+/*
+ * Other generic stuff.
+ */
+
+.label {
+	font-weight: bold;
+}
+
+td, th {
+	padding: 0.2em;
+}
+
+pre {
+	white-space: pre-line;
+}
Binary file themes/default/titilliumweb.ttf has changed