Recent changes and alternatives
authorchapel <jacob.chapel@gmail.com>
Mon, 14 Nov 2011 23:42:39 +0000 (15:42 -0800)
committerchapel <jacob.chapel@gmail.com>
Mon, 14 Nov 2011 23:42:39 +0000 (15:42 -0800)
app.js
models.js
public/index2.html [new file with mode: 0644]
public/javascripts/main2.js [new file with mode: 0644]

diff --git a/app.js b/app.js
index 2799c583dffecf8ebfb870ff52631e41485036b3..bda679382400c0d60f4a1b1f0cd70a8f5ac849f3 100644 (file)
--- a/app.js
+++ b/app.js
@@ -1548,7 +1548,7 @@ app.post( '/profile', loadUser, loggedIn, function( req, res ) {
 function loadSubject( req, res, next ) {
   if( url.parse( req.url ).pathname.match(/subject/) ) {
     ArchivedSubject.findOne({id: req.params.id }, function(err, subject) {
-      if ( err ) {
+      if ( err || !subject) {
         sendJson(res,  {status: 'error', message: 'Subject with this ID does not exist'} )
       } else {
         req.subject = subject;
@@ -1563,7 +1563,7 @@ function loadSubject( req, res, next ) {
 function loadOldCourse( req, res, next ) {
   if( url.parse( req.url ).pathname.match(/course/) ) {
     ArchivedCourse.findOne({id: req.params.id }, function(err, course) {
-      if ( err ) {
+      if ( err || !course ) {
         sendJson(res,  {status: 'error', message: 'Course with this ID does not exist'} )
       } else {
         req.course = course;
@@ -1603,7 +1603,7 @@ app.get( '/learn/random', loadUser, function( req, res ) {
 
 app.get( '/archive', checkAjax, loadUser, function( req, res ) {
   ArchivedSubject.find({}).sort( 'name', '1' ).run( function( err, subjects ) {
-    if ( err ) {
+    if ( err || subjects.length === 0) {
       sendJson(res,  {status: 'error', message: 'There was a problem gathering the archived courses, please try again later.'} );
     } else {
       sendJson(res,  { 'subjects' : subjects, 'user': req.user.sanitized } );
@@ -1613,7 +1613,7 @@ app.get( '/archive', checkAjax, loadUser, function( req, res ) {
 
 app.get( '/archive/subject/:id', checkAjax, loadUser, loadSubject, function( req, res ) {
   ArchivedCourse.find({subject_id: req.params.id}).sort('name', '1').run(function(err, courses) {
-    if ( err ) {
+    if ( err || courses.length === 0 ) {
       sendJson(res,  {status: 'error', message: 'There are no archived courses'} );
     } else {
       sendJson(res,  { 'courses' : courses, 'subject': req.subject, 'user': req.user.sanitized } );
@@ -1623,21 +1623,22 @@ app.get( '/archive/subject/:id', checkAjax, loadUser, loadSubject, function( req
 
 app.get( '/archive/course/:id', checkAjax, loadUser, loadOldCourse, function( req, res ) {
   ArchivedNote.find({course_id: req.params.id}).sort('name', '1').run(function(err, notes) {
-    if ( err ) {
+    if ( err || notes.length === 0) {
       sendJson(res,  {status: 'error', message: 'There are no notes in this course'} );
     } else {
-      sendJson(res,  { 'notes' : notes, 'course' : req.course, 'user': req.user.sanitized } );
+      notes = notes.map(function(note) { return note.sanitized });
+      sendJson(res,  { 'notes': notes, 'course' : req.course, 'user': req.user.sanitized } );
     }
   })
 })
 
 app.get( '/archive/note/:id', checkAjax, loadUser, function( req, res ) {
   ArchivedNote.findById(req.params.id, function(err, note) {
-    if ( err ) {
+    if ( err || !note ) {
       sendJson(res,  {status: 'error', message: 'This is not a valid id for a note'} );
     } else {
       ArchivedCourse.findOne({id: note.course_id}, function(err, course) {
-        if ( err ) {
+        if ( err || !course ) {
           sendJson(res,  {status: 'error', message: 'There is no course for this note'} )
         } else {
           sendJson(res,  { 'layout' : 'notesLayout', 'note' : note, 'course': course, 'user': req.user.sanitized } );
index e05e4d135bf02b72ebdf915cf5536e095f387b3c..31a41714a4564e4738b614f1dba93bcbe80cb703 100644 (file)
--- a/models.js
+++ b/models.js
@@ -412,6 +412,14 @@ var ArchivedNote = new Schema({
   text: String
 })
 
+ArchivedNote.virtual( 'sanitized' ).get(function() {
+  var note = {
+    _id: this._id,
+    topic: this.topic
+  }
+  return note;
+})
+
 mongoose.model( 'ArchivedNote', ArchivedNote )
 
 var ArchivedSubject = new Schema({
diff --git a/public/index2.html b/public/index2.html
new file mode 100644 (file)
index 0000000..1a5f79a
--- /dev/null
@@ -0,0 +1,411 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+
+       <head>
+               <title>FinalsClub.org</title>
+
+               <!-- XXX Some SEO here would be nice -->
+
+               <link rel='stylesheet' href='/stylesheets/fc2.css'>
+
+               <script type='text/javascript' src='/javascripts/jquery.min.js'></script>
+               <script type='text/javascript' src='/javascripts/es5-shim.min.js'></script>
+               <script type='text/javascript' src='/javascripts/protodiv.js'></script>
+               <script type='text/javascript' src='/javascripts/main.js'></script>
+               <script type='text/javascript' src='/socket.io/socket.io.js'></script>
+
+               <meta name="viewport" content="width=device-width,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0">
+               <meta name="apple-touch-icon" href=""> <!-- XXX -->
+               <meta name="icon" href="">
+
+       </head>
+
+       <body>
+
+               <div class="masthead">
+                       <div class="logbar">
+                               <div class="loginstatus">&nbsp;</div>
+                       </div>
+                       <div class="navbar">
+                               <table>
+                                       <tr>
+                                               <td>
+                                                       <a href="/"><img src="/images/finals-club-wht.png" class="logo"/></a>
+                                               </td>
+                                               <td class="menu">
+                                                       <a href="/schools">Start Here!</a>
+                                                       <a href="http://blog.finalsclub.org">Blog</a>
+                                                       <a href="/archive">Archive</a>
+                                                       <a href="/press">Press</a>
+                                                       <a href="/register">Create an Account</a>
+                                                       <a href="/login" class="special">Login</a>
+                                               </td>
+                                       </tr>
+                               </table>
+                       </div>
+                       <div class="logbar">&nbsp;</div>
+               </div>
+
+               <div id="topofcontent"></div>
+
+
+
+               <div class="content">
+                       <style>
+                               /* The is here is because it's related less to "styling" and more to UI "behavior" */
+                               .page { display: none; }
+                       </style>
+
+
+
+
+                       <div class=page id=pg_home>
+                               <div class="contenthome">
+                                       <div class="tagline">
+                                               <p>
+                                               Welcome to FinalsClub.org, a 501(c)(3) non-profit
+                                               open education project dedicated to helping college
+                                               students collaborate, learn, and share their
+                                               knowledge freely online.
+                                               </p>
+                                               <p>
+                                               Please create an account with your school email address
+                                               to try our tools or browse our course archive to learn
+                                               something new.
+                                               Thank you for helping us improve access to education,
+                                               one lecture at a time.
+                                               </p>
+                                               <p></p>
+                                               <div id="learnsomething" class="button green">Learn something &gt;&gt; </div>
+                                               <p></p>
+                                               <iframe src="http://player.vimeo.com/video/30647271?title=0&amp;byline=0&amp;portrait=0" width="350" height="250" frameborder="0" webkitallowfullscreen="webkitAllowFullScreen" allowfullscreen="allowFullScreen"></iframe>
+                                       </div>
+                               </div>
+                               
+                       </div>
+
+
+
+                       <div class=page id=pg_schools>
+                               <h1>Universities</h1>
+                               <div class="proto school" id=PROTO_school onclick="goPage('/school/___id__')">
+                                       <div class=name>__name__</div>
+                                       <div class=desc>__description__</div>
+                               </div>
+                       </div>
+
+
+
+                       <div class=page id=pg_courses>
+                               <h1>Courses for <span id=school_name></span></h1>
+                               <div class="proto course" id=PROTO_course>
+                                       <div class=dept>__department__</div>
+                                       <div class=name>
+                                               <a href="/course/___id__">__number__: __name__</a>
+                                       </div>
+                               </div>
+                       </div>
+
+
+
+                       <div class=page id=pg_lectures>
+                               <div class="proto lectures_head" id=PROTO_lectures_head>
+                                       <h1>Lectures for Course __number__ : __name__</h1>
+                                       Subject: __subject__<br>
+                                       Department: __department__<br>
+                               </div>
+                               <div class="proto lectures_instructor" id=PROTO_lectures_instructor>
+                                       Instructor: __name__ (__email__)<br>
+                               </div>
+                               <div class="proto lecture" id=PROTO_lecture>
+                                       <div class=name>
+                                               <a href="/lecture/___id__">__name__</a><br>
+                                               Created: __date__<br>
+                                       </div>
+                               </div>
+                       </div>
+
+
+
+                       <div class=page id=pg_notes>
+                               <h1>Notepads </h1>
+                               <div class="proto note" id=PROTO_note>
+                                       <div class=name>
+                                               <a href="/note/___id__">__name__</a>
+                                       </div>
+                               </div>
+                       </div>
+
+
+
+                       <div class=page id=pg_archive_subjects>
+                               <h1>Archived Subjects</h1>
+                               <p>
+                               Please browse our archive of past courses
+                               covered at Harvard from 2008 through 2010.
+                               </p>
+                               <ul>
+                                       <li class=proto id=PROTO_archive_subject>
+                                               <a href="/archive/subject/__id__">__name__</a>
+                                       </li>
+                               </ul>
+
+                       </div>
+
+
+
+                       <div class=page id=pg_archive_courses>
+                               <h1>Archived Courses</h1>
+                               <ul>
+                                       <li class=proto id=PROTO_archive_course>
+                                               <a href="/archive/course/__id__">__name__</a>
+                                       </li>
+                               </ul>
+
+                       </div>
+
+
+
+                       <div class=page id=pg_archive_notes>
+                               <h1>Archived Notes</h1>
+                               <ul>
+                                       <li class=proto id=PROTO_archive_note>
+                                               <a href="/archive/note/___id__">__topic__</a>
+                                       </li>
+                               </ul>
+                       </div>
+
+
+
+                       <div class=page id=pg_archive_note_display>
+                               <div id=PROTO_archive_note_display>
+                                       <h1>__topic__</h1>
+                                       <div>__text__</div>
+                               </div>
+                       </div>
+
+
+
+                       <div class=page id=pg_register>
+                               <h1>Create an Account</h1>
+                               <form id="credentials" action="/register" method="POST">
+                                       <div class="zarea">
+                                               <div class="row">
+                                                       <div class="label">
+                                                               <label for="email">Email</label>
+                                                       </div>
+                                                       <div class="field">
+                                                               <input type="text" name="email">
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">
+                                                               <label for="password">Password</label>
+                                                       </div>
+                                                       <div class="field">
+                                                               <input type="password" name="password">
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">
+                                                               <label for="school">School</label>
+                                                       </div>
+                                                       <div class="field">
+                                                               <select name="school">
+                                                                       <option value="Berkeley">Berkeley</option>
+                                                                       <option value="Brown">Brown</option>
+                                                                       <option value="Columbia">Columbia</option>
+                                                                       <option value="Cornell">Cornell</option>
+                                                                       <option value="Dartmouth">Dartmouth</option>
+                                                                       <option value="Harvard">Harvard</option>
+                                                                       <option value="MIT">MIT</option>
+                                                                       <option value="Princeton">Princeton</option>
+                                                                       <option value="Stanford">Stanford</option>
+                                                                       <option value="UPenn">UPenn</option>
+                                                                       <option value="University of Texas">University of Texas</option>
+                                                                       <option value="Yale">Yale</option>
+                                                                       <option value="Other">Other</option>
+                                                               </select>
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">
+                                                               <label for="name">Name</label>
+                                                       </div>
+                                                       <div class="field">
+                                                               <input type="text" name="name">
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">
+                                                               <label for="affil">Affiliation</label>
+                                                       </div>
+                                                       <div class="field">
+                                                               <select name="affil">
+                                                                       <option value="Student">Student</option>
+                                                                       <option value="Teachers Assistant">Teachers Assistant</option>
+                                                               </select>
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">
+                                                               &nbsp;
+                                                       </div>
+                                                       <div class="field">
+                                                               <button>Register</button>
+                                                       </div>
+                                               </div>
+                                       </div>
+                               </form>
+                       </div>
+
+
+
+                       <div class=page id=pg_login>
+                               <h1>Login</h1>
+                               <form id="credentials" action="/login" method="POST">
+                                       <div class="zarea">
+                                               <div class="row">
+                                                       <div class="label">
+                                                               <label for="email">Email</label>
+                                                       </div>
+                                                       <div class="field">
+                                                               <input type="text" name="email" size="15" value="joe@sleepless.com">
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">
+                                                               <label for="password">Password</label>
+                                                       </div>
+                                                       <div class="field">
+                                                               <input type="password" name="password" size="15">
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">&nbsp;
+                                                       </div>
+                                                       <div class="field">
+                                                               <button class="major">Login</button>
+                                                               <span class="reglink">
+                                                                       <a href="/resetpw">Forgot password?</a>
+                                                               </span>
+                                                       </div>
+                                               </div>
+                                               <div class="row">
+                                                       <div class="label">&nbsp;
+                                                       </div>
+                                                       <div class="field">
+                                                               <span class="reglink">
+                                                                       <a href="/register">Create an Account</a>
+                                                               </span>
+                                                       </div>
+                                               </div>
+                                       </div>
+                               </form>
+                       </div>
+
+
+                       <div class=page id=pg_conduct>
+                               <div class="conduct">
+                                       <h1>Code of Conduct</h1>
+                                       <p class="academic">
+                                               <img src="/images/keep-it-academic.png" alt="Keep it academic.">
+                                       </p>
+                                       <p class="vague">
+                                               This directive is deliberately vague to
+                                               accommodate creative humor, insight, and exploration.<br>
+                                               Disruptive or irrelevant material, however,
+                                               will be subject to removal.<br>
+                                               Just keep it academic, and we'll all be better off.<br>
+                                       </p>
+                               </div>
+                       </div>
+
+
+
+
+                       <div class=page id=pg_press>
+                               <h1>FinalsClub in the Press</h1>
+                               <div class="press">
+                                       <img src="/images/boston.com.png" class="press">
+                                       <p class="date">December 13, 2009</p>
+                                       <p>Plenty of Harvard graduates have traded on the fame and prestige of their alma mater, but few have done so the way Andrew Magliozzi has. The year he graduated, 2005, he started a tutoring company located steps from Harvard Yard, with a name, Veritas, that is the motto of his storied alma mater.</p>
+                                       <p>Then, two years ago, Magliozzi started up a side project called Finalsclub.org.</p>
+                                       <p class="readmore">
+                                       <a href="http://www.boston.com/bostonglobe/ideas/articles/2009/12/13/freeharvardeducationcom">Read more ...</a>
+                                       </p>
+                               </div>
+                               <hr>
+                               <div class="press">
+                                       <img src="/images/harvard-crimson.jpg" class="press">
+                                       <p class="date">Wednesday, February 18, 2009</p>
+                                       <p>A rapidly growing course preparatory Web site, FinalsClub.org, is moving forward with a plan to expand its site in spite of controversy over the legality of the venture. </p>
+                                       <p>The Web site, which allows students to share notes, create study groups, and blog about lectures and sections, recently hired 10 Harvard College students to serve as BETA testers for the site. </p>
+                                       <p class="readmore">
+                                       <a href="http://www.thecrimson.com/article/2009/2/18/finalscluborg-passes-punch-span-stylefont-weight-boldcorrection">Read more ...</a>
+                                       </p>
+                               </div>
+                               <hr>
+                               <div class="press">
+                                       <img src="/images/blown-to-bits.png" class="press">
+                                       <p class="date">September 27th, 2009</p>
+                                       <p>Computer Science professor and former Dean of Harvard, Harry Lewis, embraces FinalsClub's work and its guiding principle of open education.  Even as Harvard University has not been wholly sympathetic to the FinalsClub mission, invoking the Copyright Act of 1976, assuming a similar position to other major institutions such as University of Texas, Lewis supports working towards the proverbial "temple of the free exchange of ideas."  A course he taught in the Harvard Extension School was also shared freely online.  </p>
+                                       <p class="readmore">
+                                       <a href="http://www.bitsbook.com/2009/09/a-harvard-skirmish-in-the-copyright-wars">Read more ...</a>
+                                       </p>
+                               </div>
+                       </div>
+
+
+
+
+                       <div class=page id=pg_notfound>
+                               <h1>Page Not Found</h1>
+                               Sorry, there is no content for this page.
+                       </div>
+
+
+
+
+               </div>
+
+
+
+
+               <div class="footer">
+                       <table>
+                               <tr>
+                                       <td class="col1">
+                                               <div class="logo">
+                                                       <img src="/images/finals-club-wht.png" title="FinalsClub.org" class="lilogo"/>
+                                               </div>
+                                               <div>Copyright 2011</div>
+                                               <div>All Rights Reserved</div>
+                                       </td>
+                                       <td class="col2">
+                                               <a href="/conduct">Code of Conduct</a>
+                                               <a href="http://blog.finalsclub.org/about.html">About</a>
+                                               <a href="http://blog.finalsclub.org/contact.html">Contact</a>
+                                               <a href="http://blog.finalsclub.org/legal.html">Legal</a>
+                                               <a href="http://blog.finalsclub.org/team.html">Team</a>
+                                       </td>
+                               </tr>
+                       </table>
+               </div>
+               <div class="footerer">
+                       <p>
+                               This work is licensed under a
+                               Creative Commons Attribution-ShareAlike 3.0
+                               United States License
+                       </p>
+                       <p>
+                               <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/us/"><img alt="Creative Commons License" style="border-width:0" src="http://i.creativecommons.org/l/by-sa/3.0/us/88x31.png"/></a>
+                               <a href="http://mixpanel.com/f/partner"><img alt="Real Time Web Analytics" src="http://mixpanel.com/site_media/images/partner/badge_blue.png" style="border-width:0;margin:2px;"/></a>
+                       </p>
+               </div>
+
+
+
+
+       </body>
+</html>
diff --git a/public/javascripts/main2.js b/public/javascripts/main2.js
new file mode 100644 (file)
index 0000000..41b9f0f
--- /dev/null
@@ -0,0 +1,376 @@
+
+/*
+
+This is the core logic for the main page.
+It implements most page transitions by showing and hiding DIV elements
+in the page with javascript+jquery
+
+*/
+
+
+/* Convert a JSON string to an object, or null if unparseable */
+function j2o(json) { try { return JSON.parse(json); } catch(e) { return null; } }
+
+/* Convert an object to a JSON string (just easier to type than "JSON.stringify" */
+function o2j(obj) { return JSON.stringify(obj); }
+
+
+
+function showHome(cb) {
+       cb("home");
+}
+
+
+
+// go to the page that lists the schools
+function showSchools(response, cb) {
+
+  var path = window.location.pathname;
+
+       ProtoDiv.reset("PROTO_school");
+
+
+      var schools = []
+      if(typeof response == 'object') {
+        schools = response.schools
+      }
+
+      ProtoDiv.replicate("PROTO_school", schools);
+
+      cb("schools");
+
+}
+
+
+
+// go to the page that lists the courses for a specific school
+function showCourses(response, cb) {
+
+  var path = window.location.pathname;
+
+
+       ProtoDiv.reset("PROTO_course");
+
+               var courses = []
+               if(typeof response == 'object') {
+                       var school = response.school
+                       $("#school_name").html(school.name);
+                       courses = school.courses
+               }
+
+               ProtoDiv.replicate("PROTO_course", courses);
+
+               cb("courses")
+}
+
+
+
+
+// go to the page that lists the lectures for a specific course
+function showLectures(response, cb) {
+
+  var path = window.location.pathname;
+  
+
+       ProtoDiv.reset("PROTO_lecture");
+       
+               ProtoDiv.reset("PROTO_lectures_head")
+               ProtoDiv.reset("PROTO_lectures_instructor")
+               ProtoDiv.reset("PROTO_lecture")
+
+               if(typeof response == 'object') {
+
+                       var course = response.course
+                       if(course)
+                               ProtoDiv.replicate("PROTO_lectures_head", [course])
+
+                       var instructor = response.instructor
+                       if(instructor)
+                               ProtoDiv.replicate("PROTO_lectures_instructor", [instructor])
+
+                       var lectures = response.lectures
+                       if(lectures)
+                               ProtoDiv.replicate("PROTO_lecture", lectures);
+
+               }
+
+               cb("lectures")
+}
+
+
+
+// go to the page that lists the note taking sessions for a specific lecture
+function showNotes(response, cb) {
+
+  var path = window.location.pathname;
+
+
+       ProtoDiv.reset("PROTO_note");
+       
+               if(typeof response == 'object') {
+
+                       var course = response.course
+                       //if(course)
+                       //      ProtoDiv.replicate("PROTO_lectures_head", [course])
+
+                       var instructor = response.instructor
+                       //if(instructor)
+                       //      ProtoDiv.replicate("PROTO_lectures_instructor", [instructor])
+
+                       var lecture = response.lecture
+                       //if(lecture)
+                       //      ProtoDiv.replicate("PROTO_lecture", lectures);
+
+                       var notes = response.notes
+                       if(notes)
+                               ProtoDiv.replicate("PROTO_note", notes);
+
+               }
+
+               cb("notes")
+}
+
+
+// go to the page that lists the archived subject names
+function showArchiveSubjects(response, cb) {
+
+  var path = window.location.pathname;
+
+       ProtoDiv.reset("PROTO_archive_subject")
+
+               var subjects = response.subjects
+
+               ProtoDiv.replicate("PROTO_archive_subject", subjects)
+
+       cb("archive_subjects")
+}
+
+
+
+function showArchiveCourses(response, cb) {
+
+  var path = window.location.pathname;
+
+
+       ProtoDiv.reset("PROTO_archive_course")
+
+               var courses = response.courses
+
+               ProtoDiv.replicate("PROTO_archive_course", courses)
+
+       cb("archive_courses")
+}
+
+
+
+function showArchiveNotes(response, cb) {
+
+  var path = window.location.pathname;
+
+
+       ProtoDiv.reset("PROTO_archive_note")
+
+               var notes = response.notes
+               $.each(notes, function(i, note) {
+                       if(!note.topic)
+                               note.topic = note._id//note.text.substr(0, 15)+" ..."
+               })
+
+               ProtoDiv.replicate("PROTO_archive_note", notes)
+
+       cb("archive_notes")
+}
+
+
+
+function showArchiveNote(response, cb) {
+
+  var path = window.location.pathname;
+
+
+       ProtoDiv.reset("PROTO_archive_note_display")
+
+               var note = response.note
+note = { text: "Hi <i>Mom!</i>", topic: "21st Century Greetings" }
+               if(!note.topic)
+                       note.topic = note.text.substr(0, 15)+" ..."
+
+               ProtoDiv.replicate("PROTO_archive_note_display", note)
+
+       cb("archive_note_display")
+}
+
+
+
+// go to the account registration page
+function showRegister(response, cb) {
+       // xxx clear fields?
+       // xxx change FORM to use AJAX
+       cb("register");
+}
+
+
+function showLogin(response, cb) {
+       cb("login");
+}
+
+
+
+
+// go to the press articles page
+function showPress(response, cb) {
+       cb("press");
+}
+
+
+// go to the "code of conduct" page
+function showConduct(response, cb) {
+       cb("conduct");
+}
+
+
+
+
+var pageVectors = [
+       { regex: /^\/(index.html)?$/, func: showHome },
+       { regex: /^\/schools/, func: showSchools },
+       { regex: /^\/school\/([a-f0-9]{24})/, func: showCourses },
+       { regex: /^\/course\/([a-f0-9]{24})/, func: showLectures },
+       { regex: /^\/lecture\/([a-f0-9]{24})/, func: showNotes },
+       { regex: /^\/archive\/?$/, func: showArchiveSubjects },
+       { regex: /^\/archive\/subject\/([0-9]+)/, func: showArchiveCourses },
+       { regex: /^\/archive\/course\/([0-9]+)/, func: showArchiveNotes },
+       { regex: /^\/archive\/note\/([0-9]+)/, func: showArchiveNote },
+       { regex: /^\/login/, func: showLogin },
+       { regex: /^\/register/, func: showRegister },
+       { regex: /^\/press/, func: showPress },
+       { regex: /^\/conduct/, func: showConduct },
+];
+
+var testVectors = {
+  schools: showSchools,
+  school: showCourses,
+  course: showLectures,
+  lecture: showNotes,
+  archive: showArchiveSubjects,
+  archivesubject: showArchiveCourses,
+  archivecourse: showArchiveNotes,
+  archivenote: showArchiveNote,
+  login: showLogin,
+  press: showPress,
+  conduct: showConduct
+}
+
+/* Do and show the appropriate thing, based on the pages current URL */
+function showPage(y) {
+
+       var path = document.location.pathname
+
+  var mainSlug = path.match(/((?:[a-z][a-z]+))/) ? path.match(/((?:[a-z][a-z]+))/)[1].toLowerCase() : '';
+  if (mainSlug === 'archive') {
+    var archiveSlugs = path.match(/((?:[a-z][a-z]+))\/((?:[a-z][a-z0-9_]*))/);
+    if (archiveSlugs) {
+      mainSlug = mainSlug + archiveSlugs[2];
+    }
+  }
+
+       $(".page").hide(); //(100);             // hide all pseudo pages
+
+  if (testVectors[mainSlug]) {
+    return $.get(path, { cache: false }, function(response) {
+      if (response.status === 'error') {
+        console.log(response.message)
+        $("#pg_notfound").fadeIn(100);
+        window.scroll(0, 0)
+        return;
+      }
+      testVectors[mainSlug](response, function(pageId) {
+        $("#pg_"+pageId).fadeIn(100);
+        window.scroll(0, y)
+      })
+    });
+  } else if (path === '/') {
+    return showHome(function(pageId) {
+      $("#pg_"+pageId).fadeIn(100);
+      window.scroll(0, y)
+    })
+  }
+
+  $("#pg_notfound").fadeIn(100);
+  window.scroll(0, 0)
+  /*
+       for(var i = 0; i < pageVectors.length; i++) {
+               var vector = pageVectors[i]
+               var matches = path.match(vector.regex)
+               if(matches) {
+                       vector.func(function(pageId) {
+
+                               $("#pg_"+pageId).fadeIn(100);
+
+                               window.scroll(0, y)
+
+                       })
+                       break
+               }
+       }
+  
+
+       if(i == pageVectors.length) {
+       }
+       // scroll to top of page (as if we'd done a real page fetch)
+       /*$('html, body').animate({
+               scrollTop: $("#topofcontent").offset().top
+       }, 100);*/
+
+}
+
+
+
+
+/* Simulates a page load.
+       'path' is something like "/schools", etc.
+       A page fetch doesn't really happen.
+       Based on what path looks like, an appropriate DIV is shown, and action taken
+*/
+var topQueue = [0]
+function goPage(path) {
+       var y = 0 + window.pageYOffset
+       topQueue.push(y)
+       history.pushState({}, path, path);
+       showPage(0);
+}
+
+
+/* Simulates a "back" browser navigation.  */
+function goBack(event) {
+       var y = topQueue.pop()
+       showPage( y );
+}
+
+
+       window.onpopstate = goBack
+
+  $('a[href^=/]').live('click', function(e) {
+    var path = e.target.pathname || '/';
+    var checkNote = path.match(/((?:[a-z][a-z]+))/);
+    if (checkNote && checkNote[1] == 'note') {
+      return true;
+    } else {
+      goPage(path)
+      return false;
+    }
+  })
+$(document).ready(function() {
+
+       // This code executes after the page has been fully loaded
+
+
+       // xxx older FF browsers don't fire a page load/reload - deal with it somehow.
+       // showPage( 0 );               // needed for some older browsers, redundant for chrome
+
+})
+
+
+
+
+