Over the last days, the script has become more complex and unreadable but also more powerfull.... It is unlikely yet that someone ever will understand the code. But for now, it works! '''Here are three examples of what it's all about:''' Showing a table (note the tooltip): [http://www.8ung.at/matthias_hoffmann/prog/csvedit1.jpg] Editing a row of that table, optionally with column-dependent select-boxes to offer predefined values: [http://www.8ung.at/matthias_hoffmann/prog/csvedit2.jpg] Inserting a date via calendar-popup: [http://www.8ung.at/matthias_hoffmann/prog/csvedit3.jpg] With this [CGI] script your are able to edit predefined standard [csv] files over the web, using your web browser. It is not possible to add or delete columns (what means: the ''file structure'' is fix), but to add new rows, delete rows, edit cells and sort in ascending or descending order. As an addition, '''two cool javascripts''' are used to choose date from a popup calendar (see the noted web references for more details) and to implement ''tooltips''. To declare a field as a date field, simply add '''@date''' as the last word in it and the see what happens after klicking '''edit''' again... To generate a '''Link''' in a cell, use '''''LinkName url''''' '''@link'''-notation. To show it '''bold''', add '''@bold''' (other gimmicks not to mention...). To install the script and make it work: * Download the following script and copy it to some location below your '''cgi-bin''' * Optionally download the DatePopup-Javascript-Routines and install them under '''''httproot''''''''/jscalendar-1.0''' (or to another location, but then you must alter the source ;-) * (again optionally) download and copy the '''wz_tooltip.js''' to your webserver-root (or elsewhere, but beware) * create a standard [csv] file (that is, fields surrounded with Doublequotes and separated by commas), e.g. with [Excel] or - much better ;-) - with [OpenOffice] - somewhere below the /cgi-bin, e.g. /cgi-bin/data * point your browser to '''.../cgi-bin/csvedit.tcl?file=[[path/]]yourcsvfile''' (file relative to script path!) (optional args may follow, like '''sort'''...) * of course, your webserver must be able to serve [CGI] scripts coded in [tcl]... (what about [tclhttpd] ;-?) * optionally, you can create a '''''csvname''''''''.rc'''-file which holds special configuration options per csv-file. Such a file is shown near the bottom of this document The scripts create a ''file''.bak before each write access and stores ''deleted'' and ''overwritten'' records to a "transaction"-log named after the csv file. I implemented a simple '''todo-list''' with this script... (that's the original reason I started to wrote it). ---- #=============================================================================== # CSVEdit 0.4 (c) M.Hoffmann 2006 # 01.04.2006 # ToDo/Bugs: # - Bei Refresh: ACHTUNG DIE SEITE ENTHÄLT POSTDATEN ??? # - evtl. ToolTips nur dann und überall dort einblenden, wenn Text gekürzt wurde! # - CSS für EditElemente (Input, Button) werden vom IE ignoriert... # - evtl. Bubble-Help für Vollanzeige benutzen, oder Klick auf Details ganz # rechts zeigt VollText unten etc. # - Statt input type=text immer textarea verwenden; Anzeige wahlweise EXPANDen # = nowrap entfernen o.ä.; NOWRAP konfigurierbar machen + WIDTH # - Mehrere Sortierfelder (Datum, PRIO) - aber nicht per Interface (geht nicht # von Haus aus mit LSORT, daher komplex) # - Bei EDIT POSITIONIEREN; IST DAS MÖGLICH?! # geht nicht in CGI-URLs!? evtl. # über JS:focus (aber: welches Ziel?) # - NOSCRIPT-Auswertung! # - LfdNr als eigene Spalte mitführen/nur anzeigen? # - Wahlweise später: Insert_Before, _After, MoveUp/Dn etc. - ein ganzes Muster # an Befehlen ist in der rechten Spalte denkbar! (aber nur mit Sequenz-Vor- # haltung) # - Reset()-Button? # - MEHRERE Links mit @link handeln # - Zeilen mit @date-Einträgen in der Vergangenheit -> überfällig (markieren)? # - ALLE Farben konfigurierbar # - Auch deforder über .rc vorgebbar (geht wg. Parsingreihenfolge nicht...) # - Alternatives Editieren im 'FullScreen/Dialog'-Modus # - Diese Idee für einen generischen INIEditor nutzen! # ------------------------------------------------------------------------------ # - Löschen MUSS indirekt erfolgen, damit POS gesetzt ist! # - Wenn .log neu, auch Header schreiben. Dann ist sie auch normal einsehbar # (Link auf 'Done', dort dann evtl. 'UnDone'; oder unterscheiden zwischen # 'del' und 'done') #=============================================================================== package require ncgi; # tcllib package require html; # tcllib package require csv; # tcllib package require lock; # http://wiki.tcl.tk/15173 package require readprof; # http://wiki.tcl.tk/12647 #------------------------------------------------------------------------------- # Einträge für
proc addToHead {} { puts { } # Pfad noch variabel gestalten, nur wenn existent, einbinden; bei noscript überspringen! # muss eigentlich nur im EDITMODE eingebunden werden!! Siehe http://dynarch.com/mishoo/ puts { } } # Baut Argumentliste für Links auf: link?var1=value1&var2=value2... proc makeLink {title args} { lappend args file $::file sort $::sort order $::order back $::back readonly $::readonly mtime $::mtime foreach {p v} $args {lappend ret $p=[ncgi::encode $v]} return "$title" } # dito, aber ohne # später dies beides Verschachteln, um doppelten Code zu sparen! proc makeLink1 args { lappend args file $::file sort $::sort order $::order back $::back readonly $::readonly mtime $::mtime foreach {p v} $args {lappend ret $p=[ncgi::encode $v]} return [ncgi::urlStub]?[join $ret &] } # Baut Argumentliste für Links auf: link?var1=value1&var2=value2..., aber OHNE ORDER UND SORT proc makeLink2 {title args} { lappend args file $::file back $::back readonly $::readonly mtime $::mtime foreach {p v} $args {lappend ret $p=[ncgi::encode $v]} return "$title" } # Setzt globale Variablen aus gleichnamigen CGI-Vars, falls fehlend mit Vorgaben # es fehlt: Range-Check! proc readVars args { foreach {varname default} $args { set temp [ncgi::value $varname] set ::$varname [expr {[string length $temp] ? $temp : $default}] } } # Hidden-Inputfelder erzeugen (muss $value ESCAPEd werden???) proc makeHidden args { foreach {varname value} $args { puts "" } } # (einige) HTML-Sonderzeichen umsetzen, siehe auch http://wiki.tcl.tk/13008 proc quote in { return [string map \ {ä ä Ä Ä ö ö Ö Ö ü ü Ü Ü ß ß} \ [html::quoteFormValue $in]] } # Special-quoting for tooltips (see http://www.walterzorn.de) proc quotett in { if {[lindex $in end] == "@bold"} { set bPos [string last " @bold" $in]; incr bPos -1 set in [string range $in 0 $bPos] } return [string map \ {ä ä Ä Ä ö ö Ö Ö ü ü Ü Ü ß ß \\ \\\\ ' \\' & "& amp;" < "& lt;" > "& gt;"} \ [html::quoteFormValue $in]] } # "überlange" Anzeigen b.a.W. abkürzen, später optional expandable! I.d.Z.: kann CSV \n speichern? proc shortenCell {ix cellIn} { if {$::debug == 1} { puts "shortenCell " } set mW $::opts(maxDisplayWidth_$ix) if {$::debug == 1} { puts "mw := $mW | actLen := [string length $cellIn]Fehler: |
---|
[join $args] |
(Programm-Abbruch)\n |