summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2010-03-14 00:14:00 (GMT)
committerDavid A. Madore <david+git@madore.org>2010-03-14 00:14:00 (GMT)
commitad480a34ed432e6989ccad46268483343bc3e8ef (patch)
tree4628d66d2a8cc78bd57320e6315a9acb5b982b9a
parentd2e31598c8663f03dd571b53f4cf2e510f1d259b (diff)
downloadblogengine-ad480a34ed432e6989ccad46268483343bc3e8ef.zip
blogengine-ad480a34ed432e6989ccad46268483343bc3e8ef.tar.gz
blogengine-ad480a34ed432e6989ccad46268483343bc3e8ef.tar.bz2
Add <style> and <script> elements.
(With some yuckiness to put CDATA section nicely.)
-rwxr-xr-xdaml2html.pl30
-rw-r--r--included.css99
-rw-r--r--included.js56
3 files changed, 185 insertions, 0 deletions
diff --git a/daml2html.pl b/daml2html.pl
index bd23f32..774ee85 100755
--- a/daml2html.pl
+++ b/daml2html.pl
@@ -160,6 +160,7 @@ if ( defined($in_meta_keywords) ) {
$out_head->appendChild($out_meta_keywords);
$out_head->appendChild($out_doc->createTextNode("\n"));
}
+
my $in_body = ($xpc->findnodes("/daml/body"))[0];
if ( defined($in_body) ) {
foreach my $child ( $in_body->childNodes ) {
@@ -168,6 +169,35 @@ if ( defined($in_body) ) {
}
}
+my $pure_style_content = "";
+if ( open my $common_style_file, "<", "included.css" ) {
+ local $/;
+ $pure_style_content = <$common_style_file>;
+ close $common_style_file;
+}
+my $pure_script_content = "";
+if ( open my $common_script_file, "<", "included.js" ) {
+ local $/;
+ $pure_script_content = <$common_script_file>;
+ close $common_script_file;
+}
+
+my $out_style_section = $out_doc->createElementNS(XHTML_NS, "style");
+$out_head->appendChild($out_style_section);
+$out_head->appendChild($out_doc->createTextNode("\n"));
+$out_style_section->setAttributeNS("", "type", "text/css");
+$out_style_section->appendChild($out_doc->createTextNode("\n/* "));
+$out_style_section->appendChild($out_doc->createCDATASection(" */\n".$pure_style_content."/* "));
+$out_style_section->appendChild($out_doc->createTextNode(" */\n"));
+my $out_script_section = $out_doc->createElementNS(XHTML_NS, "script");
+$out_head->appendChild($out_script_section);
+$out_head->appendChild($out_doc->createTextNode("\n"));
+$out_script_section->setAttributeNS("", "type", "text/javascript");
+$out_script_section->setAttributeNS("", "defer", "defer");
+$out_script_section->appendChild($out_doc->createTextNode("\n// "));
+$out_script_section->appendChild($out_doc->createCDATASection("\n".$pure_script_content."// "));
+$out_script_section->appendChild($out_doc->createTextNode("\n"));
+
# sub map_children {
# my $fun = shift;
# my $node = shift;
diff --git a/included.css b/included.css
new file mode 100644
index 0000000..ff9d538
--- /dev/null
+++ b/included.css
@@ -0,0 +1,99 @@
+body {
+ color: black;
+ font-family: Optima, "Zapf Humanist", Palatino, "Palatino Linotype", serif;
+}
+h1,h2,h3,h4,h5,h6 {
+ font-family: Futura, "Century Gothic", "Avant Garde", "Avant Garde Gothic", Helvetica, Arial, sans-serif;
+}
+h1 { color: rgb(0,128,0); }
+h2 { color: rgb(96,96,0); }
+h3 { color: rgb(96,64,0); }
+.title { text-align: center; }
+.subtitle {
+ font-size: 1.5em; text-align: center;
+ font-family: Futura, "Century Gothic", "Avant Garde", "Avant Garde Gothic", Helvetica, Arial, sans-serif;
+ color: rgb(24,96,0);
+}
+.navbar {
+ font-size: .83em;
+ font-family: "Times Roman", Times, "Times New Roman", serif;
+}
+.ffii-call {
+ clear: both;
+ color: red;
+ font-size: 1.7em;
+ font-family: Helvetica, Arial, sans-serif;
+ text-align: center;
+ border: outset;
+}
+.important { font-weight: bold; border: solid; padding: 1em; }
+.outset { border: outset; padding-left: 0.5em; padding-right: 0.5em; }
+.sidenote { font-size: .83em; }
+.weblog-entry-header { color: rgb(128,64,0); }
+.weblog-entry-header > a { color: inherit; }
+.weblog-entry-title {
+ color: black;
+ font-size: 1.17em;
+ font-weight: bold;
+ font-family: Futura, "Avant Garde", Helvetica, Arial, sans-serif;
+}
+.talkback-link {
+ color: rgb(128,64,0); font-size: 0.83em; text-align: right; font-family: Futura, "Avant Garde", Helvetica, Arial, sans-serif;
+ margin-bottom: 0pt;
+}
+.talkback-link > a { color: inherit; }
+.sitemap-note {
+ font-style: italic;
+ color: rgb(96,0,0);
+}
+.idlist > dt { color: rgb(96,64,0); }
+.numtable td { text-align: right; }
+.noparskip p { margin-top: 0; margin-bottom: 0; }
+.cleared { clear: both; }
+.cleared-left { clear: left; }
+.cleared-right { clear: right; }
+.pic { float: left; margin-right: 1em; margin-bottom: 1em; }
+.pic-right { float: right; margin-left: 1em; margin-bottom: 1em; }
+.pic-embed { float: left; margin-right: 1em; margin-bottom: 1em; margin-top: 1em; }
+.pic-embed-right { float: right; margin-left: 1em; margin-bottom: 1em; margin-top: 1em; }
+.smiley { vertical-align: middle; }
+.separated { margin-top: 2.33em; }
+a { text-decoration: none; }
+:lang(en) > q { quotes: "\201C" "\201D" "\2018" "\2019"; }
+:lang(fr) > q { quotes: "\AB\A0" "\A0\BB" "\201C" "\201D"; }
+q:before { content: open-quote; }
+q:after { content: close-quote; }
+li { -moz-float-edge: content-box; } /* Undo Mozilla buggy bugware! */
+/* For despammed email addresses */
+@media all { /* Hide from various buggy browsers! */
+ .subreplace-full-stop:before { content: "."; }
+ .subreplace-full-stop > img { display: none; }
+ .subreplace-commercial-at:before { content: "@"; }
+ .subreplace-commercial-at > img { display: none; }
+}
+/* Screen-specific rules */
+@media screen {
+ body { background: rgb(192,208,224); }
+ .navbar {
+ background: rgb(224,192,192);
+ border: solid; border-color: rgb(224,0,0);
+ padding: 1em;
+ float: right; margin-left: 1.33em;
+ }
+ .important {
+ background: rgb(208,208,208);
+ border-color: rgb(255,0,0);
+ }
+ .weblog-entry {
+ background: rgb(224,224,192);
+ border: solid; border-color: rgb(128,64,0);
+ padding: 1em; margin-bottom: 1em;
+ overflow: hidden;
+ }
+ .outset { background: rgb(192,224,208); }
+ .ffii-call { background: rgb(192,224,208); }
+ :link { color: rgb(0,0,192); }
+ :visited { color: rgb(96,0,192); }
+ .weblog-internal-link:link,.weblog-internal-link:visited { color: rgb(0,64,192); }
+ :link:hover,:visited:hover { text-decoration: underline; }
+}
diff --git a/included.js b/included.js
new file mode 100644
index 0000000..7aa2a2b
--- /dev/null
+++ b/included.js
@@ -0,0 +1,56 @@
+var textNodeType;
+function textContent(n) {
+ if ( n.nodeType == textNodeType ) {
+ return n.data;
+ } else {
+ var children = n.childNodes;
+ var t = "";
+ for ( var i=0 ; i<children.length ; i++ ) {
+ t = t.concat(textContent(children.item(i)));
+ }
+ return t;
+ }
+}
+function despam() {
+ // MSIE seems to barf... Deactivate for now
+ if ( (/MSIE *[1-6]\./).test(navigator.userAgent) )
+ return;
+ // Now replace as appropriate.
+ var elts = document.getElementsByTagName("span");
+ for ( var i=0 ; i<elts.length ; i++ ) {
+ var elt = elts.item(i);
+ if ( elt.className == "replace-commercial-at" ) {
+ elt.parentNode.replaceChild(document.createTextNode("@"),elt);
+ i--; // Semi-bugware
+ } else if ( elt.className == "replace-full-stop" ) {
+ elt.parentNode.replaceChild(document.createTextNode("."),elt);
+ i--; // Semi-bugware
+ }
+ }
+ // Merge adjacent text nodes.
+ try {
+ document.normalize(); // Your DOM is BROKEN!
+ } catch (exn) {
+ document.documentElement.normalize();
+ }
+ // Next, process all <a> elements having class="despammed-address".
+ elts = document.getElementsByTagName("a");
+ for ( var i=0 ; i<elts.length ; i++ ) {
+ var elt = elts.item(i);
+ if ( elt.className == "despammed-address" ) {
+ var addr = "mailto:".concat(textContent(elt));
+ elt.setAttribute("href",addr); // (abstract)
+ elt.href = addr; // (semantic)
+ }
+ }
+}
+function onLoad() {
+ // Start with some bugware...
+ try {
+ textNodeType = Node.TEXT_NODE;
+ } catch (exn) { // Your DOM is BROKEN!
+ textNodeType = 3;
+ }
+ // Now despam email adresses.
+ despam();
+}