]> git.nbdom.net Git - nb.git/commitdiff
share/templates/netrc.php
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 9 Dec 2017 05:48:02 +0000 (05:48 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 9 Dec 2017 05:48:02 +0000 (05:48 +0000)
bin/nb-read.php [new file with mode: 0755]
bin/nb-stdin [deleted file]
lib/php/nb.php
share/templates/netrc.php
www/dbq/html/default.css

diff --git a/bin/nb-read.php b/bin/nb-read.php
new file mode 100755 (executable)
index 0000000..1fe5d83
--- /dev/null
@@ -0,0 +1,47 @@
+#!/usr/bin/env php
+<?php
+/**
+* @copyright (C) 2017 Nicolas Boisselier
+* @author Nicolas Boisselier <nicolas.boisselier@gmail.com>
+*
+* bin/nb-stdin
+*/
+require_once(dirname(__FILE__).'/../lib/php/nb.php');
+define('USAGE','nb-read.php METHOD_TO_READ_LINES FUNCTION1, FUNCTION2, ... '."\n");
+define('NAME',$argv[0]); array_shift($argv);
+if (!$argv) die(USAGE);
+define('METHOD',$argv[0]); array_shift($argv);
+
+$NB = new NB();
+
+while($line = get_line()) {
+       $line = rtrim($line);
+
+       foreach ($argv as $fct) {
+
+               if ($fct === 'cat') {
+                       if ($line) $line = file_get_contents($line);
+
+               } else {
+                       $line = $NB->$fct($line);
+
+               }
+
+       }
+
+       echo $line."\n";
+}
+
+function get_line() {
+       global $argv;
+       static $bye;
+       if (!empty($bye)) return;
+
+       if (METHOD == 'fgets') return fgets(STDIN);
+       if (METHOD == 'cat') return file_get_contents(fgets(STDIN));
+
+       $bye = true;
+       array_unshift($argv,METHOD); # that is not e method, push it back to argv
+       return stream_get_contents(STDIN);
+}
+?>
diff --git a/bin/nb-stdin b/bin/nb-stdin
deleted file mode 100755 (executable)
index 717db94..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
-* @copyright (C) 2017 Nicolas Boisselier
-* @author Nicolas Boisselier <nicolas.boisselier@gmail.com>
-*
-* bin/nb-stdin
-*/
-require_once(dirname(__FILE__).'/../lib/php/nb.php');
-define(NAME,$argv[0]); array_shift($argv);
-
-$NB = new NB();
-
-#$data = stream_get_contents(STDIN);
-while($line = fgets(STDIN)) {
-       $line = rtrim($line);
-
-       foreach ($argv as $fct) {
-
-               if ($fct === 'cat') {
-                       if ($line) $line = file_get_contents($line);
-
-               } else {
-                       $line = $NB->$fct($line);
-
-               }
-
-       }
-
-       echo $line."\n";
-}
-?>
index 0c8709556239b3bbdf8ce22cdada6f8ade1ecbd6..89ff083e27051c1a1ec434de6e67f7a85630a1f6 100644 (file)
@@ -999,7 +999,7 @@ class NB {
   public static function minify_js($code) {
     if (strpos($code,'/') === 0) $code = file_get_contents($code);
          require_once(NB_ROOT.'/lib/php/jsmin.php');
-               return JSMin::minify($code);
+               return trim(JSMin::minify($code));
   }
 
   public static function minify_css($code) {
@@ -1021,10 +1021,12 @@ class NB {
 
       array_shift($m);
       foreach ($m as $k=>$v) {
-        #$m[$k] = str_replace(' ','',$m[$k]);
-        #$m[$k] = trim($m[$k]);
-        $m[$k] = preg_replace('/\s*(\W)\s*/','$1',$m[$k]);
-        #$m[$k] = ':'.$m[$k].':';
+        #$v = str_replace(' ','',$v);
+        #$v = trim($v);
+        $v = preg_replace('/\s*(\W)\s*/','$1',$v);
+        #$v = ':'.$v.':';
+        $m[$k] = $v;
+                               #debug($v);
       }
       #bye($m);
       #debug($m);
@@ -1035,16 +1037,21 @@ class NB {
     $code = preg_replace_callback('/\s*(\{|;)\s*([\w-]+)\s*(:)\s*/',function($m){
 
       array_shift($m);
-      return join('',$m);
       #bye($m);
+      #return join('',$m);
       foreach ($m as $k=>$v) {
-        $m[$k] = trim($m[$k]);
+                               #if (!$v) continue;
+        $v = trim($v);
+        #$v = preg_replace('/\s*,\s*/',',',$v);
+        $m[$k] = $v;
       }
+
       return join('',$m);
+
     },$code);
 
     // redudant
-    $code = str_replace(':}','}',$code);
+    $code = str_replace(';}','}',$code);
 
     return $code;
   }
index fb2221bad0a91f32d2e78e0cabe61174b60bc7d3..0e79dd165efa1d0446b6a4d07eab5c200c052622 100644 (file)
@@ -3,26 +3,26 @@
        $login = '';
        $password = '';
 
+       #debug($ROW);
        if (!empty($ROW['machine'])) $machine = $ROW['machine'];
        elseif (!empty($ROW['url'])) $machine = $ROW['url'];
        elseif (!empty($ROW[0])) $machine = $ROW[0];
+       $machine = preg_replace(',^(\w+://)?([^/]+).*$,','$2',$machine);
+       if (!$machine) return;
 
        if (!empty($ROW['login'])) $login = $ROW['login'];
        elseif (!empty($ROW['user'])) $login = $ROW['user'];
        elseif (!empty($_ENV['user'])) $login = $_ENV['user'];
-       elseif (!empty($ROW[2])) $login = $ROW[2];
+       elseif (!empty($ROW[1])) $login = $ROW[1];
 
        if (!empty($ROW['password'])) $password = $ROW['password'];
        elseif (!empty($ROW['passwd'])) $password = $ROW['passwd'];
        elseif (!empty($ROW['pass'])) $password = $ROW['pass'];
        elseif (!empty($_ENV['password'])) $password = $_ENV['password'];
-       elseif (!empty($ROW[3])) $password = $ROW[3];
-
-       if (!$machine) return;
-       $machine = preg_replace('@^(\w+://)?([^/]+).*$@','$1',$machine);
+       elseif (!empty($ROW[2])) $password = $ROW[2];
 
        echo "machine ".$machine
-               . "login ".$login
-               . "password ".$password
+               . ($login ? " login ".$login : '')
+               . ($password ? " password ".$password : '')
        ;
 ?>
index 7db2e2ff991f3c629b9f5209371ed425bd9f77e1..974e3c288003c4a762f8c040f7c0f0ffaa876fbe 100644 (file)
@@ -1,60 +1,54 @@
 html {
-  font: 90% 'Trebuchet MS', sans-serif;
-  background-color: #EEEEEE;
+       font: 90% 'Trebuchet MS', sans-serif;
+       background-color: #EEEEEE;
 }
 
 body {
-  display: table;
-  margin-left: auto;
-  margin-right: auto;
-  padding-left: 1em;
-  padding-right: 1em;
-  color: #444444;
+       display: table;
+       margin-left: auto;
+       margin-right: auto;
+       padding-left: 1em;
+       padding-right: 1em;
+       color: #444444;
 }
 
 h1 {
-  margin: 0 0 0.2em 0;
-  font-size: 180%;
-  /*
-  text-decoration: underline;
-  */
-  padding-bottom: 0.3em;
-  margin-bottom: 0.5em;
-  border-bottom: dashed 1px #444444;
+       margin: 0 0 0.2em 0;
+       font-size: 180%;
+       padding-bottom: 0.3em;
+       margin-bottom: 0.5em;
+       border-bottom: dashed 1px #444444;
 }
 
 a {
-  color: inherit;
+       color: inherit;
 }
 
 p a, div > a, li a, td a {
-  color: #3572B0;
+       color: #3572B0;
 }
 
 a, a:visited {
-  text-decoration: none;
+       text-decoration: none;
 }
 
 a:hover,
 .button:hover {
-  opacity: 0.8;
+       opacity: 0.8;
 }
 
 ul {
-  padding: 0;
-  margin: 0;
+       padding: 0;
+       margin: 0;
 }
 
 li {
-  list-style:none;
-  padding: 0 0 0 0.3em;
+       list-style:none;
+       padding: 0 0 0 0.3em;
 }
 
 table { border-collapse: collapse; }
 td, th { padding: 0.2em 0.7em; }
-/*
-td form { display: inline-block; }
-*/
 th a.sort { padding: 0 0.3em; }
 
 textarea,
@@ -66,14 +60,14 @@ input[type='date'],
 input[type='email'],
 input[type='url'],
 input[type=''] {
-  border-radius: 3px;
-  border: solid 1px #DDDDDD;
-  padding: 0.3em 0.4em;
-  box-shadow: 0px 1px 1px #EEEEEE;
+       border-radius: 3px;
+       border: solid 1px #DDDDDD;
+       padding: 0.3em 0.4em;
+       box-shadow: 0px 1px 1px #EEEEEE;
 }
 
 input[size] {
-  max-width: 70%;
+       max-width: 70%;
 }
 
 div.row div label:after,
@@ -82,8 +76,8 @@ form label:after { content: ':'; }
 form label,
 form input,
 form select {
-  vertical-align: middle;
-  margin: 0.2em 0.4em 0.2em 0;
+       vertical-align: middle;
+       margin: 0.2em 0.4em 0.2em 0;
 }
 
 table.rows,
@@ -94,63 +88,63 @@ form.edit,
 .block,
 object, iframe, pre
 {
-  border-radius: 4px;
-  border-spacing: 0;
+       border-radius: 4px;
+       border-spacing: 0;
 
-  padding: 0.5em 0.2em;
-  margin-bottom: 0.5em;
-  border: solid 1px #DDDDDD;
-  background-color: #FAFAFA;
-  box-shadow: 0px 1px 2px #EEEEEE;
+       padding: 0.5em 0.2em;
+       margin-bottom: 0.5em;
+       border: solid 1px #DDDDDD;
+       background-color: #FAFAFA;
+       box-shadow: 0px 1px 2px #EEEEEE;
 
 }
 
 .rows { padding: 0; }
 
 table.rows {
-  border-style: hidden;
-  border-collapse: collapse;
-  box-shadow: 0 0 0 1px #DDDDDD;
-  table-layout: fixed;
+       border-style: hidden;
+       border-collapse: collapse;
+       box-shadow: 0 0 0 1px #DDDDDD;
+       table-layout: fixed;
 }
 
 table.rows.fixed {
-  width: 100%;
+       width: 100%;
 }
 
 table.rows tr:nth-child(even) td {
-  background-color: #FEFEFE;
+       background-color: #FEFEFE;
 }
 
 ul.row li, div.row div, table.rows th, table.rows td {
-  border-bottom: solid 1px #DDDDDD;
+       border-bottom: solid 1px #DDDDDD;
 }
 
 ul.row li, div.row div, table.rows tr:last-child td { border-bottom: none; }
 
 table.rows th, table.rows td {
-  border-right: dashed 1px #DDDDDD;
+       border-right: dashed 1px #DDDDDD;
 }
 
 table.rows th {
-  text-align: left;
+       text-align: left;
 }
 
 table.rows td {
-  padding: 0.3em 0.3em;
+       padding: 0.3em 0.3em;
 }
 
 table.rows.fixed td
 {
-  white-space: nowrap;
-  text-overflow: ellipsis;
-  overflow: hidden;
+       white-space: nowrap;
+       text-overflow: ellipsis;
+       overflow: hidden;
 }
 
 table.rows td.view,
 table.rows td.delete {
-  width: 1%;
-  white-space: nowrap;
+       width: 1%;
+       white-space: nowrap;
 }
 
 table.rows.fixed th.view { width: 2em; }
@@ -163,13 +157,13 @@ table.rows tr:last-child td { padding-bottom: 0; }
 div.row div { margin: 0; }
 
 ul.row li label, div.row div label {
-  padding: 0.1em 0.5em 0.1em 0;
-  min-width: 20%;
-  display: inline-block;
+       padding: 0.1em 0.5em 0.1em 0;
+       min-width: 20%;
+       display: inline-block;
 }
 
 .button {
-  font: inherit;
+       font: inherit;
        display: inline-block;
        text-decoration: none;
        line-height: 1.6em;
@@ -177,78 +171,67 @@ ul.row li label, div.row div label {
        white-space: nowrap;
        box-sizing: border-box;
        margin: 0 0.1em 0 0;
-  padding: 0 0.3em;
-  border-radius: 4px;
-  border: none;
+       padding: 0 0.3em;
+       border-radius: 4px;
+       border: none;
 
-  /*
-  text-size: normal;
-  color: #EEEEEE;
-  background-color: #444444;
+       color: #3572B0;
+       background-color: #EEEEEE;
+       background: linear-gradient(to bottom right, #EEEEEE, #DDDDDD);
 
-  border: solid 1px #ccc;
-  box-shadow: 1px 1px 1px #888888;
-  border-top: solid 1px #EEEEEE;
-  border: solid 1px #EEEEEE;
-  font-weight: bold;
-  */
-  color: #3572B0;
-  background-color: #EEEEEE;
-  background: linear-gradient(to bottom right, #EEEEEE, #DDDDDD);
-
-  box-shadow: 0px 1px 1px #BBBBBB;
+       box-shadow: 0px 1px 1px #BBBBBB;
 
 }
 
 .menu, .nav, .rows, td.button, .center {
-  display: table;
+       display: table;
 }
 
 .menu, .nav, .rows, .buttons, td.button, .center {
-  margin-left: auto;
-  margin-right: auto;
+       margin-left: auto;
+       margin-right: auto;
 }
 
 div.buttons {
-  text-align: center;
-  margin-top: 0.5em;
+       text-align: center;
+       margin-top: 0.5em;
 }
 
 form.menu {
-  padding: 0.5em;
-  background-color: #FAFAFA;
+       padding: 0.5em;
+       background-color: #FAFAFA;
 }
 
 form.menu .button.add {
-  float: right;
-  margin-top: 0.2em;
-  /*
-  cursor: cell;
-  display: inline-block;
-  height: 1.5em;
-  display: inline-block;
-  top: 0.9em;
-  margin-top: 0.2em;
-  margin-top: 0.3ex;
-  margin-top: 2px;
-  display: inline;
-  */
+       float: right;
+       margin-top: 0.2em;
+       /*
+       cursor: cell;
+       display: inline-block;
+       height: 1.5em;
+       display: inline-block;
+       top: 0.9em;
+       margin-top: 0.2em;
+       margin-top: 0.3ex;
+       margin-top: 2px;
+       display: inline;
+       */
 }
 
 form.menu .criterias {
-  border-top: dashed 1px #DDDDDD;
-  margin-top: 0.3em;
-  padding-top: 0.3em;
+       border-top: dashed 1px #DDDDDD;
+       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;
+       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;
+       border-right: none;
 }
 
 form.menu select:focus { max-width: auto; }
@@ -262,25 +245,25 @@ form.menu .criterias input[type=text] { width: 4em; }
 EDIT PAGE
 */
 form.edit .fields label {
-  width: 25%;
-  text-align: right;
-  display: inline-block;
-  margin-right: 1em;
-  vertical-align: top;
+       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;
-  vertical-align: middle;
-  margin-top: 0.2em;
+       width: 54%;
+       display: inline-block;
+       text-align: left;
+       vertical-align: middle;
+       margin-top: 0.2em;
 }
 form.Wedit .fields .label span input {
-  vertical-align: bottom !important;
+       vertical-align: bottom !important;
 }
 
 form.edit .fields input[size],
 form.edit .fields textarea, form.edit .fields select {
-  width: 65%;
+       width: 65%;
 }