commit
d790af3051
|
@ -1,4 +0,0 @@
|
||||||
RewriteEngine on
|
|
||||||
RewriteBase /~j3parker/
|
|
||||||
RewriteRule ^pub/(.*) - [L]
|
|
||||||
RewriteRule ^(.*) bin/web [L]
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import std.regex;
|
||||||
|
|
||||||
const string url_root = "/";
|
const string url_root = "/";
|
||||||
|
|
||||||
const string site_title = "This is a Title";
|
const string site_title = "This is a Title";
|
||||||
|
@ -5,9 +7,17 @@ const string site_subtitle = "but this is a subtitle";
|
||||||
|
|
||||||
const bool nav_tree_vert = false;
|
const bool nav_tree_vert = false;
|
||||||
|
|
||||||
string[string] handlers;
|
string[StaticRegex!char] handlers;
|
||||||
|
|
||||||
void init_handlers() {
|
void init_handlers() {
|
||||||
handlers["*.md"] = "contrib/Markdown.pl";
|
handler!("(.*).md").add("contrib/Markdown.pl");
|
||||||
handlers["changelog"] = "changelog.sh";
|
handler!("changelog").add("changelog.sh");
|
||||||
|
}
|
||||||
|
|
||||||
|
template handler(string pattern) {
|
||||||
|
void add(string h) {
|
||||||
|
try {
|
||||||
|
handlers[ctRegex!(pattern)] = h;
|
||||||
|
} catch (std.regex.Exception re) { return; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
10
src/web.d
10
src/web.d
|
@ -1,5 +1,5 @@
|
||||||
//#!/usr/bin/rdmd
|
//#!/usr/bin/rdmd
|
||||||
import std.stdio, std.path, std.process, std.file, std.array, std.string, std.algorithm, std.datetime, std.ascii;
|
import std.stdio, std.path, std.process, std.file, std.array, std.string, std.algorithm, std.datetime, std.ascii, std.regex;
|
||||||
import config;
|
import config;
|
||||||
|
|
||||||
string dweb_root;
|
string dweb_root;
|
||||||
|
@ -92,8 +92,8 @@ bool dirExists(string path) { try { if (isDir(path)) return true; else return
|
||||||
void do_content(string url) {
|
void do_content(string url) {
|
||||||
html_push("<div id=\"main-copy\"" ~ (nav_tree_vert? " class=\"main-copy-side-bar\"" : "") ~ ">");
|
html_push("<div id=\"main-copy\"" ~ (nav_tree_vert? " class=\"main-copy-side-bar\"" : "") ~ ">");
|
||||||
// first, see if we have something that wants to handle url outright
|
// first, see if we have something that wants to handle url outright
|
||||||
foreach (string glob, string h; handlers) {
|
foreach (StaticRegex!char reg, string h; handlers) {
|
||||||
if (globMatch(url, glob)) {
|
if (match(url, reg)) {
|
||||||
html(shell(dweb_root ~ "/bin/" ~ h ~ " " ~ url));
|
html(shell(dweb_root ~ "/bin/" ~ h ~ " " ~ url));
|
||||||
html_pop("</div>");
|
html_pop("</div>");
|
||||||
return;
|
return;
|
||||||
|
@ -105,8 +105,8 @@ void do_content(string url) {
|
||||||
if (isDir(f)) continue;
|
if (isDir(f)) continue;
|
||||||
string name = baseName(f); name = name[0] == '@' ? name[1..$] : name;
|
string name = baseName(f); name = name[0] == '@' ? name[1..$] : name;
|
||||||
if (stripExtension(name) == baseName(url)) {
|
if (stripExtension(name) == baseName(url)) {
|
||||||
foreach (string glob, string h; handlers) {
|
foreach (StaticRegex!char reg, string h; handlers) {
|
||||||
if (globMatch(name, glob)) {
|
if (match(name, reg)) {
|
||||||
html(shell(dweb_root ~ "/bin/" ~ h ~ " " ~ f));
|
html(shell(dweb_root ~ "/bin/" ~ h ~ " " ~ f));
|
||||||
html_pop("</div>");
|
html_pop("</div>");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue