summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--README.md1
-rw-r--r--debian/changelog8
-rw-r--r--debian/control2
-rw-r--r--src/css.css129
-rw-r--r--src/hp.html (renamed from src/hp.php)60
-rw-r--r--src/httpd.c5
-rw-r--r--src/main.c3
8 files changed, 154 insertions, 62 deletions
diff --git a/Makefile b/Makefile
index b0831c6..a8baf36 100644
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,14 @@ CC = cc
.NOTPARALLEL:
default:
mkdir tmp -p
- -[ ! -f tmp/hp.css ] && wget -c https://sijanec.eu/assets/css/styles.css?ref=sear.c-make -Otmp/hp.css
- php src/hp.php > tmp/hp.html
+ sed "s/<!--ver-->/$$PVR/g" < src/hp.html > tmp/hp.html # gentoo ebuild. git overrides it.
+ -VER=`git describe --always` && sed "s/<!--ver-->/$$VER/g" < src/hp.html > tmp/hp.html
xxd -i < tmp/hp.html > tmp/hp.xxd
echo ', 0' >> tmp/hp.xxd
xxd -i < src/osdd.xml > tmp/osdd.xxd
echo ', 0' >> tmp/osdd.xxd
+ xxd -i < src/css.css > tmp/css.xxd
+ echo ', 0' >> tmp/css.xxd
$(CC) -Wall -Wextra -pedantic -Wno-unused-parameter -g -Isrc -Itmp -pthread src/main.c $$(xml2-config --libs --cflags) -lmicrohttpd -lm -osear.c
install:
@@ -33,3 +35,5 @@ test-http-valgrind:
valgrind:
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./sear.c
+
+.PHONY: valgrind test-http-valgrind test-http prepare clean distclean install default
diff --git a/README.md b/README.md
index 3b993c1..f06b096 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,6 @@ service sear.c start
* libxml2-dev (for the simple HTML/1.0 client and HTML parser)
* libmicrohttpd-dev (for serving results - use a reverse proxy, such as nginx, for HTTPS)
* xxd (for converting HTML pages into C arrays when compiling from source)
-* php-cli for a single line of Makefile (and I talk about bloat)
## compiling from source
diff --git a/debian/changelog b/debian/changelog
index 6251242..8204a5f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+sear.c (0.0.21-1) stable; urgency=low
+
+ * removed dependency to php-cli - using sed for version substitution
+ * separated CSS and HTML, so HTML without results is less than 2 KB
+ * css is served by sear.c, but can be static on the reverse proxy.
+
+ -- Anton Luka Šijanec <anton@sijanec.eu> Sat, 16 Apr 2022 19:45:00 +0200
+
sear.c (0.0.20-1) stable; urgency=low
* Added fallback option to another server via HTTP redirect in case of
diff --git a/debian/control b/debian/control
index 30fc9d1..af0c8b9 100644
--- a/debian/control
+++ b/debian/control
@@ -2,7 +2,7 @@ Source: sear.c
Section: web
Priority: optional
Maintainer: Anton Luka Šijanec <anton@sijanec.eu>
-Build-Depends: debhelper (>=11~), libmicrohttpd-dev, libxml2-dev, php-cli
+Build-Depends: debhelper (>=11~), libmicrohttpd-dev, libxml2-dev
Standards-Version: 4.1.4
Homepage: http://git.sijanec.eu/sijanec/sear.c
diff --git a/src/css.css b/src/css.css
new file mode 100644
index 0000000..0293e79
--- /dev/null
+++ b/src/css.css
@@ -0,0 +1,129 @@
+:root { /* most of the styles are used on http://sijanec.eu, so there are some excess colours */
+ --bgc1: black;
+ --bgc2: #111;
+ --bgc3: #222;
+ --fgc1: white;
+ --fgc2: lightgray;
+ --fgc3: lightblue;
+ --fglinkc: #ae5;
+ --fglinkvisitedc: #0cd;
+ --fglinkhoverc: cyan;
+ --fglinkactivec: #eff;
+ --fgchilite: red;
+ --fgdecorc: yellow;
+ --fgcodec: #aed;
+ --bgcodec: var(--bgc2);
+ --bgclight: darkgray;
+ --scheme-name: dark;
+}
+
+@media (prefers-color-scheme: light) {
+ :root {
+ --bgc1: white;
+ --bgc2: lightgray;
+ --bgc3: darkgray;
+ --fgc1: black;
+ --fgc2: gray;
+ --fgc3: darkred;
+ --fglinkc: blue;
+ --fglinkvisitedc: purple;
+ --fglinkhoverc: darkblue;
+ --fglinkactivec: cyan;
+ --fgchilite: red;
+ --fgdecorc: darkmagenta;
+ --fgcodec: var(--bgc1);
+ --bgcodec: var(--fgc1);
+ --bgclight: darkgray;
+ --scheme-name: light;
+ }
+}
+
+input, textarea {
+ background: var(--bgc2);
+ color: var(--fgc1);
+}
+
+a {
+ text-decoration: underline;
+ cursor: pointer;
+ color: var(--fglinkc);
+}
+
+a:visited {
+ color: var(--fglinkvisitedc);
+}
+
+a:hover {
+ color: var(--fglinkhoverc);
+}
+
+a:active {
+ color: var(--fglinkactivec);
+}
+
+
+@media screen and (min-width: 1000px) {
+ body {
+ margin-left: 10%;
+ margin-right: 10%;
+ }
+}
+
+body {
+ background-color: var(--bgc1);
+ color: var(--fgc1);
+ scrollbar-color: var(--scheme-name);
+}
+
+code {
+ color: var(--fgcodec);
+ background-color: var(--bgcodec);
+}
+input[type=password], input[type=text], input[type=submit], input[type=button] {
+ height: 1cm;
+ font-size: large;
+}
+.result:hover {
+ background: var(--bgc2);
+}
+.container {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: nowrap;
+ justify-content: center;
+ align-items: stretch;
+}
+input[name=q] {
+ flex-grow: 4;
+}
+input[type=submit] {
+ flex-basis: 12.5%;
+}
+.SC_LOG_ERROR {
+ color: red;
+}
+.SC_LOG_WARNING {
+ color: orange;
+}
+.SC_LOG_INFO {
+ color: lightgreen;
+}
+.SC_LOG_DEBUG {
+ color: magenta;
+}
+.breadcrumb {
+ color: var(--fgc2);
+ font-size: small; /* small is relative to parent (h4) size */
+}
+.result h4 {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ margin-bottom: 0.314159265358em;
+}
+.result p {
+ margin-top: 0.314159265358em;
+}
+.result img {
+ height: 10em;
+}
diff --git a/src/hp.php b/src/hp.html
index cffa469..dcde692 100644
--- a/src/hp.php
+++ b/src/hp.html
@@ -8,64 +8,10 @@
%s :: sear.c
</title>
<meta name=viewport content="width=device-width, initial-scale=1.0">
- <style>
- <?php
- echo file_get_contents("tmp/hp.css");
- ?>
- </style>
+ <link rel=stylesheet href=/css.css />
<link rel="shortcut icon" href=data:image/x-icon;, type=image/x-icon> <!-- prevents favicon lookups -->
<link rel=icon href="data:;base64,iVBORw0KGgo=">
<link title=sear.c rel=search type=application/opensearchdescription+xml href=/osdd.xml>
- <style>
- input[type=password], input[type=text], input[type=submit], input[type=button] {
- height: 1cm;
- font-size: large;
- }
- .result:hover {
- background: var(--bgc2);
- }
- .container {
- display: flex;
- flex-direction: row;
- flex-wrap: nowrap;
- justify-content: center;
- align-items: stretch;
- }
- input[name=q] {
- flex-grow: 4;
- }
- input[type=submit] {
- flex-basis: 12.5%%;
- }
- .SC_LOG_ERROR {
- color: red;
- }
- .SC_LOG_WARNING {
- color: orange;
- }
- .SC_LOG_INFO {
- color: lightgreen;
- }
- .SC_LOG_DEBUG {
- color: magenta;
- }
- .breadcrumb {
- color: var(--fgc2);
- font-size: small; /* small is relative to parent (h4) size */
- }
- .result h4 {
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- margin-bottom: 0.314159265358em;
- }
- .result p {
- margin-top: 0.314159265358em;
- }
- .result img {
- height: 10em;
- }
- </style>
</head>
<body>
<form class=container action=.>
@@ -83,9 +29,7 @@
<hr>
<h4 align=center>
<a href=//git.sijanec.eu/sijanec/sear.c >sear.c</a>
- <?php
- echo `git describe --always`;
- ?>
+ <!-- the following is replaced by git or gentoo version --> <!--ver-->
</h4>
</body>
</html>
diff --git a/src/httpd.c b/src/httpd.c
index 23f4b60..efebd75 100644
--- a/src/httpd.c
+++ b/src/httpd.c
@@ -153,6 +153,11 @@ enum MHD_Result sc_httpd (void * cls,
sprintf(response, sc_osdd, host);
content_type = "application/opensearchdescription+xml";
break;
+ case 'c': /* css.css - stylesheets */
+ mhdrmm = MHD_RESPMEM_PERSISTENT;
+ response = sc_css;
+ content_type = "text/css";
+ break;
case 'l': /* logs.html */
{
#ifdef SC_LOGMEM
diff --git a/src/main.c b/src/main.c
index f57e398..0b18c0e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -58,6 +58,9 @@ unsigned char sc_hp[] = { /* html page null terminated format string, from file
char sc_osdd[] = { /* xml document for opensearch */
#include <osdd.xxd>
};
+char sc_css[] = { /* css */
+#include <css.xxd>
+};
char sc_robotstxt[] = "User-Agent: *\nDisallow: /\n";
char sc_securitytxt[] = "# This content information is provided by the developer of this opensource application.\n"
"# The developer is not responsible for the actions of his software\n"