From 25e74556c06910fda116051c3392b5ad7227d6b8 Mon Sep 17 00:00:00 2001 From: Dave Winer Date: Tue, 2 Aug 2016 11:12:29 -0400 Subject: [PATCH] v0.71 --- README.md | 176 ++++++++++++++++++++++++++++++++++++++++++++++++- docs/config.md | 164 +-------------------------------------------- 2 files changed, 176 insertions(+), 164 deletions(-) diff --git a/README.md b/README.md index a2134a1..c5b743c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #### PagePark -I wrote this simple HTTP server to park domains I've bought but not yet used. +I wrote this simple HTTP server to park domains I've bought but not yet used. But I kept going and added all the features I want to help me manage my own websites, far beyond just parking them. But I liked the name so I kept it. Think of it as a nice park where you keep your pages. ;-) It's written in JavaScript and runs in Node.js. @@ -44,6 +44,168 @@ Here's a 9. There are three special endpoints on all domains: /version, /now and /status that return the version of PagePark that's running, the time on the server and the stats and prefs. +#### File extensions + +The extension of a file determines how PagePark serves it. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +.txt + + + +The text in the file is returned, the type is text/plain. + + + +applejoke.txt + +
+ +.xml + + + +The text in the file is returned, the type is text/xml. + + + +davetwitterfeed.xml + +
+ +.json + + + +The text in the file is returned, the type is application/json. + + + +wodemo.json + +
+ +.png + + + +The contents of the file is returned with type image/png. + + + +tree.png + +
+ +.opml + + + +The outline is rendered as an expandable outline, the type returned is text/html. + + + +states.opml + +
+ +.md + + + +The text in the file is passed through a Markdown processor and that text is returned. The type returned is text/html. + + + +test.md + +
+ +.js + + + +We run the script, and the return value is returned to the caller, with type of text/html. Here's the source code for the script in the demo below. + + + +butt.js + +
+ #### Port 1339 The first time you run PagePark it will open on port 1339. You can change this by editing prefs.json in the prefs folder. @@ -58,6 +220,12 @@ sudo node pagepark.js I made the default 1339 because I wanted it to work "out of the box" for first-time users. +#### Mapping port 80 to 1339 + +Here's a magic incantation that works on Ubuntu that maps requests for port 80 to port 1339. + +
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 1339
+ #### Example pages http://noderunner.org/ -- simple home page @@ -78,6 +246,12 @@ http://pagepark.io/version -- the version of PagePark that's running on the serv http://pagepark.io/now -- the time on the server +#### config.json files in domains folders + +On every request, PagePark looks at the top level of the domain folder for a file named config.json. If it finds it, it reads it and the values in the file control how the request is handled. + +Here's a
docs page that lists the values and what they control. + #### JavaScript sample code I've iterated over the code to try to make it good sample code for JavaScript projects. diff --git a/docs/config.md b/docs/config.md index d4215da..ced5e2f 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,6 +1,6 @@ ### Programming your website -Websites evolve over time, and PagePark has features that help you adjust things so links keep working after the change. Some of the features described on this page are here to help you prevent linkrot! That's how prevalent it is. +Websites evolve over time, and PagePark has features that help you adjust things so links keep working after the change. Some of the features described on this page are here to help you keep your links working. Another thing you'll want to do is pass the content through various processors. The file extensions control that. So if a file name ends with .md, it is passed through the Markdown processor. If it's .js, it's assumed to contain JavaScript code, and that code is run, and the value it returns is what we return. You can also control whether or not the scripts run. @@ -8,168 +8,6 @@ Another thing you'll want to do is pass the content through various processors. All the values described here are added to a config.json file that's stored at the top level of a domain folder. Any time a request comes in for that domain, we read the config.json file in its folder, if there is one, and the values are applied to the request. -#### File extensions - -The extension of a file determines how PagePark serves it. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -.txt - - - -The text in the file is returned, the type is text/plain. - - - -applejoke.txt - -
- -.xml - - - -The text in the file is returned, the type is text/xml. - - - -davetwitterfeed.xml - -
- -.json - - - -The text in the file is returned, the type is application/json. - - - -wodemo.json - -
- -.png - - - -The contents of the file is returned with type image/png. - - - -tree.png - -
- -.opml - - - -The outline is rendered as an expandable outline, the type returned is text/html. - - - -states.opml - -
- -.md - - - -The text in the file is passed through a Markdown processor and that text is returned. The type returned is text/html. - - - -test.md - -
- -.js - - - -We run the script, and the return value is returned to the caller, with type of text/html. Here's the source code for the script in the demo below. - - - -butt.js - -
- #### flProcessScriptFiles If you set this value false, none of the JavaScript files in the domain folder will be processed. They will be served as text, with the source code in the file.