From 97f20aa81dc2cbb598e1d22eb2cffdb884ea0a22 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Mon, 11 Dec 2017 01:41:56 +0000 Subject: [PATCH] www/dbq/dbq.php --- etc/git/hooks/pre-commit | 3 +-- etc/vimrc | 23 +++++++++++++++++++++++ lib/php/nb.php | 1 + www/dbq/dbq.php | 20 +++++++++++++++++++- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 etc/vimrc diff --git a/etc/git/hooks/pre-commit b/etc/git/hooks/pre-commit index 15e7585d..73e94459 100755 --- a/etc/git/hooks/pre-commit +++ b/etc/git/hooks/pre-commit @@ -1,9 +1,8 @@ #!/bin/bash -l echo DEBUG: pre-commit $* 1>&2 #. /etc/profile -# NB 11.12.17 [ -x www/dbq/update.sh ] && echo www/dbq/update.sh && www/dbq/update.sh [ -d www/dbq/ ] && cd www/dbq/ && minify_dir | while read -r f; do - echo "$f" + echo "Minify $f" git add "$f" done diff --git a/etc/vimrc b/etc/vimrc new file mode 100644 index 00000000..0545cf5f --- /dev/null +++ b/etc/vimrc @@ -0,0 +1,23 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" +" ~/.vimrc +" ln -s /opt/nb/etc/vimrc ~/.vimrc +" +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +let $VIMHOME = fnamemodify(resolve(fnamemodify(expand(''),':p')),':h').'/vim' +if empty(glob($VIMHOME)) && filereadable(expand('~/.vim')) + let $VIMHOME = resolve(expand('~/.vim')) +endif + +" NB 08.03.17: infinite loop when link on /etc/vim/vimrc.local +" NB 08.03.17 if filereadable("/etc/vim/vimrc") +" NB 08.03.17 source /etc/vim/vimrc +" NB 08.03.17 endif + +if &runtimepath !~ $VIMHOME + let &runtimepath = &runtimepath . ',' . $VIMHOME +endif + +for file in split(globpath($VIMHOME . '/source/', '*.vim'), '\n') + execute 'source' fnameescape(file) +endfor diff --git a/lib/php/nb.php b/lib/php/nb.php index 6642f78e..6f096365 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -469,6 +469,7 @@ class NB { } public static function yaml_decode($str) { + self::yaml_init(); return yaml_parse($str); } diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index ca03d8b4..4eba3434 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -490,7 +490,25 @@ class DbQ extends nb { return [array_values($title),$nav]; } + public function method_post_accept() { + if ( !empty($_SERVER['REQUEST_METHOD']) and $_SERVER['REQUEST_METHOD'] == 'POST' ) { + foreach (['json','yaml'] as $type) { + if (empty($_POST[$type]) or !strpos(self::client_content_type(),'/'.$type)) continue; + + $post = $_POST; + unset($post[$type]); + + $fct = $type . '_decode'; + $_POST = array_merge((array)$this->$fct($_POST[$type]),$post); + + break; + } + #bye($_POST); + } + } + public function parse_uri() { + $this->method_post_accept(); # # Parse path, respect params order # @@ -746,7 +764,7 @@ EOF; if ( $format == 'json' and isset($_POST['json']) ) { #bye($_POST['json']); #$this->pset($this->json_decode($_POST['json'])); - $_POST = $this->json_decode($_POST['json']); + $_POST = $_POST + $this->json_decode($_POST['json']); #bye($this->p()); } -- 2.47.3