]> git.nbdom.net Git - nb.git/commitdiff
Nav
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 6 Dec 2016 12:33:06 +0000 (12:33 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 6 Dec 2016 12:33:06 +0000 (12:33 +0000)
www/dbq/dbq.php
www/dbq/html/default.css

index 35edcc6ee24ad6c02501d48aae5aa3284dca4567..a6a7fb0d8176c415328aa856853d91515870eb75 100644 (file)
@@ -2,6 +2,10 @@
 
 function dbq_run() {
 
+  $colors = [
+    'text' => '#ddd',
+    'background' => '#009B9C',
+  ];
   #
   # Url
   if (empty($_SERVER['HTTP_USER_AGENT'])) $_SERVER['HTTP_USER_AGENT'] = '';
@@ -22,32 +26,32 @@ function dbq_run() {
   # Page
   if (empty($_SERVER['DOCUMENT_ROOT'])) $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__).'/html';
   require_once($_SERVER['DOCUMENT_ROOT'].'/../../../lib/php/page.php');
-  #debug(nb::p());
-  #debug($params);
-  $title = array_filter(array_unique(array_slice(array_values($params),1)),function($v){ return($v=='ls' ? '' : $v); });
-  array_unshift($title,'Home');
   $params['ext'] = $ext;
-  $path = '/';
-  $nav = [];
-  #debug($title);
-  $i = 0;
-  foreach ($title as $k=>$v) {
-    if ($i == 0) {
-      $nav[] = [$v,'/'];
-    } else {
-      $nav[] = [$v,"$path$v.".$params['ext']];
-      $path .= "$v/";
-    }
-    $i++;
-  }
+  list($title,$nav) = title_nav($params);
   #debug($nav);
   $Page = new Page([
     'css' => '/default.css',
     'title' => join(' ',$title),
-    #'h1' => join(' ',array_map(function($v) use($Page,$params){},$nav)),
     'nav' => $nav,
   ]);
 
+  if (!empty($colors)) $Page->css_code = trim('
+body, .button {
+  color: '.$colors['text'].';
+  background-color: '.$colors['background'].';
+}
+.button {
+  border-color: '.$colors['text'].';
+}
+table.rows,
+div.rows,
+.menu,
+object, iframe, pre
+{
+  border-color: '.$colors['text'].';
+}
+table.rows th, table.rows td { border-color: '.$colors['text'].'; }
+');
   $Page->content_type($Page->ext2mime($params['format']) ? $Page->ext2mime($params['format']) : 'text/plain');
   if ($Page->is('text') and !$Page->is('html')) $Page->content_type('text/plain');
   $Page->headers_no_cache();
@@ -205,6 +209,24 @@ function not_implemented() {
   echo "$msg\n";
   exit;
 }
+
+function title_nav($params) {
+  $title = array_filter(array_unique(array_slice(array_values($params),1)),function($v){ return($v=='ls' ? '' : $v); });
+  array_unshift($title,'Home');
+  $path = '/';
+  $nav = [];
+  $i = 0;
+  foreach ($title as $k=>$v) {
+    if ($i == 0) {
+      $nav[] = [$v,'/'];
+    } else {
+      $nav[] = [$v,"$path$v.".$params['ext']];
+      $path .= "$v/";
+    }
+    $i++;
+  }
+  return [$title,$nav];
+}
 # NB 05.12.16 function row_a(&$v) {
 # NB 05.12.16   $v = Page::tag('a',$r['command'],'href="'.$r['command'].'.'.$params['ext'].'"');
 # NB 05.12.16 }
index 4d4b68050267f942aa62941e85c76a2785793546..50833b70080bf0a8cf64876cb7b97634739c2044 100644 (file)
@@ -8,16 +8,18 @@ body {
   margin-right: auto;
   padding-left: 1em;
   padding-right: 1em;
-  background-color: #009B9C;
 }
 
 h1 {
   margin: 0 0 0.2em 0;
 }
 
-a,
-body {
-  color: #ddd;
+a {
+  color :inherit;
+}
+
+a, a:visited {
+  text-decoration: none;
 }
 
 ul {
@@ -30,10 +32,6 @@ li {
   padding: 0 0 0 0.3em;
 }
 
-a, a:visited {
-  text-decoration: none;
-}
-
 table { border-collapse: collapse; }
 td, th { padding: 0.2em 0.7em; }
 
@@ -65,18 +63,18 @@ div.rows,
 .menu,
 object, iframe, pre
 {
+  border-radius: 2px;
   border-collapse: separate;
   border-spacing: 0;
-  border-radius: 2px;
-  border: solid 1px #ddd;
 
   padding: 0.5em 0.2em;
   margin-bottom: 0.5em;
+  border: solid 1px;
 
 }
 
 table.rows { padding: 0; }
-table.rows th, table.rows td { border-bottom: solid 1px #ddd; }
+table.rows th, table.rows td { border-bottom: solid 1px; }
 table.rows tr:last-child td { border-bottom: none; }
 
 .menu, .nav, .rows,
@@ -94,15 +92,11 @@ table.rows tr:last-child td { border-bottom: none; }
        text-decoration: none;
        line-height: 1.5em;
        cursor: pointer;
-  background-color: #ddd;
-       border: solid 1px #ddd;
   border-radius: 4px;
        white-space: nowrap;
        box-sizing: border-box;
-  color: #ddd;
        margin: 0;
   padding: 0 0.2em;
-  color: #009B9C;
 }
 
 a:hover,