]> git.nbdom.net Git - nb.git/commitdiff
./share/db/useragent
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 6 Dec 2017 04:36:16 +0000 (04:36 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 6 Dec 2017 04:36:16 +0000 (04:36 +0000)
bin/say
etc/profile.d/net.sh
lib/xslt/csv.xslt [deleted file]
lib/xslt/xml2csv.xslt [new file with mode: 0644]
share/db/http_status
share/db/nb.db
share/db/useragent
share/db/useragent.sql [new file with mode: 0644]

diff --git a/bin/say b/bin/say
index a10b184eca117ff912d4d379cf3ec91d8e9cd569..ecf6988c13758fca63a4080f0c71470a32851afe 100755 (executable)
--- a/bin/say
+++ b/bin/say
@@ -14,11 +14,10 @@ sub espeak {
   return $_;
 }
 
-$_ = qq{
-It was day.
-It was sunny.
-};
-
+#$_ = qq{
+#It was day.
+#It was sunny.
+#};
 #die $_;
 
 #open(SAY,"| espeak -v mb-en1+f5 -s 140 -m 2>/dev/null") or die $!;
index ba6911f88f883d73a94c1baa5a7805dffbb5df76..1e001a20c5158614cc30ef8c13e4a5e4a7e9ac1b 100644 (file)
@@ -28,9 +28,16 @@ cdr2mask() {
 }
 
 html2txt() {
-  lynx -pseudo_inlines -nomargins -display_charset=utf8 -nocolor -nolist -width=999 -dump $@
+       if which lynx > /dev/null; then
+       lynx -pseudo_inlines -nomargins -display_charset=utf8 -nocolor -nolist -width=999999 -dump "$1"
+       elif which w3m > /dev/null; then
+               w3m -dump -cols 999999 "$1"
+       else
+               echo "Please install lynx or w3m" 1>&2
+               return 1
+       fi
 }
 
 xml2csv() {
-       xsltproc lib/xslt/csv.xslt $@
+       xsltproc lib/xslt/xml2csv.xslt $@
 }
diff --git a/lib/xslt/csv.xslt b/lib/xslt/csv.xslt
deleted file mode 100644 (file)
index 5da10f5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-  <xsl:output method="text" encoding="utf-8" />
-
-  <xsl:param name="break" select="'&#xA;'" />
-  <xsl:param name="quote" select="''" />
-  <xsl:param name="delim" select="'&#009;'" />
-
-  <xsl:template match="/">
-    <xsl:apply-templates select="/*/*" />
-  </xsl:template>
-
-  <xsl:template match="/*/*">
-    <xsl:apply-templates />
-    <xsl:if test="following-sibling::*">
-      <xsl:value-of select="$break" />
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="*">
-    <!-- remove normalize-space() if you want keep white-space at it is --> 
-    <xsl:value-of select="concat($quote, normalize-space(), $quote)" />
-    <xsl:if test="following-sibling::*">
-      <xsl:value-of select="$delim" />
-    </xsl:if>
-  </xsl:template>
-
-  <xsl:template match="text()" />
-</xsl:stylesheet>
diff --git a/lib/xslt/xml2csv.xslt b/lib/xslt/xml2csv.xslt
new file mode 100644 (file)
index 0000000..5da10f5
--- /dev/null
@@ -0,0 +1,28 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:output method="text" encoding="utf-8" />
+
+  <xsl:param name="break" select="'&#xA;'" />
+  <xsl:param name="quote" select="''" />
+  <xsl:param name="delim" select="'&#009;'" />
+
+  <xsl:template match="/">
+    <xsl:apply-templates select="/*/*" />
+  </xsl:template>
+
+  <xsl:template match="/*/*">
+    <xsl:apply-templates />
+    <xsl:if test="following-sibling::*">
+      <xsl:value-of select="$break" />
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="*">
+    <!-- remove normalize-space() if you want keep white-space at it is --> 
+    <xsl:value-of select="concat($quote, normalize-space(), $quote)" />
+    <xsl:if test="following-sibling::*">
+      <xsl:value-of select="$delim" />
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="text()" />
+</xsl:stylesheet>
index 2cae0465614b6df1a8024509875866c332a44ca0..1d8837ee111d5ad31decbeb4e20d160df4720c93 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-@ARGV = ('w3m -dump -cols 10000 https://en.wikipedia.org/wiki/List_of_HTTP_status_codes |');
+@ARGV = ('bash --login -c "html2txt https://en.wikipedia.org/wiki/List_of_HTTP_status_codes" |');
 
 while (<>) {
        next unless /^\d\d\d / .. /^ /;
index 30236da3998f28bd5f141a93922aa5cf649abd42..c354813c888ec783c5f7332d696707b66c6de4e8 100644 (file)
Binary files a/share/db/nb.db and b/share/db/nb.db differ
index b5806d94b109c1bf7bd4e8bf8629c7a458e10682..c410f15e736a7b1d165605e85914036ac940b5e3 100755 (executable)
@@ -1,3 +1,3 @@
-#!/bin/sh
+#!/usr/bin/env bash
 [ -n "$NB_ROOT" ] || . "$(dirname "$0")/../../etc/profile" || exit
-xsltproc $NB_ROOT/lib/xslt/csv.xslt http://www.user-agents.org/allagents.xml
+xml2csv http://www.user-agents.org/allagents.xml
diff --git a/share/db/useragent.sql b/share/db/useragent.sql
new file mode 100644 (file)
index 0000000..ba581c8
--- /dev/null
@@ -0,0 +1,15 @@
+DROP TABLE IF EXISTS useragent;
+CREATE TABLE IF NOT EXISTS useragent (
+  id INT PRIMARY KEY,
+  string VARCHAR(500),
+  description VARCHAR(2000),
+  type VARCHAR(20),
+  comment VARCHAR(100),
+  link1 VARCHAR(1000),
+  link2 VARCHAR(1000)
+);
+
+BEGIN TRANSACTION;
+.separator \t
+.import "useragent.csv" useragent
+COMMIT;