Implemented new Nimrod website designed by @PhilipWitte.

This commit is contained in:
Dominik Picheta 2013-05-18 17:36:57 +01:00
commit f081ac0e54
19 changed files with 328 additions and 126 deletions

View file

@ -8,16 +8,17 @@
#
import
os, strutils, times, parseopt, parsecfg, streams, strtabs
os, strutils, times, parseopt, parsecfg, streams, strtabs, tables
type
TKeyValPair = tuple[key, val: string]
TKeyValPair = tuple[key, id, val: string]
TConfigData = object of TObject
tabs, links: seq[TKeyValPair]
doc, srcdoc, srcdoc2, webdoc, pdf: seq[string]
authors, projectName, projectTitle, logo, infile, outdir, ticker: string
vars: PStringTable
nimrodArgs: string
quotations: TTable[string, tuple[quote, author: string]]
proc initConfigData(c: var TConfigData) =
c.tabs = @[]
@ -36,8 +37,9 @@ proc initConfigData(c: var TConfigData) =
c.logo = ""
c.ticker = ""
c.vars = newStringTable(modeStyleInsensitive)
c.quotations = initTable[string, tuple[quote, author: string]]()
include "sunset.tmpl"
include "website.tmpl"
# ------------------------- configuration file -------------------------------
@ -132,8 +134,10 @@ proc parseIniFile(c: var TConfigData) =
of "authors": c.authors = v
else: quit(errorStr(p, "unknown variable: " & k.key))
of "var": nil
of "links": add(c.links, (k.key, v))
of "tabs": add(c.tabs, (k.key, v))
of "links":
let valID = v.split(';')
add(c.links, (k.key.replace('_', ' '), valID[1], valID[0]))
of "tabs": add(c.tabs, (k.key, "", v))
of "ticker": c.ticker = v
of "documentation":
case normalize(k.key)
@ -143,6 +147,10 @@ proc parseIniFile(c: var TConfigData) =
of "srcdoc2": addFiles(c.srcdoc2, "lib", ".nim", split(v, {';'}))
of "webdoc": addFiles(c.webdoc, "lib", ".nim", split(v, {';'}))
else: quit(errorStr(p, "unknown variable: " & k.key))
of "quotations":
let vSplit = v.split('-')
doAssert vSplit.len == 2
c.quotations[k.key.normalize] = (vSplit[0], vSplit[1])
else: nil
of cfgOption: quit(errorStr(p, "syntax error"))
@ -203,13 +211,10 @@ proc main(c: var TConfigData) =
const
cmd = "nimrod rst2html --compileonly $1 -o:web/$2.temp web/$2.txt"
if c.ticker.len > 0:
Exec(cmd % [c.nimrodArgs, c.ticker])
var temp = "web" / changeFileExt(c.ticker, "temp")
try:
c.ticker = readFile(temp)
c.ticker = readFile("web" / c.ticker)
except EIO:
quit("[Error] cannot open: " & temp)
RemoveFile(temp)
quit("[Error] cannot open: " & c.ticker)
for i in 0..c.tabs.len-1:
var file = c.tabs[i].val
Exec(cmd % [c.nimrodArgs, file])
@ -221,13 +226,15 @@ proc main(c: var TConfigData) =
quit("[Error] cannot open: " & temp)
var f: TFile
var outfile = "web/upload/$#.html" % file
if not existsDir("web/upload"):
createDir("web/upload")
if open(f, outfile, fmWrite):
writeln(f, generateHTMLPage(c, file, content))
close(f)
else:
quit("[Error] cannot write file: " & outfile)
removeFile(temp)
copyDir("web/assets", "web/upload/assets")
buildAddDoc(c, "web/upload")
buildDoc(c, "web/upload")
buildDoc(c, "doc")

View file

@ -1,76 +0,0 @@
#! stdtmpl | standard
#proc generateHTMLPage(c: var TConfigData, currentTab, content: string): string =
# result = ""
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>$c.projectTitle</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style/style.css" />
</head>
<body>
<div id="main">
<div id="links">
<!-- **** INSERT LINKS HERE **** -->
</div>
<div id="logo"><h1>$c.projectTitle</h1>
<h2>$c.logo</h2>
</div>
<div id="content">
<div id="menu">
<ul>
#for i in 0.. c.tabs.len-1:
# var name = c.tabs[i].key
# var t = c.tabs[i].val
#if currentTab == t:
<li><a id="selected"
#else:
<li><a
#end if
href="${t}.html" title = "$c.projectName - $name">$name</a></li>
#end for
</ul>
</div>
<div id="column1">
# if len(c.ticker) > 0:
<div class="sidebaritem">
<div class="sbihead">
<h1>latest news</h1>
</div>
<div class="sbicontent">
$c.ticker
</div>
</div>
# end if
# if len(c.links) > 0:
<div class="sidebaritem">
<div class="sbihead">
<h1>Links</h1>
</div>
<div class="sbilinks">
<ul>
# for i in 0..c.links.len-1:
<li><a class="reference" href="${c.links[i].val}">${c.links[i].key}</a></li>
# end for
</ul>
</div>
</div>
# end if
</div>
<div id="column2">
$content
</div>
</div>
<div id="footer">
&copy; 2012 $c.authors | Last update: ${getDateStr()}
<!-- | <iframe style="border: 0; margin: 0; padding: 0;"
src="https://www.gittip.com/Araq/widget.html"
width="48pt" height="15pt"></iframe> -->
| <a class="reference" href="http://www.dcarter.co.uk">design by dcarter</a>
</div>
</div>
</body>
</html>

75
tools/website.tmpl Normal file
View file

@ -0,0 +1,75 @@
#! stdtmpl | standard
#proc generateHTMLPage(c: var TConfigData, currentTab, content: string): string =
# result = ""
<!doctype html>
<html>
<head>
<title>$c.projectTitle</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="assets/style.css" />
</head>
<body>
<div id="site">
<!-- site_head -->
<div id="site_head">
<div id="logo"></div>
</div>
<!-- site_neck -->
<div id="site_neck">
#for i in 0.. c.tabs.len-1:
# var name = c.tabs[i].key
# var t = c.tabs[i].val
#if currentTab == t:
<a class="active"
#else:
<a
#end if
href="${t}.html" title = "$c.projectName - $name">$name</a>
#end for
</div>
<!-- site_body -->
<div id="site_body">
<!-- sidebar_wrapper -->
<div id="sidebar_wrap">
<div id="sidebar">
<div id="sidebar_head"></div>
<h2>Latest News</h2>
# if len(c.ticker) > 0:
$c.ticker
# end if
# if len(c.links) > 0:
<h2>More Links</h2>
# for i in 0..c.links.len-1:
<a class="link" href="${c.links[i].val}" id="${c.links[i].id}">${c.links[i].key}</a>
# end for
# end if
</div>
</div>
<!-- page -->
<div id="page">
#if c.quotations.hasKey(currentTab):
<div class="quote-image"></div>
<p class="quote">
${c.quotations[currentTab].quote}
<br>
<b style="float: right">-- ${c.quotations[currentTab].author}</b>
</p>
<br/>
#end if
$content
</div>
</div>
<!-- site_foot -->
<div id="site_foot">
<div id="legal">Copyright &copy; 2013 - Andreas Rumpf &amp; Contributors - All rights reserved - <a href="http://reign-studios.com/philipwitte/">Design by Philip Witte</a></div>
</div>
</div>
</body>
</html>