Conflicts:
	.htaccess
master
Jenny Wong 11 years ago
commit 58b10d477e
  1. 2
      .gitignore
  2. 4
      .htaccess
  3. 53
      README.md
  4. 4
      htaccess-sample
  5. 14
      pub/style/style.css
  6. 1
      src/build
  7. 15
      src/config.d
  8. 4
      src/web.d
  9. 16
      srv/@dweb.md

2
.gitignore vendored

@ -1,2 +1,4 @@
srv/*
bin/web
.htaccess
src/config.d

@ -1,4 +1,4 @@
RewriteEngine on
RewriteBase /~jy2wong/rofl/dweb/
RewriteBase /~jy2wong/rofl/csc/
RewriteRule ^pub/(.*) - [L]
RewriteRule ^(.*) /users/jy2wong/www/rofl/dweb/bin/web [L]
RewriteRule ^(.*) bin/web [L]

@ -0,0 +1,53 @@
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,4 @@
RewriteEngine on
RewriteBase /
RewriteRule ^pub/(.*) - [L]
RewriteRule ^(.*) bin/web [L]

@ -6,6 +6,8 @@ accent colour:
#E2AA00
dark blue:
#2724AE
alternate dark blue:
#4A47AE
*/
body {
@ -63,7 +65,7 @@ a:hover { text-decoration: underline; }
.midHeader {
color: #fff;
background-color: #2724AE;
background-color: #4A47AE;
border-bottom: solid 2px #E2AA00;
}
@ -192,7 +194,7 @@ padding: 0;}
#horiz-side-bar ul:first-child li a:hover {
/*
background-color: #2724AE;
background-color: #4A47AE;
*/
background-color: #eee;
@ -217,9 +219,9 @@ padding: 0;}
#horiz-side-bar ul:first-child li.thisPage a {
/*
color: #fff;
background-color: #2724AE;
background-color: #4A47AE;
*/
border-left: 0.5em solid #2724AE;
border-left: 0.5em solid #4A47AE;
background-color: #eee;
}
@ -334,7 +336,7 @@ li ul {
}
#main-copy a {
color: #2724AE;
color: #4A47AE;
color: #E2AA00;
color: rgb(100,135,220);
text-decoration: underline;
@ -410,7 +412,7 @@ dd {
/* # Footer # */
#footer {
color: white;
background-color: #2724AE;
background-color: #4A47AE;
padding: 0.25ex;
clear: both;
border-top: solid 2px #E2AA00;

@ -1 +1,2 @@
cd "$(dirname $0)"
dmd config.d web.d -ofweb && rm web.o && mv web ../bin/

@ -1,15 +0,0 @@
const string url_root = "/~j3parker/";
const string site_title = "This is a Title";
const string site_subtitle = "but this is a subtitle";
const bool nav_tree_vert = false;
const bool nav_tree_chev = false;
const bool page_container = true;
string[string] handlers;
void init_handlers() {
handlers["*.md"] = "contrib/Markdown.pl";
handlers["changelog"] = "changelog.sh";
}

@ -101,7 +101,7 @@ void do_content(string url) {
}
}
// if that failed, see if we can handle the file
if (url == "" ? false : url[$-1] == '/') url ~= "index";
if (url == "" ? true : url[$-1] == '/') url ~= "index";
foreach (f; array(map!"a.name"(dirEntries(dirName(dweb_root ~ "/srv/" ~ url), SpanMode.shallow)))) {
if (isDir(f)) continue;
string name = baseName(f); name = name[0] == '@' ? name[1..$] : name;
@ -146,7 +146,7 @@ void main(string[] args) {
html("<!DOCTYPE html>");
html_push("<html>\n");
string url = getenv("SCRIPT_URL")[url_root.length..$];
string url = getenv("REQUEST_URI")[url_root.length..$];
if (evil(url)) { html ("bad url."); return; }
string pagename = baseName(url);

@ -1,6 +1,6 @@
dweb - A simple website written in D
=====
dweb is a simple website framework based off the [werc][werc] software.
dweb is a simple website framework inspired by the [werc][werc] software.
Its principles are:
@ -22,14 +22,14 @@ You will need:
Extract the contents into the location you want to serve webpages from. 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.
- `$DWEB_ROOT/.htaccess`: make the rewrite path work for your setup.
- `$DWEB_ROOT/src/config.d`: change these things as desired. Custom handlers are added in init_handlers. The key is the glob to activate the handler, and the value is the `bin/` relative path of the handler.
- `$DWEB_ROOT/src/web.d`: this is the core 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 <code>build</code> in <code>$DWEB_ROOT/src</code> to recompile the website software.
Run `./build` in `$DWEB_ROOT/src` to recompile the website software.
Source
--------

Loading…
Cancel
Save