Anonymous avatar Anonymous committed 4ba4d7e

Placed the books logic in its own library file to be used by all book pages.

Changed the makefile to accomodate for this change.

Comments (0)

Files changed (3)

 
 DEST_ARC_PAGE = $(TARGET)/source/index.html
 
+LIBRARY_FILES = template.wml lib/books.wml
+
 all: dest $(SUBDIRS_DEST) $(DESTS) $(RAW_FILES_DEST)
 
 dest:
 	if [ ! -e $@ ] ; then mkdir $@ ; fi
 	
-$(DESTS) :: $(TARGET)/% : src/%.wml template.wml
+$(DESTS) :: $(TARGET)/% : src/%.wml $(LIBRARY_FILES)
 	(cd src && wml $(WML_FLAGS) -DFILENAME=$(patsubst src/%.wml,%,$<) $(patsubst src/%,%,$<)) > $@
 
 $(RAW_FILES_DEST) :: $(TARGET)/% : src/%
 
 .PHONY: 
 
-$(DEST_ARC_PAGE) :: $(TARGET)/% : src/%.wml template.wml .PHONY
+$(DEST_ARC_PAGE) :: $(TARGET)/% : src/%.wml $(LIBRARY_FILES) .PHONY
 	(cd src && wml $(WML_FLAGS) -DARCNAME=$(ARC_NAME) -DFILENAME=$(patsubst src/%.wml,%,$<) $(patsubst src/%,%,$<)) > $@
 
 arc: $(DEST_ARC_NAME) $(DEST_ARC_PAGE)
+<define-tag get:ext:publisher whitespace="delete">
+<ifeq "%0" "oreilly" "<a href="http://www.oreilly.com/">O'Reilly and Associates</a>" />
+<ifeq "%0" "manning" "<a href="http://www.manning.com/">Manning Publications Co.</a>" />
+<ifeq "%0" "new-riders" "<a href="http://www.newrider.com/">New Riders</a>" />
+</define-tag>
+
+<define-tag book:store>
+<preserve isbn />
+<preserve store />
+<preserve title />
+<set-var %attributes />
+<ifeq "<get-var store />" "ukamazon" 
+    "<set-var ucstore="Amazon UK" />"
+    "<set-var ucstore="<:{print ucfirst("<get-var store />")}:>" />"
+    />
+<a href="http://learn.perl.org/redirect?url=book;bookstore=<get-var store />;bookisbn=<get-var isbn />"><get-var title /></a>
+<restore title />
+<restore store />
+<restore isbn />
+</define-tag>
+
+<define-tag book:info>
+<preserve authors />
+<preserve publisher />
+<preserve isbn />
+<set-var %attributes />
+<set-var ext:publisher=<get:ext:publisher <get-var publisher /> /> />
+<div class="bookinfo">
+<h3>Book Information</h3>
+<b>Authors:</b> <get-var authors /><br />
+<b>Publisher:</b> <get-var ext:publisher /><br />
+<b>Buy From:</b> 
+<book:store isbn="<get-var isbn />" store="amazon" title="Amazon" /> - 
+<book:store isbn="<get-var isbn />" store="powells" title="Powells" /> - 
+<book:store isbn="<get-var isbn />" store="amazonuk" title="Amazon UK" />
+<br />
+</div>
+<restore isbn />
+<restore publisher />
+<restore authors />
+</define-tag>
+

src/books/index.html.wml

 #include '../template.wml'
 
+#include "../lib/books.wml"
+
 <subject "Paper Books" />
 
-<define-tag get:ext:publisher whitespace="delete">
-<ifeq "%0" "oreilly" "<a href="http://www.oreilly.com/">O'Reilly and Associates</a>" />
-<ifeq "%0" "manning" "<a href="http://www.manning.com/">Manning Publications Co.</a>" />
-<ifeq "%0" "new-riders" "<a href="http://www.newrider.com/">New Riders</a>" />
-</define-tag>
-
-<define-tag book:store>
-<preserve isbn />
-<preserve store />
-<preserve title />
-<set-var %attributes />
-<ifeq "<get-var store />" "ukamazon" 
-    "<set-var ucstore="Amazon UK" />"
-    "<set-var ucstore="<:{print ucfirst("<get-var store />")}:>" />"
-    />
-<a href="http://learn.perl.org/redirect?url=book;bookstore=<get-var store />;bookisbn=<get-var isbn />"><get-var title /></a>
-<restore title />
-<restore store />
-<restore isbn />
-</define-tag>
-
-<define-tag book:info>
-<preserve authors />
-<preserve publisher />
-<preserve isbn />
-<set-var %attributes />
-<set-var ext:publisher=<get:ext:publisher <get-var publisher /> /> />
-<div class="bookinfo">
-<h3>Book Information</h3>
-<b>Authors:</b> <get-var authors /><br />
-<b>Publisher:</b> <get-var ext:publisher /><br />
-<b>Buy From:</b> 
-<book:store isbn="<get-var isbn />" store="amazon" title="Amazon" /> - 
-<book:store isbn="<get-var isbn />" store="powells" title="Powells" /> - 
-<book:store isbn="<get-var isbn />" store="amazonuk" title="Amazon UK" />
-<br />
-</div>
-<restore isbn />
-<restore publisher />
-<restore authors />
-</define-tag>
 
 <h2>Note</h2>
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.