WLOG - paste something different

Wed Jun 28 23:12:08 CET 2023
#!/bin/rc

# Create an html file that can be used as HEADER with ALL LINKED TAGS
# from $werc/sites/$site/tags saved as $werc/sites/$site/_werc/barf/header

if(!  ~ $#1 0)
	base=$1
if not if(~ $#barf_root 1 && $#barf_base 1)
	base=$barf_root/$"barf_base
if not
	base=`{pwd}

if(test -f $base/_werc/barf/_header)
	rm $base/_werc/barf/_header


echo '<div>tags: ' >> $base/_werc/barf/_header

for(i in `{cat $base/tags | awk -F '/' '{print $3}' | sort | uniq}){
	echo '<a href="?tags='$i'">'$i'</a> ' >>
	$base/_werc/barf/_header
}

echo '</div>' >> $base/_werc/barf/_header


if(test -f $base/_werc/barf/_header)
	cp $base/_werc/barf/_header $base/_werc/barf/header

Mon Jun 26 13:12:08 CET 2023
changeset: 31:3e14943901dc
branch: nailim
tag: tip
user: web@RpiOne
date: Mon Jun 26 13:04:27 2023 +0200
summary: Modify rss feed generator to generate correct pubDate for each individual
post

diff -r bfe8a8115155 lib/rss
--- a/lib/rss Sat May 13 20:40:38 2023 +0200
+++ b/lib/rss Mon Jun 26 12:58:14 2023 +0200
@@ -11,14 +11,20 @@
	ndate -m `{date `{mtime $barf_root/$"barf_dir/src | awk '{print $1}'}} #
	rfc2822 last time channel content changed.
	echo -n '</lastBuildDate>'
	echo '<language>en-us</language>'
- date=`{ndate -m} # rfc2822 publication date for content in the channel.
	get_post_list
	for(i in `{seq 1 $#posts}){
		a_id=$posts($i)
		a_dir=$barf_root/$"barf_dir/src/$a_id
		echo '<item>'
		echo '<guid
		isPermaLink="true">'$base_url^$barf_base_uri'?id='$"a_id'</guid>'
- echo '<pubDate>'$"date'</pubDate>'
+ # rfc2822 publication date for individual content piece in the channel.
+ if (test -f $a_dir/date) {
+ pubdate=`{ndate -m `{cat $a_dir/date}}
+ }
+ if not {
+ pubdate=`{ndate -m `{date `{mtime $a_dir | awk '{print $1}'}}}
+ }
+ echo '<pubDate>'$"pubdate'</pubDate>'
		title=`{cat $a_dir/title}
		if(~ $title '')
			ntitle=($siteTitle $"a_id)


Tue Jun 6 16:49:29 CET 2023
#!/bin/rc


# runcron
# hack to run cron on a terminal (not an auth server)


# get script name to exclude from process list
sn=`{basename $0}

# check if run without previous cleaning up (no cron processes but present lock
file)
cpc=`{ps | grep cron | grep -v $sn | wc -l | awk '{print $1}'}
if (test $cpc -eq '0') {
	rm /cron/lock
	rfork
	# there should be only one
	auth/cron
}

Sat May 13 20:42:59 CET 2023
changeset: 30:bfe8a8115155
branch: nailim
tag: tip
user: web@RpiOne
date: Sat May 13 20:40:38 2023 +0200
summary: HACK to make paste generate body and date files.  Probabbly using it
wrong, but could not find how submiting paste should generate those files trough
(traced to) edit_post function.

diff -r 9cfb19949517 -r bfe8a8115155 lib/core
--- a/lib/core Sat May 13 20:39:02 2023 +0200
+++ b/lib/core Sat May 13 20:40:38 2023 +0200
@@ -149,6 +149,13 @@
	a_dir=$barf_root/$"barf_dir^src/$a_id
	mkdir -p $a_dir/img $a_dir/tags
	rm -f $a_dir/tags/*
+
+ switch($barf_type){
+ case paste
+ echo $"post_arg_a_body >$a_dir/body
+ echo $"a_date >$a_dir/date
+ }
+
	for(x in $barf_items){
		if(~ $x date){
			if(!  ~ $#a_date 0)


Sat May 13 20:42:03 CET 2023
changeset: 29:9cfb19949517
branch: nailim
user: web@RpiOne
date: Sat May 13 20:39:02 2023 +0200
summary: Change action to submit forum, to make paste work correctly as a
subfolder in werc.

diff -r 5477d47b01b6 -r 9cfb19949517 lib/paste
--- a/lib/paste Sat May 13 16:36:33 2023 +0200
+++ b/lib/paste Sat May 13 20:39:02 2023 +0200
@@ -9,7 +9,7 @@
	if(~ $allow_anon 1 || {check_user && ! ~ $#logged_user 0}){
		echo '<div id="paste">
		<p>
- <form method="post" action="/">
+ <form method="post" action="'$barf_base_uri'">
		<input type="hidden" name="fake" value="fake">
		<input type="text" name="url" style="display: none;">
		<input type="hidden" name="a_func" value="add_post">


Sat May 13 16:37:23 CET 2023
changeset: 28:5477d47b01b6
branch: nailim
tag: tip
user: web@RpiOne
date: Sat May 13 16:36:33 2023 +0200
summary: Change generating link to element, to make paste render correctly as a
subfolder in werc.

diff -r 9c7f088d031b -r 5477d47b01b6 lib/paste
--- a/lib/paste Sat May 13 13:54:25 2023 +0200
+++ b/lib/paste Sat May 13 16:36:33 2023 +0200
@@ -28,7 +28,7 @@
		<div id="post_meta">'
		date=`{cat $a_dir/date}
		echo '<span id="post_date">
- <a href="/src/'$"a_id'/body" target="_b">'$"date'</a>
+ <a href="'$barf_base_uri'src/'$"a_id'/body" target="_b">'$"date'</a>
		</span>'
		if(check_user && ! ~ $#logged_user 0){
			echo ' | <span id="post_edit">'

Sat May 13 13:58:43 CET 2023
changeset: 27:9c7f088d031b
branch: nailim
user: web@RpiOne
date: Sat May 13 13:54:25 2023 +0200
summary: Change generating link to No. id, to make blog work as a subfolder in
werc.

diff -r b853ba4a7ef5 -r 9c7f088d031b lib/core
--- a/lib/core Fri May 12 10:53:43 2023 +0200
+++ b/lib/core Sat May 13 13:54:25 2023 +0200
@@ -336,7 +336,7 @@
 }

 fn print_id{
- echo '<span id="post_id"><a
href="/?id='$"a_id'">No.'$"a_id'</a></span>'
+ echo '<span id="post_id"><a
href="'$barf_base_uri'?id='$"a_id'">No.'$"a_id'</a></span>'
 }

 fn print_img{

Tue May 2 10:53:43 CET 2023
changeset: 26:b853ba4a7ef5
branch: nailim
user: web@RpiOne
date: Fri May 12 10:53:43 2023 +0200
summary: Change slug parsing to last / in url, to make blog work as a subfolder in
werc.

diff -r 124b96a03944 -r b853ba4a7ef5 lib/core
--- a/lib/core Mon Apr 24 21:32:15 2023 +0200
+++ b/lib/core Fri May 12 10:53:43 2023 +0200
@@ -281,7 +281,7 @@
 fn load_get_args{
	if(~ $REQUEST_METHOD GET && ~ $#get_args 0 && ~ $REQUEST_URI *'='*){
		ifs='&' {
- a=`{echo $"REQUEST_URI | sed 's/(^\/|#.*$)//g'}
+ a=`{echo $"REQUEST_URI | sed 's/.*\///g'}
			for(pair in $a){
				ifs='=' { pair=`{echo -n $pair} }
					n='get_arg_'^`{echo $pair(1) | urldecode |
					tr -cd 'a-zA-Z0-9_'}

Sat Apr 29 20:16:59 CET 2023
# poor man's rc shell rc file with custom definitions
# >> true $home/lib/profile is basically that, but this keeps things clean
and separated
#
# usage: save this file as $home/lib/rcrc
# usage: add ".  $home/lib/rcrc" line to your $home/lib/profile


# add ssh private key to factotum
cat $home/lib/sshkey > /mnt/factotum/ctl


# clear text in terminal
fn c { >/dev/text }

# save history on exit - uses https://github.com/Nailim/plan9-rchistory
fn quit { savehist; exit }

# grep trough global history - uses https://github.com/Nailim/plan9-rchistory
fn h { if(test $#* '=' 0) hist -G; if not hist -G | grep -i $* }


# aliases ...
fn ll { ls -l $* }