Permalink
Browse files

Importing course gen framework

  • Loading branch information...
dave-andersen committed Jul 4, 2012
0 parents commit 1ce7dca2371580df7973bb72a7837a4370172214
Showing with 4,125 additions and 0 deletions.
  1. +26 −0 README
  2. +37 −0 bin/announce_rss.rb
  3. +173 −0 bin/bibparse.rb
  4. +11 −0 bin/datereplace.rb
  5. +278 −0 bin/mklectures.rb
  6. +40 −0 ex/dga-744/Makefile
  7. +19 −0 ex/dga-744/announcements.srhtml
  8. +100 −0 ex/dga-744/announcements.txt
  9. +52 −0 ex/dga-744/assignments.srhtml
  10. +13 −0 ex/dga-744/bodyhead.srhtml
  11. +136 −0 ex/dga-744/class.bib
  12. +7 −0 ex/dga-744/exams.srhtml
  13. +134 −0 ex/dga-744/index.srhtml
  14. +219 −0 ex/dga-744/lectures.txt
  15. +5 −0 ex/dga-744/pagebottom.srhtml
  16. +9 −0 ex/dga-744/pagehead.srhtml
  17. +170 −0 ex/dga-744/project.srhtml
  18. +17 −0 ex/dga-744/readinglist.head
  19. +13 −0 ex/dga-744/readinglist.tail
  20. +259 −0 ex/dga-744/style.css
  21. +61 −0 ex/dga-744/syllabus.head
  22. +3 −0 ex/dga-744/syllabus.tail
  23. +2 −0 ex/dga-849/bodyhead.srhtml
  24. +1,040 −0 ex/dga-849/class.bib
  25. +41 −0 ex/dga-849/index.srhtml
  26. +168 −0 ex/dga-849/lectures.txt
  27. +5 −0 ex/dga-849/pagebottom.srhtml
  28. +9 −0 ex/dga-849/pagehead.srhtml
  29. +8 −0 ex/dga-849/readinglist.head
  30. +11 −0 ex/dga-849/readinglist.tail
  31. +169 −0 ex/dga-849/style.css
  32. +82 −0 ex/dga-849/syllabus.head
  33. +4 −0 ex/dga-849/syllabus.tail
  34. +125 −0 ex/feamster-7260/class.bib
  35. +166 −0 ex/feamster-7260/lectures.txt
  36. +17 −0 ex/feamster-7260/readinglist.head
  37. +13 −0 ex/feamster-7260/readinglist.tail
  38. +272 −0 ex/feamster-7260/style.css
  39. +76 −0 ex/feamster-7260/syllabus.head
  40. +13 −0 ex/feamster-7260/syllabus.tail
  41. +4 −0 include/doctype.html
  42. +81 −0 include/weblib.rb
  43. +37 −0 www/Makefile
26 README
@@ -0,0 +1,26 @@
+Course web page software.
+Authors: Dave Andersen, Nick Feamster
+
+This program generates the framework for the undergrad and grad networks
+courses that Dave and Nick teach. It produces a syllabus from a simple
+text file describing the lectures, produces announcements and RSS feeds
+of the announcements, links to papers, etc.
+
+To use:
+
+look at one of the example directories.
+Type make
+Copy to your own course directory and adjust the COURSE=
+pointer in the makefile appropriately
+
+Edit lectures.txt
+Edit announcements.txt
+Edit class.bib
+Edit index.srhtml to customize the main page to your desires
+Edit syllabus.head and syllabus.tail to customize per your class
+ ** note: Do not edit syllabus.srhtml or .html directly; it will be
+ overwritten **
+make
+
+You can customize things more by editing the other files. Almost all
+stylistic things (presentation, layout, etc) are controlled by style.css
@@ -0,0 +1,37 @@
+#!/usr/bin/env ruby
+
+require 'yaml'
+require 'rss/2.0'
+require 'rss/maker'
+require 'rss/content'
+
+## Ugly hack to get content stuff with RSS 2.0
+module RSS
+ class RDF
+ class Item; include ContentModel; end
+ end
+end
+
+@ann = YAML::load_file("announcements.txt")
+@conf = YAML::load_file("lectures.txt")
+
+rss = RSS::Maker.make("2.0") do |maker|
+ maker.channel.title = "#{@conf["CLASS_SHORT"]} Announcements"
+ maker.channel.description = "Announcements feed for the #{@conf["CLASS"]} course"
+ maker.channel.link = @conf["COURSE_URL"]
+ maker.encoding = "UTF-8"
+
+ @ann.each { |a|
+ item = maker.items.new_item
+ item.link = "#{@conf["COURSE_URL"]}/announcements.html"
+ item.title = a["T"]
+ item.date = Time.parse(a["D"])
+ item.description = a["C"]
+ }
+ maker.items.do_sort = true
+ maker.items.max_size = 100
+end
+
+File.open("rss2.xml", "w+") do |f|
+ f.print rss
+end
@@ -0,0 +1,173 @@
+#!/usr/bin/env ruby
+
+class BibParse
+ def initialize(bf)
+ @bibfile = bf
+
+ @entries = Hash.new
+ @crossrefs = Hash.new
+ @readinglist = Hash.new
+ @readinglistbytype = Hash.new
+ @strs = Hash.new
+
+ parse
+ end
+
+ def cleanup(val)
+ val.gsub(/\"/, "").gsub(/[\{\}]/, "").sub(/,\s*$/, "")
+ end
+
+
+ def parse
+
+ bibent = nil
+ ref = nil
+
+ IO.foreach("#{@bibfile}") { |l|
+
+ if (l =~ /\@(.*)\{\s*(.*?)\s*,/)
+ type = $1
+ ref = $2
+
+ bibent = Hash.new
+ bibent["type"] = type
+
+ elsif (l =~ /@string\{(.*)\}/i)
+ strdef = $1
+ if (strdef =~ /(\w+)\s*\=\s*(.*)/)
+ strname = $1
+ strval = $2
+ val = cleanup(strval)
+ @strs[strname] = val
+ end
+
+ elsif (l =~ /\s*(\w+)\s*\=\s*(.*)/)
+ key = $1
+ val = $2
+
+ val.gsub!(/\"/, "")
+ val.gsub!(/[\{\}]/, "")
+ val.sub!(/,\s*$/, "")
+ if (@strs[val])
+ val = @strs[val]
+ end
+
+ bibent["#{key}"] = val
+
+ elsif (l =~ /^\}/)
+
+ if (bibent["type"] == "proceedings")
+ @crossrefs[ref] = bibent
+ else
+ @entries[ref] = bibent
+ end
+ end
+ }
+ end
+
+
+ def printHTML(ref, out)
+
+ r = @entries[ref]
+
+ out.puts "#{r["author"]}<br />"
+ out.puts "<a href=\"#{r["url"]}\"><i>#{r["title"]}</i></a><br />"
+
+
+ if (r["crossref"] && r["crossref"].length > 0)
+ cr = @crossrefs[r["crossref"]]
+ else
+ cr = r
+ end
+
+ if (cr["booktitle"] || cr["journal"])
+
+ title = cr["booktitle"]?cr["booktitle"]:cr["journal"]
+ mon = cr["month"] ? cr["month"].capitalize : ""
+ year = cr["year"] || ""
+ out.print "In <i>#{title}</i>, #{mon} #{year}"
+ out.print ", pages #{cr["pages"]}" if cr["pages"]
+ out.print "<br />\n"
+ end
+
+
+# if r["url"]
+# out.puts "<a href=\"#{r["url"]}\">Link</a><br />"
+# end
+
+ end
+
+
+ def setURL(ref,url)
+ if (!@entries[ref])
+ $stderr.puts "URL for undefined reading list entry #{ref}. Creating."
+ $stderr.puts "Create an entry in class.bib to suppress this warning"
+ @entries[ref] = Hash.new
+ end
+ @entries[ref]["url"] = url
+ end
+
+ def addToList(ref, lecent, type=nil)
+ if (!@readinglist[lecent] || @readinglist[lecent].size <= 0)
+ @readinglist[lecent] = Array.new
+ end
+ @readinglist[lecent] << ref
+
+ end
+
+
+ def printReadingList(filename, head=nil, tail=nil)
+
+ out = File.new(filename, "w+")
+
+ out.print IO.read(head) if head
+
+ out.puts "<ul>"
+
+ @readinglist.keys.sort {
+ |x,y| x["lecnum"].to_i <=> y["lecnum"].to_i
+ }.each { |l|
+ out.puts "<li>"
+ out.puts "#{l["date"]} -- Lecture #{l["lecnum"]}: #{l["T"]}<br />"
+
+ out.puts "<ul>"
+
+ @readinglist[l].each { |ref|
+ out.puts "\n<li>"
+ printHTML(ref, out)
+ out.puts "</li>\n"
+ }
+ out.puts "</ul>"
+ out.puts "</li>"
+ }
+ out.puts "</ul>"
+
+ now = Time.new
+ out.puts "<p class=\"lastupdated\">Last Updated #{now}</p>"
+
+ out.print IO.read(tail) if tail
+
+ end
+end
+
+if $0 == __FILE__
+ bp = BibParse.new("./class.bib")
+ bp.setURL("Infranet", "http://foo/")
+
+
+ # add some test entries
+ lecent = Hash.new
+ lecent["date"] = "10/17"
+ lecent["T"] = "Anonymity"
+ bp.addToList("Infranet",lecent)
+
+ lecent = Hash.new
+ lecent["date"] = "10/18"
+ lecent["T"] = "Management"
+ bp.addToList("rcc",lecent)
+
+
+ bp.printReadingList("readinglist.srhtml",
+ "readinglist.head",
+ "readinglist.tail")
+end
@@ -0,0 +1,11 @@
+#!/usr/bin/ruby
+
+now = Time.new
+system("cp #{ARGV[0]} #{ARGV[0]}.tmp")
+f = File.new(ARGV[0], "w+")
+IO.foreach("#{ARGV[0]}.tmp") { |l|
+ l.gsub!(/Updated .*$/,
+ sprintf("Updated %s", now.to_s))
+ f.print l
+}
+system("rm #{ARGV[0]}.tmp")
Oops, something went wrong.

0 comments on commit 1ce7dca

Please sign in to comment.