mirror of https://github.com/xvxx/phd
Compare commits
83 Commits
Author | SHA1 | Date |
---|---|---|
chris west | 5b02ccc1db | 2 years ago |
chris west | 1e31a05f9d | 2 years ago |
chris west | 006a3f58a5 | 2 years ago |
chris west | 6761e1d738 | 2 years ago |
chris west | ae866b4609 | 2 years ago |
chris west | 555504689f | 2 years ago |
chris west | a0ab2fa9c5 | 3 years ago |
chris west | fb304bce9e | 4 years ago |
chris west | be85890d84 | 4 years ago |
chris west | 2e78294135 | 4 years ago |
chris west | 0db0c7e149 | 4 years ago |
chris west | 10ba1ca69d | 4 years ago |
chris west | fe7e2e43e6 | 4 years ago |
chris west | 4c0d707a7a | 4 years ago |
chris west | 06c0a2d5ea | 4 years ago |
chris west | 954855fd80 | 4 years ago |
chris west | 1cb71b3450 | 4 years ago |
chris west | 4de39201ba | 4 years ago |
chris west | 4ee7008070 | 4 years ago |
chris west | de8607bee8 | 4 years ago |
chris west | db0de166e8 | 4 years ago |
chris west | 19e7579a4f | 4 years ago |
chris west | f3ff3fb3eb | 4 years ago |
chris west | 924c5b1ae9 | 4 years ago |
chris west | 68979f2d88 | 4 years ago |
Richard Bradfield | a07c921fee | 4 years ago |
chris west | f3bfbbd9f5 | 4 years ago |
chris west | 3d19ac030c | 4 years ago |
chris west | e7e0ff9294 | 4 years ago |
chris west | dc1f48e917 | 4 years ago |
chris west | 3b0d9de144 | 4 years ago |
chris west | d63f0e866b | 4 years ago |
chris west | 85865968e3 | 4 years ago |
chris west | c0e0aa4548 | 4 years ago |
chris west | 36cdefd32c | 4 years ago |
chris west | 03b557312c | 4 years ago |
chris west | 822e1e0f26 | 4 years ago |
chris west | b527304e67 | 4 years ago |
chris west | ee2d324a98 | 4 years ago |
chris west | 73a0016893 | 4 years ago |
chris west | 63b12145ad | 4 years ago |
chris west | 4d712e9a05 | 4 years ago |
chris west | 497185c2e3 | 4 years ago |
chris west | 4717780bfb | 4 years ago |
chris west | ab890ec450 | 4 years ago |
chris west | bc30c3a209 | 4 years ago |
chris west | 2714841316 | 4 years ago |
chris west | 49ae7abb63 | 4 years ago |
chris west | 67665c3327 | 5 years ago |
chris west | 9964d2c530 | 5 years ago |
chris west | c94b6c986f | 5 years ago |
chris west | a1eb708980 | 5 years ago |
chris west | 1a102fa9a8 | 5 years ago |
chris west | aeaf8d36c4 | 5 years ago |
chris west | 08e3056f55 | 5 years ago |
chris west | 1dd632e433 | 5 years ago |
chris west | 5dc22bf677 | 5 years ago |
chris west | ac41b7f191 | 5 years ago |
chris west | 1c2b065ee7 | 5 years ago |
chris west | 0241a698c8 | 5 years ago |
chris west | 3f6c5c43de | 5 years ago |
chris west | 3f5fed5631 | 5 years ago |
chris west | 82bbb4edd3 | 5 years ago |
chris west | b90325579b | 5 years ago |
chris west | 5ae4663bf0 | 5 years ago |
dvkt | fc22f88363 | 5 years ago |
dvkt | 5cc05f1349 | 5 years ago |
dvkt | 87bc9a7a58 | 5 years ago |
dvkt | eeb342ebfd | 5 years ago |
dvkt | a1bb9c24d3 | 5 years ago |
dvkt | 525d06383a | 5 years ago |
dvkt | d295650413 | 5 years ago |
dvkt | 01c327192d | 5 years ago |
dvkt | f911b4a355 | 5 years ago |
dvkt | 8b825dbd5e | 5 years ago |
dvkt | bdd127f665 | 5 years ago |
dvkt | 4eebc84c1b | 5 years ago |
dvkt | 99178d51d9 | 5 years ago |
dvkt | 49dab5b83d | 5 years ago |
dvkt | 616a164baf | 5 years ago |
dvkt | 43e596d01b | 5 years ago |
dvkt | 9ee7416403 | 5 years ago |
dvkt | 840c1dd5cc | 5 years ago |
@ -0,0 +1,2 @@
|
||||
[build]
|
||||
rustflags = ["-C", "link-arg=-s"]
|
@ -0,0 +1,73 @@
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: ["*"]
|
||||
|
||||
name: build
|
||||
|
||||
jobs:
|
||||
test_macos:
|
||||
name: Run Tests on macOS
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo build
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Setup toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
components: clippy
|
||||
override: true
|
||||
- name: check
|
||||
run: cargo check
|
||||
- name: clippy
|
||||
run: cargo clippy
|
||||
- name: test
|
||||
run: cargo test
|
||||
- name: build
|
||||
run: cargo build --release
|
||||
|
||||
test_ubuntu:
|
||||
name: Run Tests on Ubuntu (x86_64)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: check
|
||||
run: cargo check
|
||||
- name: clippy
|
||||
run: cargo clippy
|
||||
- name: test
|
||||
run: cargo test
|
||||
- name: build
|
||||
run: cargo build --release
|
@ -0,0 +1,162 @@
|
||||
name: Create Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*.*.*"
|
||||
|
||||
jobs:
|
||||
build_armv7:
|
||||
name: Build for armv7
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Setup Toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: armv7-unknown-linux-gnueabihf
|
||||
override: true
|
||||
- name: Build release
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
use-cross: true
|
||||
command: build
|
||||
args: --release --locked --target armv7-unknown-linux-gnueabihf
|
||||
- name: Get current version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
|
||||
- name: Package Binary
|
||||
run: cp doc/phd.1 target/armv7-unknown-linux-gnueabihf/release && cd target/armv7-unknown-linux-gnueabihf/release && tar zcvf phd-${{ steps.get_version.outputs.VERSION }}-linux-armv7.tgz phd phd.1
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: phd-linux-armv7
|
||||
path: target/armv7-unknown-linux-gnueabihf/release/phd-${{ steps.get_version.outputs.VERSION }}-linux-armv7.tgz
|
||||
|
||||
build_linux:
|
||||
name: Build for Linux x86_64
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Build release
|
||||
run: cargo build --locked --release
|
||||
- name: Get current version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
|
||||
- name: Package Binary
|
||||
run: cp doc/phd.1 target/release && cd target/release && tar zcvf phd-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tgz phd phd.1
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: phd-linux-x86_64
|
||||
path: target/release/phd-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tgz
|
||||
|
||||
build_macos:
|
||||
name: Build for macOS
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- name: Cache cargo registry
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo index
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Cache cargo build
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: target
|
||||
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
|
||||
- name: Setup Toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: stable
|
||||
override: true
|
||||
- name: Build release
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --locked --release
|
||||
- name: Get current version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
|
||||
- name: Package Binary
|
||||
run: cp doc/phd.1 target/release && cd target/release && zip -r phd-${{ steps.get_version.outputs.VERSION }}-macos.zip phd phd.1
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v1
|
||||
with:
|
||||
name: phd-macos
|
||||
path: target/release/phd-${{ steps.get_version.outputs.VERSION }}-macos.zip
|
||||
|
||||
create:
|
||||
name: Create Release
|
||||
needs: [build_armv7, build_linux, build_macos]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Get current version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
|
||||
- name: Download macOS artifact
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: phd-macos
|
||||
- name: Download Linux (x86_64) artifact
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: phd-linux-x86_64
|
||||
- name: Download Linux (armv7) artifact
|
||||
uses: actions/download-artifact@v1
|
||||
with:
|
||||
name: phd-linux-armv7
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: true
|
||||
prerelease: true
|
||||
files: |
|
||||
phd-macos/phd-${{ steps.get_version.outputs.VERSION }}-macos.zip
|
||||
phd-linux-x86_64/phd-${{ steps.get_version.outputs.VERSION }}-linux-x86_64.tgz
|
||||
phd-linux-armv7/phd-${{ steps.get_version.outputs.VERSION }}-linux-armv7.tgz
|
||||
body_path: CHANGELOG.md
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@ -0,0 +1,62 @@
|
||||
## v0.1.15
|
||||
|
||||
- Update `alphanumeric-sort` dependency so `cargo install phd` works again.
|
||||
- Recommend `cargo install phd --locked` in the README
|
||||
|
||||
## v0.1.14
|
||||
|
||||
- If the `NO_COLOR` env variable is set, colors won't be printed to
|
||||
the log. Same as starting with `--no-color`.
|
||||
See https://no-color.org/.
|
||||
|
||||
## v0.1.13
|
||||
|
||||
- Added `--no-color` command line option to not display color when
|
||||
logging.
|
||||
- Slight change to binding behavior: if `-p` is passed without `-b`,
|
||||
we'll try to bind to that port. To this easier: `phd -p 7777`
|
||||
- Accept `?` as query string indicator, not just `TAB`. See #3.
|
||||
|
||||
## v0.1.12
|
||||
|
||||
`phd` now uses `-b` and `--bind` to set the host and port to
|
||||
bind to. `-p` and `-h` are now strictly for URL generation.
|
||||
|
||||
This should hopefully make it easier to run `phd` behind a
|
||||
proxy and still generate proper links.
|
||||
|
||||
Thanks to @bradfier for the patch!
|
||||
|
||||
## v0.1.11
|
||||
|
||||
`phd` now ships with a basic manual!
|
||||
|
||||
It will be installed via homebrew and (eventually) AUR.
|
||||
|
||||
For now you can view it by cloning the repository and running:
|
||||
|
||||
man ./doc/phd.1
|
||||
|
||||
Enjoy!
|
||||
|
||||
## v0.1.10
|
||||
|
||||
`phd` can now render a single page to stdout, instead of starting
|
||||
as a server. Those of us in the biz refer to this as "serverless".
|
||||
|
||||
For example, if your Gopher site lives in `/srv/gopher` and you want
|
||||
to render the main page, just run:
|
||||
|
||||
phd -r / /srv/gopher
|
||||
|
||||
This will print the raw Gopher menu to stdout!
|
||||
|
||||
To view the "/about" page, pass that selector:
|
||||
|
||||
phd -r / /srv/gopher
|
||||
|
||||
Edge computing is now Gopher-scale! Enjoy!
|
||||
|
||||
## v0.1.9
|
||||
|
||||
Switch to using GitHub Actions for release automation.
|
@ -0,0 +1,206 @@
|
||||
.\" Generated by scdoc 1.11.0
|
||||
.\" Complete documentation for this program is not available as a GNU info page
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.nh
|
||||
.ad l
|
||||
.\" Begin generated content:
|
||||
.TH "PHD" "1" "2020-06-27"
|
||||
.P
|
||||
.SH NAME
|
||||
.P
|
||||
phd - an estoeric gopher server
|
||||
.P
|
||||
.SH SYNOPSIS
|
||||
.P
|
||||
\fBphd\fR [\fIOPTIONS\fR] [\fISITE ROOT\fR]
|
||||
.P
|
||||
.SH DESCRIPTION
|
||||
.P
|
||||
\fBphd\fR is a small, easy-to-use gopher server.
|
||||
.P
|
||||
Point it at a directory and it'll serve up all the text files,
|
||||
sub-directories, and binary files over Gopher. Any \fB.gph\fR files will
|
||||
be served up as Gophermaps and executable \fB.gph\fR files will be
|
||||
run as a program with their output served to the client, like the
|
||||
glorious cgi-bin days of yore!
|
||||
.P
|
||||
Usually \fBphd\fR is started with a path to your Gopher site:
|
||||
.P
|
||||
.RS 4
|
||||
phd /srv/gopher
|
||||
.P
|
||||
.RE
|
||||
If no path is given, \fBphd\fR will use the current directory as the root
|
||||
of your Gopher site.
|
||||
.P
|
||||
.SH OPTIONS
|
||||
.P
|
||||
\fB-r\fR \fISELECTOR\fR, \fB--render\fR \fISELECTOR\fR
|
||||
.P
|
||||
.RS 4
|
||||
Rather than start as a server, render the \fISELECTOR\fR of the site using the options provided and print the raw response to \fBSTDOUT\fR.
|
||||
.P
|
||||
.RE
|
||||
\fB-b\fR \fIADDRESS\fR, \fB--bind\fR \fIADDRESS\fR
|
||||
.RS 4
|
||||
Set the socket address to bind to, e.g. \fB127.0.0.1:7070\fR
|
||||
.P
|
||||
.RE
|
||||
\fB-p\fR \fIPORT\fR, \fB--port\fR \fIPORT\fR
|
||||
.RS 4
|
||||
Set the \fIPORT\fR to use when generating Gopher links.
|
||||
.P
|
||||
.RE
|
||||
\fB-h\fR \fIHOST\fR, \fB--host\fR \fIHOST\fR
|
||||
.RS 4
|
||||
Set the \fIHOST\fR to use when generating Gopher links.
|
||||
.P
|
||||
.RE
|
||||
\fB-h\fR, \fB--help\fR
|
||||
.RS 4
|
||||
Print a help summary and exit.
|
||||
.P
|
||||
.RE
|
||||
\fB-v\fR, \fB--version\fR
|
||||
.RS 4
|
||||
Print version information and exit.
|
||||
.P
|
||||
.RE
|
||||
.SH SPECIAL FILES
|
||||
.P
|
||||
The following files have special behavior when present in a directory
|
||||
that \fBphd\fR is tasked with serving:
|
||||
.P
|
||||
\fBheader.gph\fR
|
||||
.RS 4
|
||||
If it exists in a directory, its content will be shown above the directory's content. Put ASCII art in it.
|
||||
.P
|
||||
.RE
|
||||
\fBfooter.gph\fR
|
||||
.RS 4
|
||||
Same, but will be shown below a directory's content.
|
||||
.P
|
||||
.RE
|
||||
\fBindex.gph\fR
|
||||
.RS 4
|
||||
Completely replaces a directory's content with what's in this file.
|
||||
.P
|
||||
.RE
|
||||
\fB??.gph\fR
|
||||
.RS 4
|
||||
Visiting \fBgopher://yoursite/1/dog/\fR will try to render \fBdog.gph\fR from disk. Visiting \fB/1/dog.gph\fR will render the raw content of the .gph file.
|
||||
.P
|
||||
.RE
|
||||
\fB.reverse\fR
|
||||
.RS 4
|
||||
If this exists, the directory contents will be listed in reverse alphanumeric order. Useful for phloggin', if you date your posts.
|
||||
.P
|
||||
.RE
|
||||
.SH GOPHERMAP SYNTAX
|
||||
.P
|
||||
Any line in a \fB.gph\fR file that doesn't contain tabs (\fBt\fR) will get an
|
||||
\fBi\fR automatically prefixed, turning it into a Gopher information item.
|
||||
.P
|
||||
For your convenience, phd supports \fBgeomyidae\fR syntax for
|
||||
creating links:
|
||||
.P
|
||||
.nf
|
||||
.RS 4
|
||||
This is an info line\&.
|
||||
[1|This is a link|/help|server|port]
|
||||
[h|URL Link|URL:https://noogle\&.com]
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
\fBserver\fR and \fBport\fR will get translated into the server and port of
|
||||
the actively running server, eg \fBlocalhost\fR and \fB7070\fR.
|
||||
.P
|
||||
Any line containing a tab character (\fBt\fR) will be sent as-is to the
|
||||
client, meaning you can write and serve up raw Gophermap files too.
|
||||
.P
|
||||
.SH DYNAMIC CONTENT
|
||||
.P
|
||||
Any \fB.gph\fR file that is marked \fBexecutable\fR with be run as if it
|
||||
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.
|
||||
.P
|
||||
For example:
|
||||
.P
|
||||
.nf
|
||||
.RS 4
|
||||
$ cat echo\&.gph
|
||||
#!/bin/sh
|
||||
echo "Hi, world! You said:" $1
|
||||
echo "1Visit Gopherpedia / gopherpedia\&.com 70"
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
Then:
|
||||
.P
|
||||
.nf
|
||||
.RS 4
|
||||
$ gopher-client gopher://localhost/1/echo?something
|
||||
[INFO] Hi, world! You said: something
|
||||
[LINK] Visit Gopherpedia
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
Or more seriously:
|
||||
.P
|
||||
.nf
|
||||
.RS 4
|
||||
$ cat figlet\&.gph
|
||||
#!/bin/sh
|
||||
figlet $1
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
then:
|
||||
.P
|
||||
.nf
|
||||
.RS 4
|
||||
$ gopher-client gopher://localhost/1/figlet?hi gopher
|
||||
[INFO] _ _ _
|
||||
[INFO] | |__ (_) __ _ ___ _ __ | |__ ___ _ __
|
||||
[INFO] | '_ | | / _` |/ _ | '_ | '_ / _ '__|
|
||||
[INFO] | | | | | | (_| | (_) | |_) | | | | __/ |
|
||||
[INFO] |_| |_|_| __, |___/| \&.__/|_| |_|___|_|
|
||||
[INFO] |___/ |_|
|
||||
.fi
|
||||
.RE
|
||||
.P
|
||||
.SS RESOURCES
|
||||
.P
|
||||
geomyidae source code
|
||||
.RS 4
|
||||
gopher://bitreich.org/1/scm/geomyidae/files.gph
|
||||
.P
|
||||
.RE
|
||||
Example Gophermap
|
||||
.RS 4
|
||||
https://github.com/gophernicus/gophernicus/blob/master/README.Gophermap
|
||||
.P
|
||||
.RE
|
||||
Gophermaps
|
||||
.RS 4
|
||||
https://gopher.zone/posts/how-to-gophermap/
|
||||
.P
|
||||
.RE
|
||||
RFC 1436:
|
||||
.RS 4
|
||||
https://tools.ietf.org/html/rfc1436
|
||||
.P
|
||||
.RE
|
||||
.SH ABOUT
|
||||
.P
|
||||
\fBphd\fR is maintained by chris west and released under the MIT license.
|
||||
.P
|
||||
phd's Gopher hole:
|
||||
.RS 4
|
||||
\fIgopher://phkt.io/1/phd\fR
|
||||
.RE
|
||||
phd's webpage:
|
||||
.RS 4
|
||||
\fIhttps://github.com/xvxx/phd\fR
|
@ -0,0 +1,154 @@
|
||||
PHD(1)
|
||||
|
||||
# NAME
|
||||
|
||||
phd - an estoeric gopher server
|
||||
|
||||
# SYNOPSIS
|
||||
|
||||
*phd* [_OPTIONS_] [_SITE ROOT_]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
*phd* is a small, easy-to-use gopher server.
|
||||
|
||||
Point it at a directory and it'll serve up all the text files,
|
||||
sub-directories, and binary files over Gopher. Any *.gph* files will
|
||||
be served up as Gophermaps and executable *.gph* files will be
|
||||
run as a program with their output served to the client, like the
|
||||
glorious cgi-bin days of yore!
|
||||
|
||||
Usually *phd* is started with a path to your Gopher site:
|
||||
|
||||
phd /srv/gopher
|
||||
|
||||
If no path is given, *phd* will use the current directory as the root
|
||||
of your Gopher site.
|
||||
|
||||
# OPTIONS
|
||||
|
||||
*-r* _SELECTOR_, *--render* _SELECTOR_
|
||||
|
||||
Rather than start as a server, render the _SELECTOR_ of the site using the options provided and print the raw response to *STDOUT*.
|
||||
|
||||
*-b* _ADDRESS_, *--bind* _ADDRESS_
|
||||
Set the socket address to bind to, e.g. *127.0.0.1:7070*
|
||||
|
||||
*-p* _PORT_, *--port* _PORT_
|
||||
Set the _PORT_ to use when generating Gopher links.
|
||||
|
||||
*-h* _HOST_, *--host* _HOST_
|
||||
Set the _HOST_ to use when generating Gopher links.
|
||||
|
||||
*-h*, *--help*
|
||||
Print a help summary and exit.
|
||||
|
||||
*-v*, *--version*
|
||||
Print version information and exit.
|
||||
|
||||
# SPECIAL FILES
|
||||
|
||||
The following files have special behavior when present in a directory
|
||||
that *phd* is tasked with serving:
|
||||
|
||||
*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 in this file.
|
||||
|
||||
*??.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.
|
||||
|
||||
# GOPHERMAP SYNTAX
|
||||
|
||||
Any line in a *.gph* file that doesn't contain tabs (*\t*) will get an
|
||||
*i* automatically prefixed, turning it into a Gopher information item.
|
||||
|
||||
For your convenience, phd supports *geomyidae* syntax for
|
||||
creating links:
|
||||
|
||||
```
|
||||
This is an info line.
|
||||
[1|This is a link|/help|server|port]
|
||||
[h|URL Link|URL:https://noogle.com]
|
||||
```
|
||||
|
||||
*server* and *port* will get translated into the server and port of
|
||||
the actively running server, eg *localhost* and *7070*.
|
||||
|
||||
Any line containing a tab character (*\t*) will be sent as-is to the
|
||||
client, meaning you can write and serve up raw Gophermap files too.
|
||||
|
||||
# DYNAMIC CONTENT
|
||||
|
||||
Any *.gph* file that is marked *executable* with be run as if it
|
||||
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.
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
$ cat echo.gph
|
||||
#!/bin/sh
|
||||
echo "Hi, world! You said:" $1
|
||||
echo "1Visit Gopherpedia / gopherpedia.com 70"
|
||||
```
|
||||
|
||||
Then:
|
||||
|
||||
```
|
||||
$ gopher-client gopher://localhost/1/echo?something
|
||||
[INFO] Hi, world! You said: something
|
||||
[LINK] Visit Gopherpedia
|
||||
```
|
||||
|
||||
Or more seriously:
|
||||
|
||||
```
|
||||
$ cat figlet.gph
|
||||
#!/bin/sh
|
||||
figlet $1
|
||||
```
|
||||
|
||||
then:
|
||||
|
||||
```
|
||||
$ gopher-client gopher://localhost/1/figlet?hi gopher
|
||||
[INFO] _ _ _
|
||||
[INFO] | |__ (_) __ _ ___ _ __ | |__ ___ _ __
|
||||
[INFO] | '_ \| | / _` |/ _ \| '_ \| '_ \ / _ \ '__|
|
||||
[INFO] | | | | | | (_| | (_) | |_) | | | | __/ |
|
||||
[INFO] |_| |_|_| \__, |\___/| .__/|_| |_|\___|_|
|
||||
[INFO] |___/ |_|
|
||||
```
|
||||
|
||||
## RESOURCES
|
||||
|
||||
geomyidae source code
|
||||
gopher://bitreich.org/1/scm/geomyidae/files.gph
|
||||
|
||||
Example Gophermap
|
||||
https://github.com/gophernicus/gophernicus/blob/master/README.Gophermap
|
||||
|
||||
Gophermaps
|
||||
https://gopher.zone/posts/how-to-gophermap/
|
||||
|
||||
RFC 1436:
|
||||
https://tools.ietf.org/html/rfc1436
|
||||
|
||||
# ABOUT
|
||||
|
||||
*phd* is maintained by chris west and released under the MIT license.
|
||||
|
||||
phd's Gopher hole:
|
||||
_gopher://phkt.io/1/phd_
|
||||
phd's webpage:
|
||||
_https://github.com/xvxx/phd_
|
@ -0,0 +1,10 @@
|
||||
|
||||
/ |
|
||||
___ (___ ___|
|
||||
| )| )| )
|
||||
|__/ | / |__/
|
||||
|
|
||||
|
||||
~ browse source ~
|
||||
(updated nightly)
|
||||
|
@ -0,0 +1,127 @@
|
||||
//! Gopher type "borrowed" from phetch.
|
||||
use std::fmt;
|
||||
|
||||
/// Gopher types are defined according to RFC 1436.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum Type {
|
||||
Text, // 0
|
||||
Menu, // 1
|
||||
CSOEntity, // 2
|
||||
Error, // 3
|
||||
Binhex, // 4
|
||||
DOSFile, // 5
|
||||
UUEncoded, // 6
|
||||
Search, // 7
|
||||
Telnet, // 8
|
||||
Binary, // 9
|
||||
Mirror, // +
|
||||
GIF, // g
|
||||
Telnet3270, // T
|
||||
HTML, // h
|
||||
Image, // I
|
||||
PNG, // p
|
||||
Info, // i
|
||||
Sound, // s
|
||||
Document, // d
|
||||
}
|
||||
|
||||
impl Type {
|
||||
/// Is this an info line?
|
||||
pub fn is_info(self) -> bool {
|
||||
self == Type::Info
|
||||
}
|
||||
|
||||
/// Text document?
|
||||
pub fn is_text(self) -> bool {
|
||||
self == Type::Text
|
||||
}
|
||||
|
||||
/// HTML link?
|
||||
pub fn is_html(self) -> bool {
|
||||
self == Type::HTML
|
||||
}
|
||||
|
||||
/// Telnet link?
|
||||
pub fn is_telnet(self) -> bool {
|
||||
self == Type::Telnet
|
||||
}
|
||||
|
||||
/// Is this a link, ie something we can navigate to or open?
|
||||
pub fn is_link(self) -> bool {
|
||||
!self.is_info()
|
||||
}
|
||||
|
||||
/// Is this something we can download?
|
||||
pub fn is_download(self) -> bool {
|
||||
match self {
|
||||
Type::Binhex
|
||||
| Type::DOSFile
|
||||
| Type::UUEncoded
|
||||
| Type::Binary
|
||||
| Type::GIF
|
||||
| Type::Image
|
||||
| Type::PNG
|
||||
| Type::Sound
|
||||
| Type::Document => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Gopher Item Type to RFC char.
|
||||
pub fn to_char(self) -> char {
|
||||
match self {
|
||||
Type::Text => '0',
|
||||
Type::Menu => '1',
|
||||
Type::CSOEntity => '2',
|
||||
Type::Error => '3',
|
||||
Type::Binhex => '4',
|
||||
Type::DOSFile => '5',
|
||||
Type::UUEncoded => '6',
|
||||
Type::Search => '7',
|
||||
Type::Telnet => '8',
|
||||
Type::Binary => '9',
|
||||
Type::Mirror => '+',
|
||||
Type::GIF => 'g',
|
||||
Type::Telnet3270 => 'T',
|
||||
Type::HTML => 'h',
|
||||
Type::Image => 'I',
|
||||
Type::PNG => 'p',
|
||||
Type::Info => 'i',
|
||||
Type::Sound => 's',
|
||||
Type::Document => 'd',
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a Gopher Item Type from its RFC char code.
|
||||
pub fn from(c: char) -> Option<Type> {
|
||||
Some(match c {
|
||||
'0' => Type::Text,
|
||||
'1' => Type::Menu,
|
||||
'2' => Type::CSOEntity,
|
||||
'3' => Type::Error,
|
||||
'4' => Type::Binhex,
|
||||
'5' => Type::DOSFile,
|
||||
'6' => Type::UUEncoded,
|
||||
'7' => Type::Search,
|
||||
'8' => Type::Telnet,
|
||||
'9' => Type::Binary,
|
||||
'+' => Type::Mirror,
|
||||
'g' => Type::GIF,
|
||||
'T' => Type::Telnet3270,
|
||||
'h' => Type::HTML,
|
||||
'I' => Type::Image,
|
||||
'p' => Type::PNG,
|
||||
'i' => Type::Info,
|
||||
's' => Type::Sound,
|
||||
'd' => Type::Document,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Type {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "{}", self.to_char())
|
||||
}
|
||||
}
|
@ -1,7 +1,21 @@
|
||||
//! phd is a small, easy-to-use Gopher server that tries to make
|
||||
//! serving up a Gopher site quick and painless. Best used for local
|
||||
//! development or low traffic Gopher sites.
|
||||
|
||||
#![allow(unused_must_use)]
|
||||
#![warn(absolute_paths_not_starting_with_crate)]
|
||||
#![warn(explicit_outlives_requirements)]
|
||||
#![warn(unreachable_pub)]
|
||||
#![warn(deprecated_in_future)]
|
||||
#![warn(missing_docs)]
|
||||
#![allow(clippy::while_let_on_iterator)]
|
||||
|
||||
pub mod color;
|
||||
pub mod gopher;
|
||||
pub mod request;
|
||||
pub mod server;
|
||||
|
||||
pub use crate::request::Request;
|
||||
|
||||
/// Alias for a generic Result type.
|
||||
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;
|
||||
|
Loading…
Reference in New Issue