r4998 - in trunk/BOOK: . stylesheets

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Mon Aug 29 14:32:11 PDT 2005


Author: manuel
Date: 2005-08-29 15:32:10 -0600 (Mon, 29 Aug 2005)
New Revision: 4998

Added:
   trunk/BOOK/obfuscate.sh
   trunk/BOOK/stylesheets/dump-commands.xsl
Removed:
   trunk/BOOK/goTidy
Modified:
   trunk/BOOK/Makefile
Log:
Added obfuscate.sh and dump-commands.xsl.
Removed goTidy.

Modified: trunk/BOOK/Makefile
===================================================================
--- trunk/BOOK/Makefile	2005-08-29 20:13:26 UTC (rev 4997)
+++ trunk/BOOK/Makefile	2005-08-29 21:32:10 UTC (rev 4998)
@@ -5,6 +5,7 @@
 # $Date$
 # Adjust these to suit your installation
 OUTPUTDIR = $(HOME)/public_html/blfs-book
+DUMPDIR= $(HOME)/blfs-commands
 INSTALL = install
 JADE = openjade
 DOCBOOK = /usr/share/sgml/docbook/dsssl-stylesheets-1.78
@@ -35,8 +36,14 @@
 	cp images/*.png $(BASEDIR)/images
 	cd $(BASEDIR); sed -i -e "s at ../stylesheets at stylesheets@g" *.html
 	cd $(BASEDIR); sed -i -e "s at ../images at images@g" *.html
-	sh goTidy $(BASEDIR)/
 
+	for filename in `find $(BASEDIR) -name "*.html"`; do \
+	  tidy -config tidy.conf $$filename; \
+	  true; \
+	  sh obfuscate.sh $$filename; \
+	  sed -i -e "s at text/html at application/xhtml+xml at g" $$filename; \
+	done;
+
 nochunks:
 	@echo "Generating nochunks version of BLFS..."
 	xsltproc --xinclude --nonet -stringparam profile.condition html \
@@ -45,6 +52,8 @@
 
 	tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
 
+	sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
+
 	sed -i -e "s at text/html at application/xhtml+xml at g"  \
           $(BASEDIR)/$(NOCHUNKS_OUTPUT)
 
@@ -74,6 +83,10 @@
 	@cd $(TEXBASEDIR) && xsltproc --nonet -o blfs-book.tex \
 	    $(SRCDIR)/stylesheets/blfs-tex.xsl index.xml
 
+dump-commands:
+	xsltproc --xinclude --nonet --output $(DUMPDIR)/ \
+	   stylesheets/dump-commands.xsl index.xml
+
 validate:
 	xmllint --noout --nonet --xinclude --postvalid index.xml
 

Deleted: trunk/BOOK/goTidy
===================================================================
--- trunk/BOOK/goTidy	2005-08-29 20:13:26 UTC (rev 4997)
+++ trunk/BOOK/goTidy	2005-08-29 21:32:10 UTC (rev 4998)
@@ -1,17 +0,0 @@
-#!/bin/bash
-#######################################################################
-#
-# File:        goTidy
-#
-# Description: Tidy is best used inside a loop, but Makefiles don't do
-# bash loops well.  This file alleviates that problem.
-#
-# Author:      James Robertson
-#
-########################################################################
-
-for file in `find "$1" -name "*.html"`; do
-        tidy -config tidy.conf $file
-done
-
-exit 0

Added: trunk/BOOK/obfuscate.sh
===================================================================
--- trunk/BOOK/obfuscate.sh	2005-08-29 20:13:26 UTC (rev 4997)
+++ trunk/BOOK/obfuscate.sh	2005-08-29 21:32:10 UTC (rev 4998)
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# obfuscate.sh
+# obfuscate email addresses in XML/HTML
+# Script written (and slight perl modification) by Archaic <archaic AT linuxfromscratch D0T org>
+# Original Perl expression by Anderson Lizardo <lizardo AT linuxfromscratch D0T org>
+# Released under the GNU General Public License
+#
+# This script currently only seeks out mailto: addresses. If those same
+# addresses also appear in plaintext, we need to obfuscate those as well.
+#
+# This script was made for a very specific purpose so I was a bit lazy in
+# writing the regex's.
+#
+# Please send comments, enhancements, etc. to the above address
+
+#set -e  # Bail on all errors
+
+# First, ensure that we are given a file to process
+# if [ $# -lt 1 ]; then
+#   echo -e "\nYou must provide an input file."
+#   exit 1
+# fi
+
+# Nothing like a backup plan!
+#cp "$1" "$1".bak
+
+for i in `grep -o '"mailto:.*@.*"' "$1" |sed -e 's|^"mailto:||' -e 's|"$||'`; do
+  link=`echo $i | perl -pe 's/[^\n]/"\\\&#".ord($&)."\;"/ge'`
+  plaintext=`echo $i | sed -e 's|@| AT |' -e 's|\.| D0T |g'`
+  sed -i "s|mailto:$i|mailto:$link|" "$1"
+  sed -i "s|$i|$plaintext|" "$1"
+done
+
+#exit 0


Property changes on: trunk/BOOK/obfuscate.sh
___________________________________________________________________
Name: svn:keywords
   + "Author Date Revision Id"

Added: trunk/BOOK/stylesheets/dump-commands.xsl
===================================================================
--- trunk/BOOK/stylesheets/dump-commands.xsl	2005-08-29 20:13:26 UTC (rev 4997)
+++ trunk/BOOK/stylesheets/dump-commands.xsl	2005-08-29 21:32:10 UTC (rev 4998)
@@ -0,0 +1,84 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:exsl="http://exslt.org/common"
+    extension-element-prefixes="exsl"
+    version="1.0">
+
+<!-- XSLT stylesheet to extract commands from [B,H]LFS books. -->
+
+  <xsl:template match="/">
+    <xsl:apply-templates select="//sect1"/>
+  </xsl:template>
+
+  <xsl:template match="sect1">
+      <!-- The dirs names -->
+    <xsl:variable name="pi-dir" select="../../processing-instruction('dbhtml')"/>
+    <xsl:variable name="pi-dir-value" select="substring-after($pi-dir,'dir=')"/>
+    <xsl:variable name="quote-dir" select="substring($pi-dir-value,1,1)"/>
+    <xsl:variable name="dirname" select="substring-before(substring($pi-dir-value,2),$quote-dir)"/>
+      <!-- The file names -->
+    <xsl:variable name="pi-file" select="processing-instruction('dbhtml')"/>
+    <xsl:variable name="pi-file-value" select="substring-after($pi-file,'filename=')"/>
+    <xsl:variable name="filename" select="substring-before(substring($pi-file-value,2),'.html')"/>
+      <!-- The build order -->
+    <xsl:variable name="position" select="position()"/>
+    <xsl:variable name="order">
+      <xsl:choose>
+        <xsl:when test="string-length($position) = 1">
+          <xsl:text>00</xsl:text>
+          <xsl:value-of select="$position"/>
+        </xsl:when>
+        <xsl:when test="string-length($position) = 2">
+          <xsl:text>0</xsl:text>
+          <xsl:value-of select="$position"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="$position"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+      <!-- Creating dirs and files -->
+    <exsl:document href="{$dirname}/{$order}-{$filename}" method="text">
+      <xsl:apply-templates select=".//screen"/>
+    </exsl:document>
+  </xsl:template>
+
+  <xsl:template match="screen">
+    <xsl:if test="child::* = userinput">
+      <xsl:choose>
+        <xsl:when test="@role = 'nodump'"/>
+        <xsl:when test="@role = 'root'">
+          <xsl:text>&#xA;</xsl:text>
+          <xsl:text># Run this as root</xsl:text>
+          <xsl:apply-templates select="userinput"/>
+          <xsl:text># End root commands</xsl:text>
+          <xsl:text>&#xA;</xsl:text>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:apply-templates select="userinput"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="userinput">
+    <xsl:text>&#xA;</xsl:text>
+    <xsl:if test=".//replaceable">
+      <xsl:text># This block must be edited to suit your needs.</xsl:text>
+    </xsl:if>
+    <xsl:text>&#xA;</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>&#xA;</xsl:text>
+    <xsl:if test=".//replaceable">
+      <xsl:text># End of editable block.</xsl:text>
+    </xsl:if>
+    <xsl:text>&#xA;</xsl:text>
+  </xsl:template>
+
+  <xsl:template match="replaceable">
+    <xsl:text>**EDITME</xsl:text>
+    <xsl:apply-templates/>
+    <xsl:text>EDITME**</xsl:text>
+  </xsl:template>
+
+</xsl:stylesheet>


Property changes on: trunk/BOOK/stylesheets/dump-commands.xsl
___________________________________________________________________
Name: svn:keywords
   + "Author Date Revision Id"




More information about the blfs-book mailing list