Hi

Happy new year, I wish you health, happiness and success in your projects.

Le 11/12/2013 21:17, Bruce Dubbs a écrit :

That will be useful.  Thanks.

What might also be helpful is to create a script to extract those links
from the book and automate the check.

    -- Bruce

I send you a patch to automate the checking of all links contained in the book.

I add the "test-all-links" fonction in the Makefile (make test-all-links). This fonction call a xls file (stylesheets/list_url.xsl) to extract a list of URLs from the book.

This fonction don't check the package links (use make test-links to check it)

You can find a list of bad urls in the file $(BASEDIR)/true_bad_urls, and the list of xml files using this urls in the file $(BASEDIR)/broken_urls.

I hope this can help you

When I study stylesheets to write this script, I saw that it is possible to generate a "epub3" file of the LFS book. It is planned for the next release of LFS to have a "epub3" file of the LFS book ??

Regards,

Denis

Index: Makefile
===================================================================
--- Makefile	(révision 12508)
+++ Makefile	(copie de travail)
@@ -160,6 +160,38 @@
 	    fi; \
 	done
 
+test-all-links: $(BASEDIR)/test-all-links
+$(BASEDIR)/test-all-links: $(RENDERTMP)/blfs-full.xml
+	@echo "Generating test-all-links file..."
+	$(Q)mkdir -p $(BASEDIR)
+	$(Q)xsltproc --nonet \
+	  --output $(BASEDIR)/test-all-links stylesheets/list_url.xsl \
+	  $(RENDERTMP)/blfs-full.xml
+
+	@echo "Checking URLs, first pass..."
+	$(Q)rm -f $(BASEDIR)/{good,bad,true_bad,broken}_urls
+	$(Q)for URL in `uniq $(BASEDIR)/test-all-links`; do \
+	    wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
+	    if test $$? -ne 0 ; then echo $$URL >> $(BASEDIR)/bad_urls ; \
+	    else echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
+	    fi; \
+	done
+
+	@echo "Checking URLs, second pass..."
+	$(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
+	    wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
+	    if test $$? -ne 0 ; then echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
+	    else echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
+	    fi; \
+	done
+	
+	@echo "Generating broken_urls file ..."
+	$(Q)for URL in `cat $(BASEDIR)/true_bad_urls`; do \
+		grep -r "$$URL" * >> $(BASEDIR)/broken_urls ; \
+	done
+	
+	$(Q)sed -i $(BASEDIR)/broken_urls -e "/^tmp/d" -e "/xml~/d"
+
 dump-commands: $(DUMPDIR)
 $(DUMPDIR): $(RENDERTMP)/blfs-full.xml
 	@echo "Dumping book commands..."

Index: stylesheets/list_url.xsl
===================================================================
--- stylesheets/list_url.xsl	(révision 0)
+++ stylesheets/list_url.xsl	(copie de travail)
@@ -0,0 +1,26 @@
+<?xml version='1.0' encoding='ISO-8859-1'?>
+
+<!-- Create a list of broken URLs listed in dependencies. -->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+    version="1.0">
+
+  <xsl:output method="text"/>
+  
+  <xsl:template match="/">
+       <xsl:apply-templates select="//ulink" mode="full">
+          <xsl:sort select="@url" order="ascending"/>
+       </xsl:apply-templates>
+  </xsl:template>
+
+  <xsl:template match="ulink" mode="full">
+<!-- To check only url in text and not check url of packages (you can check it with test-links in Makefile -->
+    <xsl:if test="not(ancestor::itemizedlist)">
+        <xsl:if test="not(contains(@url, 'file:') or contains(@url, 'wiki.linuxfromscratch.org') or contains(@url, 'mailto') or contains(@url, 'localhost')) and (contains(@url, 'http:') or contains(@url, 'ftp:') or contains(@url, 'https:'))">
+           <xsl:value-of select="@url"/>
+           <xsl:text>&#x0a;</xsl:text>
+        </xsl:if>   
+    </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>
-- 
http://linuxfromscratch.org/mailman/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to