sw

changeset 0:ef7717416cdc

* Initial import
author nibble
date Sun, 04 Apr 2010 03:18:14 +0200
parents
children c5918f590700
files md2html.awk style.css sw
diffstat 3 files changed, 714 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/md2html.awk	Sun Apr 04 03:18:14 2010 +0200
     1.3 @@ -0,0 +1,427 @@
     1.4 +#!/usr/bin/awk -f
     1.5 +#
     1.6 +# by: Jesus Galan (yiyus) 2009
     1.7 +#
     1.8 +# Usage: md2html.awk file.md > file.html
     1.9 +# See: http://4l77.com/src/md2html.awk
    1.10 +
    1.11 +function eschtml(t) {
    1.12 +	gsub("&", "\\&", t);
    1.13 +	gsub("<", "\\&lt;", t);
    1.14 +	return t;
    1.15 +}
    1.16 +
    1.17 +function oprint(t){
    1.18 +	if(nr == 0)
    1.19 +		print t;
    1.20 +	else
    1.21 +		otext = otext "\n" t;
    1.22 +}
    1.23 +
    1.24 +function subref(id){
    1.25 +	for(; nr > 0 && sub("<<" id, ref[id], otext); nr--);
    1.26 +	if(nr == 0 && otext) {
    1.27 +		print otext;
    1.28 +		otext = "";
    1.29 +	}
    1.30 +}
    1.31 +
    1.32 +function nextil(t) {
    1.33 +	if(!match(t, /[`<&\[*_\\-]|(\!\[)/))
    1.34 +		return t;
    1.35 +	t1 = substr(t, 1, RSTART - 1);
    1.36 +	tag = substr(t, RSTART, RLENGTH);
    1.37 +	t2 = substr(t, RSTART + RLENGTH);
    1.38 +	if(ilcode && tag != "`")
    1.39 +		return eschtml(t1 tag) nextil(t2);
    1.40 +	# Backslash escaping
    1.41 +	if(tag == "\\"){
    1.42 +		if(match(t2, /^[\\`*_{}\[\]()#+\-\.!]/)){
    1.43 +			tag = substr(t2, 1, 1);
    1.44 +			t2 = substr(t2, 2);
    1.45 +		}
    1.46 +		return t1 tag nextil(t2);
    1.47 +	}
    1.48 +	# Dashes
    1.49 +	if(tag == "-"){
    1.50 +		if(sub(/^-/, "", t2))
    1.51 +			tag = "&#8212;";
    1.52 +		return t1 tag nextil(t2);
    1.53 +	}
    1.54 +	# Inline Code
    1.55 +	if(tag == "`"){
    1.56 +		if(sub(/^`/, "", t2)){
    1.57 +			if(!match(t2, /``/))
    1.58 +				return t1 "&#8221;" nextil(t2);
    1.59 +			ilcode2 = !ilcode2;
    1.60 +		}
    1.61 +		else if(ilcode2)
    1.62 +			return t1 tag nextil(t2);
    1.63 +		tag = "<code>";
    1.64 +		if(ilcode){
    1.65 +			t1 = eschtml(t1);
    1.66 +			tag = "</code>";
    1.67 +		}
    1.68 +		ilcode = !ilcode;
    1.69 +		return t1 tag nextil(t2);
    1.70 +	}
    1.71 +	if(tag == "<"){
    1.72 +	# Autolinks
    1.73 +		if(match(t2, /^[^ 	]+[\.@][^ 	]+>/)){
    1.74 +			url = eschtml(substr(t2, 1, RLENGTH - 1));
    1.75 +			t2 = substr(t2, RLENGTH + 1);
    1.76 +			linktext = url;
    1.77 +			if(match(url, /@/) && !match(url, /^mailto:/))
    1.78 +				url = "mailto:" url;
    1.79 +			return t1 "<a href=\"" url "\">" linktext "</a>" nextil(t2);
    1.80 +		}
    1.81 +	# Html tags
    1.82 +		if(match(t2, /^[A-Za-z\/!][^>]*>/)){
    1.83 +			tag = tag substr(t2, RSTART, RLENGTH);
    1.84 +			t2 = substr(t2, RLENGTH + 1);
    1.85 +			return t1 tag nextil(t2);
    1.86 +		}
    1.87 +		return t1 "&lt;" nextil(t2);
    1.88 +	}
    1.89 +	# Html special entities
    1.90 +	if(tag == "&"){
    1.91 +		if(match(t2, /^#?[A-Za-z0-9]+;/)){
    1.92 +			tag = tag substr(t2, RSTART, RLENGTH);
    1.93 +			t2 = substr(t2, RLENGTH + 1);
    1.94 +			return t1 tag nextil(t2);
    1.95 +		}
    1.96 +		return t1 "&amp;" nextil(t2);
    1.97 +	}
    1.98 +	# Images
    1.99 +	if(tag == "!["){
   1.100 +		if(!match(t2, /(\[.*\])|(\(.*\))/))
   1.101 +			return t1 tag nextil(t2);
   1.102 +		match(t2, /^[^\]]*/);
   1.103 +		alt = substr(t2, 1, RLENGTH);
   1.104 +		t2 = substr(t2, RLENGTH + 2);
   1.105 +		if(match(t2, /^\(/)){
   1.106 +			# Inline
   1.107 +			sub(/^\(/, "", t2);
   1.108 +			match(t2, /^[^\)]+/);
   1.109 +			url = eschtml(substr(t2, 1, RLENGTH));
   1.110 +			t2 = substr(t2, RLENGTH + 2);
   1.111 +			title = "";
   1.112 +			if(match(url, /[ 	]+\".*\"[ 	]*$/)) {
   1.113 +				title = substr(url, RSTART, RLENGTH);
   1.114 +				url = substr(url, 1, RSTART - 1);
   1.115 +				match(title, /\".*\"/);
   1.116 +				title = " title=\"" substr(title, RSTART + 1, RLENGTH - 2) "\"";
   1.117 +			}
   1.118 +			if(match(url, /^<.*>$/))
   1.119 +				url = substr(url, 2, RLENGTH - 2);
   1.120 +			return t1 "<img src=\"" url "\" alt=\"" alt "\"" title " />" nextil(t2);
   1.121 +		}
   1.122 +		else{
   1.123 +			# Referenced
   1.124 +			sub(/^ ?\[/, "", t2);
   1.125 +			id = alt;
   1.126 +			if(match(t2, /^[^\]]+/))
   1.127 +				id = substr(t2, 1, RLENGTH);
   1.128 +			t2 = substr(t2, RLENGTH + 2);
   1.129 +			if(ref[id])
   1.130 +				r = ref[id];
   1.131 +			else{
   1.132 +				r = "<<" id;
   1.133 +				nr++;
   1.134 +			}
   1.135 +			return t1 "<img src=\"" r "\" alt=\"" alt "\" />" nextil(t2);
   1.136 +		}
   1.137 +	}
   1.138 +	# Links
   1.139 +	if(tag == "["){
   1.140 +		if(!match(t2, /(\[.*\])|(\(.*\))/))
   1.141 +			return t1 tag nextil(t2);
   1.142 +		match(t2, /^[^\]]*(\[[^\]]*\][^\]]*)*/);
   1.143 +		linktext = substr(t2, 1, RLENGTH);
   1.144 +		t2 = substr(t2, RLENGTH + 2);
   1.145 +		if(match(t2, /^\(/)){
   1.146 +			# Inline
   1.147 +			match(t2, /^[^\)]+(\([^\)]+\)[^\)]*)*/);
   1.148 +			url = substr(t2, 2, RLENGTH - 1);
   1.149 +			pt2 = substr(t2, RLENGTH + 2);
   1.150 +			title = "";
   1.151 +			if(match(url, /[ 	]+\".*\"[ 	]*$/)) {
   1.152 +				title = substr(url, RSTART, RLENGTH);
   1.153 +				url = substr(url, 1, RSTART - 1);
   1.154 +				match(title, /\".*\"/);
   1.155 +				title = " title=\"" substr(title, RSTART + 1, RLENGTH - 2) "\"";
   1.156 +			}
   1.157 +			if(match(url, /^<.*>$/))
   1.158 +				url = substr(url, 2, RLENGTH - 2);
   1.159 +			url = eschtml(url);
   1.160 +			return t1 "<a href=\"" url "\"" title ">" nextil(linktext) "</a>" nextil(pt2);
   1.161 +		}
   1.162 +		else{
   1.163 +			# Referenced
   1.164 +			sub(/^ ?\[/, "", t2);
   1.165 +			id = linktext;
   1.166 +			if(match(t2, /^[^\]]+/))
   1.167 +				id = substr(t2, 1, RLENGTH);
   1.168 +			t2 = substr(t2, RLENGTH + 2);
   1.169 +			if(ref[id])
   1.170 +				r = ref[id];
   1.171 +			else{
   1.172 +				r = "<<" id;
   1.173 +				nr++;
   1.174 +			}
   1.175 +			pt2 = t2;
   1.176 +			return t1 "<a href=\"" r "\" />" nextil(linktext) "</a>" nextil(pt2);
   1.177 +		}
   1.178 +	}
   1.179 +	# Emphasis
   1.180 +	if(match(tag, /[*_]/)){
   1.181 +		ntag = tag;
   1.182 +		if(sub("^" tag, "", t2)){
   1.183 +			if(stag[ns] == tag && match(t2, "^" tag))
   1.184 +				t2 = tag t2;
   1.185 +			else
   1.186 +				ntag = tag tag
   1.187 +		}
   1.188 +		n = length(ntag);
   1.189 +		tag = (n == 2) ? "strong" : "em";
   1.190 +		if(match(t1, / $/) && match(t2, /^ /))
   1.191 +			return t1 tag nextil(t2);
   1.192 +		if(stag[ns] == ntag){
   1.193 +			tag = "/" tag;
   1.194 +			ns--;
   1.195 +		}
   1.196 +		else
   1.197 +			stag[++ns] = ntag;
   1.198 +		tag = "<" tag ">";
   1.199 +		return t1 tag nextil(t2);
   1.200 +	}
   1.201 +}
   1.202 +
   1.203 +function inline(t) {
   1.204 +	ilcode = 0;
   1.205 +	ilcode2 = 0;
   1.206 +	ns = 0;
   1.207 +	
   1.208 +	return nextil(t);
   1.209 +}
   1.210 +
   1.211 +function printp(tag) {
   1.212 +	if(!match(text, /^[ 	]*$/)){
   1.213 +		text = inline(text);
   1.214 +		if(tag != "")
   1.215 +			oprint("<" tag ">" text "</" tag ">");
   1.216 +		else
   1.217 +			oprint(text);
   1.218 +	}
   1.219 +	text = "";
   1.220 +}
   1.221 +
   1.222 +BEGIN {
   1.223 +	blank = 0;
   1.224 +	code = 0;
   1.225 +	hr = 0;
   1.226 +	html = 0;
   1.227 +	nl = 0;
   1.228 +	nr = 0;
   1.229 +	otext = "";
   1.230 +	text = "";
   1.231 +	par = "p";
   1.232 +}
   1.233 +
   1.234 +# References
   1.235 +!code && /^ *\[[^\]]*\]:[ 	]+/ {
   1.236 +	sub(/^ *\[/, "");
   1.237 +	match($0, /\]/);
   1.238 +	id = substr($0, 1, RSTART - 1);
   1.239 +	sub(id "\\]:[ 	]+", "");
   1.240 +	title = "";
   1.241 +	if(match($0, /\".*\"$/))
   1.242 +		title = "\" title=\"" substr($0, RSTART + 1, RLENGTH - 2);
   1.243 +	sub(/[ 	]+\".*\"$/, "");
   1.244 +	url = eschtml($0);
   1.245 +	ref[id] = url title;
   1.246 +
   1.247 +	subref(id);
   1.248 +	next;
   1.249 +}
   1.250 +
   1.251 +# html
   1.252 +!html && /^<(address|blockquote|center|dir|div|dl|fieldset|form|h[1-6r]|\
   1.253 +isindex|menu|noframes|noscript|ol|p|pre|table|ul|!--)/ {
   1.254 +	if(code)
   1.255 +		oprint("</pre></code>");
   1.256 +	for(; !text && block[nl] == "blockquote"; nl--)
   1.257 +		oprint("</blockquote>");
   1.258 +	match($0, /^<(address|blockquote|center|dir|div|dl|fieldset|form|h[1-6r]|\
   1.259 +	isindex|menu|noframes|noscript|ol|p|pre|table|ul|!--)/);
   1.260 +	htag = substr($0, 2, RLENGTH - 1);
   1.261 +	if(!match($0, "(<\\/" htag ">)|((^<hr ?\\/?)|(--)>$)"))
   1.262 +		html = 1;
   1.263 +	if(html && match($0, /^<hr/))
   1.264 +		hr = 1;
   1.265 +	oprint($0);
   1.266 +	next;
   1.267 +}
   1.268 +
   1.269 +html && (/(^<\/(address|blockquote|center|dir|div|dl|fieldset|form|h[1-6r]|\
   1.270 +isindex|menu|noframes|noscript|ol|p|pre|table|ul).*)|(--)>$/ ||
   1.271 +(hr && />$/)) {
   1.272 +	html = 0;
   1.273 +	hr = 0;
   1.274 +	oprint($0);
   1.275 +	next;
   1.276 +}
   1.277 +
   1.278 +html {
   1.279 +	oprint($0);
   1.280 +	next;
   1.281 +}
   1.282 +
   1.283 +# List and quote blocks
   1.284 +
   1.285 +#   Remove indentation
   1.286 +{
   1.287 +	for(nnl = 0; nnl < nl; nnl++)
   1.288 +		if((match(block[nnl + 1], /[ou]l/) && !sub(/^(    |	)/, "")) || \
   1.289 +		(block[nnl + 1] == "blockquote" && !sub(/^> ?/, "")))
   1.290 +			break;
   1.291 +}
   1.292 +nnl < nl && !blank && text && ! /^ ? ? ?([*+-]|([0-9]+\.)+)( +|	)/ { nnl = nl; }
   1.293 +#   Quote blocks
   1.294 +{ 
   1.295 +	while(sub(/^> /, ""))
   1.296 +		nblock[++nnl] = "blockquote";
   1.297 +}
   1.298 +#   Horizontal rules
   1.299 +{ hr = 0; }
   1.300 +(blank || (!text && !code)) && /^ ? ? ?([-*_][ 	]*)([-*_][ 	]*)([-*_][ 	]*)+$/ {
   1.301 +	if(code){
   1.302 +		oprint("</pre></code>");
   1.303 +		code = 0;
   1.304 +	}
   1.305 +	blank = 0;
   1.306 +	nnl = 0;
   1.307 +	hr = 1;
   1.308 +}
   1.309 +#   List items
   1.310 +block[nl] ~ /[ou]l/ && /^$/ {
   1.311 +	blank = 1;
   1.312 +	next;
   1.313 +}
   1.314 +{ newli = 0; }
   1.315 +!hr && (nnl != nl || !text || block[nl] ~ /[ou]l/) && /^ ? ? ?[*+-]( +|	)/ {
   1.316 +	sub(/^ ? ? ?[*+-]( +|	)/, "");
   1.317 +	nnl++;
   1.318 +	nblock[nnl] = "ul";
   1.319 +	newli = 1;
   1.320 +}
   1.321 +(nnl != nl || !text || block[nl] ~ /[ou]l/) && /^ ? ? ?([0-9]+\.)+( +|	)/ {
   1.322 +	sub(/^ ? ? ?([0-9]+\.)+( +|	)/, "");
   1.323 +	nnl++;
   1.324 +	nblock[nnl] = "ol";
   1.325 +	newli = 1;
   1.326 +}
   1.327 +newli { 
   1.328 +	if(blank && nnl == nl && !par)
   1.329 +		par = "p";
   1.330 +	blank = 0;
   1.331 +	printp(par);
   1.332 +	if(nnl == nl && block[nl] == nblock[nl])
   1.333 +		oprint("</li><li>");
   1.334 +}
   1.335 +blank && ! /^$/ {
   1.336 +	if(match(block[nnl], /[ou]l/) && !par)
   1.337 +		par = "p";
   1.338 +	printp(par);
   1.339 +	par = "p";
   1.340 +	blank = 0;
   1.341 +}
   1.342 +		
   1.343 +# Close old blocks and open new ones
   1.344 +nnl != nl || nblock[nl] != block[nl] {
   1.345 +	if(code){
   1.346 +		oprint("</pre></code>");
   1.347 +		code = 0;
   1.348 +	}
   1.349 +	printp(par);
   1.350 +	b = (nnl > nl) ? nblock[nnl] : block[nnl];
   1.351 +	par = (match(b, /[ou]l/)) ? "" : "p";
   1.352 +}
   1.353 +nnl < nl || (nnl == nl && nblock[nl] != block[nl]) {
   1.354 +	for(; nl > nnl || (nnl == nl && pblock[nl] != block[nl]); nl--){
   1.355 +		if(match(block[nl], /[ou]l/))
   1.356 +			oprint("</li>");
   1.357 +		oprint("</" block[nl] ">");
   1.358 +	}
   1.359 +}
   1.360 +nnl > nl {
   1.361 +	for(; nl < nnl; nl++){
   1.362 +		block[nl + 1] = nblock[nl + 1];
   1.363 +		oprint("<" block[nl + 1] ">");
   1.364 +		if(match(block[nl + 1], /[ou]l/))
   1.365 +			oprint("<li>");
   1.366 +	}
   1.367 +}
   1.368 +hr {
   1.369 +	oprint("<hr>");
   1.370 +	next;
   1.371 +}
   1.372 +
   1.373 +# Code blocks
   1.374 +code && /^$/ { 
   1.375 +	if(blanK)
   1.376 +		oprint("");
   1.377 +	blank = 1;
   1.378 +	next;
   1.379 +}
   1.380 +!text && sub(/^(	|    )/, "") {
   1.381 +	if(blanK)
   1.382 +		oprint("");
   1.383 +	blank = 0;
   1.384 +	if(!code)
   1.385 +		oprint("<code><pre>");
   1.386 +	code = 1;
   1.387 +	$0 = eschtml($0);
   1.388 +	oprint($0);
   1.389 +	next;
   1.390 +}
   1.391 +code {
   1.392 +	oprint("</pre></code>");
   1.393 +	code = 0;
   1.394 +}
   1.395 +
   1.396 +# Setex-style Headers
   1.397 +text && /^=+$/ {printp("h1"); next;}
   1.398 +text && /^-+$/ {printp("h2"); next;} 
   1.399 +
   1.400 +# Atx-Style headers
   1.401 +/^#+/ && (!newli || par=="p" || /^##/) {
   1.402 +	for(n = 0; n < 6 && sub(/^# */, ""); n++)
   1.403 +		sub(/#$/, "");
   1.404 +	par = "h" n;
   1.405 +}
   1.406 +
   1.407 +# Paragraph	
   1.408 +/^$/ {
   1.409 +	printp(par);
   1.410 +	par = "p";
   1.411 +	next;
   1.412 +}
   1.413 +
   1.414 +# Add text
   1.415 +{ text = (text ? text " " : "") $0; }
   1.416 +
   1.417 +END {
   1.418 +	if(code){
   1.419 +		oprint("</pre></code>");
   1.420 +		code = 0;
   1.421 +	}
   1.422 +	printp(par);
   1.423 +	for(; nl > 0; nl--){
   1.424 +		if(match(block[nl], /[ou]l/))
   1.425 +			oprint("</li>");
   1.426 +		oprint("</" block[nl] ">");
   1.427 +	}
   1.428 +	gsub(/<<[^\"]*/, "", otext);
   1.429 +	print(otext);
   1.430 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/style.css	Sun Apr 04 03:18:14 2010 +0200
     2.3 @@ -0,0 +1,209 @@
     2.4 +/* Based on werc stylesheet (werc.cat-v.org) */
     2.5 +
     2.6 +/* Header */
     2.7 +.header {
     2.8 +  color: rgb(39,78,144);
     2.9 +  background-color: rgb(140,170,230);
    2.10 +  background-color: #ff6d06;
    2.11 +  border: solid 0 black;
    2.12 +  border-width: 2px 0;
    2.13 +}
    2.14 +
    2.15 +.headerTitle {
    2.16 +  color: black;
    2.17 +  font-size: 233%;
    2.18 +  font-weight: normal;
    2.19 +  margin: 0 0 0 4mm;
    2.20 +  padding: 0.25ex 0;
    2.21 +}
    2.22 +
    2.23 +.headerSubTitle {
    2.24 +  font-size: 50%;
    2.25 +  font-style: italic;
    2.26 +  margin-left: 1em;
    2.27 +}
    2.28 +
    2.29 +.headerTitle a { color: black; }
    2.30 +.headerTitle a:hover { text-decoration: none; }
    2.31 +
    2.32 +/* Side */
    2.33 +#side-bar {
    2.34 +  width: 16em;
    2.35 +  float: left;
    2.36 +  clear: left;
    2.37 +  border-right: 1px solid #ddd;
    2.38 +}
    2.39 +
    2.40 +#side-bar ul {
    2.41 +  list-style-type: none;
    2.42 +  list-style-position: outside;
    2.43 +  margin: 0;
    2.44 +  padding: 0 0 0.3em 0;
    2.45 +}
    2.46 +
    2.47 +#side-bar li {
    2.48 +  margin: 0;
    2.49 +  padding: 0.1ex 0;  /* Circumvents a rendering bug (?) in MSIE 6.0  XXX should move to iehacks.css, this causes an ugly gap */
    2.50 +}
    2.51 +
    2.52 +#side-bar a {
    2.53 +  color: rgb(0,102,204);
    2.54 +  background-color: transparent;
    2.55 +  margin: 0;
    2.56 +  padding: 0.25em 1ex 0.25em 2mm;
    2.57 +  display: block;
    2.58 +  text-transform: capitalize;
    2.59 +  font-weight: bold!important;
    2.60 +  font-size: 102%;
    2.61 +  border-left: white solid 0.2em;
    2.62 +}
    2.63 +
    2.64 +#side-bar a:hover {
    2.65 +  color: white;
    2.66 +  background-color: rgb(100,135,220);
    2.67 +  border-left: black solid 0.2em;
    2.68 +  text-decoration: none;
    2.69 +}
    2.70 + 
    2.71 +/* Main Copy */
    2.72 +#main {
    2.73 +  max-width: 70em;
    2.74 +  color: black;
    2.75 +  background-color: transparent;
    2.76 +  text-align: justify;
    2.77 +  line-height: 1.5em;
    2.78 +  margin: 0em 0 0 16em;
    2.79 +  padding: 0.5mm 5mm 5mm 5mm;
    2.80 +  border-left: 1px solid #ddd;
    2.81 +}
    2.82 +
    2.83 +#bodyText {
    2.84 +  margin: 0 0 0 15.5em;
    2.85 +  padding: 2mm 5mm 2mm 5mm;
    2.86 +}
    2.87 +
    2.88 +#main p {
    2.89 +  margin: 1em 1ex 1em 1ex !important; /* Need !important so troff-generated pages don't look totally squezed */
    2.90 +  padding: 0;
    2.91 +}
    2.92 +
    2.93 +#main a {
    2.94 +  color: rgb(0,102,204);
    2.95 +  background-color: transparent;
    2.96 +}
    2.97 +
    2.98 +#main a:hover {
    2.99 +  color:  rgb(100,135,220);
   2.100 +}
   2.101 +
   2.102 +#main h1, #main h2 {
   2.103 +  color: rgb(0,102,204);
   2.104 +  background-color: transparent;
   2.105 +  font-size: 145.5%;
   2.106 +  font-weight: bold;
   2.107 +  margin: 2em 0 0 0;
   2.108 +  padding: 0.5ex 0 0.5ex 0.6ex;
   2.109 +  border-bottom: 2px solid rgb(0,102,204);
   2.110 +}
   2.111 +
   2.112 +#main h2 {
   2.113 +  font-size: 115.5%;
   2.114 +  border-bottom: 1px solid rgb(0,102,204);
   2.115 +}
   2.116 +
   2.117 +#main .topOfPage {
   2.118 +  color: rgb(0,102,204);
   2.119 +  background-color: transparent;
   2.120 +  font-size: 91%;
   2.121 +  font-weight: bold;
   2.122 +  text-decoration: none;
   2.123 +  margin: 3ex 1ex 0 0;
   2.124 +  padding: 0;
   2.125 +  float: right;
   2.126 +}
   2.127 +
   2.128 +dl {
   2.129 +  margin: 1em 1ex 2em 1ex;
   2.130 +  padding: 0;
   2.131 +}
   2.132 +
   2.133 +dt {
   2.134 +  font-weight: bold;
   2.135 +  margin: 0 0 0 0;
   2.136 +  padding: 0;
   2.137 +}
   2.138 +
   2.139 +dd {
   2.140 +  margin: 0 0 2em 2em;
   2.141 +  padding: 0;
   2.142 +}
   2.143 +
   2.144 +/* Footer */
   2.145 +#footer {
   2.146 +  color: white;
   2.147 +  background-color: rgb(100,135,220);
   2.148 +  padding: 0.4em;
   2.149 +  clear: both;
   2.150 +}
   2.151 +
   2.152 +#footer .right {
   2.153 +  text-align: right;
   2.154 +  line-height: 1.45em;
   2.155 +}
   2.156 +
   2.157 +#footer a {
   2.158 +  color: white;
   2.159 +  background-color: transparent;
   2.160 +}
   2.161 +
   2.162 +/* General */
   2.163 +body {
   2.164 +  color: black;
   2.165 +  background-color: white;
   2.166 +  font-family: Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif;
   2.167 +  font-size: 84%;  /* Enables font size scaling in MSIE */
   2.168 +  margin: 0;
   2.169 +  padding: 0;
   2.170 +}
   2.171 +
   2.172 +a { text-decoration: none; }
   2.173 +a:hover { text-decoration: underline; }
   2.174 +
   2.175 +li ul {
   2.176 +  padding-left: 0.6em !important;
   2.177 +}
   2.178 +
   2.179 +table {
   2.180 +  border: solid 1px black;
   2.181 +}
   2.182 +th {
   2.183 +  background-color: #abc;
   2.184 +  border: solid 1px black;
   2.185 +   text-align: center;
   2.186 +}
   2.187 +td {
   2.188 +  background-color: #def;
   2.189 +  border: solid 1px black;
   2.190 +}
   2.191 +
   2.192 +hr {
   2.193 +  border-width: 0px 0px 0.1em 0px;
   2.194 +  border-color: black;
   2.195 +}
   2.196 +
   2.197 +acronym, .titleTip {
   2.198 +  border-bottom: 1px solid #ddd;
   2.199 +  cursor: help;
   2.200 +  margin: 0;
   2.201 +  padding: 0 0 0.4px 0;
   2.202 +}
   2.203 +
   2.204 +pre {
   2.205 +  margin-left: 2em; 
   2.206 +  font-size: 1.2em;
   2.207 +}
   2.208 +
   2.209 +blockquote {
   2.210 +  border-left: 1px solid blue;
   2.211 +  font-style: italic;
   2.212 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/sw	Sun Apr 04 03:18:14 2010 +0200
     3.3 @@ -0,0 +1,78 @@
     3.4 +#!/bin/sh
     3.5 +# sw - 2010 - nibble <develsec.org>
     3.6 +
     3.7 +# Configuration
     3.8 +TITLE="nibble.develsec.org" # Site title
     3.9 +SUBTITLE=""                 # Site subtitle
    3.10 +SITE="site"                 # Site folder
    3.11 +BL="^index.md$ ^images$"    # Black list
    3.12 +BIN="/sw"                   # CGI location
    3.13 +STYLE="/style.css"          # Stylesheet location
    3.14 +# External apps
    3.15 +MDHANDLER="/usr/local/bin/md2html.awk" # md handler
    3.16 +
    3.17 +echo Content-type: text/html
    3.18 +echo
    3.19 +
    3.20 +if [ -n "`echo ${REQUEST_URI} | grep "[^a-zA-Z0-9_\./ ]\+"`" ]; then
    3.21 +	echo "<script>window.location=\"${BIN}\";</script>"
    3.22 +	exit 1
    3.23 +fi
    3.24 +
    3.25 +QUERY=`echo ${REQUEST_URI} | sed -e "s,.*${BIN}/*\(.*\),\1,"`
    3.26 +DIR="."
    3.27 +FILE="index.md"
    3.28 +if [ -n "${QUERY}" ]; then
    3.29 +	if [ -f "${SITE}/${QUERY}" ]; then
    3.30 +		DIR=`dirname ${QUERY} | sed -e "s,/*$,,"`
    3.31 +		FILE=${QUERY}
    3.32 +	elif [ -d "${SITE}/${QUERY}" ]; then
    3.33 +		DIR=`echo ${QUERY} | sed -e "s,/*$,,"`
    3.34 +		FILE="$DIR/index.md"
    3.35 +	fi
    3.36 +fi
    3.37 +
    3.38 +sw_menu() {
    3.39 +	BL=`echo ${BL} | sed -e "s/\( \+\|^\)/ -e /g"`
    3.40 +	echo "<ul>"
    3.41 +	[ "${DIR}" != "." ] && echo "<li><a href=\"${BIN}/${DIR}/..\">..</a></li>"
    3.42 +	for i in `ls ${SITE}/${DIR} | grep -v ${BL}`; do
    3.43 +		NAME=`echo ${i} | sed -e "s/\..*$//" -e "s/_/ /g" \
    3.44 +			 -e "s/\([a-z]\?\)\(.*\)/\u\1\2/"`
    3.45 +		echo "<li><a href=\"${BIN}/${DIR}/${i}\">${NAME}</a></li>"
    3.46 +	done
    3.47 +	echo "</ul>"
    3.48 +}
    3.49 +
    3.50 +# Header
    3.51 +cat << _header_
    3.52 +<html>
    3.53 +<head>
    3.54 +<title>${TITLE}</title>
    3.55 +<link rel="stylesheet" href="${STYLE}" type="text/css">
    3.56 +</head>
    3.57 +<body>
    3.58 +<div class="header">
    3.59 +<h1 class="headerTitle">
    3.60 +<a href="${BIN}">${TITLE}</a> <span class="headerSubtitle">${SUBTITLE}</span>
    3.61 +</h1>
    3.62 +</div>
    3.63 +_header_
    3.64 +# Menu
    3.65 +echo "<div id=\"side-bar\">"
    3.66 +sw_menu
    3.67 +echo "</div>"
    3.68 +# Body
    3.69 +echo "<div id=\"main\">"
    3.70 +${MDHANDLER} "${SITE}/${FILE}"
    3.71 +echo "</div>"
    3.72 +# Footer
    3.73 +cat << _footer_
    3.74 +<div id="footer">
    3.75 +<div class="right">Powered by sw</div>
    3.76 +</div>
    3.77 +</body>
    3.78 +</html>
    3.79 +_footer_
    3.80 +
    3.81 +exit 0