From: Devops Date: Thu, 25 May 2017 21:02:31 +0000 (+0100) Subject: www/dbq/html/default.css X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=c8e6de0c507ccc8ee1defa210d48089d6a685272;p=nb.git www/dbq/html/default.css --- diff --git a/bin/nb-install b/bin/nb-install index 225b33d7..8750d9f5 100755 --- a/bin/nb-install +++ b/bin/nb-install @@ -5,123 +5,128 @@ # ############################################################################## main() { -# NB 13.12.16 . "${BASH_SOURCE%/*}/../etc/profile" || exit -. $(dirname "$0")/../etc/profile || exit 1; [ -z "$NB_ROOT" ] && exit -NAME="$(basename "${0}")" -TMP=/tmp/$NAME.$$ -INSTALL="rsync --archive --checksum --force" -BY="Generated by $0" - -if [ "$UID" != "0" ] ; then - echo "$NAME: please login as root." 1>&2 - exit 1 -fi + # NB 13.12.16 . "${BASH_SOURCE%/*}/../etc/profile" || exit + . $(dirname "$0")/../etc/profile || exit 1; [ -z "$NB_ROOT" ] && exit + NAME="$(basename "${0}")" + TMP=/tmp/$NAME.$$ + INSTALL="rsync --archive --checksum --force" + BY="Generated by $0" + + if [ "$UID" != "0" ] ; then + echo "$NAME: please login as root." 1>&2 + exit 1 + fi -############################################################################## -# -# Args -# -############################################################################## -case "$@" in *-h*|*-help*) exec echo "Usage: $NAME [-v] [-n]";; esac -case "$@" in *-v*) INSTALL="$INSTALL -v";; esac -case "$@" in *-n*) INSTALL="$INSTALL -n";; esac -if ! which rsync >/dev/null; then - INSTALL="cp -a" + ############################################################################## + # + # Args + # + ############################################################################## + case "$@" in *-h*|*-help*) exec echo "Usage: $NAME [-v] [-n]";; esac case "$@" in *-v*) INSTALL="$INSTALL -v";; esac - case "$@" in *-n*) INSTALL="echo DRY:";; esac -fi + case "$@" in *-n*) INSTALL="$INSTALL -n";; esac + if ! which rsync >/dev/null; then + INSTALL="cp -a" + case "$@" in *-v*) INSTALL="$INSTALL -v";; esac + case "$@" in *-n*) INSTALL="echo DRY:";; esac + fi -############################################################################## -# -# Functions -# -############################################################################## -verbose() { - [ -z "$@" ] && return - printf '> %s\n' "$@" -} + ############################################################################## + # + # Functions + # + ############################################################################## + verbose() { + [ -z "$@" ] && return + printf '> %s\n' "$@" + } + + fdiff() { + [ -e "$1" ] || return 0 + [ -e "$2" ] || return 0 + [ -n "$(diff -q $1 $2 2>/dev/null)" ] && return 0 + return 1 + } + + ############################################################################## + # + # Cron + # + if [ -e /etc/nb/cron.no ]; then + rm -f /etc/cron.d/nb /var/log/nb.log + else + #shell_help_noarg "zaza" "$@" && exit 0 + cron_d_install "$NB_ROOT/etc/cron/nb" "nb-update|$NB_ROOT|NB_LOG" && verbose "Cron: $NB_ROOT/etc/cron/nb" + #cron_d_install "test" "" "nico.*true" && verbose "Cron: nico" + fi -fdiff() { - [ -e "$1" ] || return 0 - [ -e "$2" ] || return 0 - [ -n "$(diff -q $1 $2 2>/dev/null)" ] && return 0 - return 1 -} + # + # Profile + # + echo "[ -r $NB_ROOT/etc/profile ] && . $NB_ROOT/etc/profile" > $TMP.profile + if [ -d /etc/profile.d ]; then -############################################################################## -# -# Cron -# -if [ -e /etc/nb/cron.no ]; then - rm -f /etc/cron.d/nb /var/log/nb.log -else - #shell_help_noarg "zaza" "$@" && exit 0 - cron_d_install "$NB_ROOT/etc/cron/nb" "nb-update|$NB_ROOT|NB_LOG" && verbose "Cron: $NB_ROOT/etc/cron/nb" - #cron_d_install "test" "" "nico.*true" && verbose "Cron: nico" -fi + if fdiff $TMP.profile /etc/profile.d/nb.sh 1>/dev/null 2>&1; then + verbose "Install /etc/profile.d/nb.sh" + $INSTALL $TMP.profile /etc/profile.d/nb.sh + chmod 755 /etc/profile.d/nb.sh + fi -# -# Profile -# -echo "[ -r $NB_ROOT/etc/profile ] && . $NB_ROOT/etc/profile" > $TMP.profile -if [ -d /etc/profile.d ]; then + elif [ -w /etc/profile ]; then - if fdiff $TMP.profile /etc/profile.d/nb.sh 1>/dev/null 2>&1; then - verbose "Install /etc/profile.d/nb.sh" - $INSTALL $TMP.profile /etc/profile.d/nb.sh - chmod 755 /etc/profile.d/nb.sh - fi + grep -vF "$NB_ROOT/etc/profile.sh" /etc/profile > $TMP.clean + if fdiff /etc/profile $TMP.clean; then + verbose "Clean /etc/profile" + cat $TMP.clean > /etc/profile + fi -elif [ -w /etc/profile ]; then + if ! grep -qm1 -F "$(cat $TMP.profile)" /etc/profile; then + verbose "Install /etc/profile" + cat $TMP.profile >> /etc/profile + fi - grep -vF "$NB_ROOT/etc/profile.sh" /etc/profile > $TMP.clean - if fdiff /etc/profile $TMP.clean; then - verbose "Clean /etc/profile" - cat $TMP.clean > /etc/profile - fi + else + echo "Can't install /etc/profile. Directory not exists or wrong permission" 1>&2 - if ! grep -qm1 -F "$(cat $TMP.profile)" /etc/profile; then - verbose "Install /etc/profile" - cat $TMP.profile >> /etc/profile fi -else - echo "Can't install /etc/profile. Directory not exists or wrong permission" 1>&2 + # + # Specifics + # + chmod 755 $NB_ROOT/etc/vim/vim* $NB_ROOT/etc/vim/*.sh $NB_ROOT/etc/vim/*.pl $NB_ROOT/etc/vim/vimplate-dump -fi + # + # Log + # + NB_USER=`(ls -dl $NB_ROOT 2>/dev/null || printf '- 0 root') | awk '{print $3}'` + verbose $(chown "$NB_USER" /var/log/nb.log 2> /dev/null) -# -# Specifics -# -chmod 755 $NB_ROOT/etc/vim/vim* $NB_ROOT/etc/vim/*.sh $NB_ROOT/etc/vim/*.pl $NB_ROOT/etc/vim/vimplate-dump + # + # nb-commit + # + cd "$NB_ROOT" || exit -# -# Log -# -NB_USER=`(ls -dl $NB_ROOT 2>/dev/null || printf '- 0 root') | awk '{print $3}'` -verbose $(chown "$NB_USER" /var/log/nb.log 2> /dev/null) + rm -f .git/hooks/pre-push -# -# nb-commit -# -cd "$NB_ROOT" || exit -rm -v .git/hooks/pre-push -if [ ! -e .git/hooks/pre-push -a -w .git/hooks ]; then - echo "Create .git/hooks/pre-push" - cat < .git/hooks/pre-push + if [ -w .git/hooks ]; then + + #echo "Create .git/hooks/pre-push" + cat < .git/hooks/pre-commit #!/bin/sh -echo Git hooks pre-push $* 1>&2 +echo Git hooks pre-commit $* 1>&2 $([ -e www/dbq/update.sh ] && echo www/dbq/update.sh) EOF - chmod 755 .git/hooks/pre-push - chown "$NB_USER" .git/hooks/pre-push -fi -# -# Bye -# -rm -f $TMP* -exit 0 + chmod 755 .git/hooks/pre-commit + chown "$NB_USER" .git/hooks/pre-commit + + fi + + # + # Bye + # + rm -f $TMP* + exit 0 } main diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 4d95e70d..74b9f581 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -488,7 +488,7 @@ class DbQ extends nb { if ($password=='') $password = $this->params['table']; if ($password=='' and !empty($_POST['password'])) $password = $_POST['password']; if ($this->is_html) echo << +
@@ -792,7 +792,8 @@ EOF; $r['command'] = $this->page->tag('a',$r['command'],'href="' .$this->db->base.'/'.($r['command'] == self::PARAM_DB_DEFAULT ? '' - : $r['command'].'.'.$this->ext +# NB 25.05.17 : $r['command'].'.'.$this->ext + : $r['command'] ) .'"'); }); @@ -800,8 +801,10 @@ EOF; } 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.'"'); +# NB 25.05.17 $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'.'.$this->ext.'"'); + $r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.'/'.$r['id'].'"'); }); } elseif ($action == 'logout') { diff --git a/www/dbq/html/default.js b/www/dbq/html/default.js index c1ac9c72..2164f4bd 100644 --- a/www/dbq/html/default.js +++ b/www/dbq/html/default.js @@ -108,14 +108,6 @@ document.addEventListener("DOMContentLoaded", function() { document.querySelector("table.rows").insertAdjacentHTML("beforebegin","
"+document.querySelector(".nav.bottom").innerHTML+"
"); } - /* - document.querySelectorAll("form.menu input[type=text]").forEach(function(e) { - e.onfocus = function() { - this.setAttribute('style','border:solid 1px red'); - }; - }); - */ - // No more than 100% width document.querySelectorAll("table").forEach(function(e) { if (parseInt(e.offsetWidth) > parseInt(window.innerWidth)) { diff --git a/www/dbq/update.sh b/www/dbq/update.sh index 9bb5d14d..dfb4779e 100755 --- a/www/dbq/update.sh +++ b/www/dbq/update.sh @@ -1,27 +1,21 @@ #!/usr/bin/env sh -! which minify && echo "Please install minify !" 1>&2 && exit 0 +! which minify > /dev/null 2>&1 && echo "Please install minify (npm -g install minify) !" 1>&2 && exit 0 +minify -h | grep -qm1 no-comments && echo "Version not supported" && exit 0 + set -e cd "$(dirname $0)" -if minify -h|grep -qm1 no-comments; then - - minify='minify --no-comments' - - echo Update html/default.min.css - $minify -o html/default.min.css html/default.css > /dev/null 2>&1 - - echo Update html/default.min.js - $minify -o html/default.min.js html/default.js > /dev/null 2>&1 - - exit -fi - +ex=0 for f in $(find html -type f \( -name '*.css' -o -name '*.js' \) -a -not -name '*.min.*'); do + min=$(echo "$f" | sed 's/\./.min./') ext="${f##*.}" - #echo minify --$ext " < $f > $min" - echo "$f" + + echo "Minify "$( ( realpath "$f" 2> /dev/null || echo "$f" ) | sed "s,^$NB_ROOT/,," ) + eval minify --$ext < "$f" > "$min.bak" && mv "$min.bak" "$min" + [ "$?" = "0" ] || ex=1 + done -[ "$?" = "0" ] || echo Failed +[ "$ex" = "0" ] || echo Failed