From 801486effcdd15008d895824ab6cb88fdd7fdfbd Mon Sep 17 00:00:00 2001 From: io <> Date: Sat, 13 Nov 2004 05:14:44 +0000 Subject: [PATCH] Weboberflaeche fuer Editor fast fertig --- gnome-menu/viertversuch/kategorien-debian.lst | 34 +++ gnome-menu/viertversuch/kategorien-norm.lst | 4 +- gnome-menu/viertversuch/manage-kategs.sh | 226 ++++++++++++++++++ 3 files changed, 262 insertions(+), 2 deletions(-) create mode 100644 gnome-menu/viertversuch/kategorien-debian.lst create mode 100755 gnome-menu/viertversuch/manage-kategs.sh diff --git a/gnome-menu/viertversuch/kategorien-debian.lst b/gnome-menu/viertversuch/kategorien-debian.lst new file mode 100644 index 0000000..111af16 --- /dev/null +++ b/gnome-menu/viertversuch/kategorien-debian.lst @@ -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 diff --git a/gnome-menu/viertversuch/kategorien-norm.lst b/gnome-menu/viertversuch/kategorien-norm.lst index ebe3726..4ee5bf1 100644 --- a/gnome-menu/viertversuch/kategorien-norm.lst +++ b/gnome-menu/viertversuch/kategorien-norm.lst @@ -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 diff --git a/gnome-menu/viertversuch/manage-kategs.sh b/gnome-menu/viertversuch/manage-kategs.sh new file mode 100755 index 0000000..ddab4da --- /dev/null +++ b/gnome-menu/viertversuch/manage-kategs.sh @@ -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 "" + echo "
" + echo "