Weboberflaeche fuer Editor fast fertig
This commit is contained in:
parent
3a73392044
commit
801486effc
3 changed files with 262 additions and 2 deletions
34
gnome-menu/viertversuch/kategorien-debian.lst
Normal file
34
gnome-menu/viertversuch/kategorien-debian.lst
Normal file
|
@ -0,0 +1,34 @@
|
|||
X-Debian-Apps-Databases Database
|
||||
X-Debian-Apps-Editors TextEditor Office Wordprocessor
|
||||
X-Debian-Apps-Education Education
|
||||
X-Debian-Apps-Emulators Emulator
|
||||
X-Debian-Apps-Graphics Graphics
|
||||
X-Debian-Apps-Math Math
|
||||
X-Debian-Apps-Net Network
|
||||
X-Debian-Apps-Programming Development
|
||||
X-Debian-Apps-Science Science
|
||||
X-Debian-Apps-Shells Shell
|
||||
X-Debian-Apps-Sound Audio
|
||||
X-Debian-Apps-System System
|
||||
X-Debian-Apps-System-Admin System
|
||||
X-Debian-Apps-System-Gnome System GNOME
|
||||
X-Debian-Apps-System-Language-Environment System Languages
|
||||
X-Debian-Apps-Technical Engineering
|
||||
X-Debian-Apps-Text TextEditor WordProcessor Office
|
||||
X-Debian-Apps-Tools Utility
|
||||
X-Debian-Apps-Viewers Viewer
|
||||
X-Debian-Games-Adventure AdventureGame
|
||||
X-Debian-Games-Arcade ActionGame
|
||||
X-Debian-Games-Board BoardGame
|
||||
X-Debian-Games-Card CardGame
|
||||
X-Debian-Games-Puzzles LogicGame
|
||||
X-Debian-Games-Sports SportsGame
|
||||
X-Debian-Games-Strategy StrategyGame
|
||||
X-Debian-Games-Tetris-like BlocksGame
|
||||
X-Debian-Games-Toys Amusement
|
||||
X-Debian-Help
|
||||
X-Debian-Screen-Lock System
|
||||
X-Debian-Screen-Root-window System
|
||||
X-Debian-Screen-Save Screensaver
|
||||
X-Debian-Screen-Save-Text Screensaver
|
||||
X-Debian-XShells Shell
|
|
@ -16,7 +16,7 @@ Biology Science
|
|||
BlocksGame Game
|
||||
BoardGame Game
|
||||
Building Development
|
||||
Calculator Utilitiy
|
||||
Calculator Utility
|
||||
Calendar Office
|
||||
CardGame Game
|
||||
Chart Office
|
||||
|
@ -100,7 +100,7 @@ System Settings
|
|||
Teaching Education
|
||||
Telephony Network
|
||||
TerminalEmulator
|
||||
TextEditor Utilitiy
|
||||
TextEditor Utility
|
||||
Translation Development
|
||||
TrayIcon
|
||||
Tuner Audio
|
||||
|
|
226
gnome-menu/viertversuch/manage-kategs.sh
Executable file
226
gnome-menu/viertversuch/manage-kategs.sh
Executable file
|
@ -0,0 +1,226 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -u
|
||||
|
||||
KATEG_FILES="`dirname $0`/kategorien-norm.lst `dirname $0`/kategorien-debian.lst"
|
||||
READ_DESKTOP_DIR="/var/lib/menu-xdg/applications/menu-xdg"
|
||||
WRITE_DESKTOP_DIR="`dirname $0`/desktop-files"
|
||||
#DATA_FILE="`dirname $0`/database.dat"
|
||||
DATA_FILE="/tmp/database.dat"
|
||||
EINTRAEGE_PRO_SEITE=10
|
||||
|
||||
exec -- 2>&1
|
||||
|
||||
############# Menue-Verwaltung ################
|
||||
hole_app_liste()
|
||||
{
|
||||
find "$READ_DESKTOP_DIR" -type f -name \*.desktop | while read a
|
||||
do basename "${a%.desktop}"
|
||||
done | sort | nl
|
||||
}
|
||||
|
||||
|
||||
# zuerst in der Datenbank nachsehen - ansonsten aus dem desktop-Verzeichnis holen
|
||||
# Parameter: app-name
|
||||
lade_app_kategs()
|
||||
{
|
||||
DDATEI="$READ_DESKTOP_DIR/$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
|
||||
}
|
||||
|
||||
|
||||
hole_kateg_liste()
|
||||
{
|
||||
cat $KATEG_FILES | cut -f 1 | sort | uniq
|
||||
}
|
||||
|
||||
|
||||
# liefert eine Liste von Kategorien zurueck, die entweder auf die angegebene verweisen oder
|
||||
# solche, auf die sie selbst verweist
|
||||
# Parameter: die zu bearbeitende Kategorie
|
||||
hole_verwandte_kategs()
|
||||
{
|
||||
(
|
||||
# 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
|
||||
}
|
||||
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
speichere_formdaten()
|
||||
{
|
||||
local POST_DATA=`cat - | tr "&" "\n" | tee /tmp/out`
|
||||
local EINTRAEGE=`echo "$POST_DATA" | grep "^text_kategs_" | cut -d = -f 1 | sed 's/^text_kategs_//'`
|
||||
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`"
|
||||
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:]]/=/'`
|
||||
[ ! -e "$DATA_FILE" ] && touch "$DATA_FILE"
|
||||
sed -i "s/^$APP_NAME=.*/$NEUE_ZEILE/" "$DATA_FILE"
|
||||
grep -q "^$APP_NAME=" "$DATA_FILE" || echo -e "$NEUE_ZEILE" >> "$DATA_FILE"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
app_num2name()
|
||||
{
|
||||
echo "$ALLE_APPS" | grep "^[[:space:]]*$1[[:space:]]" | cut -f 2
|
||||
}
|
||||
|
||||
|
||||
app_name2num()
|
||||
{
|
||||
echo "$ALLE_APPS" | grep "[[:space:]]$1$" | cut -f 1
|
||||
}
|
||||
|
||||
################# debug & test #################
|
||||
debug_zeige_alle_apps()
|
||||
{
|
||||
for a in `hole_app_liste`
|
||||
do echo -en "$a\t-\t"
|
||||
lade_app_kategs "$a"
|
||||
echo
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
############## html-encoding ################
|
||||
html_header()
|
||||
{
|
||||
echo "Content-type: text/html"
|
||||
echo
|
||||
echo "<HTML>"
|
||||
echo "<HEAD>"
|
||||
echo " <TITLE>Debian-Menue-Designer</TITLE>"
|
||||
echo ' <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">'
|
||||
echo "</HEAD>"
|
||||
echo "<BODY>"
|
||||
}
|
||||
|
||||
html_footer()
|
||||
{
|
||||
echo "</BODY>"
|
||||
echo "</HTML>"
|
||||
}
|
||||
|
||||
# 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)
|
||||
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
|
||||
echo "</SELECT>"
|
||||
echo
|
||||
}
|
||||
|
||||
|
||||
# Parameter: app-nummer
|
||||
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>`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>"
|
||||
echo " </TR>"
|
||||
}
|
||||
|
||||
|
||||
# als Parameter ist die Nummer der ersten Anwendung der Liste erforderlich
|
||||
html_formular()
|
||||
{
|
||||
echo -n '<FORM NAME="Kategorien-Zuordnung" METHOD="POST"'
|
||||
echo " ACTION=\"`basename $0`?action=speichern&app_start_nr=$1\">"
|
||||
echo "<TABLE BORDER=\"0\">"
|
||||
echo " <TR>"
|
||||
echo " <TH>Programm</TH>"
|
||||
echo " <TH>bisherige Kategorien</TH>"
|
||||
echo " <TH>verwandte Kategorie I</TH>"
|
||||
echo " <TH>verwandte Kategorie II</TH>"
|
||||
echo " <TH>weitere Kategorie</TH>"
|
||||
echo " </TR>"
|
||||
|
||||
local START=$1
|
||||
local i=$START
|
||||
local ENDE=$((START+EINTRAEGE_PRO_SEITE-1))
|
||||
while [ $i -le $ENDE ]
|
||||
do html_apps_config $i
|
||||
i=$((i+1))
|
||||
done
|
||||
|
||||
echo "</TABLE>"
|
||||
echo '<DIV ALIGN="CENTER"><INPUT TYPE="SUBMIT" VALUE=" Speichern "></DIV>'
|
||||
echo "</FORM>"
|
||||
}
|
||||
|
||||
############# cgi-Zeug #############
|
||||
hole_parameter()
|
||||
{
|
||||
set | grep -q "^QUERY_STRING" || return
|
||||
echo "$QUERY_STRING" | tr "&" "\n" | grep "^$1" | cut -d "=" -f 2
|
||||
}
|
||||
|
||||
############# los geht es! ############
|
||||
|
||||
html_header
|
||||
|
||||
ALLE_KATEGS=`hole_kateg_liste`
|
||||
ALLE_APPS=`hole_app_liste`
|
||||
|
||||
ACTION=`hole_parameter action`
|
||||
[ -z "$ACTION" ] && ACTION=formular
|
||||
|
||||
case "$ACTION" in
|
||||
speichern|formular)
|
||||
[ "$ACTION" = "speichern" ] && speichere_formdaten
|
||||
APP_START_NR=`hole_parameter app_start_nr`
|
||||
[ -z "$APP_START_NR" ] && APP_START_NR=1
|
||||
|
||||
html_formular $APP_START_NR
|
||||
html_footer
|
||||
;;
|
||||
*)
|
||||
echo '<H1><DIV ALIGN="CENTER">Fehlerhafte Aktion ('
|
||||
echo "$ACTION"
|
||||
echo ') angefordert!</DIV></H1>'
|
||||
;;
|
||||
esac
|
||||
|
||||
html_footer
|
Loading…
Reference in a new issue