From: Nicolas Boisselier Date: Tue, 19 Jun 2018 20:13:20 +0000 (+0100) Subject: share/db/update.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=ed53cc485891b171b1c8e3bca2271d08e3b8184b;p=nb.git share/db/update.sh --- diff --git a/lib/php/mime.php b/lib/php/mime.php index 82153308..d5127511 100644 --- a/lib/php/mime.php +++ b/lib/php/mime.php @@ -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 ''.htmlentities($v[1]).''; + },$str) and $str != $v) return $v; + #else preg_replace(',(\w+://\S+),e',''.htmlentities('$1').'',$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 index 00000000..d7ddd79d --- /dev/null +++ b/lib/postgres/css_reference.sql @@ -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; diff --git a/share/db/nb.db b/share/db/nb.db index b6a387e6..c5d5000c 100644 Binary files a/share/db/nb.db and b/share/db/nb.db differ diff --git a/share/db/update.sh b/share/db/update.sh index 9fa408e7..f963d92e 100755 --- a/share/db/update.sh +++ b/share/db/update.sh @@ -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"