From: W. Trevor King Date: Tue, 22 Sep 2009 19:06:34 +0000 (-0400) Subject: Lots of changes to make installation more flexible & user friendly. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8a4d469c74adac4e12fe9e2056d4ed3442d65ed3;p=course.git Lots of changes to make installation more flexible & user friendly. Generalized out a lot of the leftover phys201 content, replacing it with dummy content. Now the test coursepage doesn't reveal any email addresses, names of real people, etc. Moved all the course information that used to be spread through the text of index.shtml and in quarter.php over to a new course.xml file. This provides a centralized location for updates, which are then included in the page bodies and headers for free :). Tagged locations of example patter and dummy information in the html directory with "...", so you won't miss any dummy info if you adjust things near the locations turned up by a grep -r '[.][.][.]' html/ Reactivated contact.shtml and redirected the Contact links to point to it, because most users will not have a contact page in the parent directory as I do. announcements.shtml now handles a missing atom.xml gracefully, which I imagine will be a common occurrence for new users. Assorted updates to README files, as well as the addition of REAMDE.newbie, which I phrased to be more supportive to the HTML-wary ;). Added html-includes.sh, which adapts the standard source to handle some SSI-parsing problems that poke up occasionally. I don't know why yet, but the adjusted source avoids them. Added local-install.sh, which adapts the standard source to handle INSTALL_DIR on the same host as the source. See the comments at the top of both shell scripts for more details. --- diff --git a/Makefile b/Makefile index 69702dd..52f85a7 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ INSTALL_HOST = einstein INSTALL_USER = wking -INSTALL_DIR = public_html/courses/phys201_s09 +INSTALL_DIR = public_html/courses/test SOURCE_DIR := $(INSTALL_DIR)/source # := to avoid shifting with $INSTALL_DIR FRAMEWORK_SUBDIR = html -CONTENT_SUBDIRS = announcements latex +CONTENT_SUBDIRS = #announcements latex SUBDIRS = $(FRAMEWORK_SUBDIR) $(CONTENT_SUBDIRS) export INSTALL_HOST diff --git a/README b/README index ba9a1be..b7b945d 100644 --- a/README +++ b/README @@ -1,9 +1,9 @@ This is an attempt at an organized, open source, course website. The idea is that a course website consists of a static HTML framework and -a bunch of content that is gradually filled in as the semester/quarter -progresses. I've put the HTML framework in the HTML directory, along -with some of the write-once-per-course content (e.g. Prof & TA info). -See html/README for more information on the layout of the HTML. +a bunch of content that is gradually filled in as the term progresses. +I've put the HTML framework in the HTML directory, along with some of +the write-once-per-course content (e.g. Prof & TA info). See +html/README for more information on the layout of the HTML. The rest of the directories contain the code for compiling material that is deployed as the course progresses. The announcements diff --git a/README.newbie b/README.newbie new file mode 100644 index 0000000..cc51fa4 --- /dev/null +++ b/README.newbie @@ -0,0 +1,115 @@ +Course Web-admin, + +This is the framework I used for the Phys201 course in the winter of +2008-2009, and I think it works pretty well. The workflow is, +however, a bit different than anything I've found elsewhere, so I'll +explain how it works for me below. Feel free to email me with any +questions or problems. + +~/src/ +====== + +The source for the website (and a bunch of LaTeX problems/solutions +I've written up over the last few years as a TA), are all over in +~/src/, and in my own work I make all my changes there and then run +"make" in the ~/src/ directory to push the changes to ~/public_html, +which is the actively served directory. This is mostly to allow +automatic compiling and installation of my LaTeX solutions. You can +look around in ~/src/ if you like, but if it's too confusing, I +suggest you stick to handling ~/public_html directory. + +~/public_html/ and overview +=========================== + +~/public_html/ contains assorted *.shtml files, each of which +corresponds to one of the course pages. They all use Server Side +Includes (SSI) to include headers and footers stored in + ~/public_html/shared/ +which take care of a lot of HTML boilerplate. If you want to add +content to any of the pages, just hack away on the appropriate *.shtml +file (for example, see labs.shtml). You'll definitely want to flesh +out the content in index.shtml (the main page) with appropriate course +details. + +Inside many of the *.shtml files are tags. These tags use +PHP to include all the site's dynamic content. I suggest you leave +them alone. You won't have to worry about the PHP code itself, but +you will have to supply those scripts with content to parse. This +content lives in ~/public_html/xml/ and ~/public_html/docs. + +~/public_html/xml/ +================== + +profs.xml, TAs.xml, and course.xml are pretty clear. Just fill in the +XML as appropriate for the course. webmaster.xml is even easier, +since you don't have to look up your own information. + +atom.xml is an atom feed (which is also parsed by atom.php to fill in +the announcements page). I wrote a command line atom feed generator +"atomgen", which I've installed for you. Run + atomgen --help +and + atomgen add --help +to see information about how to add to the atom.xml I've already +created. For example, to add a comment saying you'd posted the +first set of homework solutions, you might run + echo "Homework 1 solutions posted. Hope you didn't have too much trouble." | \ + atomgen -o ~/public_html/xml/atom.xml add -i ~/public_html/atom.xml \ + "Homework 1 solutions posted." \ + "http://www.physics.drexel.edu/~phys201admin/homeworks.shtml#s1" +where we use echo and the pipe (|) to pass the content for the post in +via atomgen's stdin. + +~/public_html/doc/ +================== + +Each of the *.shtml pages except index.shtml, content.shtml, and +announcements.shtml (whose content we've already discussed) has a call +to printSectionDocs() in its PHP. This call links in data from the +~/public_html/doc/. The syntax is + printSectionDocs($title, $directory, $startswith, $maxnum); +for example + printSectionDocs('Lecture', 'doc/lec', 'lec', 20); +which searches through $directory (doc/lec) for any files of the form +$startswith$index_* (lec5_slides.pdf) and links to them, calling them +* (slides.pdf). $maxnum makes it easy for printSectionDocs() to +reference the files newest-to-oldest, finding files with +0 < $index <= $maxnum. $title sets the headings of the per-index +blurbs. + +To make the system work, you just drop your content into (for example) + ~/public_html/doc/lec/ +with appropriate file names, and links show up on lectures.shtml +automatically. Because of the automatic linking, make sure you it's +OK to post the information (e.g. exam solutions) BEFORE you place them +in the doc/ tree. + +To keep everything organized, I've also added doc/note to store things +like a course syllabus.pdf, and write the link by hand in index.html's +list of course resources. + +In the past, I've used + doc/lec/ for lecture notes/slides. + doc/rec/ for recitation problems and solutions. + doc/lab/ for lab procedures and prelabs. + doc/hwk/ for homework problems and solutions. + doc/exams/ for exam solutions. +but it should be pretty clear what to change if you want to fiddle +with that layout. + +style +===== + +I haven't spent much time making everything look all pretty, so +there's surely room for improvement if you like playing with CSS. + + +And that's it! + +Good luck, +Trevor + + +p.s. don't worry about what's in ~/bin/ or ~/lib/ unless you want to. +They're there so you have atomgen and it works, but are not important +for website maintenance. diff --git a/html-includes.sh b/html-includes.sh new file mode 100755 index 0000000..4815fb9 --- /dev/null +++ b/html-includes.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# I've occasionally had problems with .shtml inclusion for the header +# and footer. Since there's not any processing going on in those +# files, they can be straight .html instead. This script makes the +# necessary adjustments. +# +# In one installation, the errors raised in the apache logs were +# unable to include potential exec +# since the SSI handler was attempting to parse the header/footer as +# well. I'm not sure why it had a problem with that, but changing +# them to .html files means the SSI handler will no longer try to +# parse them and you avoid the problem. +# +# +# Usage: ./html-includes.sh + +set -e # exit immediately on failed command +set -o pipefail # pipes fail if any stage fails +set -v # verbose, echo commands to stdout + + +for FILE in $(ls html/shared/ | grep '.shtml$'); do + mv -v "html/shared/${FILE}" "html/shared/${FILE/shtml/html}" + for CALLER in html/*.shtml; do + # correct links for callers + sed -i "s/shared\/$FILE/shared\/${FILE/shtml/html}/" "$CALLER" + done +done + diff --git a/html/README b/html/README index b01d1a9..5bdeeba 100644 --- a/html/README +++ b/html/README @@ -23,8 +23,9 @@ run-time, the served page will always reflect the current xml data. ** Course Information ** Add appropriate entries to the course.xml file in the xml directory. -The course xml file is formatted by quarter.php, and maybe a few more -in the future. +The course xml file is read by course.php. See the title of +index.shtml for an example of how to use this information dynamically +in your HTML. **** Dynamic information **** diff --git a/html/announcements.shtml b/html/announcements.shtml index 0175860..9ae7d02 100644 --- a/html/announcements.shtml +++ b/html/announcements.shtml @@ -1,8 +1,11 @@ diff --git a/html/inactive/contact.shtml b/html/contact.shtml similarity index 100% rename from html/inactive/contact.shtml rename to html/contact.shtml diff --git a/html/inactive/labs.shtml b/html/inactive/labs.shtml index 3abfa6a..e38a670 100644 --- a/html/inactive/labs.shtml +++ b/html/inactive/labs.shtml @@ -3,8 +3,8 @@

Labs

diff --git a/html/php/atom.php b/html/php/atom.php index 5990683..6a4d4ce 100644 --- a/html/php/atom.php +++ b/html/php/atom.php @@ -21,6 +21,11 @@ function printContent($xml_data){ function printAtom($feed_title, $feed, $ignored_title){ echo "

$feed_title

\n\n"; + if ($feed == NULL) { + echo "

No entries yet

\n"; + return; + } + /* convert entries to an array (from some sort of iterable) */ $entries = array(); foreach($feed->entry as $entry) diff --git a/html/php/course.php b/html/php/course.php new file mode 100644 index 0000000..12c3043 --- /dev/null +++ b/html/php/course.php @@ -0,0 +1,32 @@ +title = $s->title; + $this->subject_code = $s->subjectcode; + $this->number = $s->number; + $this->term = $s->term; + $this->url = $s->url; + } + public function course_id() { // (e.g. "Physics 101") + return $this->subject_code.' '.$this->number; + } +} + +// index.shtml lives in level 0, shared/header.shtml lives in level 1, etc. +function course($level=0) { + $path = 'xml/course.xml'; + while ($level > 0) { + $path = '../'.$path; + $level -= 1; + } + return new Course($path); +} + +?> diff --git a/html/php/quarter.php b/html/php/quarter.php deleted file mode 100644 index 59d38f2..0000000 --- a/html/php/quarter.php +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/html/php/webmaster.php b/html/php/webmaster.php index fba3f4e..d816447 100644 --- a/html/php/webmaster.php +++ b/html/php/webmaster.php @@ -1,9 +1,9 @@ name; diff --git a/html/shared/footer.shtml b/html/shared/footer.shtml index 3d5e456..4e92c0a 100644 --- a/html/shared/footer.shtml +++ b/html/shared/footer.shtml @@ -10,8 +10,10 @@

- Copyright © W. Trevor King.
- This material is released under the GNU FDL. + This website is based on W. Trevor King's course-site package, Copyright + © W. Trevor King.
+ Released under the GNU FDL.

Validate xhtml diff --git a/html/shared/header.shtml b/html/shared/header.shtml index a525627..ff9f7a6 100644 --- a/html/shared/header.shtml +++ b/html/shared/header.shtml @@ -3,13 +3,16 @@ +course_id(); +?> + - - + + -Phys201 +<?=$cid?> @@ -37,8 +47,10 @@