hlfw.ca

plumb

Download patch

ref: 85ec3ed2097759464f95448bd3f37115c4f4a0f6
parent: 6cb7b57c774d3ab64d38b4957f86571d3dc11b8c
author: Michael Misch <michaelmisch1985@gmail.com>
date: Tue Jul 13 07:02:56 PDT 2021

Update README.md

Update README for clarity

--- a/README.md
+++ b/README.md
@@ -2,22 +2,52 @@
 
 ## Overview
 
-plumb is a drop-in replacement for plan9's plumb command, that understands mime-types of local files and URLs. 
+Plumb is a drop-in replacement for plan9's [plumb](https://9fans.github.io/plan9port/man/man1/plumb.html) utility.
 
+Notably different from it, are how it handles the `type` attribute of the plumb messages.
+They will be set to a proper mimetype, instead of the simple `type is text` that the traditional plumber utilized. 
+
+This is considerably more powerful, as you no longer need to attempt to infer the content based on URIs, extensions, or directory structure.
+
 ## Rules
 
-plumb will write plumb messages as the usual `type is text` for non-files, and non-URLs. When the content is one of those, however, it will set the type to that mime.
+Your plumber rules will have to be updated to reflect this more granular message:
 
 ```
-# Examples of types sent to plumber by this implementation of plumb
+## In this example, plan9front's plumber is being used; but similar rule changes would apply for plan9 regular.
+
 type is image/png
+## No longer need to match paths
+#data matches '[a-zA-Z¡-￿0-9_\-./@]+'
+#data matches '([a-zA-Z¡-￿0-9_\-./@]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|bit|png|PNG)'
+arg isfile	$0
+plumb to image
+plumb start 9 page $file
+
+# local html files (Your dev work, for example) can be opened in your editor
 type is text/html
-type is text/plain
+arg isfile $0
+plumb to edit
+plumb start $editor $0
+
+# remote html files will likely be opened in your browser
+type is text/html
+# With the above case matching local files, we no longer need this convolution
+#data matches '(https?|ftp|file|gopher|mailto|news|nntp|telnet|wais|prospero)://[a-zA-Z0-9_@\-]+([.:][a-zA-Z0-9_@\-]+)*/?[a-zA-Z0-9_?,%#~&/\-+=]+([:.][a-zA-Z0-9_?,%#~&/\-+=]+)*'
+plumb to web
+plumb start web $0
+
 type is application/pdf
+## No longer need to match paths
+#data matches '[a-zA-Z¡-￿0-9_\-./@]+'
+#data matches '([a-zA-Z¡-￿0-9_\-./@]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI)'
+arg isfile	$0
+plumb to postscript
+plumb start 9 page $file
 ```
 
-In practice, setting a rule for most common mimetypes will serve you well. For example, my last implementation of plumber used a relatively small amount of mimes, after a few years' worth of plumbing in this manner. 
-See https://github.com/halfwit/Plumber/tree/master/cfg/plumber
+In practice, setting a rule for most common mimetypes will serve you well. (For example, my last implementation of plumber used a relatively small amount of mimes, after a few years' worth of plumbing in this manner. 
+See https://github.com/halfwit/Plumber/tree/master/cfg/plumber)
 
 ## About application/octet-stream mimetype
 If the remote mimetype is `application/octet-stream`, which is a fallback when it cannot infer the mimetype this client will attempt to find a content-type field in any remote URL, finally setting the type to `text`.