9front - general discussion about 9front
 help / color / mirror / Atom feed
* rc webshit browser
@ 2019-05-01 22:04 umbraticus
  2019-05-02 10:27 ` [9front] " hiro
  2019-05-02 16:43 ` Eli Cohen
  0 siblings, 2 replies; 3+ messages in thread
From: umbraticus @ 2019-05-01 22:04 UTC (permalink / raw)
  To: 9front

mothra's great, don't get me wrong.

#!/bin/rc
# webshittery for use with the following plumb rule:
# data matches 'https?://.+|/tmp/webshit.*|[₀-₉]+|hpost.*'
# plumb to webshit
# plumb client window webshit
rfork e
history = `{seq -w 02 99; echo 01}
fmtopts = $*
mkdir -p /tmp/webshit
cd /tmp/webshit
w = `{ls -t | sed 1q}
if(! ~ $w $history)
	w = $#history
label webshit
echo scroll >/dev/wctl
fn focus{
	echo unhide >/dev/wctl >[2]/dev/null
	echo current >/dev/wctl
	if(test -f /dev/kbdin)
		echo -n  >/dev/kbdin
}
fn pleaseexcusemetheoutflow{
	read -c 6000 > incoming
	mime = `{file -m incoming}
	switch($mime){
	case text/html
		w = $history($w)
		>$w{
			echo /tmp/webshit/$w $plumb
			echo
			if(~ $plumb(2) -u)	# hpost output
				plumb = $plumb(3)
			plumb = `{echo $plumb | sed 's,(https?://.*)/[^/]*,\1,'}
			root = `{echo $plumb | sed 's,(https?://[^/]*).*,\1,'}
			cat incoming /fd/0 | htmlfmt -l 4294967295 -a | awk '
/\[formfield\]/{
	gsub("\\[formfield\\]", "")
	print "§ hpost §"
}
/\[#[^\]]+\]/{
	gsub("\\[#[^\\]]+\\]", "")
}
{
	while(match($0, "\\[(image )?[^ \\]]*[^0-9 \\]][^ \\]]*\\]")){
		ref = utf(8320 + links / 1000 % 10)
		ref = ref utf(8320 + links / 100 % 10)
		ref = ref utf(8320 + links / 10 % 10)
		ref = ref utf(8320 + links % 10)
		url[links++] = sprintf("%s%s", ref, substr($0, RSTART + 1, RLENGTH - 2))
		if(index($0, "[image ") == RSTART)
			sub("\\[image [^ \\]]+\\]", "{ " ref " }")
		else
			sub("\\[[^ \\]]*[^0-9 \\]][^ \\]]*\\]", ref)
	}
	print
}
END{
	print "\nlinks:"
	for(i = 0; i < links; i++){
		sub("image ", "", url[i])
		if(match(url[i], "^[₀-₉]+//"))
			sub("^[₀-₉]+", "&http:", url[i])
		else if(match(url[i], "^[₀-₉]+/"))
			sub("^[₀-₉]+", "&" ENVIRON["root"], url[i])
		else if(!match(url[i], "^[₀-₉]+https?://"))
			sub("^[₀-₉]+", "&" ENVIRON["plumb"] "/", url[i])
		print url[i]
	}
}' | fmt -j $fmtopts
		}
		cat $w > /dev/text
		focus
	case text/*
		if(test -s incoming){
			w = $history($w)
			>$w{
				echo /tmp/webshit/$w $plumb
				echo
				cat incoming /fd/0
			}
			cat $w > /dev/text
			focus
		}
	case image/* application/^(troff postscript pdf ghostscript)
		w = $history($w)
		cat incoming /fd/0 > $w
		echo plumbing $mime
		echo '	plumb -d image' $w
		plumb -d image $w
	case audio/*
		echo playing $mime
		echo '	window -scroll -hide play' $plumb
		window -scroll -hide play $plumb
	case *
		echo 'don''t know what to do with' $mime
	}
	rm incoming
}
</mnt/plumb/webshit while(){
	plumb = `{syscall -o read 0 buf 1048575 >[2]/dev/null | tail -1}
	switch($plumb){
	case http*
		echo fetching $plumb
		hget $plumb | pleaseexcusemetheoutflow
	case hpost
		plumb = `{sed 's,.*(https?://[^ '']+).*,\1,;q' /dev/text}
		hpost $"plumb | awk '{print};END{printf "%c", 8}'
	case hpost*
		echo posting to $plumb(3)
		rc -c $"plumb | pleaseexcusemetheoutflow
	case [₀-₉][₀-₉][₀-₉][₀-₉]
		plumb = `{sed -n '/^'^$plumb^'http/{s/[₀-₉]+//p;q;}' /dev/text}
		if(~ $#plumb 1){
			echo fetching $plumb
			hget $plumb | pleaseexcusemetheoutflow
		}
	case /tmp/webshit*
		if(test -s $plumb){
			if(~ `{file -m $plumb} image/* application/^(troff postscript pdf ghostscript)){
				echo plumbing $plumb to image port
				plumb -d image $plumb
			}
			if not{
				cat $plumb > /dev/text
				focus
			}
		}
		if not
			>/dev/text for(i in `{ls -rt}){
				mime = `{file -m $i}
				if(~ $mime image/* application/^(troff postscript pdf ghostscript))
					echo /tmp/webshit/$i `{basename $mime}
				if not
					sed 1q $i
			}
	}
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9front] rc webshit browser
  2019-05-01 22:04 rc webshit browser umbraticus
@ 2019-05-02 10:27 ` hiro
  2019-05-02 16:43 ` Eli Cohen
  1 sibling, 0 replies; 3+ messages in thread
From: hiro @ 2019-05-02 10:27 UTC (permalink / raw)
  To: 9front

mothra sucks, and may you misunderstand it as you wish.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9front] rc webshit browser
  2019-05-01 22:04 rc webshit browser umbraticus
  2019-05-02 10:27 ` [9front] " hiro
@ 2019-05-02 16:43 ` Eli Cohen
  1 sibling, 0 replies; 3+ messages in thread
From: Eli Cohen @ 2019-05-02 16:43 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 5755 bytes --]

I think this is FANTASTIC. thank you

On Wed, May 1, 2019, 3:04 PM <umbraticus@prosimetrum.com> wrote:

> mothra's great, don't get me wrong.
>
> #!/bin/rc
> # webshittery for use with the following plumb rule:
> # data matches 'https?://.+|/tmp/webshit.*|[₀-₉]+|hpost.*'
> # plumb to webshit
> # plumb client window webshit
> rfork e
> history = `{seq -w 02 99; echo 01}
> fmtopts = $*
> mkdir -p /tmp/webshit
> cd /tmp/webshit
> w = `{ls -t | sed 1q}
> if(! ~ $w $history)
>         w = $#history
> label webshit
> echo scroll >/dev/wctl
> fn focus{
>         echo unhide >/dev/wctl >[2]/dev/null
>         echo current >/dev/wctl
>         if(test -f /dev/kbdin)
>                 echo -n  >/dev/kbdin
> }
> fn pleaseexcusemetheoutflow{
>         read -c 6000 > incoming
>         mime = `{file -m incoming}
>         switch($mime){
>         case text/html
>                 w = $history($w)
>                 >$w{
>                         echo /tmp/webshit/$w $plumb
>                         echo
>                         if(~ $plumb(2) -u)      # hpost output
>                                 plumb = $plumb(3)
>                         plumb = `{echo $plumb | sed
> 's,(https?://.*)/[^/]*,\1,'}
>                         root = `{echo $plumb | sed
> 's,(https?://[^/]*).*,\1,'}
>                         cat incoming /fd/0 | htmlfmt -l 4294967295 -a |
> awk '
> /\[formfield\]/{
>         gsub("\\[formfield\\]", "")
>         print "§ hpost §"
> }
> /\[#[^\]]+\]/{
>         gsub("\\[#[^\\]]+\\]", "")
> }
> {
>         while(match($0, "\\[(image )?[^ \\]]*[^0-9 \\]][^ \\]]*\\]")){
>                 ref = utf(8320 + links / 1000 % 10)
>                 ref = ref utf(8320 + links / 100 % 10)
>                 ref = ref utf(8320 + links / 10 % 10)
>                 ref = ref utf(8320 + links % 10)
>                 url[links++] = sprintf("%s%s", ref, substr($0, RSTART + 1,
> RLENGTH - 2))
>                 if(index($0, "[image ") == RSTART)
>                         sub("\\[image [^ \\]]+\\]", "{ " ref " }")
>                 else
>                         sub("\\[[^ \\]]*[^0-9 \\]][^ \\]]*\\]", ref)
>         }
>         print
> }
> END{
>         print "\nlinks:"
>         for(i = 0; i < links; i++){
>                 sub("image ", "", url[i])
>                 if(match(url[i], "^[₀-₉]+//"))
>                         sub("^[₀-₉]+", "&http:", url[i])
>                 else if(match(url[i], "^[₀-₉]+/"))
>                         sub("^[₀-₉]+", "&" ENVIRON["root"], url[i])
>                 else if(!match(url[i], "^[₀-₉]+https?://"))
>                         sub("^[₀-₉]+", "&" ENVIRON["plumb"] "/", url[i])
>                 print url[i]
>         }
> }' | fmt -j $fmtopts
>                 }
>                 cat $w > /dev/text
>                 focus
>         case text/*
>                 if(test -s incoming){
>                         w = $history($w)
>                         >$w{
>                                 echo /tmp/webshit/$w $plumb
>                                 echo
>                                 cat incoming /fd/0
>                         }
>                         cat $w > /dev/text
>                         focus
>                 }
>         case image/* application/^(troff postscript pdf ghostscript)
>                 w = $history($w)
>                 cat incoming /fd/0 > $w
>                 echo plumbing $mime
>                 echo '  plumb -d image' $w
>                 plumb -d image $w
>         case audio/*
>                 echo playing $mime
>                 echo '  window -scroll -hide play' $plumb
>                 window -scroll -hide play $plumb
>         case *
>                 echo 'don''t know what to do with' $mime
>         }
>         rm incoming
> }
> </mnt/plumb/webshit while(){
>         plumb = `{syscall -o read 0 buf 1048575 >[2]/dev/null | tail -1}
>         switch($plumb){
>         case http*
>                 echo fetching $plumb
>                 hget $plumb | pleaseexcusemetheoutflow
>         case hpost
>                 plumb = `{sed 's,.*(https?://[^ '']+).*,\1,;q' /dev/text}
>                 hpost $"plumb | awk '{print};END{printf "%c", 8}'
>         case hpost*
>                 echo posting to $plumb(3)
>                 rc -c $"plumb | pleaseexcusemetheoutflow
>         case [₀-₉][₀-₉][₀-₉][₀-₉]
>                 plumb = `{sed -n '/^'^$plumb^'http/{s/[₀-₉]+//p;q;}'
> /dev/text}
>                 if(~ $#plumb 1){
>                         echo fetching $plumb
>                         hget $plumb | pleaseexcusemetheoutflow
>                 }
>         case /tmp/webshit*
>                 if(test -s $plumb){
>                         if(~ `{file -m $plumb} image/* application/^(troff
> postscript pdf ghostscript)){
>                                 echo plumbing $plumb to image port
>                                 plumb -d image $plumb
>                         }
>                         if not{
>                                 cat $plumb > /dev/text
>                                 focus
>                         }
>                 }
>                 if not
>                         >/dev/text for(i in `{ls -rt}){
>                                 mime = `{file -m $i}
>                                 if(~ $mime image/* application/^(troff
> postscript pdf ghostscript))
>                                         echo /tmp/webshit/$i `{basename
> $mime}
>                                 if not
>                                         sed 1q $i
>                         }
>         }
> }
>

[-- Attachment #2: Type: text/html, Size: 7695 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-02 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-01 22:04 rc webshit browser umbraticus
2019-05-02 10:27 ` [9front] " hiro
2019-05-02 16:43 ` Eli Cohen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).