dweb v0.2: horizontal side bar configuration, optional chevrons (the bloat begins.)
This commit is contained in:
parent
c3c1116e5f
commit
45c0e50ab5
|
@ -1,5 +1,3 @@
|
|||
/* Default werc style */
|
||||
|
||||
/* General style guidelines:
|
||||
- All font-size at least 14px (recommended 16px)
|
||||
- Line-height: 1.5 for paragraph body, 1.1 for header
|
||||
|
@ -14,7 +12,6 @@ body {
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/* # Header # */
|
||||
.superHeader {
|
||||
color: white;
|
||||
|
@ -88,6 +85,55 @@ a:hover { text-decoration: underline; }
|
|||
background-color: transparent;
|
||||
}
|
||||
|
||||
/* # Horiz-side # */
|
||||
#horiz-side-bar {
|
||||
width:100%;
|
||||
float left;
|
||||
clear: both;
|
||||
border: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#horiz-side-bar ul {
|
||||
margin: 0;
|
||||
padding: 0.3em;
|
||||
list-style-type: none;
|
||||
list-style-image: none;
|
||||
background: #eeeeee;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#horiz-side-bar ul:nth-child(even) {
|
||||
background-color: #dddddd;
|
||||
}
|
||||
|
||||
#horiz-side-bar li {
|
||||
display: inline;
|
||||
white-space: nowrap;
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
#horiz-side-bar li.thisPage a {
|
||||
color: black!important;
|
||||
font-weight: bold;
|
||||
}
|
||||
#horiz-side-bar ul li a {
|
||||
margin: 0;
|
||||
padding: 0.1em 1ex 0.1em 1ex;
|
||||
color: #336699;
|
||||
background-color: transparent;
|
||||
text-decoration: none;
|
||||
font-size: 1em;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
#horiz-side-bar ul li a:hover {
|
||||
color: black;
|
||||
text-decoration: none;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
|
||||
/* # Side # */
|
||||
#side-bar {
|
||||
|
@ -120,7 +166,6 @@ li ul {
|
|||
|
||||
#side-bar li {
|
||||
margin: 0;
|
||||
padding: 0.1ex 0; /* Circumvents a rendering bug (?) in MSIE 6.0 XXX should move to iehacks.css, this causes an ugly gap */
|
||||
}
|
||||
|
||||
#side-bar a {
|
||||
|
@ -135,10 +180,10 @@ li ul {
|
|||
border-left: white solid 0.2em;
|
||||
}
|
||||
|
||||
.thisPage, .thisPage a {
|
||||
#side-bar li.thisPage a {
|
||||
color: black!important;
|
||||
background-color: white;
|
||||
padding-left: 5mm;
|
||||
font-style:italic;
|
||||
}
|
||||
|
||||
#side-bar a:hover {
|
||||
|
@ -170,11 +215,15 @@ li ul {
|
|||
|
||||
/* # Main Copy # */
|
||||
#main-copy {
|
||||
max-width: 70em;
|
||||
padding: 0.5mm 5mm 5mm 5mm;
|
||||
color: black;
|
||||
background-color: transparent;
|
||||
text-align: justify;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
.main-copy-side-bar {
|
||||
max-width: 70em;
|
||||
margin: 0em 0 0 16em;
|
||||
padding: 0.5mm 5mm 5mm 5mm;
|
||||
border-left: 1px solid #ddd;
|
||||
|
|
|
@ -2,5 +2,8 @@ const string url_root = "/~j3parker/";
|
|||
const string dweb_root = "/users/j3parker/www/";
|
||||
const string site_root = dweb_root ~ "srv/";
|
||||
|
||||
const string site_title = "Test Title";
|
||||
const string site_subtitle = "this is a subtitle";
|
||||
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;
|
||||
|
|
38
src/web.d
38
src/web.d
|
@ -14,35 +14,46 @@ void html_push(string s) { html(s); indent ~= " "; }
|
|||
|
||||
void write_link(string root, string file, bool expand) {
|
||||
bool isdir = dirExists(file);
|
||||
html_push("<li>");
|
||||
html("<a href=\"" ~ construct_rel_link(root, file) ~ "\"" ~
|
||||
(expand? " class=\"thisPage\">» <i>" : ">› ")
|
||||
~ last_in_path(file) ~ (isdir ? "/" : "")
|
||||
~ (expand? "</i>" : "") ~ "</a>");
|
||||
string flair = nav_tree_chev? (expand? "» " : "› ") : "";
|
||||
html_push("<li" ~ (expand? " class=\"thisPage\" " : "") ~ ">");
|
||||
html("<a href=\"" ~ construct_rel_link(root, file) ~ "\">"
|
||||
~ flair ~last_in_path(file) ~ (isdir ? "/" : "")
|
||||
~ "</a>");
|
||||
html_pop("</li>");
|
||||
}
|
||||
|
||||
void nav_tree_r(string root, string cur_loc, string[] subdirs) {
|
||||
string[] dirs = dir(cur_loc);
|
||||
if (dirs.length == 0) return;
|
||||
html_push("<ul>");
|
||||
foreach(string s; dir(cur_loc)) {
|
||||
if (s[max(0,$-8)..$]=="index.md") continue;
|
||||
bool next = false;
|
||||
string next_loc;
|
||||
foreach(string s; dirs) {
|
||||
bool hidden = last_in_path(s).length > 0 && last_in_path(s)[0] == '.';
|
||||
bool expand = s[cur_loc.length..$] == (subdirs.length == 0 ? "" : subdirs[0]);
|
||||
if (hidden && !expand) continue;
|
||||
write_link(root, s, expand);
|
||||
if (expand && isDir(cur_loc ~ subdirs[0])) {
|
||||
html_push("<li>");
|
||||
nav_tree_r(root, cur_loc ~ subdirs[0] ~ "/", subdirs[1..$]);
|
||||
html_pop("</li>");
|
||||
if (nav_tree_vert) {
|
||||
html_push("<li>");
|
||||
nav_tree_r(root, cur_loc ~ subdirs[0] ~ "/", subdirs[1..$]);
|
||||
html_pop("</li>");
|
||||
} else {
|
||||
next = true;
|
||||
next_loc = cur_loc ~ subdirs[0] ~ "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
html_pop("</ul>");
|
||||
if (next) nav_tree_r(root, next_loc, subdirs[1..$]);
|
||||
}
|
||||
|
||||
// this could be better
|
||||
string[] dir(string path) {
|
||||
string[] files;
|
||||
foreach(string s; dirEntries(path, SpanMode.shallow)) files ~= s;
|
||||
foreach(string s; dirEntries(path, SpanMode.shallow)) {
|
||||
if (s[max(0,$-8)..$] != "index.md") files ~= s;
|
||||
}
|
||||
sort(files);
|
||||
return files;
|
||||
}
|
||||
|
@ -51,11 +62,12 @@ void do_nav_tree(string path) {
|
|||
try { if (isDir(path) && path[path.length - 1] != '/') { path = site_root; } }
|
||||
catch (Exception e) { path = site_root; }
|
||||
|
||||
html_push("<div id=\"side-bar\">");
|
||||
html_push("<div id=\"" ~ (nav_tree_vert ? "" : "horiz-") ~ "side-bar\">");
|
||||
|
||||
string root = get_root_dir(path);
|
||||
string[] subdirs = explode_slashes(path[site_root.length..$]);
|
||||
nav_tree_r(root, site_root, subdirs);
|
||||
|
||||
html_pop("</div>\n");
|
||||
}
|
||||
|
||||
|
@ -124,7 +136,7 @@ bool fileExists(string path) { try { if (isFile(path)) return true; else return
|
|||
bool dirExists(string path) { try { if (isDir(path)) return true; else return false; } catch (Exception e) { return false; } }
|
||||
|
||||
void do_content(string path) {
|
||||
html_push("<div id=\"main-copy\">");
|
||||
html_push("<div id=\"main-copy\"" ~ (nav_tree_vert? " class=\"main-copy-side-bar\"" : "") ~ ">");
|
||||
string url = path[site_root.length..$];
|
||||
switch (url) {
|
||||
case "changelog":
|
||||
|
|
Loading…
Reference in New Issue