]> git.nbdom.net Git - nb.git/commitdiff
dbq
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 5 Dec 2016 16:34:56 +0000 (16:34 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 5 Dec 2016 16:34:56 +0000 (16:34 +0000)
lib/php/db/table.php
lib/php/out.php
www/dbq/html/default.css
www/dbq/html/index.php

index 5294cded837524bea2d0470836a60dcbaa3f4806..f1ff7979b38ef0775da9e813490af026270510cc 100644 (file)
@@ -833,7 +833,7 @@ Class Table extends nb {
     $opt['use_out'] = false;
 
     if ($this->p('out') or !preg_match('/^('.join('|',
-      [ '','template','table','sql','div','wp','_csv','_xml','_json','_yaml' ] # local
+      [ '','template','table','sql','div','wp' ] # local
     ).')$/',$format))
     {
 
index f7e3d8311668d704c6748f5fd640c9910289b924..e8aa4a635697da5a09c3899be408bc33262fc793 100644 (file)
@@ -201,7 +201,7 @@ Class Out extends Nb {
 
       'json' => array(
         #'enclose' => array('['.NB_EOL,NB_EOL.']'),
-        'enclose' => array('[',']'),
+        'enclose' => array('['.self::p('eol',NB_EOL),']'),
         'row' => function(&$o,&$row) { return json_encode($row); },
         'eol' => self::p('eol',NB_EOL),
         'rec' => ',',
index 6dd4b1893f1587ef1690db2d98a447d0e7621e96..b40665e55fd8d836c5962a19c2b5074009a73444 100644 (file)
@@ -9,6 +9,7 @@ body {
   padding-left: 1em;
   padding-right: 1em;
   background-color: #E6E6E6;
+  background-color: #009B9C;
 }
 
 h1 {
@@ -17,7 +18,7 @@ h1 {
 
 a,
 body {
-  color: #333333;
+  color: #cccccc;
 }
 
 ul {
@@ -94,8 +95,8 @@ table.rows tr:last-child td { border-bottom: none; }
        text-decoration: none;
        line-height: 1.5em;
        cursor: pointer;
-  background-color: #3C3C3B;
-       border: solid 1px #3C3C3B;
+  background-color: #cccccc;
+       border: solid 1px #cccccc;
   border-radius: 4px;
        -webkit-border-radius: 4px;
        white-space: nowrap;
@@ -105,6 +106,7 @@ table.rows tr:last-child td { border-bottom: none; }
   color: #ddd;
        margin: 0;
   padding: 0 0.2em;
+  color: #009B9C;
 }
 
 a:hover,
index b16fecf8db22ecf43bbd3dae440b0740b2534d72..1fee63bb6012e2395f5c6033ebe400deb9c1ca6e 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 # Make it work in php_cli
 if (empty($_SERVER['DOCUMENT_ROOT'])) $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
+if (empty($_SERVER['HTTP_USER_AGENT'])) $_SERVER['HTTP_USER_AGENT'] = '';
 #var_export([$_SERVER['REQUEST_URI']]);
 
 function run() {
@@ -8,7 +9,7 @@ function run() {
     'db' => 'ls',
     'table' => 'ls',
     'action' => 'ls',
-    'format' => 'human',
+    'format' => ( preg_match('/^\S+\s+.Windows|iPhone|Android|Macintosh/',$_SERVER['HTTP_USER_AGENT']) ? 'table' : 'human' ),
   ]);
 
   if (!$params['db']) not_implemented();
@@ -16,6 +17,13 @@ function run() {
   #
   # Page
   require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/page.php');
+  Page::pdef('out',1);
+  $formats = array_keys(out::types());
+  foreach ($params as $k=>$v) {
+    if (!in_array($v,$formats)) continue;
+    $params['format'] = $v;
+    break;
+  }
   $Page = new Page([
     'css' => '/default.css',
   ]);
@@ -103,7 +111,7 @@ function run() {
     return $Page->end();
 
   } elseif ($params['action'] == 'status') {
-    $Db->out($Table->status()+$Table->status(['fields','sql']));
+    $Db->out($Table->status()+$Table->status(['fields']));
     return $Page->end();
 
   } elseif ($params['action'] == 'fields') {