From c1fe67693803bae1d78abe6b1fdeeafb5a22b105 Mon Sep 17 00:00:00 2001 From: Jacob Parker Date: Wed, 7 Mar 2012 03:13:30 -0500 Subject: [PATCH] fixed up some things due to the move to templating etc., made some changes to make it easier for people to start using this. --- .gitignore | 5 +- htaccess-sample => .htaccess | 2 +- README.md | 53 --------------- src/config.d | 25 +++++++ src/config.d.sample | 23 ------- src/web.d | 3 +- srv/@changelog | 0 .../index.md => Constitution.md} | 0 srv/About/Executive.md | 1 + srv/About/Members/index.md | 2 +- srv/index.md | 1 + templates/default.html | 66 +++++++++---------- 12 files changed, 65 insertions(+), 116 deletions(-) rename htaccess-sample => .htaccess (75%) delete mode 100644 README.md create mode 100644 src/config.d delete mode 100644 src/config.d.sample delete mode 100644 srv/@changelog rename srv/About/{Constitution/index.md => Constitution.md} (100%) create mode 100644 srv/About/Executive.md create mode 100644 srv/index.md diff --git a/.gitignore b/.gitignore index d1c41a2..1d56547 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ -srv/* -bin/web .nfs* -.htaccess -src/config.d +bin/web diff --git a/htaccess-sample b/.htaccess similarity index 75% rename from htaccess-sample rename to .htaccess index 23c9137..7b23492 100644 --- a/htaccess-sample +++ b/.htaccess @@ -1,4 +1,4 @@ RewriteEngine on -RewriteBase / +RewriteBase /~j3parker/ RewriteRule ^pub/(.*) - [L] RewriteRule ^(.*) bin/web [L] diff --git a/README.md b/README.md deleted file mode 100644 index bd0dab3..0000000 --- a/README.md +++ /dev/null @@ -1,53 +0,0 @@ -dweb - A simple website written in D -===== -dweb is a simple website framework based off the [werc][werc] software. - -Its principles are: - -- Database free, uses files and directories instead. -- Written using the D programming language. -- Minimize tedious work: eg., no need to ever write HTML, use markdown instead. -- Very minimalist yet extensible codebase. Handlers for special things should be easy to add. - -It was created because werc was annoying to deploy on UW Computer Science Club's Apache setup and because [Not Invented Here](http://en.wikipedia.org/wiki/Not_Invented_Here). - -[werc]:http://werc.cat-v.org/ -[md]:http://daringfireball.net/projects/markdown - -Install Guide ------- -You will need: -- An HTTP server with CGI support. -- The D compiler. - -Extract the contents into the location you want to serve webpages from. Create $DWEB\_ROOT/.htaccess and $DWEB\_ROOT/src/config.d by copying the provided sample files. Then edit the following files: - -- $DWEB_ROOT/.htaccess: make the paths work for your setup. -- $DWEB_ROOT/src/config.d: change these strings as necessary. -- $DWEB_ROOT/src/web.d: this is the main web code. -- $DWEB_ROOT/pub/: static content goes here. -- $DWEB_ROOT/srv/: directories, markdown webpages etc. go in here. -- $DWEB_ROOT/bin/: custom handlers go here. - -Run build in $DWEB_ROOT/src to recompile the website software. - -Source --------- - -You can get the source code on [github](https://github.com/j3parker/dweb) or by running - - git clone git://github.com/j3parker/dweb.git - -Contact --------- -For questions, suggestions, bug reports and contributing patches email [j3parker](mailto:j3parker@csclub.uwaterloo.ca) - -License -------- -Public domain. - -Credits -------- -The idea and css stolen from [werc][werc]. This page itself also plagarised. - -Thanks to John Gruber for the [Markdown.pl][md] script. diff --git a/src/config.d b/src/config.d new file mode 100644 index 0000000..94aa9df --- /dev/null +++ b/src/config.d @@ -0,0 +1,25 @@ +import std.regex; + +const string url_root = "/~j3parker/"; +const string site_title = "CSC"; +const string site_subtitle = "UWaterloo Computer Science Club"; + +const bool nav_tree_vert = false; + +string[StaticRegex!char] handlers; + +void init_handlers() { + handler!("(.*).md").add("contrib/Markdown.pl"); + handler!("^changelog$").add("changelog.sh"); + handler!("^About/Members/$").add("members.py"); + handler!("^About/Members/(.+)$").add("member_info.py"); + handler!("^About/Executive$").add("exec_positions.py"); +} + +template handler(string pattern) { + void add(string h) { + try { + handlers[ctRegex!(pattern)] = h; + } catch (std.regex.Exception re) { return; } + } +} diff --git a/src/config.d.sample b/src/config.d.sample deleted file mode 100644 index d4eba96..0000000 --- a/src/config.d.sample +++ /dev/null @@ -1,23 +0,0 @@ -import std.regex; - -const string url_root = "/"; - -const string site_title = "This is a Title"; -const string site_subtitle = "but this is a subtitle"; - -const bool nav_tree_vert = false; - -string[StaticRegex!char] handlers; - -void init_handlers() { - handler!("(.*).md").add("contrib/Markdown.pl"); - handler!("changelog").add("changelog.sh"); -} - -template handler(string pattern) { - void add(string h) { - try { - handlers[ctRegex!(pattern)] = h; - } catch (std.regex.Exception re) { return; } - } -} diff --git a/src/web.d b/src/web.d index 499cf6f..d185035 100755 --- a/src/web.d +++ b/src/web.d @@ -8,10 +8,11 @@ string[string] headers; string write_link(string to, bool expand) { bool isdir = dirExists(dweb_root ~ "/srv/" ~ to[url_root.length..$]); + string result = ""; result ~= ""; result ~= "" - ~ baseName(to) ~ (isdir ? "/" : "") ~ ""; + ~ baseName(to) ~ /* (isdir ? "/" : "") ~ */ ""; result ~= ""; return result; } diff --git a/srv/@changelog b/srv/@changelog deleted file mode 100644 index e69de29..0000000 diff --git a/srv/About/Constitution/index.md b/srv/About/Constitution.md similarity index 100% rename from srv/About/Constitution/index.md rename to srv/About/Constitution.md diff --git a/srv/About/Executive.md b/srv/About/Executive.md new file mode 100644 index 0000000..fefc330 --- /dev/null +++ b/srv/About/Executive.md @@ -0,0 +1 @@ +If you can read this, you broke the handlers bro! diff --git a/srv/About/Members/index.md b/srv/About/Members/index.md index 9daeafb..fefc330 100644 --- a/srv/About/Members/index.md +++ b/srv/About/Members/index.md @@ -1 +1 @@ -test +If you can read this, you broke the handlers bro! diff --git a/srv/index.md b/srv/index.md new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/srv/index.md @@ -0,0 +1 @@ +test diff --git a/templates/default.html b/templates/default.html index fafb96a..6e16877 100644 --- a/templates/default.html +++ b/templates/default.html @@ -7,42 +7,42 @@ -