fixed up some things due to the move to templating etc., made some changes to make it easier for people to start using this.
This commit is contained in:
parent
8998486e2b
commit
c1fe676938
|
@ -1,5 +1,2 @@
|
|||
srv/*
|
||||
bin/web
|
||||
.nfs*
|
||||
.htaccess
|
||||
src/config.d
|
||||
bin/web
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
RewriteEngine on
|
||||
RewriteBase /
|
||||
RewriteBase /~j3parker/
|
||||
RewriteRule ^pub/(.*) - [L]
|
||||
RewriteRule ^(.*) bin/web [L]
|
53
README.md
53
README.md
|
@ -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 <code>$DWEB\_ROOT/.htaccess</code> and <code>$DWEB\_ROOT/src/config.d</code> by copying the provided sample files. Then edit the following files:
|
||||
|
||||
- <code>$DWEB_ROOT/.htaccess</code>: make the paths work for your setup.
|
||||
- <code>$DWEB_ROOT/src/config.d</code>: change these strings as necessary.
|
||||
- <code>$DWEB_ROOT/src/web.d</code>: this is the main web code.
|
||||
- <code>$DWEB_ROOT/pub/</code>: static content goes here.
|
||||
- <code>$DWEB_ROOT/srv/</code>: directories, markdown webpages etc. go in here.
|
||||
- <code>$DWEB_ROOT/bin/</code>: custom handlers go here.
|
||||
|
||||
Run <code>build</code> in <code>$DWEB_ROOT/src</code> 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.
|
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -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; }
|
||||
}
|
||||
}
|
|
@ -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 ~= "<li" ~ (expand? " class=\"thisPage\" " : "") ~ ">";
|
||||
result ~= "<a href=\"" ~ to ~ (isdir ? "/" : "") ~ "\">"
|
||||
~ baseName(to) ~ (isdir ? "/" : "") ~ "</a>";
|
||||
~ baseName(to) ~ /* (isdir ? "/" : "") ~ */ "</a>";
|
||||
result ~= "</li>";
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
If you can read this, you broke the handlers bro!
|
|
@ -1 +1 @@
|
|||
test
|
||||
If you can read this, you broke the handlers bro!
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
test
|
|
@ -7,42 +7,42 @@
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<div class="superHeader">
|
||||
<div id="container">
|
||||
<div id="header">
|
||||
<div class="superHeader">
|
||||
<div class="left">
|
||||
<a href=\"http://wiki.csclub.uwaterloo.ca/\">wiki</a>
|
||||
<a href=\"http://git.csclub.uwaterloo.ca/\">git</a>
|
||||
<a href=\"http://mirror.csclub.uwaterloo.ca/\">mirror</a>
|
||||
<a href=\"http://csclub.uwaterloo.ca/stats\">stats</a>
|
||||
<a href=\"http://mail.csclub.uwaterloo.ca/\">webmail</a>
|
||||
<a href=\"http://csclub.uwaterloo.ca/newsgroup/\">newsgroups</a>
|
||||
<a href=\"http://csclub.uwaterloo.ca/mailman/\">mailman</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a href="{{ url_root }}changelog">changelog</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="midHeader">
|
||||
<h1 class="headerTitle">
|
||||
<a href="{{ url_root }}"><img src="{{ url_root }}/pub/style/logo.png" id="logo">
|
||||
<span id="headerSubTitle">{{ site_subtitle }}</span></a>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div id="horiz-side-bar">
|
||||
{{ nav_tree }}
|
||||
</div>
|
||||
<div id="main-copy">
|
||||
{{ content }}
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="left">
|
||||
<a href=\"http://wiki.csclub.uwaterloo.ca/\">wiki</a>
|
||||
<a href=\"http://git.csclub.uwaterloo.ca/\">git</a>
|
||||
<a href=\"http://mirror.csclub.uwaterloo.ca/\">mirror</a>
|
||||
<a href=\"http://csclub.uwaterloo.ca/stats\">stats</a>
|
||||
<a href=\"http://mail.csclub.uwaterloo.ca/\">webmail</a>
|
||||
<a href=\"http://csclub.uwaterloo.ca/newsgroup/\">newsgroups</a>
|
||||
<a href=\"http://csclub.uwaterloo.ca/mailman/\">mailman</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a href="{{ url_root }}changelog">changelog</a>
|
||||
<a href="{{ url_root }}dweb">Powered by dweb</a>
|
||||
</div>
|
||||
<div class="right"> </div>
|
||||
</div>
|
||||
<div class="midHeader">
|
||||
<h1 class="headerTitle">
|
||||
<a href="{{ url_root }}">{{ site_title }}</a>
|
||||
<span id="headerSubTitle">{{ site_subtitle }}</a>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="horiz-side-bar">
|
||||
{{ nav_tree }}
|
||||
</div>
|
||||
|
||||
<div id="main-copy">
|
||||
{{ content }}
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<div class="left">
|
||||
<a href="{{ url_root }}dweb">Powered by dweb</a>
|
||||
</div>
|
||||
<div class="right"> </div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue