xref: /plan9/sys/lib/plumb/basic (revision 84860c5d80372cab6c5e871d17f5695a8d0192c9)
1# these are generally in order from most specific to least,
2# since first rule that fires wins.
3
4include fileaddr
5
6# declarations of ports without rules
7plumb to seemail
8plumb to showmail
9
10# cheap http/gif,jpeg,ps,pdf renderer
11type is text
12data 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_?,%#~&/\-+=]+)*\.(jpe?g|JPE?G|gif|GIF|ps|PS|pdf|PDF|png|PNG)'
13plumb start rc -c 'hget '''$0''' | page -w'
14
15## open urls with abaco web browser
16#type is text
17#data matches 'https?://[a-zA-Z0-9_@\-]+([.:][a-zA-Z0-9_@\-]+)*/?[a-zA-Z0-9_?,%#~&/\-+=]+([:.][a-zA-Z0-9_?,''%#~&/\-+=;]+)*'
18#plumb to web
19#plumb client window abaco
20
21# rtf files go to wdoc2txt
22type is text
23data matches '[a-zA-Z¡-￿0-9_\-./]+'
24data matches '([a-zA-Z¡-￿0-9_\-./]+)\.rtf'
25arg isfile	$0
26plumb to msword
27plumb start wdoc2txt $file
28
29# start rule for microsoft word documents without .doc suffix
30type is text
31dst is msword
32plumb to msword
33plumb start wdoc2txt $file
34
35# email addresses get a new mail window
36type is text
37data matches '[a-zA-Z0-9_+.\-]+@[a-zA-Z0-9_+.\-]*'
38plumb to sendmail
39plumb start window rc -c '''echo % mail '''$0'; mail '$0
40
41# image files go to page
42type is text
43data matches '[a-zA-Z¡-￿0-9_\-./]+'
44data matches '([a-zA-Z¡-￿0-9_\-./]+)\.(jpe?g|JPE?G|gif|GIF|tiff?|TIFF?|ppm|PPM|bit|BIT|png|PNG|pgm|PGM|bmp|BMP|yuv|YUV)'
45arg isfile	$0
46plumb to image
47plumb client page -wi
48
49# postscript/pdf/dvi/doc go to page but not over the a plumb port
50# the port is here for reference but is unused
51type is text
52data matches '[a-zA-Z¡-￿0-9_\-./]+'
53data matches '([a-zA-Z¡-￿0-9_\-./]+)\.(ps|PS|eps|EPS|pdf|PDF|dvi|DVI|doc|DOC)'
54arg isfile	$0
55plumb to postscript
56plumb start page -w $file
57
58# existing files, possibly tagged by line number, go to editor
59type is text
60data matches '([.a-zA-Z¡-￿0-9_/+\-]*[a-zA-Z¡-￿0-9_/+\-])('$addr')?'
61arg isfile	$1
62data set	$file
63attr add	addr=$3
64plumb to edit
65plumb client window $editor
66
67# .h files are looked up in /sys/include and passed to edit
68type is text
69data matches '([a-zA-Z¡-￿0-9]+\.h)('$addr')?'
70arg isfile	/sys/include/$1
71data set	$file
72attr add	addr=$3
73plumb to edit
74plumb client window $editor
75
76# .m files are looked up in /usr/inferno/module and passed to edit
77type is text
78data matches '([a-zA-Z¡-￿0-9]+\.m)('$addr')?'
79arg isfile	/usr/inferno/module/$1
80data set	$file
81attr add	addr=$3
82plumb to edit
83plumb client window $editor
84
85# faces -> new mail window for message
86type	is	text
87data	matches	'[a-zA-Z¡-￿0-9_\-./]+'
88data	matches	'/mail/fs/[a-zA-Z¡-￿0-9/]+/[0-9]+'
89plumb	to	showmail
90plumb	start	window -r 4 120 750 600 upas/nedmail -s $0
91
92# man index entries are synthesized
93type is text
94data matches '([a-zA-Z¡-￿0-9_\-./]+)\(([1-8])\)'
95plumb start rc -c 'man -b '$2' '$1'
96
97# RFC references are looked up in /lib/rfc and passed to editor
98type is text
99data	matches 'RFC ?([0-9]+)'
100arg isfile /lib/rfc/rfc$1
101data set	$file
102plumb to edit
103plumb client window $editor
104
105# start rule for images without known suffixes
106dst is image
107plumb to image
108plumb client page -wi
109
110# start rule for postscript without known suffixes
111dst is postscript
112arg isfile $data
113plumb start page -w $data
114
115type	is	text
116data	matches	'Local (.*)'
117plumb	to	none
118plumb	start	rc -c $1
119