changeset 1:12573db75437

added cute error page by dylan. Going to fix index page
author Robert McIntyre <rlm@mit.edu>
date Mon, 17 Oct 2011 22:21:38 -0700
parents c1a872bbc9f9
children c2beff8e5b5d
files .hgignore html/err.html org/index.org org/level-0.org org/publish.org
diffstat 5 files changed, 319 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/.hgignore	Sun Oct 16 06:51:55 2011 -0700
     1.2 +++ b/.hgignore	Mon Oct 17 22:21:38 2011 -0700
     1.3 @@ -1,3 +1,4 @@
     1.4  syntax: glob
     1.5  src*
     1.6 -html*
     1.7 \ No newline at end of file
     1.8 +html/export.html
     1.9 +html/level-0.html
    1.10 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/html/err.html	Mon Oct 17 22:21:38 2011 -0700
     2.3 @@ -0,0 +1,131 @@
     2.4 +<html>
     2.5 +<head>
     2.6 +	<title>error-daemon@aurellem:</title>
     2.7 +	<style type="text/css">
     2.8 +		html,body{margin:0;padding:0;}
     2.9 +		body{font:100% monospace;line-height:1.2em;}
    2.10 +		
    2.11 +		body{background:black;color:white;}
    2.12 +		em{color:#444;font-style:normal; background:white;}	
    2.13 +		em{background:inherit;color:inherit;color:#fcc;}
    2.14 +	</style>
    2.15 +	<script type="text/javascript" src="/aurellem/src/js/jquery.min.js"></script>
    2.16 +
    2.17 +<script type="text/javascript">
    2.18 +var caret;
    2.19 +
    2.20 +// caret functions
    2.21 +
    2.22 +function Caret(){
    2.23 +	this.obj = null;
    2.24 +	this.txt = "";
    2.25 +	this.glyph = "_";
    2.26 +	this.glyph = "&#x2588;";
    2.27 +	this.gylph_mode = false;
    2.28 +	this.queue = new Array();//queue of things to type next 
    2.29 +
    2.30 +	this.attach = function(elt){this.obj = elt;}
    2.31 +	this.refresh = function(){
    2.32 +		$(this.obj).html(this.txt + (this.glyph_mode ? this.glyph : ""));
    2.33 +	}	
    2.34 +	this.stall = function(n){
    2.35 +		for(i=0;i<n;i++){this.instantly('##')};// ## is used to mean Stall for one increment
    2.36 +	}
    2.37 +	this.blink = function(){
    2.38 +		this.glyph_mode = !this.glyph_mode;
    2.39 +		this.refresh();
    2.40 +	}
    2.41 +	this.keystroke = function(str){this.queue = this.queue.concat(str.split(""));} 
    2.42 +	this.instantly = function(str){this.queue.push(str)}	
    2.43 +	this.newline = function(str){this.instantly('<br>');}
    2.44 +	this.prompt = function(){this.instantly('<em>error-daemon@aurellem:$</em> ');}
    2.45 +
    2.46 +	this.type = function(){
    2.47 +		if(this.queue.length > 0){
    2.48 +			var x = this.queue.shift();
    2.49 +			if(x != "##"){this.txt += x;}
    2.50 +			this.refresh();
    2.51 +		}
    2.52 +	} 
    2.53 +}
    2.54 +
    2.55 +
    2.56 +
    2.57 +function error_404(){
    2.58 +
    2.59 +	caret.instantly("**** ERROR 404: PAGE NOT FOUND");
    2.60 +	
    2.61 +	caret.newline();
    2.62 +	caret.prompt();
    2.63 +	caret.stall(80);
    2.64 +	caret.keystroke("I regret to inform you that the page you have requested does not exist on our servers at this time.");
    2.65 +	
    2.66 +	caret.newline();
    2.67 +	caret.prompt();
    2.68 +	caret.stall(40);
    2.69 +	caret.keystroke("Preliminary analysis, building on previously acquired data, indicates that some form of human error is to blame. ");
    2.70 +	caret.stall(20);
    2.71 +	caret.keystroke("Furthermore, all available data indicate that computer involvement of any kind is extremely unlikely.");
    2.72 +	caret.stall(20);
    2.73 +
    2.74 +	caret.keystroke(" Possible human errors include:");
    2.75 +	caret.newline();
    2.76 +	caret.prompt();
    2.77 +	caret.stall(40);
    2.78 +	caret.instantly("&nbsp;&nbsp;&nbsp;&nbsp;");
    2.79 +	caret.keystroke("1. The authors of aurellem, both of whom are are manifestly human, may have directed you, the user, to a nonexistent page.");	
    2.80 +	
    2.81 +	caret.newline();
    2.82 +	caret.prompt();
    2.83 +	caret.stall(40);
    2.84 +	caret.instantly("&nbsp;&nbsp;&nbsp;&nbsp;");
    2.85 +	caret.keystroke("2. The authors of another webpage, many of whom are manifestly human, may have directed you, the user, to a nonexistent page.");
    2.86 +	
    2.87 +	caret.newline();
    2.88 +	caret.prompt();
    2.89 +	caret.stall(40);
    2.90 +	caret.instantly("&nbsp;&nbsp;&nbsp;&nbsp;");
    2.91 +	caret.keystroke("3. You, the user, ");
    2.92 +	caret.stall(40);
    2.93 +	caret.keystroke("manifestly human");
    2.94 +	caret.stall(20);
    2.95 +	caret.keystroke(", may have directed yourself to a nonexistent page.");
    2.96 +	
    2.97 +	
    2.98 +	caret.newline();
    2.99 +	caret.prompt();
   2.100 +	caret.stall(40);
   2.101 +	caret.keystroke("Please be advised that you or another human may have subjected you to malice and/or incompetence by directing you to request a page that does not exist on our servers at this time.");
   2.102 +	caret.stall(20);caret.newline();caret.keystroke("Please be advised that this incident has been reported and that the responsible parties are being determined. ");
   2.103 +caret.stall(40);
   2.104 +	caret.instantly("*****Have a nice day.*****");
   2.105 +	caret.stall(60);
   2.106 +	caret.instantly("<br><br>Connection to aurellem closed.");
   2.107 +}
   2.108 +
   2.109 +
   2.110 +$(document).ready(function(){
   2.111 +	caret = new Caret();
   2.112 +	caret.attach($('body'));
   2.113 +	caret.refresh();
   2.114 +	
   2.115 +	error_404();
   2.116 +
   2.117 +	// blinking cursor
   2.118 +	(function(){caret.blink();setTimeout(String("("+arguments.callee+")()"),500);})();
   2.119 +	// typing text
   2.120 +	(function(){caret.type();setTimeout(String("("+arguments.callee+")()"),40);})();
   2.121 +
   2.122 +	
   2.123 +	
   2.124 +});
   2.125 +
   2.126 +</script>
   2.127 +
   2.128 +</head>
   2.129 +<body>
   2.130 +	testsetahslkfashdljkasdfhkljasdhflskadfhlksadfhlkasdfhlkajsdfhlkasdfhlaksdfhlkjadfhalkjsdfhkalsdfhlkj
   2.131 +	<em>TESERHKSJLDFHKSJLDF</em>
   2.132 +</body>
   2.133 +
   2.134 +</html>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/org/index.org	Mon Oct 17 22:21:38 2011 -0700
     3.3 @@ -0,0 +1,22 @@
     3.4 +#+title: Our Blog Entries
     3.5 +#+STYLE: <link rel="stylesheet" type="text/css" href="./aurellem/src/css/aurellem.css" />
     3.6 +#+INCLUDE: ../templates/level-0.org
     3.7 +
     3.8 +#+begin_HTML
     3.9 +<!--
    3.10 +   This area is replaced with the appropiate list of posts when the blog
    3.11 +   is published.
    3.12 +-->
    3.13 +<div id="posts">
    3.14 +  <ul class="post_list">
    3.15 +    <li>
    3.16 +      POST
    3.17 +    </li>
    3.18 +  </ul>
    3.19 +</div>
    3.20 +<!--
    3.21 +   No other areas of this page are replaced.
    3.22 +-->
    3.23 +#+end_HTML
    3.24 +
    3.25 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/org/level-0.org	Mon Oct 17 22:21:38 2011 -0700
     4.3 @@ -0,0 +1,24 @@
     4.4 +#+BEGIN_HTML
     4.5 +<div class="header">
     4.6 +  <div class="float-right">	
     4.7 +    <!-- 
     4.8 +    <form>
     4.9 +      <input type="text"/><input type="submit" value="search the blog &raquo;"/> 
    4.10 +    </form>
    4.11 +    -->
    4.12 +  </div>
    4.13 +
    4.14 +  <h1>aurellem <em>&#x2609;</em></h1>
    4.15 +  <ul class="nav">
    4.16 +    <li><a href="/">read the blog &raquo;</a></li>
    4.17 +    <!-- li><a href="#">learn about us &raquo;</a></li-->
    4.18 +  </ul>
    4.19 +</div>
    4.20 +
    4.21 +<h1 class="title">{{{title}}}</h1>
    4.22 +<div class="author">Written by <author>{{{author}}}</author></div>
    4.23 +
    4.24 +#+END_HTML
    4.25 +
    4.26 +
    4.27 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/org/publish.org	Mon Oct 17 22:21:38 2011 -0700
     5.3 @@ -0,0 +1,140 @@
     5.4 +#+title: Serving a blog using Clojure
     5.5 +#+author: Robert McIntyre
     5.6 +#+MATHJAX: align:"left" mathml:t path:"../MathJax/MathJax.js"
     5.7 +#+STYLE: <link rel="stylesheet" type="text/css" href="../css/aurellem.css" />
     5.8 +#+BEGIN_HTML
     5.9 +<h1>{{{title}}}</h1>
    5.10 +#+END_HTML
    5.11 +
    5.12 +
    5.13 +* Aurellem Export Program
    5.14 +#+srcname: publish
    5.15 +#+begin_src clojure :results silent
    5.16 +(ns aurellem.publish
    5.17 +  (:use rlm.ns-rlm))
    5.18 +(rlm.ns-rlm/ns-clone rlm.light-base)
    5.19 +(import org.htmlcleaner.HtmlCleaner)
    5.20 +(import org.htmlcleaner.TagNode)
    5.21 +(import java.io.File)
    5.22 +(import java.net.URL)
    5.23 +(import org.apache.commons.io.FileUtils)
    5.24 +(use 'clojure.java.io)
    5.25 +(use 'rlm.sanitize-file)
    5.26 +(use 'net.cgrand.enlive-html)
    5.27 +(use 'rlm.pikasemechu)
    5.28 +(require 'rlm.push)
    5.29 +(use 'clojure.contrib.shell-out)
    5.30 +
    5.31 +(declare publish)
    5.32 +
    5.33 +
    5.34 +(defvar *exports*
    5.35 +  [(file-str "~/aurellem/src/pokemon/types.html")
    5.36 +   (file-str "~/aurellem/src/pokemon/lpsolve.html")
    5.37 +   (file-str "~/aurellem/src/abomination/no_parens.html")
    5.38 +   (file-str "/home/r/aurellem/src/qm/quandary.html")
    5.39 +   (file-str "/home/r/cortex/cortex.html")
    5.40 +   (file-str "/home/r/cortex/capture-video.html")]
    5.41 +  "The html files which will be exported to the auerllem
    5.42 +  website. Listed in the order they will appear on the site
    5.43 +  to add more entries to the site, add them here.")
    5.44 +
    5.45 +(defvar *other-files*
    5.46 +  [(file-str "/home/r/aurellem/src/MathJax/")
    5.47 +   (file-str "/home/r/aurellem/src/css/aurellem.css")
    5.48 +   (file-str "/home/r/aurellem/src/js/jquery.min.js")
    5.49 +   (file-str "/home/r/aurellem/src/aurellem/err.html")
    5.50 +   (file-str "/home/r/cortex/sources/turing.pdf")
    5.51 +   (file-str "/home/r/cortex/images/brick-wall-standing.jpg")
    5.52 +   (file-str "/home/r/cortex/images/brick-wall-knocked-down.jpg")
    5.53 +   (file-str "/home/r/cortex/images/dominos.jpg")
    5.54 +   (file-str "/home/r/cortex/images/simple-app.jpg")]
    5.55 +   
    5.56 +  "other files needed by the website, but which are not posts.")
    5.57 +
    5.58 +(defvar *index*
    5.59 +  (file-str "~/aurellem/src/aurellem/index.html")
    5.60 +  "this is the main index.html file for the site. It will be updated
    5.61 +  with new posts")
    5.62 +
    5.63 +(defvar *site*
    5.64 +  (file-str "~/aurellem/site-output")
    5.65 +  "the target output directoty for the site's content")
    5.66 +
    5.67 +(defvar *export-base* (file-str "~/"))
    5.68 +
    5.69 +(defn target-file [#^File file]
    5.70 +  (file-str
    5.71 +   (.replace (.getCanonicalPath file)
    5.72 +	     (.getCanonicalPath *export-base*)
    5.73 +	     (.getCanonicalPath *site*))))
    5.74 +
    5.75 +(defn title [page]
    5.76 +  (str (.getText (first (tags-by-name (parse page) "title")))))
    5.77 +
    5.78 +(defn link [#^File file]
    5.79 +  (.replace (.getCanonicalPath (target-file file))
    5.80 +	    (.getCanonicalPath *site*)
    5.81 +	    "."))
    5.82 +
    5.83 +(defn rsync-string [#^java.io.File file]
    5.84 +  (if (.isFile file) 
    5.85 +    (.getPath file)
    5.86 +    (str (.getPath file) "/")))
    5.87 +
    5.88 +(defn rsync-local [#^File src #^File dst]
    5.89 +  (let [parent (.getParentFile dst)]
    5.90 +    (if (not (.exists parent))
    5.91 +      ;; rsync won't make parent directories
    5.92 +      (sh "mkdir" "-p" (.getCanonicalPath parent))))
    5.93 +  (sw "rsync" "-avz" "--human-readable" (rsync-string src) (.getCanonicalPath dst)))
    5.94 +
    5.95 +(defn cp [#^File src #^File dst]
    5.96 +  (if (.isDirectory src)
    5.97 +    (FileUtils/copyDirectory src dst)
    5.98 +    (FileUtils/copyFile src dst)))
    5.99 +
   5.100 +(defn copy-site-files 
   5.101 +  "copy all the files in *exports* and *other-files* to the site directory
   5.102 + preserving the folder structure."
   5.103 +  []
   5.104 +  (dorun
   5.105 +   (for [file (concat *other-files* *exports*)]
   5.106 +     (let [source file destination (target-file file)]
   5.107 +	   (rsync-local source destination)))))
   5.108 +
   5.109 +(deftemplate fill-list *index* [posts]
   5.110 +  [:div#posts :ul.post_list :li]
   5.111 +  (clone-for [post posts]
   5.112 +	     (content {:tag :a 
   5.113 +		       :attrs {:href (link post)}
   5.114 +		       :content [(title post)]})))
   5.115 +  
   5.116 +(defn update-index
   5.117 +  "update the index.html post list and write it to the site directory"
   5.118 +  []
   5.119 +  (println "Rebuilding index.html")
   5.120 +  (FileUtils/writeStringToFile 
   5.121 +   (file-str "~/aurellem/site-output/index.html")
   5.122 +   ;; reverse the list to get reverse chronological order for the site.
   5.123 +   (apply str (fill-list *exports*))))
   5.124 +  
   5.125 +(defn publish-local []
   5.126 +  (rlm.rlm-commands/re)
   5.127 +  (copy-site-files)
   5.128 +  (update-index))
   5.129 +
   5.130 +(defn publish-web []
   5.131 +  (publish-local)
   5.132 +  (rlm.push/push "-u" "-t" "slice"))
   5.133 +
   5.134 +
   5.135 +
   5.136 +#+end_src
   5.137 +
   5.138 +
   5.139 +
   5.140 +#+begin_src clojure :results silent :tangle publish.clj :noweb yes :exports none
   5.141 +<<publish>>
   5.142 +#+end_src
   5.143 +