]> git.nbdom.net Git - nb.git/commitdiff
share/db/update.sh
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 19 Jun 2018 20:13:20 +0000 (21:13 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 19 Jun 2018 20:13:20 +0000 (21:13 +0100)
lib/php/mime.php
lib/postgres/css_reference.sql [new file with mode: 0644]
share/db/nb.db
share/db/update.sh

index 82153308b21258b3eb99b167d89fa5eee1a634b7..d5127511106f057fef06bdf91af0591a01fe5f82 100644 (file)
@@ -862,6 +862,11 @@ class Mime {
 
                if ($mime == 'text/plain') {
                        if ($v = self::html_video($str)) return $v;
+                       elseif($v = preg_replace_callback(',(\w+://\S+),',function($v){
+                               return '<a target="_blank" href="'.$v[1].'">'.htmlentities($v[1]).'</a>';
+                       },$str) and $str != $v) return $v;
+                       #else preg_replace(',(\w+://\S+),e','<a href="$1">'.htmlentities('$1').'</a>',$str);
+
 
                } elseif (preg_match('@^image/@',$mime)) {
                        return self::html_img_data($str);
diff --git a/lib/postgres/css_reference.sql b/lib/postgres/css_reference.sql
new file mode 100644 (file)
index 0000000..d7ddd79
--- /dev/null
@@ -0,0 +1,15 @@
+DROP TABLE IF EXISTS css_reference;
+CREATE TABLE IF NOT EXISTS css_reference (
+  name varchar(200) PRIMARY KEY,
+  description varchar(500),
+  link varchar(300)
+);
+BEGIN TRANSACTION;
+DELETE FROM css_reference;
+COPY css_reference (name,description,link) FROM PROGRAM '. /etc/profile && html2txt https://www.w3schools.com/cssref/ | perl -ne " \
+next unless /^align-content .*Specifies/ .. /^z-index/ and /^[a-z]/; \
+s/\s+/\t/; \
+chomp; /^(\S+)/; \
+print qq|\$_\thttps://www.w3schools.com/cssref/css3_pr_\$1.asp\n|" \
+' WITH (format 'text', NULL ''); 
+COMMIT;
index b6a387e622391a45c0953fb0350d6c111152fc86..c5d5000c848b2bdd9161abfa530f2911ac57eac3 100644 (file)
Binary files a/share/db/nb.db and b/share/db/nb.db differ
index 9fa408e7acf6629678209fa623785e141cee42e0..f963d92e1db75e4798accdac2961adc6ce8e8ae9 100755 (executable)
@@ -5,11 +5,20 @@
 #
 #
 set +e
-cd "$(dirname "$0")" && (
+cd "$(dirname "$0")"
+
+# Get existing tables, we don't want everything
+tables=$(
+sqlite3 "nb.db" ".tab" | sed -E 's/\s+/\n/g' | sort -u | grep -v '^$' | tr "\n" ","
+)
+tables=${tables%,*}
+#echo $tables; exit
+
+[ -n "$tables" ] && (
 
        echo 'PRAGMA encoding="UTF-8";'
        echo 'PRAGMA foreign_keys=OFF;'
-       nb_api '/pub/dump/sqlite?table-name=!~^(zipcode|geo|meta)'
+       nb_api "/pub/dump/sqlite?table-name=$tables"
        echo 'VACUUM;'
 
 ) | sqlite3 "nb.db"