]> git.nbdom.net Git - nb.git/commitdiff
Bed
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 27 Dec 2016 04:11:35 +0000 (04:11 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 27 Dec 2016 04:11:35 +0000 (04:11 +0000)
14 files changed:
etc/profile
etc/profile.d/docker.sh
etc/profile.d/functions
lib/php/db/table.php
lib/php/nb.php
src/Docker/nginx/Dockerfile
www/dbq/dbq.php
www/dbq/docker-compose.yaml
www/dbq/etc/nginx/default.conf
www/dbq/html/default.css
www/dbq/html/default.js
www/dbq/html/default.min.css [new file with mode: 0644]
www/dbq/html/default.min.js [new file with mode: 0644]
www/dbq/minify.sh [new file with mode: 0755]

index 41f7c00ef14e9a82f6d42d9bd9675ab2fd662f00..ced7675e3a7ab834ba5d3887133c96ebff414a1e 100755 (executable)
@@ -84,6 +84,7 @@ else
   if [ -n "$NB_ROOT" ]; then
     #[ -e "$NB_ROOT/etc/profile.d/envs" ] && . "$NB_ROOT/etc/profile.d/envs"
 
+    #alias which=in_path
     for i in \
       ${NB_ROOT}/etc/profile.d/envs \
       ${NB_ROOT}/etc/profile.d/aliases \
@@ -93,6 +94,7 @@ else
       [ -n "$NB_DEBUG" ] && $NB_DEBUG ". $i"
       [ -r "$i" -a -f "$i" ] && . "$i"
     done
+    #unalias which
 
   fi
 
index 232c1a51d15b7e97c3bf3c51997c2da823b26cad..1ae7c544582b2d9a28cb248d3b69caa06d6b9966 100644 (file)
@@ -8,7 +8,8 @@ which docker > /dev/null || return 0
 [ -z "$DOCKER_HUB" ] && DOCKER_HUB=""
 
 # Docker env only if `is_prompt` !!!
-if is_prompt && which docker-machine > /dev/null && [ -z "$MYVIMRC" ]; then
+# NB 26.12.16 if is_prompt && which docker-machine > /dev/null && [ -z "$MYVIMRC" ]; then
+if which docker-machine >/dev/null; then
 
   if [ -z "$DOCKER_CERT_PATH" -o ! -e "$DOCKER_CERT_PATH" ] \
     && [ _$(docker-machine status "$DOCKER_MACHINE_NAME" 2>/dev/null) =  _Running ] \
index 6928bd69a497a8cb04ba8e260e47e39a763aa0e6..447fe2889698d29a936cbf6853f9abceb7021fa2 100644 (file)
@@ -809,3 +809,16 @@ password_create() {
   [ "$encrypt" == "1" ] && password="$password "`echo "$password" | makepasswd --clearfrom=- --crypt-md5 | sed 's/^.*\(\$.*\)$/\1/'`
   echo "$password"
 }
+
+# NB 27.12.16 in_path() {
+# NB 27.12.16   local IFS=':'
+# NB 27.12.16   local p
+# NB 27.12.16   for p in $PATH; do
+# NB 27.12.16     test -x "$p/$1" || continue
+# NB 27.12.16     #echo "$p/$1"
+# NB 27.12.16     #echo "$p/$1" 1>&2
+# NB 27.12.16     return
+# NB 27.12.16   done
+# NB 27.12.16   #/usr/bin/which
+# NB 27.12.16   return 1
+# NB 27.12.16 }
index 4f20302247907efbabd154d852f841c96bf7f859..0939f1968d87bb2cbe8a7dfc70a5b96f0c7458a1 100644 (file)
@@ -1343,20 +1343,46 @@ Class Table extends nb {
 
     $html = '';
 
-    #$html .= '<table data-role="table" class="ui-responsive rows '.$this->name.'">'.NB_EOL;
     $html .= '<table class="rows wp-list-table widefat fixed striped">'.NB_EOL;
     #if (!empty($opt)) $html .= '<caption>' . $this->nav($opt['count'],$opt['tot'],$opt['limit']) . '</caption>' .NB_EOL;
 
+    $this->__rows_table_attr = [];
+    $this->__rows_table_keys = [];
+    foreach ($fields as $name => $f) {
+      $this->__rows_table_attr[$name] = ''
+        . ' class="' . $name . ($f->key?' key':'') . (isset($this->extras[$name])?' extra':'') . '"'
+      ;
+      if ($f->key) $this->__rows_table_keys[] = $name;
+    }
+
     if ($this->show_header) {
-      $html .= '<thead>'.NB_EOL.'<tr class="head">'.NB_EOL;
+      $html .= '<thead>'.NB_EOL;
 
+      // Columns names
+      $html .= '<tr class="head">'.NB_EOL;
       if ($this->buttons() and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
+      foreach ($fields as $name => $f) {
+        $html .= '<th'.$this->__rows_table_attr[$name].'>'.$this->url_sort($name).'</th>'.NB_EOL;
+      }
+      if ($this->buttons() and DB_HTML_DELETE) $html .= '<th class="delete"></th>'.NB_EOL;
+      $html .= '</tr>'.NB_EOL;
 
+      // Filters - beta
+    /*
+    if (0) {
+      $html .= '<tr class="head">'.NB_EOL;
+      if ($this->buttons() and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
       foreach ($fields as $name => $f) {
-        $html .= '<th class="'.$name.($f->key?' key':'').'">'.$this->url_sort($name).'</th>'.NB_EOL;
+        $html .= '<th class="'.$name.($f->key?' key':'').'">'
+        . (preg_match('/^\w/',$name) ? '<input type="text" id="t-'.$name.'" name="'.$name.'" value="'.$name.$f->p($name).'" />' : '')
+        .'</th>'.NB_EOL;
       }
       if ($this->buttons() and DB_HTML_DELETE) $html .= '<th class="delete"></th>'.NB_EOL;
-      $html .= '</tr>'.NB_EOL.'</thead>'.NB_EOL;
+      $html .= '</tr>'.NB_EOL;
+    }
+    */
+
+      $html .= '</thead>'.NB_EOL;
     }
 
     $html .= '<tbody>'.NB_EOL;
@@ -1367,13 +1393,18 @@ Class Table extends nb {
 
     $buttons = $this->html_row_buttons($row);
 
-    $html = '<tr class="row">'.NB_EOL;
+    $id = [];
+    foreach ($this->__rows_table_keys as $k) {
+      $id[] = $row[$k];
+    }
+    $id = empty($id) ? '' : ' '.'__'.join('__',$id).'__';
+
+    $html = '<tr class="row'.$id.'">'.NB_EOL;
 
     if ($this->buttons() and !empty($buttons[0])) $html .= '<td class="action">'.$buttons[0].'</td>'.NB_EOL;
 
     foreach ($row as $k => $v) {
-      if (isset($this->extras[$k])) $k .= " extra";
-      $html .= '<td class="'.$k.'">'.$v.'</td>'.NB_EOL;
+      $html .= '<td'.$this->__rows_table_attr[$k].'>'.$v.'</td>'.NB_EOL;
     }
 
     if ($this->buttons() and !empty($buttons[1])) $html .= '<td class="action">'.$buttons[1].'</td>'.NB_EOL;
@@ -1384,6 +1415,7 @@ Class Table extends nb {
   }
 
   public function rows_end_table() {
+    unset($this->__rows_table_attr,$this->__rows_table_keys);
     $html = '';
     $html .= '</tbody>'.NB_EOL;
     $html .= '</table>'.NB_EOL;
@@ -1769,7 +1801,7 @@ Class Table extends nb {
 
   public function html_menu($opt=[]) {
 
-    $buttons = '<input type="submit" class="button button-small" value="GO"/>';
+    $buttons = '<input type="submit" class="button button-small" value="Go"/>';
     if (!empty($opt['buttons'])) $buttons = $opt['buttons'];
 
     $r = '<form class="menu" method="get" action="?">'.NB_EOL;
@@ -1821,7 +1853,7 @@ Class Table extends nb {
         'html'       => 'class="format" name="format" id="format"',
         'selected'   => $this->db()->format,
         'prettyText' => true,
-        'sort'       => 'natcasesort',
+# NB 26.12.16         'sort'       => 'natcasesort',
       ]);
       $r .= '</span>';
 
@@ -1832,6 +1864,7 @@ Class Table extends nb {
           'html'       => 'class="limit" name="limit" id="limit"',
           'selected'   => $this->p('limit'),
           'prettyText' => true,
+          'sort' => 'sort',
         ]);
         $r .= '</span>';
       }
index 36bc956d91c8c022f827f0d4e9497b5eacc4b19f..972d768b37eda461d9efe456b7a8ed1e3565bd65 100644 (file)
@@ -1,13 +1,11 @@
 <?php
 if (!defined('NB_ROOT')) define('NB_ROOT',realpath(dirname(__FILE__).'/../..'));
-if (defined('PRODUCTION') and !defined('NB_PROD')) define('NB_PROD',PRODUCTION);
-if (!defined('NB_EOL')) define('NB_EOL',defined('NB_PROD') ? '' : "\n");
+if (!defined('NB_PROD') and defined('PRODUCTION')) define('NB_PROD',PRODUCTION);
+if (!defined('NB_EOL')) define('NB_EOL',(defined('NB_PROD') and NB_PROD) ? '' : "\n");
 
-require_once(realpath(dirname(__FILE__).'/functions.php'));
-#$nb = new NB(); debug($nb->test());
-#if (!defined('NB_PARAMS')) define('NB_PARAMS',$_REQUEST);
-if (class_exists('NB')) return;
+require_once(NB_ROOT.'/lib/php/functions.php');
 
+if (class_exists('NB')) return; # protect against double include
 class NB {
 
   const ROOT_DIR = NB_ROOT;
@@ -353,7 +351,7 @@ class NB {
   private static function yaml_init() {
     static $Spyc;
     if (empty($Spyc) and !function_exists('yaml_emit')) {
-      require_once(realpath(dirname(__FILE__).'/Spyc.php'));
+      require_once(NB_ROOT.'/lib/php/Spyc.php');
       function yaml_emit($data) { return Spyc::YAMLDump($data, false, false, true); }
       function yaml_parse_file($file) { return Spyc::YAMLLoad($file); }
       $Spyc = true;
@@ -911,7 +909,7 @@ class NB {
   public static function md2html($txt) {
     static $_txt2md = null;
     if ($_txt2md === null) {
-      require_once(dirname(__FILE__).'/parsedown/Parsedown.php');
+      require_once(NB_ROOT.'/lib/php/parsedown/Parsedown.php');
       $_txt2md = new Parsedown();
     }
     return $_txt2md->text($txt);
index f584fe9299cc672e4f91bfe9670f6eeda20a04a4..ff60f0a96aca9f1f179415e5060a6c4c0e808659 100644 (file)
@@ -3,25 +3,19 @@ FROM nginx:alpine
 ARG WWW_ROOT
 ENV WWW_ROOT=${WWW_ROOT:-/var/www/html}
 
-ARG PHP_HOST
-ENV PHP_HOST=${PHP_HOST:-php}
-
-ARG PHP_PORT
-ENV PHP_PORT=${PHP_PORT:-9000}
+ARG FASTCGI_PASS
+ENV FASTCGI_PASS=${FASTCGI_PASS:-php:9000}
 
 COPY ./default.conf /etc/nginx/conf.d/default.conf
 
 # Set DOCUMENT_ROOT
 RUN test "$WWW_ROOT" && sed -i -e 's,^\([\t ]*root \).*$,\1'$WWW_ROOT';,' /etc/nginx/conf.d/default.conf
 
-# Set PHP_HOST
-RUN test "$PHP_HOST" && sed -i -e 's,^\([\t ]*fastcgi_pass \)\([^:]\+\)\(:.*\)$,\1'$PHP_HOST'\3,' /etc/nginx/conf.d/default.conf
-
-# Set PHP_PORT
-RUN test "$PHP_PORT" && sed -i -e 's,^\([\t ]*fastcgi_pass [^:]\+:\)\([0-9]\+\),\1'$PHP_PORT',' /etc/nginx/conf.d/default.conf
+# Set FASTCGI_PASS
+RUN test "$FASTCGI_PASS" && sed -i -e 's,^\([\t ]*fastcgi_pass[\t ]*\).*,\1'$FASTCGI_PASS';,' /etc/nginx/conf.d/default.conf
 
 # Create default index.html
-RUN mkdir -p $WWW_ROOT && echo '<html><head><title>Welcom to Nginx Php Fpm</title></head><body><h1>Welcom to Nginx Php Fpm</h1></body></html>' > $WWW_ROOT/index.html
+RUN mkdir -p $WWW_ROOT && echo '<html><head><title>Welcom to Nginx Php Fpm</title></head><body><h1>Welcom to Nginx Php Fpm</h1><p>You are connected to '$FASTCGI_PASS'</p></body></html>' > $WWW_ROOT/index.html
 
 # Run daemon
 CMD nginx -g "daemon off; error_log /dev/stdout info;"
index 1c33acefbcaff98a9af1cbee1367b459a3c05e1b..4db08e7a10469be0e4f6eac25cff124d13a8a822 100644 (file)
@@ -1,16 +1,10 @@
 <?php
+define(PRODUCTION,empty($_SERVER['PRODUCTION']) ? false : (bool)$_SERVER['PRODUCTION']);
+
 require_once(realpath(dirname(__FILE__).'/../../lib/php/nb.php'));
 require_once(NB_ROOT.'/lib/php/http.php');
 require_once(NB_ROOT.'/lib/php/mime.php');
 
-/*
-  Default action
-*/
-define('DBQ_PARAM_DEFAULT',(string)(isset($_SERVER['DBQ_PARAM_DEFAULT'])
-  ? $_SERVER['DBQ_PARAM_DEFAULT']
-  : 'ls')
-);
-
 class DbQ extends nb {
   
   public $perm = 9; // Minimum permission access 0 = readonly
@@ -22,26 +16,28 @@ class DbQ extends nb {
   public $title = 'Dbq';
   public $sep_title = ' / ';
 
-  const HTML_FORMAT = 'table';
-  const CLI_FORMAT = 'human';
-  public $human_ua_exp = '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/';
-  public $formats = []; # for Db web list
-
-
-  const PARAM_ARGS_SEP = '|';
-  const PARAM_EXP = '[\w\._:-]{2,100}';
-  const PARAM_DB_DEFAULT = DBQ_PARAM_DEFAULT;
+  public $format_html = 'table';
+  public $format_cli = 'human';
+  public $format_cli_ua_exp = '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/';
+  public $limits = [];
+  # to overwrite Db web list
+  public $formats = [ 'html','csv','xml','json','yaml','sh','sql','php' ];
+
+  public $param_args_sep = '|';
+  public $param_exp_value = '[\w\._:-]{2,100}';
+  const PARAM_DB_DEFAULT = 'ls';
+  #public $action = 'ls';
   public $params = [
     'format' => '',
     'db' => self::PARAM_DB_DEFAULT,
-    'table' => 'ls',
-    'action' => 'ls',
+    'table' => self::PARAM_DB_DEFAULT,
+    'action' => self::PARAM_DB_DEFAULT,
     'args' => '',
   ];
 # NB 23.12.16   public $params_deep = [];
 
-  public $css = '/default.css';
-  public $js = '/default.js';
+  public $css = '/default'.(PRODUCTION ? '.min' : '').'.css';
+  public $js = '/default'.(PRODUCTION ? '.min' : '').'.js';
   public $ext;
 
   public $uri;
@@ -62,7 +58,7 @@ class DbQ extends nb {
       'title',
       'css',
       'js',
-      'human_ua_exp'
+      'format_cli_ua_exp'
     ] as $k) {
       $env = 'DBQ_'.strtoupper($k);
       if (!empty($_SERVER[$env])) $this->$k = $_SERVER[$env];
@@ -100,21 +96,33 @@ class DbQ extends nb {
     if ($run) $this->run();
   }
 
+  public function limit($set=false) {
+    static $limit=false;
+    if ($set !== false) return ($limit=$set);
+
+    if ($limit !== false) return $limit;
+
+    if ($limit=$this->p('limit')) return $limit;
+    if ($this->page->is('html')) return ($limit=$this->default_limit);
+
+  }
+
   public function page($obj,$meth=null,$head=[],$fct=null) {
 
     // Write output
 
-    $this->default_limit = $this->db->limits[0];
-    $this->pdef('limit',$this->default_limit);
-    $this->db->limit = $this->p('limit');
+    if (empty($this->default_limit)) $this->default_limit = $this->db->limits[0];
+    $this->db->limit = $this->limit();
+
     if (empty($this->_nopage)) {
 
       $this->page->headers_no_cache();
       $this->page->js = $this->js;
       $this->page->js_code = 'window._dbq = '
         . json_encode([
-        'HTML_FORMAT' => self::HTML_FORMAT,
-        'default.format' => self::HTML_FORMAT,
+        'db.base' => ( empty($this->db) ? '' : $this->db->base ),
+        'table.base' => ( empty($this->table) ? '' : $this->table->base ),
+        'default.format' => $this->format_html,
         'default.limit' => $this->default_limit,
         'param.format' => $this->params['format'],
         'param.db' => $this->params['db'],
@@ -124,6 +132,10 @@ class DbQ extends nb {
         ])
       .'';
 
+      list($title,$nav) = $this->title_nav();
+      $this->page->title = join($this->sep_title,$title);
+      $this->page->nav = $nav;
+
       $this->page->begin();
     }
 
@@ -215,7 +227,7 @@ class DbQ extends nb {
     if (!$keys) $keys = $all;
     $keys = array_keys($keys);
 
-    $values = explode(self::PARAM_ARGS_SEP,$this->params['args']);
+    $values = explode($this->param_args_sep,$this->params['args']);
 
     $this->table->html_edit(array_combine($keys,$values),$this->table->base.($add ? 'insert/' : 'update/').$this->params['args'],$add);
   }
@@ -226,13 +238,8 @@ class DbQ extends nb {
       and ($this->perm >= self::VIEW)
       and $this->table->type() != 'sql'
     ) ? [
-      'buttons' => join('&nbsp;',[
-        '<input type="submit" class="button button-small" value="GO"/>',
-        '<input type="button" class="button button-small" onclick="window.location=\''.$this->table->base.'add/'.'\'" value="Add"/>',
-        '<input type="button" class="button button-small" onclick="form_clean(this.form)" value="X"/>',
-      ]),
       'row_parse_pre' => function(&$r){
-        $GLOBALS['dbq_args'] = urlencode( join(self::PARAM_ARGS_SEP,$this->table->fields_keys_values($r)) );
+        $GLOBALS['dbq_args'] = urlencode( join($this->param_args_sep,$this->table->fields_keys_values($r)) );
       },
       'row_parse_post' => function(&$r){
 
@@ -255,6 +262,7 @@ class DbQ extends nb {
     ] : [];
 
     $this->table->rows($opt);
+    unset($GLOBALS['dbq_args']);
   }
 
 
@@ -290,6 +298,9 @@ class DbQ extends nb {
     $params = $this->params;
     $ext = $this->ext;
 
+    /*
+    $title = array_unique(array_slice(array_values($params),1));
+    */
     $title = array_filter(array_unique(array_slice(array_values($params),1)),
       function($v){
         return($v==self::PARAM_DB_DEFAULT ? '' : $v);
@@ -353,13 +364,17 @@ class DbQ extends nb {
 
         # Sanitize
         if ($values[$i]!=='') {
+
           $values[$i] = urldecode($values[$i]);
+
           if (
             $this->perm < self::ADMIN
             and
-            !preg_match('/^'.self::PARAM_EXP.'$/',$values[$i])
+            !preg_match('/^'.$this->param_exp_value.'$/',$values[$i])
           ) $this->error('Wrong value');
+
           $this->params[$p] = $values[$i];
+
         }
 
       }
@@ -484,9 +499,9 @@ class DbQ extends nb {
 
     } else {
       $format = 
-        (!empty($_SERVER['HTTP_USER_AGENT']) and preg_match($this->human_ua_exp,$_SERVER['HTTP_USER_AGENT']))
+        (!empty($_SERVER['HTTP_USER_AGENT']) and preg_match($this->format_cli_ua_exp,$_SERVER['HTTP_USER_AGENT']))
           ? 'html'
-          : self::CLI_FORMAT
+          : $this->format_cli
       ;
 
     }
@@ -494,20 +509,17 @@ class DbQ extends nb {
     // Post defaults values
     if (empty($this->ext)) $this->ext = $format;
 
-    list($title,$nav) = $this->title_nav();
-    $this->page->title = join($this->sep_title,$title);
-    $this->page->nav = $nav;
-
     if (!empty($this->formats)) $this->db->formats = $this->formats;
+    if (!empty($this->limits)) $this->db->limits = $this->limits;
 
     // Then content type
-    if (empty($content_type)) $content_type = Mime::fromExt($format==self::CLI_FORMAT ? 'txt' : $format);
+    if (empty($content_type)) $content_type = Mime::fromExt($format==$this->format_cli ? 'txt' : $format);
     if (empty($content_type) and $this->db->out->is_html($format)) $content_type = 'text/html';
     if (empty($content_type)) $content_type = 'text/plain';
     if ($content_type) $this->page->content_type($content_type);
 
     // Affect values to objects
-    if ($format == 'html') $format = self::HTML_FORMAT;
+    if ($format == 'html') $format = $this->format_html;
     $this->params['format'] = $format;
     $this->db->format = $format;
 
@@ -578,11 +590,19 @@ class DbQ extends nb {
         [ 'ls', 'List configured databases' ],
         [ 'databases', 'List others databases' ],
         [ 'cryptkey', 'Generate a random encryption key' ],
+        [ 'status', 'Status infos page' ],
       ],['command','description'],function(&$r) {
-        $r['command'] = $this->page->tag('a',$r['command'],'href="'.$this->db->base.$r['command'].'.'.$this->ext.'"');
+        $r['command'] = $this->page->tag('a',$r['command'],'href="'
+          .$this->db->base.($r['command'] == self::PARAM_DB_DEFAULT
+            ? ''
+            : $r['command'].'.'.$this->ext
+          )
+        .'"');
       });
 
     } elseif ($action == 'ls') {
+      #$this->params += [ 'db' => '', 'table' => '', 'action' => '' ];
+      #$this->params = array_merge($this->params,[ 'db' => '', 'table' => '', 'action' => '' ]);
       $this->page($this->db,'ls',[],function(&$r){
         $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.$r['id'].'.'.$this->ext.'"');
       });
@@ -632,7 +652,12 @@ class DbQ extends nb {
         [ 'status', 'Database status' ],
         [ 'ls', 'List tables' ],
       ],['command','description'],function(&$r){
-        $r['command'] = $this->page->tag('a',$r['command'],'href="'.$this->db->base.$r['command'].'.'.$this->ext.'"');
+        $r['command'] = $this->page->tag('a',$r['command'],'href="'
+          .$this->db->base.($r['command'] == self::PARAM_DB_DEFAULT
+            ? ''
+            : $r['command'].'.'.$this->ext
+          )
+        .'"');
       });
 
     } elseif ($action == 'ls') {
@@ -669,19 +694,25 @@ class DbQ extends nb {
         [ 'help', 'This help' ],
         [ 'ls', 'List records' ],
         [ 'fields', 'List fields' ],
+        [ 'status', 'Status page' ],
       ],['command','description'],function(&$r){
-        $r['command'] = $this->page->tag('a',$r['command'],'href="'.$this->db->base.$r['command'].'.'.$this->ext.'"');
+        $r['command'] = $this->page->tag('a',$r['command'],'href="'
+          .$this->table->base.($r['command'] == self::PARAM_DB_DEFAULT
+            ? ''
+            : $r['command'].'.'.$this->ext
+          )
+        .'"');
       });
 
     } elseif ($action == 'ls') {
       $this->page($this,'table_rows');
 
-    } elseif ($action == 'status') {
-      $this->page($this->table->status()+$this->table->status(['fields']));
-
     } elseif ($action == 'fields') {
       $this->page($this->table,'fields_rows');
 
+    } elseif ($action == 'status') {
+      $this->page($this->table->status()+$this->table->status(['fields']));
+
     } elseif ($action == 'add') {
       $this->page($this,'table_html_add');
 
index cd9e06928027f8dfd88a9488cc5052949106a747..300db01c066de20e2f866a0694f7c82cb74025cd 100644 (file)
@@ -24,6 +24,8 @@ services:
       context: ../Docker/nginx/
       args:
         - WWW_ROOT=$NB_ROOT/www/dbq/html
+        - FASTCGI_PASS=php:9000
+        #- CONF=$NB_ROOT/www/dbq/etc/nginx/default.conf
     volumes_from:
       - php
     links:
index 5ce711207abd9323f7a44aa7e1da1e7fc75fbb72..109add2e820e4da8bcf120357fce8985a791d366 100644 (file)
@@ -61,7 +61,8 @@ server {
 
         fastcgi_param DBQ_CONF_FILE $document_root/../../../etc/dbq/000-local.php;
         fastcgi_param DBQ_PERM 0;
-        fastcgi_param DBQ_PARAM_DEFAULT ls;
+        fastcgi_param DBQ_PARAM_DB ls;
+        fastcgi_param PRODUCTION 1;
         #fastcgi_param DBQ_TITLE 'Local Db';
     }
 
index 58d148d4db36e887f0012c4983308860310d316b..b796c96f725760fa2c45828f1be8c89383dceb1c 100644 (file)
@@ -67,6 +67,7 @@ form select {
 
 table.rows,
 div.row,
+ul.row,
 form.edit,
 .menu,
 .block,
@@ -83,13 +84,14 @@ object, iframe, pre
 }
 
 .rows { padding: 0; }
-div.row div, table.rows th, table.rows td { border-bottom: solid 1px #ccc; }
-div.row div, table.rows tr:last-child td { border-bottom: none; }
-div.row div {
-  margin: 0;
+ul.row li, div.row div, table.rows th, table.rows td {
+  border-bottom: solid 1px #ccc;
 }
+ul.row li, div.row div, table.rows tr:last-child td { border-bottom: none; }
+
+div.row div { margin: 0; }
 
-div.row div label {
+ul.row li label, div.row div label {
   padding: 0.1em 0.5em 0.1em 0;
   min-width: 20%;
   display: inline-block;
@@ -127,7 +129,14 @@ a:hover,
   opacity: 0.8;
 }
 
-.menu { padding: 0.5em; }
+form.menu {
+  padding: 0.5em;
+  background-color: #F9F9F9;
+}
+
+form.menu .button.add {
+  float: right;
+}
 
 form.menu .criterias {
   border-top: dashed 1px #ccc;
@@ -136,15 +145,28 @@ form.menu .criterias {
 }
 
 form.menu .criterias span.label {
-  /*
-  width: 23%;
-  */
-  display: inline-block;
-  border: solid 1px #fff;
-  padding: 0.1em 0.3em;
+  border-right: solid 1px #fff;
+  padding: 0.2em 0.1em;
   margin: 0.2em 0.2em 0 0;
   border-radius: 3px;
 }
+form.menu .criterias span.label:last-child {
+  border-right: none;
+}
+
+form.menu select:focus {
+  max-width: auto;
+}
+form.menu select {
+  max-width: 15%;
+}
+
+form.menu .criterias input[type=text]:focus {
+  width: auto;
+}
+form.menu .criterias input[type=text] {
+  width: 4em;
+}
 /*
 form.menu .criterias label {
   width: 60%;
index f7a140b5af701dd9594d6edddaff9186c87ac7bc..00e38ec188d67b0a675709252dc7be1c3dfefe22 100644 (file)
@@ -1,20 +1,29 @@
-// NB 25.12.16: TODEL 
 /*
+NB 25.12.16: TODEL 
 function form_submit_clean(form) {
   form_clean(form);
   form.submit();
 }
 
+*/
 function form_clean(form) {
     var e;
     for(i=0;i<form.length;i++) {
       e = form.elements[i];
       if (e.style.display == "none") continue;
-      if (e.type != "text") continue;
-      e.value = ""
+
+      if (e.type == "text") {
+        e.value = "";
+      } else if (e.type.match(/^select/) && (0
+        || e.name == 'limit'
+        || e.name == 'format'
+      )) {
+        e.selectedIndex = 0;
+      /*
+      */
+      }
     }
 }
-*/
 
 function form_submit_clean(f) {
   var i = 0;
@@ -31,7 +40,6 @@ function form_submit_clean(f) {
     url += (url ? "&" : "?") + encodeURI(p.name) + "=" + encodeURI(p.value);
   }
 
-  //alert(url);
   url = (action == "?" ? "" : action) + url;
 
   window.location = url;
@@ -40,56 +48,72 @@ function form_submit_clean(f) {
 
 document.addEventListener("DOMContentLoaded", function() {
 
-  // Clean when submit
-  for (var e of document.querySelectorAll("form")) {
+  //console.log('LOADED');
+  NodeList.prototype.forEach = Array.prototype.forEach;
+
+  /* Clean when submit */
+  document.querySelectorAll("form").forEach(function(e) {
     e.onsubmit = function() {
       return form_submit_clean(this);
     };
-  }
+  });
 
   /*
     Menu
   */
-  for (var form of document.querySelectorAll("form.menu")) {
+  document.querySelectorAll("form.menu").forEach(function(form) {
     form.setAttribute('action',window.location.toString().replace(/\?.*$/,''));
 
-    // Format
-    for (var e of form.querySelectorAll("form.menu select.format")) {
+    /* Format */
+    form.querySelectorAll("form.menu select.format").forEach(function(e) {
       e.removeAttribute('name');
       e.onchange = function() {
-        var format = this.value;
-        if (format == window._dbq["HTML_FORMAT"]) format = "html";
-        this.form.setAttribute('action',this.form.getAttribute('action').replace(/(\/|\.\w+)$/,'.'+format));
+        this.form.setAttribute('action',this.form.getAttribute('action').replace(/^(.*\/[^\.?\/]+)(\.\w+)?/,'$1.'+this.value));
         this.form.onsubmit();
         return false;
       }
-    }
+    });
 
-    // Table
-    for (var e of form.querySelectorAll("form.menu select.tables")) {
+    /* Table */
+    form.querySelectorAll("form.menu select.tables").forEach(function(e) {
       e.removeAttribute('name');
       e.onchange = function() {
-        this.form.setAttribute('action',this.form.getAttribute('action').replace(/([^\/\.]+)(\.\w+)?$/,this.value+'$2'));
+        this.form.setAttribute('action',this.form.getAttribute('action').replace(/^(.*\/)[^\/\.\?]+/,'$1'+this.value));
         return this.form.onsubmit();
       }
-    }
+    });
 
-    // Limit
-    for (var e of form.querySelectorAll("form.menu select.limit option")) {
+    /* Limit */
+    form.querySelectorAll("form.menu select.limit option").forEach(function(e) {
       if (e.value == window._dbq["default.limit"]) e.setAttribute('value','');
-    }
+    });
 
-    // Auto submit
-    for (var e of form.querySelectorAll("form.menu select.limit")) {
+    /* Auto submit */
+    form.querySelectorAll("form.menu select.limit").forEach(function(e) {
       e.onchange = function() {
         return this.form.onsubmit();
       };
-    }
+    });
 
-  }
+  });
 
   if (document.querySelector(".nav.bottom") && document.querySelector("table.rows")) {
     document.querySelector("table.rows").insertAdjacentHTML("beforebegin","<div class=\"nav top\">"+document.querySelector(".nav.bottom").innerHTML+"</div>");
   }
 
+  /*
+  document.querySelectorAll("form.menu input[type=text]").forEach(function(e) {
+    e.onfocus = function() {
+      this.setAttribute('style','border:solid 1px red');
+    };
+  });
+  */
+
+  document.querySelectorAll("form.menu input[type=submit]").forEach(function(e) {
+    e.insertAdjacentHTML("afterend",''
+      +'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="Clear"/>'
+      +(window._dbq['table.base'] ? '&nbsp;<input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq['table.base']+'add/\'" value="Add"/>' : '')
+    );
+  });
+
 });
diff --git a/www/dbq/html/default.min.css b/www/dbq/html/default.min.css
new file mode 100644 (file)
index 0000000..6a3cbe5
--- /dev/null
@@ -0,0 +1 @@
+html{font:90% 'Trebuchet MS',sans-serif;background-color:#eee}body{display:table;margin-left:auto;margin-right:auto;padding-left:1em;padding-right:1em;color:#444}h1{margin:0 0 0.2em 0}a{color:inherit}a,a:visited{text-decoration:none}ul{padding:0;margin:0}li{list-style:none;padding:0 0 0 0.3em}table{border-collapse:collapse}td,th{padding:0.2em 0.7em}th a.sort{padding:0 0.3em}textarea,select,input:not([type]),input[type='text'],input[type='password'],input[type='date'],input[type='email'],input[type='url'],input[type='']{border-radius:3px;border:solid 1px #ddd;padding:0.3em 0.4em}input[size]{max-width:70%}div.row div label:after,form label:after{content:':'}form label,form input,form select{vertical-align:middle;margin:0.2em 0.4em 0.2em 0}table.rows,div.row,form.edit,.menu,.block,object,iframe,pre{border-radius:4px;border-collapse:separate;border-spacing:0;padding:0.5em 0.2em;margin-bottom:0.5em;border:solid 1px #ccc}.rows{padding:0}div.row div,table.rows th,table.rows td{border-bottom:solid 1px #ccc}div.row div,table.rows tr:last-child td{border-bottom:none}div.row div{margin:0}div.row div label{padding:0.1em 0.5em 0.1em 0;min-width:20%;display:inline-block}.menu,.nav,.rows,.buttons,.center{margin-left:auto;margin-right:auto;display:table}.button{font:inherit;display:inline-block;text-decoration:none;line-height:1.5em;cursor:pointer;border-radius:4px;white-space:nowrap;box-sizing:border-box;margin:0;padding:0 0.2em;color:#eee;border:solid 1px #000;background-color:#444}a:hover,.button:hover{opacity:0.8}form.menu{padding:0.5em;background-color:#F9F9F9}form.menu .button.add{float:right}form.menu .criterias{border-top:dashed 1px #ccc;margin-top:0.3em;padding-top:0.3em}form.menu .criterias span.label{border-right:solid 1px #fff;padding:0.2em 0.1em;margin:0.2em 0.2em 0 0;border-radius:3px}form.menu .criterias span.label:last-child{border-right:none}form.menu select:focus{max-width:auto}form.menu select{max-width:15%}form.menu .criterias input[type=text]:focus{width:auto}form.menu .criterias input[type=text]{width:4em}form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}form.edit .fields .label span{width:54%;display:inline-block;text-align:left}form.edit .fields input,form.edit .fields textarea,form.edit .fields select{width:65%}form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}form.edit .fields .label span{width:54%;display:inline-block;text-align:left}form.edit .fields input,form.edit .fields textarea,form.edit .fields select{width:65%}
\ No newline at end of file
diff --git a/www/dbq/html/default.min.js b/www/dbq/html/default.min.js
new file mode 100644 (file)
index 0000000..c947a76
--- /dev/null
@@ -0,0 +1,5 @@
+function form_clean(e){var t
+for(i=0;i<e.length;i++)t=e.elements[i],"none"!=t.style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action"),r=e.getAttribute("method")
+if("get"!=r)return!0
+for(t=0;t<e.length;t++){var i=e[t]
+i.name&&""!=i.value&&"undefined"!=i.value&&(n+=(n?"&":"?")+encodeURI(i.name)+"="+encodeURI(i.value))}return n=("?"==o?"":o)+n,window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",this.form.getAttribute("action").replace(/^(.*\/[^\.?\/]+)(\.\w+)?/,"$1."+this.value)),this.form.onsubmit(),!1}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",this.form.getAttribute("action").replace(/^(.*\/)[^\/\.\?]+/,"$1"+this.value)),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit option").forEach(function(e){e.value==window._dbq["default.limit"]&&e.setAttribute("value","")}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",'&nbsp;<input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="Clear"/>'+(window._dbq["table.base"]?'&nbsp;<input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'add/\'" value="Add"/>':""))})})
diff --git a/www/dbq/minify.sh b/www/dbq/minify.sh
new file mode 100755 (executable)
index 0000000..5e4b551
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env sh
+set -e
+cd "$(dirname $0)" 
+
+minify -s '.min.' --no-comments html/
+exit
+
+# NB 27.12.16 alias minify='minify --no-comments'
+# NB 27.12.16 
+# NB 27.12.16 echo Create html/default.min.css
+# NB 27.12.16 minify -o html/default.min.css html/default.css
+# NB 27.12.16 echo
+# NB 27.12.16 
+# NB 27.12.16 echo Create html/default.min.js
+# NB 27.12.16 minify -o html/default.min.js html/default.js
+# NB 27.12.16 echo