2019-12-28 20:45:20 +00:00
|
|
|
<!--
|
2019-12-19 18:27:15 +00:00
|
|
|
/ |
|
|
|
|
___ (___ ___|
|
|
|
|
| )| )| )
|
2019-12-23 02:05:48 +00:00
|
|
|
|__/ | / |__/
|
|
|
|
|
|
2020-01-05 00:49:36 +00:00
|
|
|
--> <p align="center"> <img src="./img/logo.png"> <br>
|
2020-01-11 21:07:47 +00:00
|
|
|
<a href="https://github.com/xvxx/phd/releases">
|
|
|
|
<img src="https://img.shields.io/github/v/release/xvxx/phd?include_prereleases">
|
2020-01-05 00:49:36 +00:00
|
|
|
</a>
|
|
|
|
</p>
|
2019-12-19 18:27:15 +00:00
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
`phd` is a small, easy-to-use gopher server.
|
2019-12-19 18:27:15 +00:00
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
Point it at a directory and it'll serve up all its text files,
|
2020-01-14 07:24:30 +00:00
|
|
|
sub-directories, and binary files over Gopher. Any `.gph` files will
|
2019-12-31 19:25:30 +00:00
|
|
|
be served up as [gopermaps][map] and executable `.gph` files will be
|
2020-01-13 22:26:32 +00:00
|
|
|
run as a program with their output served to the client, like the
|
2020-01-09 00:14:05 +00:00
|
|
|
glorious cgi-bin days of yore!
|
2019-12-28 05:06:33 +00:00
|
|
|
|
2020-01-06 19:35:19 +00:00
|
|
|
### special files:
|
2019-12-19 18:27:15 +00:00
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
- **header.gph**: If it exists in a directory, its content will be
|
|
|
|
shown above the directory's content. Put ASCII art in it.
|
|
|
|
- **footer.gph**: Same, but will be shown below a directory's content.
|
|
|
|
- **index.gph**: Completely replaces a directory's content with what's
|
2019-12-31 19:25:30 +00:00
|
|
|
in this file.
|
2020-01-09 00:14:05 +00:00
|
|
|
- **??.gph**: Visiting gopher://yoursite/1/dog/ will try to render
|
|
|
|
`dog.gph` from disk. Visiting /1/dog.gph will render the raw content
|
|
|
|
of the .gph file.
|
|
|
|
- **.reverse**: If this exists, the directory contents will be listed
|
|
|
|
in reverse alphanumeric order. Useful for phloggin', if you date
|
|
|
|
your posts.
|
|
|
|
|
|
|
|
Any line in a `.gph` file that doesn't contain tabs (`\t`) and doesn't
|
2019-12-31 19:25:30 +00:00
|
|
|
start with an `i` will get an `i` automatically prefixed, turning it
|
|
|
|
into a gopher information item.
|
|
|
|
|
2020-01-13 22:26:32 +00:00
|
|
|
Alternatively, phd supports [geomyidae][gmi] syntax:
|
|
|
|
|
|
|
|
This is an info line.
|
|
|
|
[1|This is a link|/help|server|port]
|
2020-01-14 07:24:30 +00:00
|
|
|
[h|URL Link|URL:https://noogle.com]
|
2020-01-13 22:26:32 +00:00
|
|
|
|
|
|
|
`server` and `port` will get translated into the server and port of
|
|
|
|
the actively running server, eg `localhost` and `7070`.
|
|
|
|
|
2020-01-06 19:35:19 +00:00
|
|
|
### dynamic content:
|
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
Any `.gph` file that is marked **executable** with be run as if it
|
2020-01-13 22:26:32 +00:00
|
|
|
were a standalone program and its output will be sent to the client.
|
|
|
|
It will be passed three arguments: the query string (if any), the
|
|
|
|
server's hostname, and the current port. Do with them what you will.
|
2019-12-28 07:46:27 +00:00
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
For example:
|
2019-12-28 07:46:27 +00:00
|
|
|
|
2020-01-13 22:26:32 +00:00
|
|
|
$ cat echo.gph
|
|
|
|
#!/bin/sh
|
|
|
|
echo "Hi, world! You said:" $1
|
|
|
|
echo "1Visit Gopherpedia / gopherpedia.com 70"
|
2019-12-28 07:46:27 +00:00
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
Then:
|
2019-12-28 07:46:27 +00:00
|
|
|
|
2019-12-28 09:27:29 +00:00
|
|
|
$ gopher-client gopher://localhost/1/echo?something
|
2019-12-28 20:45:20 +00:00
|
|
|
[INFO] Hi, world! You said: something
|
|
|
|
[LINK] Visit Gopherpedia
|
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
Or more seriously:
|
2019-12-28 20:45:20 +00:00
|
|
|
|
2020-01-13 22:26:32 +00:00
|
|
|
$ cat figlet.gph
|
|
|
|
#!/bin/sh
|
|
|
|
figlet $1
|
2019-12-28 20:45:20 +00:00
|
|
|
|
|
|
|
then:
|
|
|
|
|
|
|
|
$ gopher-client gopher://localhost/1/figlet?hi gopher
|
2019-12-29 22:48:40 +00:00
|
|
|
[INFO] _ _ _
|
|
|
|
[INFO] | |__ (_) __ _ ___ _ __ | |__ ___ _ __
|
2019-12-28 20:45:20 +00:00
|
|
|
[INFO] | '_ \| | / _` |/ _ \| '_ \| '_ \ / _ \ '__|
|
2019-12-29 22:48:40 +00:00
|
|
|
[INFO] | | | | | | (_| | (_) | |_) | | | | __/ |
|
|
|
|
[INFO] |_| |_|_| \__, |\___/| .__/|_| |_|\___|_|
|
2020-01-15 20:37:41 +00:00
|
|
|
[INFO] |___/ |_|
|
2019-12-28 20:45:20 +00:00
|
|
|
|
2020-01-06 19:35:19 +00:00
|
|
|
### ruby on rails:
|
|
|
|
|
|
|
|
`sh` is fun, but for serious work you need a serious scripting
|
|
|
|
language like Ruby or PHP or Node.JS:
|
|
|
|
|
2020-01-13 22:26:32 +00:00
|
|
|
$ cat sizes.gph
|
|
|
|
#!/usr/bin/env ruby
|
2020-01-06 19:36:06 +00:00
|
|
|
|
2020-01-13 22:26:32 +00:00
|
|
|
def filesize(file)
|
|
|
|
(size=File.size file) > (k=1024) ? "#{size/k}K" : "#{size}B"
|
|
|
|
end
|
2020-01-06 19:36:06 +00:00
|
|
|
|
2020-01-13 22:26:32 +00:00
|
|
|
puts "~ file sizes ~"
|
|
|
|
spaces = 20
|
|
|
|
Dir[__dir__ + "/*"].each do |entry|
|
|
|
|
name = File.basename entry
|
|
|
|
puts "#{name}#{' ' * (spaces - name.length)}#{filesize entry}"
|
|
|
|
end
|
2020-01-06 19:35:19 +00:00
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
Now you can finally share the file sizes of a directory with the world
|
2020-01-06 19:35:19 +00:00
|
|
|
of Gopher!
|
|
|
|
|
|
|
|
$ phetch -r 0.0.0.0:7070/1/sizes
|
|
|
|
i~ file sizes ~ (null) 127.0.0.1 7070
|
|
|
|
iCargo.toml 731B (null) 127.0.0.1 7070
|
|
|
|
iLICENSE 1K (null) 127.0.0.1 7070
|
|
|
|
iMakefile 724B (null) 127.0.0.1 7070
|
|
|
|
itarget 288B (null) 127.0.0.1 7070
|
|
|
|
iphd 248K (null) 127.0.0.1 7070
|
|
|
|
iCargo.lock 2K (null) 127.0.0.1 7070
|
|
|
|
iREADME.md 4K (null) 127.0.0.1 7070
|
|
|
|
img 96B (null) 127.0.0.1 7070
|
|
|
|
isizes.gph 276B (null) 127.0.0.1 7070
|
|
|
|
isrc 224B (null) 127.0.0.1 7070
|
2019-12-28 07:46:27 +00:00
|
|
|
|
2019-12-19 18:27:15 +00:00
|
|
|
## usage
|
|
|
|
|
2019-12-28 21:45:47 +00:00
|
|
|
phd [options] <root directory>
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
|
|
-p, --port Port to bind to.
|
|
|
|
-h, --host Hostname to use when generating links.
|
|
|
|
|
|
|
|
Other flags:
|
|
|
|
|
|
|
|
-h, --help Print this screen.
|
|
|
|
-v, --version Print phd version.
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
2019-12-31 19:25:30 +00:00
|
|
|
phd ./path/to/site # Serve directory over port 7070.
|
|
|
|
phd -p 70 docs # Serve 'docs' directory on port 70
|
|
|
|
phd -h gopher.com # Serve current directory over port 7070
|
|
|
|
# using hostname "gopher.com"
|
2019-12-19 18:27:15 +00:00
|
|
|
|
2019-12-28 21:25:01 +00:00
|
|
|
## installation
|
|
|
|
|
2020-01-15 20:37:41 +00:00
|
|
|
On macOS you can install with [Homebrew](https://brew.sh/):
|
|
|
|
|
|
|
|
brew install xvxx/code/phd
|
|
|
|
|
2020-01-13 22:26:32 +00:00
|
|
|
Binaries for Linux, Mac, and Raspberry Pi are available at
|
2020-01-11 21:07:47 +00:00
|
|
|
gopher://phkt.io/1/releases/phd and https://github.com/xvxx/phd/releases:
|
2019-12-28 21:25:01 +00:00
|
|
|
|
2020-01-14 07:39:21 +00:00
|
|
|
- [phd-v0.1.7-linux-x86_64.tar.gz][0]
|
|
|
|
- [phd-v0.1.7-linux-armv7.tar.gz (Raspberry Pi)][1]
|
|
|
|
- [phd-v0.1.7-macos.zip][2]
|
2019-12-28 21:25:01 +00:00
|
|
|
|
2020-01-09 00:14:05 +00:00
|
|
|
Just unzip/untar the `phd` program into your $PATH and get going!
|
2019-12-28 21:25:01 +00:00
|
|
|
|
2019-12-19 18:27:15 +00:00
|
|
|
## development
|
|
|
|
|
|
|
|
cargo run -- ./path/to/gopher/site
|
|
|
|
|
|
|
|
## resources
|
|
|
|
|
2020-01-13 06:23:30 +00:00
|
|
|
- gopher://bitreich.org/1/scm/geomyidae/files.gph
|
2019-12-19 18:27:15 +00:00
|
|
|
- https://github.com/gophernicus/gophernicus/blob/master/README.Gophermap
|
|
|
|
- https://gopher.zone/posts/how-to-gophermap/
|
2019-12-28 00:53:36 +00:00
|
|
|
- [rfc 1436](https://tools.ietf.org/html/rfc1436)
|
2019-12-19 18:27:15 +00:00
|
|
|
|
2019-12-28 06:27:56 +00:00
|
|
|
## todo
|
|
|
|
|
2019-12-31 19:25:30 +00:00
|
|
|
- [ ] script/serverless mode
|
2019-12-28 21:37:08 +00:00
|
|
|
- [ ] systemd config, or something
|
2019-12-28 21:47:39 +00:00
|
|
|
- [ ] TLS support
|
|
|
|
- [ ] man page
|
2020-01-01 03:47:34 +00:00
|
|
|
- [ ] ipv6
|
2020-01-09 00:11:28 +00:00
|
|
|
- [ ] user input sanitization tests
|
2019-12-29 22:48:40 +00:00
|
|
|
|
2020-01-14 07:39:21 +00:00
|
|
|
[0]: https://github.com/xvxx/phd/releases/download/v0.1.7/phd-v0.1.7-linux-x86_64.tar.gz
|
|
|
|
[1]: https://github.com/xvxx/phd/releases/download/v0.1.7/phd-v0.1.7-linux-armv7.tar.gz
|
|
|
|
[2]: https://github.com/xvxx/phd/releases/download/v0.1.7/phd-v0.1.7-macos.zip
|
2020-01-01 03:47:34 +00:00
|
|
|
[map]: https://en.wikipedia.org/wiki/Gopher_(protocol)#Source_code_of_a_menu
|
2020-01-13 22:26:32 +00:00
|
|
|
[gmi]: gopher://bitreich.org/1/scm/geomyidae
|