summaryrefslogtreecommitdiffstats
path: root/_site/log
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-12-28 21:17:30 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-12-30 21:46:51 +0800
commit9fec793abe0a73e5cd502a1d1e935e2413b85079 (patch)
treedf5827fbc7032d982c07c06f6d9783751cc6b62d /_site/log
parent06c5dc32086a1aaae6e6f48c017ea9b5e331cdf3 (diff)
downloadwww-9fec793abe0a73e5cd502a1d1e935e2413b85079.tar.gz
Search via CGI script.
Diffstat (limited to '_site/log')
-rw-r--r--_site/log/arduino-due/index.html7
-rw-r--r--_site/log/arduino-uno/index.html7
-rw-r--r--_site/log/bumblebee/index.html7
-rw-r--r--_site/log/e-reader/index.html7
-rw-r--r--_site/log/etlas/index.html7
-rw-r--r--_site/log/fpm-door-lock-lp/index.html7
-rw-r--r--_site/log/fpm-door-lock-rf/index.html7
-rw-r--r--_site/log/index.html20
-rw-r--r--_site/log/matrix-digital-rain/index.html10
-rw-r--r--_site/log/mosfet-switches/index.html7
-rw-r--r--_site/log/neo4j-a-star-search/index.html7
-rw-r--r--_site/log/search-with-cgi/index.html152
12 files changed, 232 insertions, 13 deletions
diff --git a/_site/log/arduino-due/index.html b/_site/log/arduino-due/index.html
index 0916c6f..a2135cb 100644
--- a/_site/log/arduino-due/index.html
+++ b/_site/log/arduino-due/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/arduino-uno/index.html b/_site/log/arduino-uno/index.html
index 95681a4..66fff37 100644
--- a/_site/log/arduino-uno/index.html
+++ b/_site/log/arduino-uno/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/bumblebee/index.html b/_site/log/bumblebee/index.html
index 0962a27..b4c9c25 100644
--- a/_site/log/bumblebee/index.html
+++ b/_site/log/bumblebee/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/e-reader/index.html b/_site/log/e-reader/index.html
index 3eef05d..44ae1e6 100644
--- a/_site/log/e-reader/index.html
+++ b/_site/log/e-reader/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/etlas/index.html b/_site/log/etlas/index.html
index c1b5975..8149618 100644
--- a/_site/log/etlas/index.html
+++ b/_site/log/etlas/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/fpm-door-lock-lp/index.html b/_site/log/fpm-door-lock-lp/index.html
index 76715d7..a5d237c 100644
--- a/_site/log/fpm-door-lock-lp/index.html
+++ b/_site/log/fpm-door-lock-lp/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/fpm-door-lock-rf/index.html b/_site/log/fpm-door-lock-rf/index.html
index 0c5037b..04c84de 100644
--- a/_site/log/fpm-door-lock-rf/index.html
+++ b/_site/log/fpm-door-lock-rf/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/index.html b/_site/log/index.html
index de9c470..defcfed 100644
--- a/_site/log/index.html
+++ b/_site/log/index.html
@@ -28,7 +28,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
@@ -46,6 +51,19 @@
<tr>
<td class="posts-td posts-td-link">
+ <a href="/log/search-with-cgi/" class="link-decor-none">Site search using Perl + CGI</a>
+ </td>
+ <td class="posts-td posts-td-time">
+ <span class="post-meta">
+ <time datetime="2025-12-29 00:00:00 +0800">2025-12-29</time>
+ </span>
+ </td>
+ </tr>
+
+
+
+ <tr>
+ <td class="posts-td posts-td-link">
<a href="/log/matrix-digital-rain/" class="link-decor-none">Matrix Rain: 2025 refactor</a>
</td>
<td class="posts-td posts-td-time">
diff --git a/_site/log/matrix-digital-rain/index.html b/_site/log/matrix-digital-rain/index.html
index 8383776..a570230 100644
--- a/_site/log/matrix-digital-rain/index.html
+++ b/_site/log/matrix-digital-rain/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
@@ -91,8 +96,7 @@ static inline void insert_code(matrix *mat,
<p>Tossed license and automake cruft. Just <code class="language-plaintext highlighter-rouge">cc -O3 main.c -o matrix</code> now. Don’t
need the ceremony.</p>
-<p>Runs at 2-3% CPU on OpenBSD (T490). No cause to measure performance more
-precisely. No regressions. Fans are quiet.</p>
+<p>Runs at 2-3% CPU on OpenBSD (T490). No regressions. Fans are quiet.</p>
<p>Commit:
<a href="https://git.asciimx.com/matrix-digital-rain/commit/main.c?id=69a888a5b0bc4ef4bce4f86c1556a06f0f131fda">69a888a</a></p>
diff --git a/_site/log/mosfet-switches/index.html b/_site/log/mosfet-switches/index.html
index 97bba07..37d6707 100644
--- a/_site/log/mosfet-switches/index.html
+++ b/_site/log/mosfet-switches/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/neo4j-a-star-search/index.html b/_site/log/neo4j-a-star-search/index.html
index a00dd6c..013cd95 100644
--- a/_site/log/neo4j-a-star-search/index.html
+++ b/_site/log/neo4j-a-star-search/index.html
@@ -32,7 +32,12 @@
<li >
<a href="/about/" class="link-decor-none">abt</a>
</li>
- <li><a href="/feed.xml" class="link-decor-none">rss</a></li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
</ul>
</div>
diff --git a/_site/log/search-with-cgi/index.html b/_site/log/search-with-cgi/index.html
new file mode 100644
index 0000000..060a282
--- /dev/null
+++ b/_site/log/search-with-cgi/index.html
@@ -0,0 +1,152 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Site search using Perl + CGI</title>
+
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>Site search using Perl + CGI</title>
+ <link rel="stylesheet" href="/assets/css/main.css">
+ <link rel="stylesheet" href="/assets/css/skeleton.css">
+</head>
+
+
+
+ </head>
+ <body>
+
+ <div id="nav-container" class="container">
+ <ul id="navlist" class="left">
+
+ <li >
+ <a href="/" class="link-decor-none">hme</a>
+ </li>
+ <li class="active">
+ <a href="/log/" class="link-decor-none">log</a>
+ </li>
+ <li >
+ <a href="/projects/" class="link-decor-none">poc</a>
+ </li>
+ <li >
+ <a href="/about/" class="link-decor-none">abt</a>
+ </li>
+ <li>
+ <a href="/cgi-bin/find.cgi" class="link-decor-none">sws</a>
+ </li>
+ <li>
+ <a href="/feed.xml" class="link-decor-none">rss</a>
+ </li>
+ </ul>
+</div>
+
+
+
+ <main>
+ <div class="container">
+ <div class="container-2">
+ <h2 class="center" id="title">SITE SEARCH USING PERL + CGI</h2>
+ <h6 class="center">29 DECEMBER 2025</h5>
+ <br>
+ <div class="twocol justify"><p>Need a way to search site–number of articles are growing.</p>
+
+<p>Searching site client-side using the RSS feed and JavaScript is not an option–
+bloats the feed and breaks the site for Lynx and other text browsers.</p>
+
+<p>Perl’s great for text processing–especially regex work. Few lines of Perl
+could do a regex search and send the result back via CGI. OpenBSD httpd speaks
+CGI, Perl and slowcgi are in the base systems. No dependencies. Works on every
+conceivable browser.</p>
+
+<p>Perl: traverse the directory with File::Find recursively. If search text is
+found grab the file name, title and up to 50 chars of the first paragraph to
+include in the search result.</p>
+
+<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>find(sub {
+ if (open my $fh, '&lt;', $_) {
+ my $content = do { local $/; &lt;$fh&gt; };
+ close $fh;
+
+ if ($content =~ /\Q$search_text\E/i) {
+ my ($title) = $content =~ /&lt;title&gt;(.*?)&lt;\/title&gt;/is;
+ $title ||= $File::Find::name;
+ my ($p_content) = $content =~ /&lt;p[^&gt;]*&gt;(.*?)&lt;\/p&gt;/is;
+ my $snippet = $p_content || "";
+ $snippet =~ s/&lt;[^&gt;]*&gt;//g;
+ $snippet =~ s/\s+/ /g;
+ $snippet = substr($snippet, 0, 50);
+ $snippet .= "..." if length($p_content || "") &gt; 50;
+
+ push @results, {
+ path =&gt; $File::Find::name,
+ title =&gt; $title,
+ snippet =&gt; $snippet
+ };
+ }
+ }
+}, $dir);
+</code></pre></div></div>
+
+<p>Don’t need the Perl CGI module, httpd sets QUERY_STRING for the slowcgi script:</p>
+
+<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>my %params;
+if ($ENV{QUERY_STRING}) {
+ foreach my $pair (split /&amp;/, $ENV{QUERY_STRING}) {
+ my ($key, $value) = split /=/, $pair;
+ $value =~ tr/+/ /;
+ $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
+ $params{$key} = $value;
+ }
+}
+</code></pre></div></div>
+
+<p>Run the script as www user. Permissions: 554 (read + execute).</p>
+
+<p>Running in OpenBSD chroot: Check Perl’s dynamic object dependencies:</p>
+
+<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ ldd $(which perl)
+/usr/bin/perl:
+ Start End Type Open Ref GrpRef Name
+ 000008797e8e6000 000008797e8eb000 exe 1 0 0 /usr/bin/perl
+ 0000087c1ffe5000 0000087c20396000 rlib 0 1 0 /usr/lib/libperl.so.26.0
+ 0000087bf4508000 0000087bf4539000 rlib 0 2 0 /usr/lib/libm.so.10.1
+ 0000087b9e801000 0000087b9e907000 rlib 0 2 0 /usr/lib/libc.so.102.0
+ 0000087bba182000 0000087bba182000 ld.so 0 1 0 /usr/libexec/ld.so
+</code></pre></div></div>
+
+<p>Copy them over to chroot. Now should have /var/www/usr/bin/perl,
+/usr/lib/libperl.so.26.0, and so on.</p>
+
+<p>Troubleshooting: look for issues in logs or try executing the script in chroot:</p>
+
+<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ cat /var/log/messages | grep slowcgi
+# chroot /var/www/ htdocs/path/to/script/script.cgi
+</code></pre></div></div>
+<p>The last command exposes any missing Perl modules in chroot and where to find
+them. Copy them over as well.</p>
+
+<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>location "/cgi-bin/*" {
+ fastcgi socket "/run/slowcgi.sock"
+}
+</code></pre></div></div>
+
+<p>in httpd.conf routes queries to slowcgi.</p>
+
+</div>
+ <p class="post-author right">by W. D. Sadeep Madurange</p>
+ </div>
+ </div>
+ </main>
+
+ <div class="footer">
+ <div class="container">
+ <div class="twelve columns right container-2">
+ <p id="footer-text">&copy; ASCIIMX - 2025</p>
+ </div>
+ </div>
+</div>
+
+
+ </body>
+</html>