[xiph-cvs] r6604 - in websites-ngen: . xiph.org xiph.org/CSS

comatoast at xiph.org comatoast at xiph.org
Tue May 4 21:29:56 PDT 2004



Author: comatoast
Date: 2004-04-29 02:13:16 -0400 (Thu, 29 Apr 2004)
New Revision: 6604

Added:
   websites-ngen/xiph.org/aftermaintext.include
   websites-ngen/xiph.org/inhead.include
Modified:
   websites-ngen/todo.txt
   websites-ngen/wrapup.py
   websites-ngen/xiph.org/CSS/all.css
Log:
This version adds the "try the parents' includes if there's none here" functionality.

I don't /think/ the comments lie.

More fiddling with the stylesheet. Note to self: Never test colors on this laptop screen.

<p>Modified: websites-ngen/todo.txt
===================================================================
--- websites-ngen/todo.txt	2004-04-28 20:58:47 UTC (rev 6603)
+++ websites-ngen/todo.txt	2004-04-29 06:13:16 UTC (rev 6604)
@@ -7,11 +7,7 @@
 *	After I've implemented that, I need a way for this sort of thing to "use whatever my
         ancestors used", kinda like an OO derivation thing.
 
-*	Anyhow, for this out-of-band data thing: In it, I'd have stuff for:
-	*	Extra things to put in <head>
-	*	Extra things to put **before** `<div id='content'>`
-	*	Extra things to put **after**  `<div id='content'>`
-	* 	Maybe a partially-automated way to do next and previous <link rel='...'> bits.
+* 	Maybe a partially-automated way to do next and previous <link rel='...'> bits.
         Maybe I could use PyYaml. Although that's probably serious overkill.
 
 *	We need a tagline. Lame starter: "Compressing your media into byte-size chunks"
@@ -30,16 +26,3 @@
 *	News items must be able to be placed in multiple categories; the oggenc that shipped with
         the 1.0.1 release that could encode to vorbis from flac should be mentioned in both
         the "vorbis" and "flac" sections.
-
-File Structure :
---------------
-
-	/
-	 inhead.include
-	 beforecontent.include
-	 content.markdown
-	 aftercontent.include
-
-	 						/vorbis/ (for example
-							 inhead.include (adding styles)
-

Modified: websites-ngen/wrapup.py
===================================================================
--- websites-ngen/wrapup.py	2004-04-28 20:58:47 UTC (rev 6603)
+++ websites-ngen/wrapup.py	2004-04-29 06:13:16 UTC (rev 6604)
@@ -20,6 +20,7 @@
 #    3. This notice may not be removed or altered from any source distribution.
 
 import os, re, sys, glob, os.path
+import pdb
 MARKDOWN_COMMAND = "Markdown" # could also be "Markdown.pl"
 TITLE_REGEX = re.compile(r"<h1.*>(.*)</h1>")
 class MarkdownWrapper(object):
@@ -82,21 +83,20 @@
                 
                 # this if cascade is ugly, ugly, ugly, ugly. Suggestions, please.
                 
-		for filename in includerList:
-			filename = getParallelFile(self.sourceFilename, filename)
-			print filename
+		for baseFilename in includerList:
+			filename = getParallelFile(self.sourceFilename, baseFilename)
+#			if filename.endswith('aftermaintext.include'): pdb.runcall(getParentedFile, filename)
+			filename = getParentedFile(filename)
+			if not filename: continue
+			
+			print filename	
                         if os.path.isfile(filename):
                                 contents = file(filename).read()
-				print contents
                                 if filename.endswith('inhead.include'):			self.inHead			= contents
                                 if filename.endswith('beforecontent.include'):	self.beforeContent	= contents
                                 if filename.endswith('aftermaintext.include'):	self.afterMainText	= contents
                                 if filename.endswith('aftercontent.include'):	self.afterContent 	= contents
 
-		print "self.inHead: ", self.inHead
-		
-		# todo: similarly to append, say, copyright.inc to afterMainTextBits
-
         def renderToFile(self):
                 outfile = file(self.destFilename, "w")
                 try:
@@ -141,6 +141,65 @@
         """
         return os.path.join(os.path.split(where)[0], what)
 
+def hasTwoDirseps(path):
+	firstIndex = path.find(os.sep)
+	if firstIndex == -1: return False
+
+	secondIndex = path.find(os.sep, firstIndex+1)
+	if secondIndex == -1: return False
+
+	return True
+def getParentedFile(filename):
+	r"""
+	given a path to a file, say, /meals/breakfast/sausage/index.html, tries to return
+	the first valid file of:
+		/meals/breakfast/sausage/index.html
+		/meals/breakfast/index.html
+		/meals/index.html
+		/index.html
+	Or given .\meals\breakfast\eggs\index.html:
+		.\meals\breakfast\eggs\index.html
+		.\meals\breakfast\index.html
+		.\meals\index.html
+		.\index.html
+	Or even given cheeses\france\brie.html:
+		cheeses\france\brie.html
+		cheeses\brie.html
+		brie.html	
+
+	"""
+	while True:
+		# okay, we need to abort out on two conditions:
+		# 1) we found a valid path
+		# 2) we've gone as far as we can, and there is no valid path
+		if os.path.isfile(filename): return filename
+
+		# There is no parented file if there's only one separator in the path
+		if filename.find(os.sep) == -1:
+			return ""
+
+
+		# if the full string has two directory separators in it or more, then
+		# there are still intermediate directories to back up through.
+		# We need to chop out the thing just before the last dirsep,
+		# but end just before the penultimate dirsep.
+		if hasTwoDirseps(filename):
+			indexOfLastDirsep = filename.rfind(os.sep)
+			indexOfPenultimateDirsep = filename.rfind(os.sep, 0, indexOfLastDirsep)
+			filename = filename[:indexOfPenultimateDirsep] + filename[indexOfLastDirsep:]
+			if os.path.isfile(filename): return filename
+		elif filename.find(os.sep) > -1:
+			# If it has only one dirsep, then it's one of the following forms (modulo / vs. \)
+			#	* /foo.html
+			#	* ./foo.html
+			if os.path.isfile(filename): return filename
+			else: return ""
+		else:
+			if os.path.isfile(filename): return filename
+			else: return ""
+
+		
+
 if __name__ == '__main__':
         for dirpath, dirnames, filenames in os.walk('xiph.org'):
                 # bug if more than one .markdown file in a directory

Modified: websites-ngen/xiph.org/CSS/all.css
===================================================================
--- websites-ngen/xiph.org/CSS/all.css	2004-04-28 20:58:47 UTC (rev 6603)
+++ websites-ngen/xiph.org/CSS/all.css	2004-04-29 06:13:16 UTC (rev 6604)
@@ -1,5 +1,5 @@
 html {
-	font: 80% "Helvetica Neue", Verdana, sans-serif;
+	font: 80% Verdana, sans-serif;
         color: #000;
         color: #122;
 
@@ -16,9 +16,9 @@
         background: #1e90ff; /* cornflower blue */
         background: #556b2f; /* dark olive green */
         background: #333;
-	background: #696969; /* dim gray */
         background: #f5f5f5; /* white smoke */
         background: #ffdead; /* navajo white */
+	background: #696969; /* dim gray */
 
         margin: 0;
         padding: 0;
@@ -33,6 +33,12 @@
         margin-top: 0;
 }
 
+h1, h2, h3, h4, h5, h6, ul#bignavbuttons strong {
+	font-family: "Palatino Linotype", Georgia, "Book Antiqua", serif;
+	font-weight: normal;
+	color: #088;
+
+}
 div#content {
         margin: 0 1em 1em 19em;
         padding: 0 .5em;

Added: websites-ngen/xiph.org/aftermaintext.include
===================================================================
--- websites-ngen/xiph.org/aftermaintext.include	2004-04-28 20:58:47 UTC (rev 6603)
+++ websites-ngen/xiph.org/aftermaintext.include	2004-04-29 06:13:16 UTC (rev 6604)
@@ -0,0 +1,4 @@
+
+<div id='footer'>
+© 2004 Xiph.org
+</div>

Added: websites-ngen/xiph.org/inhead.include
===================================================================
--- websites-ngen/xiph.org/inhead.include	2004-04-28 20:58:47 UTC (rev 6603)
+++ websites-ngen/xiph.org/inhead.include	2004-04-29 06:13:16 UTC (rev 6604)
@@ -0,0 +1,4 @@
+	<meta http=equiv='Content-type' content='text/html; charset=UTF-8'>
+	<style type='text/css'>
+		@import url(/CSS/all.css);
+	</style>

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list