From 77b2ca4754e9afab8962e9ec74f6ee2b46569428 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sat, 9 Dec 2017 06:16:03 +0000 Subject: [PATCH] www/dbq/dbq.php --- bin/nb-read.php | 17 +++++++++---- lib/js/nb.js | 62 +++++++++++++++++++++++------------------------ lib/php/nb.php | 6 ++--- www/dbq/dbq.php | 2 +- www/dbq/update.sh | 4 ++- 5 files changed, 49 insertions(+), 42 deletions(-) diff --git a/bin/nb-read.php b/bin/nb-read.php index 1fe5d83f..a588d4f8 100755 --- a/bin/nb-read.php +++ b/bin/nb-read.php @@ -7,11 +7,13 @@ * 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); +$METHOD = $argv[0]; array_shift($argv); $NB = new NB(); while($line = get_line()) { @@ -33,15 +35,20 @@ while($line = get_line()) { } function get_line() { - global $argv; + global $argv, $METHOD; static $bye; if (!empty($bye)) return; - if (METHOD == 'fgets') return fgets(STDIN); - if (METHOD == 'cat') return file_get_contents(fgets(STDIN)); + if ($METHOD == 'fgets') return fgets(STDIN); +# NB 09.12.17 if ($METHOD == 'cat') { +# NB 09.12.17 $bye = true; +# NB 09.12.17 $line = fgets(STDIN); +# NB 09.12.17 return $line ? file_get_contents($line) : $line; +# NB 09.12.17 } $bye = true; - array_unshift($argv,METHOD); # that is not e method, push it back to argv + array_unshift($argv,$METHOD); # that is not e method, push it back to argv + $METHOD = ''; return stream_get_contents(STDIN); } ?> diff --git a/lib/js/nb.js b/lib/js/nb.js index 3d9476df..89f90a89 100644 --- a/lib/js/nb.js +++ b/lib/js/nb.js @@ -550,44 +550,44 @@ function NB(args) { } this.dump = function (arr,level) { - var dumped_text = ""; - if(!level) level = 0; - - //The padding given at the beginning of the line. - var level_padding = ""; - for(var j=0;j \"" + value + "\"\n"; - } - } - } else { //Stings/Chars/Numbers etc. - dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; - } - return dumped_text; + var dumped_text = ""; + if(!level) level = 0; + + //The padding given at the beginning of the line. + var level_padding = ""; + for(var j=0;j \"" + value + "\"\n"; } + } + } else { //Stings/Chars/Numbers etc. + dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; + } + return dumped_text; + } this.msg = function(msg) { $('

'+msg+'

').prependTo( "#nb-msg" ); } this.reload_head_js = function() { - $("head script").each(function(){ - var oldScript = this.getAttribute("src"); - $(this).remove(); - var newScript; - newScript = document.createElement('script'); - newScript.type = 'text/javascript'; - newScript.src = oldScript; - document.getElementsByTagName("head")[0].appendChild(newScript); - }); + $("head script").each(function(){ + var oldScript = this.getAttribute("src"); + $(this).remove(); + var newScript; + newScript = document.createElement('script'); + newScript.type = 'text/javascript'; + newScript.src = oldScript; + document.getElementsByTagName("head")[0].appendChild(newScript); + }); } // <<< FUNCTIONS diff --git a/lib/php/nb.php b/lib/php/nb.php index 89ff083e..6642f78e 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -997,15 +997,13 @@ class NB { } public static function minify_js($code) { - if (strpos($code,'/') === 0) $code = file_get_contents($code); + if (strpos($code,'/') === 0 and file_exists($code)) $code = file_get_contents($code); require_once(NB_ROOT.'/lib/php/jsmin.php'); return trim(JSMin::minify($code)); } public static function minify_css($code) { - if (strpos($code,'/') === 0) $code = file_get_contents($code); - - #$code = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $code); + if (strpos($code,'/') === 0 and file_exists($code)) $code = file_get_contents($code); // comments /* */ $code = preg_replace(',/\*.*?\*/,s','',$code); diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 0bb9320f..ca03d8b4 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -233,7 +233,7 @@ class DbQ extends nb { } #debug($_SERVER); - if ($this->http_user()) $bottom[] = 'Logout: '.$this->http_user().' ('.$this->perm2h().')'.''; + if ($this->http_user()) $bottom[] = 'Logout: '.$this->http_user().' (can: '.$this->perm2h().')'.''; if ($bottom and $this->page->is('html')) echo $this->page->tag('div class="block" style="display:inline-block"',join('
'.NB_EOL,$bottom)); diff --git a/www/dbq/update.sh b/www/dbq/update.sh index d3b3c8ea..cd8c7019 100755 --- a/www/dbq/update.sh +++ b/www/dbq/update.sh @@ -13,7 +13,9 @@ for f in $(find html -type f \( -name '*.css' -o -name '*.js' \) -a -not -name ' echo "Minify "$( ( realpath "$f" 2> /dev/null || echo "$f" ) | sed "s,^$NB_ROOT/,," ) - eval minify --$ext < "$f" > "$min.bak" && mv "$min.bak" "$min" + eval minify --$ext < "$f" > "$min.new" && mv "$min.new" "$min" + #nb-read.php minify_$ext < "$f" > "$min.new" + #[ -t "$min.new" ] && diff -q "$"$min.new"" "$min" &> /dev/null && mv "$min.new" "$min" || rm $min.new" [ "$?" = "0" ] || ex=1 #git add "$min" #[ "$ex" = "0" ] && echo DEBUG: Should: git add "$min" -- 2.47.3