]> git.nbdom.net Git - nb.git/commitdiff
lib/php/out.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 8 May 2018 16:56:39 +0000 (17:56 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 8 May 2018 16:56:39 +0000 (17:56 +0100)
etc/vim/source/debian.vim [deleted file]
etc/vim/source/debian.vim.disable [new file with mode: 0644]
etc/vim/source/vars.vim
lib/lua/nb.lua
lib/php/out.php
lib/php/out/php_hash.php
lib/php/out/vim_hash.php
share/db/nb.db
share/db/update.sh

diff --git a/etc/vim/source/debian.vim b/etc/vim/source/debian.vim
deleted file mode 100644 (file)
index 1d64115..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-"
-" Take from the Debian package and the exemple on $VIM/vim_exemples
-" AUGROUP
-"
-""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-if has("autocmd")
-
-       """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-       " Set some sensible defaults for editing C-files
-       "
-       augroup cprog
-         " Remove all cprog autocommands
-         au!
-
-         " When starting to edit a file:
-         "   For *.c and *.h files set formatting of comments and set C-indenting on.
-         "   For other files switch it off.
-         "   Don't change the order, it's important that the line with * comes first.
-         autocmd BufRead *       set formatoptions=tcql nocindent comments&
-         autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
-       augroup END
-
-       """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-       "" Gzip and Bzip2 files support
-       " Also, support editing of gzip-compressed files. DO NOT REMOVE THIS!
-       " This is also used when loading the compressed helpfiles.
-       "
-       augroup gzip
-         " Remove all gzip autocommands
-         au!
-
-         " Enable editing of gzipped files
-         "       read: set binary mode before reading the file
-         "             uncompress text in buffer after reading
-         "      write: compress file after writing
-         "     append: uncompress file, append, compress file
-         autocmd BufReadPre,FileReadPre        *.gz set bin
-         autocmd BufReadPre,FileReadPre        *.gz let ch_save = &ch|set ch=2
-         autocmd BufReadPost,FileReadPost      *.gz '[,']!gunzip
-         autocmd BufReadPost,FileReadPost      *.gz set nobin
-         autocmd BufReadPost,FileReadPost      *.gz let &ch = ch_save|unlet ch_save
-" NB 19.07.14    autocmd BufReadPost,FileReadPost      *.gz execute ":doautocmd BufReadPost " . %:r
-
-         autocmd BufWritePost,FileWritePost    *.gz !mv <afile> <afile>:r
-         autocmd BufWritePost,FileWritePost    *.gz !gzip -9 <afile>:r
-
-         autocmd FileAppendPre                 *.gz !gunzip <afile>
-         autocmd FileAppendPre                 *.gz !mv <afile>:r <afile>
-         autocmd FileAppendPost                *.gz !mv <afile> <afile>:r
-         autocmd FileAppendPost                *.gz !gzip <afile>:r
-       augroup END
-
-       """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-       " BZIP2
-       "
-       augroup bzip2
-         " Remove all bzip2 autocommands
-         au!
-
-         " Enable editing of bzipped files
-         "       read: set binary mode before reading the file
-         "             uncompress text in buffer after reading
-         "      write: compress file after writing
-         "     append: uncompress file, append, compress file
-         autocmd BufReadPre,FileReadPre        *.bz2 set bin
-         autocmd BufReadPre,FileReadPre        *.bz2 let ch_save = &ch|set ch=2
-         autocmd BufReadPost,FileReadPost      *.bz2 set cmdheight=2|'[,']!bunzip2
-         autocmd BufReadPost,FileReadPost      *.bz2 set cmdheight=1 nobin|execute ":doautocmd BufReadPost " . %:r
-         autocmd BufReadPost,FileReadPost      *.bz2 let &ch = ch_save|unlet ch_save
-
-         autocmd BufWritePost,FileWritePost    *.bz2 !mv <afile> <afile>:r
-         autocmd BufWritePost,FileWritePost    *.bz2 !bzip2 <afile>:r
-
-         autocmd FileAppendPre                 *.bz2 !bunzip2 <afile>
-         autocmd FileAppendPre                 *.bz2 !mv <afile>:r <afile>
-         autocmd FileAppendPost                *.bz2 !mv <afile> <afile>:r
-         autocmd FileAppendPost                *.bz2 !bzip2 -9 --repetitive-best <afile>:r
-       augroup END
-
-endif " has ("autocmd")
-
diff --git a/etc/vim/source/debian.vim.disable b/etc/vim/source/debian.vim.disable
new file mode 100644 (file)
index 0000000..1d64115
--- /dev/null
@@ -0,0 +1,82 @@
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+"
+" Take from the Debian package and the exemple on $VIM/vim_exemples
+" AUGROUP
+"
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+if has("autocmd")
+
+       """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+       " Set some sensible defaults for editing C-files
+       "
+       augroup cprog
+         " Remove all cprog autocommands
+         au!
+
+         " When starting to edit a file:
+         "   For *.c and *.h files set formatting of comments and set C-indenting on.
+         "   For other files switch it off.
+         "   Don't change the order, it's important that the line with * comes first.
+         autocmd BufRead *       set formatoptions=tcql nocindent comments&
+         autocmd BufRead *.c,*.h set formatoptions=croql cindent comments=sr:/*,mb:*,el:*/,://
+       augroup END
+
+       """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+       "" Gzip and Bzip2 files support
+       " Also, support editing of gzip-compressed files. DO NOT REMOVE THIS!
+       " This is also used when loading the compressed helpfiles.
+       "
+       augroup gzip
+         " Remove all gzip autocommands
+         au!
+
+         " Enable editing of gzipped files
+         "       read: set binary mode before reading the file
+         "             uncompress text in buffer after reading
+         "      write: compress file after writing
+         "     append: uncompress file, append, compress file
+         autocmd BufReadPre,FileReadPre        *.gz set bin
+         autocmd BufReadPre,FileReadPre        *.gz let ch_save = &ch|set ch=2
+         autocmd BufReadPost,FileReadPost      *.gz '[,']!gunzip
+         autocmd BufReadPost,FileReadPost      *.gz set nobin
+         autocmd BufReadPost,FileReadPost      *.gz let &ch = ch_save|unlet ch_save
+" NB 19.07.14    autocmd BufReadPost,FileReadPost      *.gz execute ":doautocmd BufReadPost " . %:r
+
+         autocmd BufWritePost,FileWritePost    *.gz !mv <afile> <afile>:r
+         autocmd BufWritePost,FileWritePost    *.gz !gzip -9 <afile>:r
+
+         autocmd FileAppendPre                 *.gz !gunzip <afile>
+         autocmd FileAppendPre                 *.gz !mv <afile>:r <afile>
+         autocmd FileAppendPost                *.gz !mv <afile> <afile>:r
+         autocmd FileAppendPost                *.gz !gzip <afile>:r
+       augroup END
+
+       """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+       " BZIP2
+       "
+       augroup bzip2
+         " Remove all bzip2 autocommands
+         au!
+
+         " Enable editing of bzipped files
+         "       read: set binary mode before reading the file
+         "             uncompress text in buffer after reading
+         "      write: compress file after writing
+         "     append: uncompress file, append, compress file
+         autocmd BufReadPre,FileReadPre        *.bz2 set bin
+         autocmd BufReadPre,FileReadPre        *.bz2 let ch_save = &ch|set ch=2
+         autocmd BufReadPost,FileReadPost      *.bz2 set cmdheight=2|'[,']!bunzip2
+         autocmd BufReadPost,FileReadPost      *.bz2 set cmdheight=1 nobin|execute ":doautocmd BufReadPost " . %:r
+         autocmd BufReadPost,FileReadPost      *.bz2 let &ch = ch_save|unlet ch_save
+
+         autocmd BufWritePost,FileWritePost    *.bz2 !mv <afile> <afile>:r
+         autocmd BufWritePost,FileWritePost    *.bz2 !bzip2 <afile>:r
+
+         autocmd FileAppendPre                 *.bz2 !bunzip2 <afile>
+         autocmd FileAppendPre                 *.bz2 !mv <afile>:r <afile>
+         autocmd FileAppendPost                *.bz2 !mv <afile> <afile>:r
+         autocmd FileAppendPost                *.bz2 !bzip2 -9 --repetitive-best <afile>:r
+       augroup END
+
+endif " has ("autocmd")
+
index dd574a757bcf28c3d78d53545187d752ed0af4ab..a22460fb2f23db1d1ee32506a8e0fdca6b72fb15 100644 (file)
@@ -4,20 +4,21 @@
 " Command to check files per file types
 "
 " rows.fields=id,cmd_check
-">SHELL_REPLACE echo "let mimeCheck = {"; nb_api '/pub/meta/ls/key,val.csv?cat=file.check' | tail -n +2 | sort -k 1 | sed -E -e "s/'/''/g" -e "s/^(.*?)\t(.*)$/  \\\,'\1' : '\2'/" -e "0,/,/s/,//"; echo "\}"
+">SHELL_REPLACE nb_api '/nb/meta/ls/key,val.vim_hash?cat=file.check&preff=%09&name=mimeCheck'
 let mimeCheck = {
-  \'bash' : 'bash -c'
-  \,'erb' : 'sh -c "cat | erb -x - | ruby -c" <'
-  \,'haproxy' : 'haproxy -c -f'
-  \,'html' : 'xmllint --noout --html'
-  \,'json' : 'ruby -rjson -e ''puts JSON.parse(File.read(ARGV[0]))'''
-  \,'perl' : 'perl -c -w'
-  \,'php' : 'php --define error_reporting=22519 --define display_errors=1 --define log_errors=1 --define html_errors=0'
-  \,'puppet' : 'perl -e ''system qq/puppet parser validate $ARGV[0] && puppet-lint --no-selector_inside_resource-check --no-autoloader_layout-check --no-hard_tabs-check --no-80chars-check $ARGV[0]/'''
-  \,'python' : 'python -m py_compile'
-  \,'ruby' : 'ruby -c'
-  \,'sh' : 'sh -c'
-  \,'xml' : 'xmllint --noout'
-  \,'yaml' : 'ruby -ryaml -e ''''puts YAML.dump(YAML.load_file(ARGV[0]))'''
+       \ 'bash'   : 'bash -c'
+       \,'erb'    : 'sh -c "cat | erb -x - | ruby -c" <'
+       \,'haproxy': 'haproxy -c -f'
+       \,'html'   : 'xmllint --noout --html'
+       \,'json'   : 'ruby -rjson -e ''puts JSON.parse(File.read(ARGV[0]))'''
+       \,'lua'    : 'lua'
+       \,'perl'   : 'perl -c -w'
+       \,'php'    : 'php --define error_reporting=22519 --define display_errors=1 --define log_errors=1 --define html_errors=0'
+       \,'puppet' : 'perl -e ''system qq/puppet parser validate $ARGV[0] && puppet-lint --no-selector_inside_resource-check --no-autoloader_layout-check --no-hard_tabs-check --no-80chars-check $ARGV[0]/'''
+       \,'python' : 'python -m py_compile'
+       \,'ruby'   : 'ruby -c'
+       \,'sh'     : 'sh -c'
+       \,'xml'    : 'xmllint --noout'
+       \,'yaml'   : 'ruby -ryaml -e ''puts YAML.dump(YAML.load_file(ARGV[0]))'''
 \}
 "<SHELL_REPLACE
index 51b604c49ca1f455f1c460bb92b6c324818d51db..69fba34183bad54602ccf0a87004c0d0690a0b35 100644 (file)
@@ -73,6 +73,7 @@ function nb:ngx_location_md(fheader,ffooter)
                -- for tag in self:values(tags) do
                        -- content = content:gsub(" +(</th>)","%1")
                -- end
+               -- Fix markdown module
                content = content:gsub(" +(</th>)","%1")
                content = content:gsub("(<th>) +","%1")
                content = content:gsub(" +(</td>)","%1")
index cf0b29f7cc23a01c7c0d61d838797b2af71d559f..296cf2510b0968f3375afda4d9f41cec679c811d 100644 (file)
@@ -166,6 +166,8 @@ Class Out extends Nb {
                        if (is_scalar($v) and self::is_binary($v)) $row[$k] = base64_encode($v);
                }
 
+    if (!empty($o['quote'])) $row = self::quote($row,$o);
+
     # buffering
     if (!empty($o['align'])) {
        if (!isset($o['sep'])) $o['sep'] = $o['align'];
@@ -175,7 +177,7 @@ Class Out extends Nb {
                        $tmp_row = $row;
                        foreach ($tmp_row as $k => $v) {
                                if (!isset($o['length'][$k])) $o['length'][$k] = 0;
-        if (!empty($o['quote'])) $tmp_row[$k] = $v = self::quote($v,$o['quote'],isset($o['quote_escape']) ? $o['quote_escape'] : null);
+# NB 08.05.18         if (!empty($o['quote'])) $tmp_row[$k] = $v = self::quote($v,$o);
        $l = mb_strlen($v,self::charset());
        if ($l > $o['length'][$k]) $o['length'][$k] = $l;
                        }
@@ -183,8 +185,10 @@ Class Out extends Nb {
                        $o['rows'][] = $tmp_row;
                        return true;
 
+    }
+
     # user function
-    } elseif (self::type_call('row',$o,$row)) {
+               if (self::type_call('row',$o,$row)) {
       $ret = true;
 
     # html/xml tag style
@@ -379,8 +383,21 @@ Class Out extends Nb {
   }
 
   public static function quote($str,$quote='"',$quote_escape='\\') {
-       if ($quote === null or $quote == true) $quote = '"';
+               if (is_array($str)) {
+                       foreach ($str as $k=>$v) {
+                               $str[$k] = self::quote($v,$quote,$quote_escape);
+                       }
+                       return $str;
+               }
+
+               if (is_array($quote)) {
+                       if (isset($quote['quote_escape'])) $quote_escape = $quote['quote_escape'];
+                       $quote = $quote['quote'];
+               }
+
+       if ($quote === null or $quote === true) $quote = '"';
        if ($quote_escape === null) $quote_escape = '\\';
+
     $str = str_replace($quote,$quote_escape.$quote,$str);
     $str = $quote . $str . $quote;
     return $str;
@@ -427,13 +444,7 @@ Class Out extends Nb {
     $values = [];
 
     foreach (array_values($row) as $k=>$v) {
-# NB 14.12.17                  if (self::is_binary($v)) {
-# NB 14.12.17                          $values[] = $v;
-# NB 14.12.17                          break;
-# NB 14.12.17                  }
-      if (!empty($o['quote'])) $v = $o['quote'] .
-        str_replace($o['quote'],$o['quote_escape'].$o['quote'],$v)
-      . $o['quote'];
+# NB 08.05.18       if (!empty($o['quote'])) $v = self::quote($v,$o);
       $values[] = str_replace("\n",'\\n',str_replace("\r","",self::scalar($v)));
     }
 
index f56823c479c8d8b541cf40bc446445e9a56f9f48..79cd584f42026870e5fd2282043ed4d2de981ebd 100644 (file)
@@ -6,6 +6,7 @@ return [
 'preff' => self::p('preff',''),
 'row' => function (&$o,&$r) {
        if ($o['preff']) echo $o['preff'];
+
        $keys = array_keys($r);
        for ($i=2;$i<count($keys);$i++) {
                $k = $keys[$i];
index b14c499183d6699cd9db91b04ef3988b8c9a504b..093f30c9716366553c5aed7bf06235004290b138 100644 (file)
@@ -1,15 +1,28 @@
 <?php
-return [ 'align' => self::p('sep',':'), 'eol' => "\n", 'quote' => "'", 
-'row' => function (&$o,&$r) {
-       static $count;
-       echo '\\'.( empty($count) ? ' ' : ',' );
-       $count++;
+return [
+       'align' => self::p('sep',': '),
+       'eol' => "\n",
+       'quote' => "'", 
+       'quote_escape' => "'", 
+       'preff' => self::p('preff',''),
+       'name' => self::p('name','CHANGEME'),
+       'head' => function (&$o,&$r) {
+               echo 'let '.$o['name'].' = {';
+       },
+       'end' => function (&$o,&$r) {
+               echo '\\}'.$o['eol'];
+       },
+       'row' => function (&$o,&$r) {
+               static $count;
+               if ($o['preff']) echo $o['preff'];
+               echo '\\'.( empty($count) ? ' ' : ',' );
+               $count++;
 
-       $keys = array_keys($r);
-       for ($i=2;$i<count($keys);$i++) {
-               $k = $keys[$i];
-               unset($r[$k]);
-       }
+               $keys = array_keys($r);
+               for ($i=2;$i<count($keys);$i++) {
+                       $k = $keys[$i];
+                       unset($r[$k]);
+               }
        },
 ];
 ?>
index 165daab691b67d527db170e89c62aa2f32f1e018..820cbfc2a2e4aa23ebd4e3f0dfadf87f64fbc583 100644 (file)
Binary files a/share/db/nb.db and b/share/db/nb.db differ
index 04a510e15cf5c3c82d1ebd36e9bbd8559979a9c3..9fa408e7acf6629678209fa623785e141cee42e0 100755 (executable)
@@ -9,8 +9,7 @@ cd "$(dirname "$0")" && (
 
        echo 'PRAGMA encoding="UTF-8";'
        echo 'PRAGMA foreign_keys=OFF;'
-       #dbq2sqlite db=pub 'table-name=!~^(zipcode|geo)'
-       nb_api '/pub/dump/sqlite?table-name=!~^(zipcode|geo)'
+       nb_api '/pub/dump/sqlite?table-name=!~^(zipcode|geo|meta)'
        echo 'VACUUM;'
 
 ) | sqlite3 "nb.db"