verwandte-Kategorien-Filter gefixt
Navigation hinzugefuegt
This commit is contained in:
parent
90255cea97
commit
78a9acad47
4 changed files with 103 additions and 42 deletions
|
@ -24,7 +24,7 @@ Chemistry Science
|
|||
Clock Utility
|
||||
ConsoleOnly
|
||||
ContactManagement Office
|
||||
Contruction Education
|
||||
Construction Education
|
||||
Core
|
||||
Database Office Development AudioVideo
|
||||
Debugger Development
|
||||
|
|
6
gnome-menu/viertversuch/kategorien-verwandte.lst
Normal file
6
gnome-menu/viertversuch/kategorien-verwandte.lst
Normal file
|
@ -0,0 +1,6 @@
|
|||
Network News Monitor
|
||||
Development Java Qt GTK Motif Utility
|
||||
Graphics VectorGraphics Rastergraphics OCR
|
||||
Construction 3DGraphics
|
||||
Engineering Construction 3DGraphics Geology Physics
|
||||
Graphics FlowChart
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
set -u
|
||||
|
||||
KATEG_FILES="`dirname $0`/kategorien-norm.lst `dirname $0`/kategorien-debian.lst"
|
||||
KATEG_FILES="`dirname $0`/kategorien-norm.lst `dirname $0`/kategorien-debian.lst `dirname $0`/kategorien-verwandte.lst"
|
||||
#READ_DESKTOP_DIR="/var/lib/menu-xdg/applications/menu-xdg"
|
||||
READ_DESKTOP_DIR="/usr/share/applications"
|
||||
WRITE_DESKTOP_DIR="`dirname $0`/desktop-files"
|
||||
|
@ -10,14 +10,22 @@ WRITE_DESKTOP_DIR="`dirname $0`/desktop-files"
|
|||
DATA_FILE="/tmp/database.dat"
|
||||
EINTRAEGE_PRO_SEITE=10
|
||||
|
||||
exec -- 2>&1
|
||||
exec -- 2>/tmp/output
|
||||
#set -x
|
||||
|
||||
############# Menue-Verwaltung ################
|
||||
|
||||
filter_empty()
|
||||
{
|
||||
sed -r '/^[[:space:]]*$/d ; s/^[[:space:]]*// ; s/[[:space:]]*$//'
|
||||
}
|
||||
|
||||
|
||||
hole_app_liste()
|
||||
{
|
||||
find "$READ_DESKTOP_DIR" -type f -name \*.desktop | while read a
|
||||
do basename "${a%.desktop}"
|
||||
done | sort | nl
|
||||
done | filter_empty | sort | nl
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,46 +35,40 @@ lade_app_kategs()
|
|||
{
|
||||
DDATEI=`find $READ_DESKTOP_DIR -type f -name $1.desktop`
|
||||
if [ -e "$DATA_FILE" ] && grep -q "^$1=" "$DATA_FILE"
|
||||
then grep "^$1=" "$DATA_FILE" | cut -d "=" -f 2
|
||||
else [ -e "$DDATEI" ] && grep "^Categories=" "$DDATEI" | cut -d "=" -f 2 | tr "\n" " " | tr ";" " "
|
||||
fi
|
||||
then grep "^$1=" "$DATA_FILE" | cut -d "=" -f 2 | tr " " "\n"
|
||||
else [ -e "$DDATEI" ] && grep "^Categories=" "$DDATEI" | cut -d "=" -f 2 | tr ";" "\n"
|
||||
fi | filter_empty | sort | uniq
|
||||
}
|
||||
|
||||
|
||||
hole_kateg_liste()
|
||||
{
|
||||
cat $KATEG_FILES | cut -f 1 | sort | uniq
|
||||
cat $KATEG_FILES | cut -f 1 | filter_empty | sort | uniq
|
||||
}
|
||||
|
||||
|
||||
# liefert eine Liste von Kategorien zurueck, die entweder auf die angegebene verweisen oder
|
||||
# solche, auf die sie selbst verweist
|
||||
# nicht-standard-konforme Kategorien (X-???-???) werden herausgefiltert
|
||||
# Parameter: die zu bearbeitende Kategorie
|
||||
hole_verwandte_kategs()
|
||||
{
|
||||
(
|
||||
[ -z "$1" ] && return
|
||||
# erstmal die verweisenden:
|
||||
cat $KATEG_FILES | sed 's/$/\t/' | grep "[[:space:]]$1[[:space:]]" | cut -f 1
|
||||
# dann die, auf die verwiesen wird:
|
||||
cat $KATEG_FILES | grep "^$1[[:space:]]" | cut -f 2-30 | tr "\t" "\n"
|
||||
) | sort | uniq
|
||||
cat $KATEG_FILES | grep "^$1[[:space:]]" | cut -f 2-30 | tr "\t" "\n" | tr " " "\n"
|
||||
) | grep -v "^X-" | filter_empty | sort | uniq
|
||||
}
|
||||
|
||||
# liefert alle Kategorien zurueck, die mit den bisherigen Kategorien der Anwendung verwandt sind,
|
||||
# ihr jedoch noch nicht zugeordnet wurden
|
||||
hole_verwandte_kategs_der_app()
|
||||
{
|
||||
local APP_KATEGS="`lade_app_kategs $1`"
|
||||
(
|
||||
# zweimal die eingetragenen Kategorien, damit diese auf jeden Fall rausgefiltert werden
|
||||
echo "$APP_KATEGS"
|
||||
echo "$APP_KATEGS"
|
||||
(
|
||||
for a in $APP_KATEGS
|
||||
do hole_verwandte_kategs $a
|
||||
done
|
||||
) | sort | uniq
|
||||
) | sort | uniq -u
|
||||
#local FILTER=`lade_app_kategs "$1" | sed 's#^#/# ; s#$#/d;#' | tr "\n" " "`
|
||||
local FILTER=`lade_app_kategs "$1" | sed 's#^.*$#/&/d; #' | tr "\n" " "`
|
||||
lade_app_kategs "$1" | while read a; do hole_verwandte_kategs "$a"; done | sed "$FILTER" | filter_empty | sort | uniq
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,8 +99,8 @@ speichere_formdaten()
|
|||
local NEUE_KATEGS
|
||||
local APP_NAME
|
||||
for a in $EINTRAEGE
|
||||
do NEUE_KATEGS=`echo "$POST_DATA" | grep "^text_kategs_$a" | cut -d '=' -f 2 | tr '+' ' ' | tr ' ' '\n'`
|
||||
NEUE_KATEGS="$NEUE_KATEGS\n`echo -e \"$POST_DATA\" | grep ^liste_kateg[123]_$a | cut -d '=' -f 2`"
|
||||
do NEUE_KATEGS=`echo "$POST_DATA" | grep "^text_kategs_$a=" | cut -d '=' -f 2 | tr '+' ' ' | tr ' ' '\n'`
|
||||
NEUE_KATEGS="$NEUE_KATEGS\n`echo -e \"$POST_DATA\" | grep "^liste_kateg[123]_$a=" | cut -d '=' -f 2`"
|
||||
NEUE_KATEGS=`echo -e "$NEUE_KATEGS" | sort | uniq | tr '\n' ' '`
|
||||
APP_NAME=`app_num2name $a`
|
||||
NEUE_ZEILE=`echo -e "$APP_NAME=$NEUE_KATEGS" | sed -r 's/[[:space:]]+/ /g; s/=[[:space:]]/=/'`
|
||||
|
@ -125,7 +127,7 @@ debug_zeige_alle_apps()
|
|||
{
|
||||
for a in `hole_app_liste`
|
||||
do echo -en "$a\t-\t"
|
||||
lade_app_kategs "$a"
|
||||
lade_app_kategs "$a" | tr "\n" " "
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
@ -144,12 +146,55 @@ html_header()
|
|||
echo "<BODY>"
|
||||
}
|
||||
|
||||
|
||||
html_footer()
|
||||
{
|
||||
echo "</BODY>"
|
||||
echo "</HTML>"
|
||||
}
|
||||
|
||||
|
||||
html_nav()
|
||||
{
|
||||
echo '<DIV ALIGN="CENTER"><TABLE BORDER="0" CELLPADDING="20"><TR>'
|
||||
|
||||
echo "<FORM ACTION=\"`basename $0`\" METHOD=\"GET\">"
|
||||
|
||||
echo ' <TD>Kategorie: <BR><SELECT NAME="kateg_filter">'
|
||||
echo ' <OPTION VALUE="">alle</OPTION>'
|
||||
for a in $ALLE_KATEGS
|
||||
do if [ "$a" = "$KATEG_FILTER" ]
|
||||
then echo " <OPTION SELECTED>$a</OPTION>"
|
||||
else echo " <OPTION>$a</OPTION>"
|
||||
fi
|
||||
done
|
||||
echo ' </SELECT></TD>'
|
||||
|
||||
echo ' <TD>Einträge je Seite:<BR><SELECT NAME="eintraege_pro_seite">'
|
||||
for a in 10 25 50 100 500 1000
|
||||
do if [ "$a" = "$EINTRAEGE_PRO_SEITE" ]
|
||||
then echo " <OPTION SELECTED>$a</OPTION>"
|
||||
else echo " <OPTION>$a</OPTION>"
|
||||
fi
|
||||
done
|
||||
echo ' </SELECT>'
|
||||
echo ' </TD>'
|
||||
|
||||
echo ' <TD>Beginne bei Eintrag:<BR><SELECT NAME="app_start_nr">'
|
||||
for a in 1 10 25 100 500
|
||||
do if [ "$a" = "$APP_START_NR" ]
|
||||
then echo " <OPTION SELECTED>$a</OPTION>"
|
||||
else echo " <OPTION>$a</OPTION>"
|
||||
fi
|
||||
done
|
||||
echo ' </SELECT>'
|
||||
echo ' </TD>'
|
||||
|
||||
echo ' <TD><INPUT TYPE="SUBMIT" VALUE="Anzeigen"></TD>'
|
||||
echo '</FORM></TR></TABLE></DIV>'
|
||||
echo '<HR>'
|
||||
}
|
||||
|
||||
# zwei Paramater:
|
||||
# (1) _all_ ODER Name der Anwendung, zu der nur die noch nicht verwendeten Verwandten eingetragen werden sollen
|
||||
# (2) der Name der HTML-Auswahlliste (entspricht dem spaeteren Variablennamen des Inhalts)
|
||||
|
@ -157,14 +202,10 @@ html_kateg_liste()
|
|||
{
|
||||
echo "<SELECT NAME=\"$2\" SIZE=\"1\">"
|
||||
echo " <OPTION></OPTION>"
|
||||
local LISTE
|
||||
if [ $1 = "_all_" ]
|
||||
then LISTE="$ALLE_KATEGS"
|
||||
else LISTE="`hole_verwandte_kategs_der_app $1`"
|
||||
fi
|
||||
for a in $LISTE
|
||||
do echo " <OPTION>$a</OPTION>"
|
||||
done
|
||||
then echo -e "$ALLE_KATEGS"
|
||||
else hole_verwandte_kategs_der_app "$1"
|
||||
fi | while read a; do echo " <OPTION>$a</OPTION>"; done
|
||||
echo "</SELECT>"
|
||||
echo
|
||||
}
|
||||
|
@ -176,7 +217,7 @@ html_apps_config()
|
|||
local APP_NAME=`app_num2name $1`
|
||||
echo " <TR>"
|
||||
echo " <TD>$APP_NAME</TD>"
|
||||
echo " <TD><INPUT NAME=\"text_kategs_$1\" SIZE=\"30\" VALUE=\"`lade_app_kategs $APP_NAME`\"></TD>"
|
||||
echo " <TD><INPUT NAME=\"text_kategs_$1\" SIZE=\"50\" VALUE=\"`lade_app_kategs $APP_NAME | tr '\n' ' '`\"></TD>"
|
||||
echo " <TD>`html_kateg_liste $APP_NAME liste_kateg1_$1`</TD>"
|
||||
echo " <TD>`html_kateg_liste $APP_NAME liste_kateg2_$1`</TD>"
|
||||
echo " <TD>`html_kateg_liste _all_ liste_kateg3_$1`</TD>"
|
||||
|
@ -185,10 +226,10 @@ html_apps_config()
|
|||
|
||||
|
||||
# als Parameter ist die Nummer der ersten Anwendung der Liste erforderlich
|
||||
html_formular()
|
||||
html_edit_liste()
|
||||
{
|
||||
echo -n '<FORM NAME="Kategorien-Zuordnung" METHOD="POST"'
|
||||
echo " ACTION=\"`basename $0`?action=speichern&app_start_nr=$APP_START_NR\">"
|
||||
echo " ACTION=\"`basename $0`?action=speichern&app_start_nr=$APP_START_NR&eintraege_pro_seite=$EINTRAEGE_PRO_SEITE&kateg_filter=$KATEG_FILTER\">"
|
||||
echo "<TABLE BORDER=\"0\">"
|
||||
echo " <TR>"
|
||||
echo " <TH>Programm</TH>"
|
||||
|
@ -199,14 +240,28 @@ html_formular()
|
|||
echo " </TR>"
|
||||
|
||||
local uebrig=$EINTRAEGE_PRO_SEITE
|
||||
echo -e "$ALLE_APPS" | sed 1,$((APP_START_NR-1))d | while [ $uebrig -gt 0 ] && read num name
|
||||
do html_apps_config $num
|
||||
echo -e "$ALLE_APPS\n" | sed -n "$((APP_START_NR)),$((APP_START_NR+EINTRAEGE_PRO_SEITE-1))p" | while read num name
|
||||
do [ -n "$num" ] && html_apps_config $num
|
||||
uebrig=$((uebrig-1))
|
||||
done
|
||||
|
||||
echo "</TABLE>"
|
||||
echo '<DIV ALIGN="CENTER"><INPUT TYPE="SUBMIT" VALUE=" Speichern "></DIV>'
|
||||
echo "</FORM>"
|
||||
|
||||
if [ $APP_START_NR -gt 1 -o $((APP_START_NR+EINTRAEGE_PRO_SEITE-1)) -lt `hole_anzahl_apps` ]
|
||||
then echo '<P><BR><DIV ALIGN="CENTER">'
|
||||
if [ $APP_START_NR -gt 1 ]
|
||||
then local PREV_START_NR=$((APP_START_NR-EINTRAEGE_PRO_SEITE))
|
||||
[ "$PREV_START_NR" -lt 1 ] && PREV_START_NR=1
|
||||
echo "<A HREF=\"`basename $0`?app_start_nr=$PREV_START_NR&eintraege_pro_seite=$EINTRAEGE_PRO_SEITE&kateg_filter=$KATEG_FILTER\">vorherige Seite</A>"
|
||||
fi
|
||||
if [ $((APP_START_NR+EINTRAEGE_PRO_SEITE-1)) -lt `hole_anzahl_apps` ]
|
||||
then local NEXT_START_NR=$((APP_START_NR+EINTRAEGE_PRO_SEITE))
|
||||
echo "<A HREF=\"`basename $0`?app_start_nr=$NEXT_START_NR&eintraege_pro_seite=$EINTRAEGE_PRO_SEITE&kateg_filter=$KATEG_FILTER\">nächste Seite</A>"
|
||||
fi
|
||||
echo "</DIV></P>"
|
||||
fi
|
||||
}
|
||||
|
||||
############# cgi-Zeug #############
|
||||
|
@ -226,14 +281,17 @@ hole_parameter()
|
|||
|
||||
############# los geht es! ############
|
||||
|
||||
html_header
|
||||
|
||||
ALLE_KATEGS=`hole_kateg_liste`
|
||||
ALLE_APPS=`hole_app_liste`
|
||||
|
||||
KATEG_FILTER=`hole_parameter kateg_filter ""`
|
||||
[ -n "$KATEG_FILTER" ] && ALLE_APPS=`filter_apps_nach_kateg "$KATEG_FILTER"`
|
||||
|
||||
APP_START_NR=`hole_parameter app_start_nr 1`
|
||||
EINTRAEGE_PRO_SEITE=`hole_parameter eintraege_pro_seite $EINTRAEGE_PRO_SEITE`
|
||||
|
||||
html_header
|
||||
html_nav
|
||||
|
||||
ACTION=`hole_parameter action formular`
|
||||
|
||||
|
@ -241,10 +299,7 @@ case "$ACTION" in
|
|||
speichern|formular)
|
||||
[ "$ACTION" = "speichern" ] && speichere_formdaten
|
||||
|
||||
APP_START_NR=`hole_parameter app_start_nr 1`
|
||||
|
||||
html_formular
|
||||
html_footer
|
||||
html_edit_liste
|
||||
;;
|
||||
*)
|
||||
echo '<H1><DIV ALIGN="CENTER">Fehlerhafte Aktion ('
|
||||
|
|
Loading…
Reference in a new issue