Readable detailed presentation format as well as raw format.
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 9 Nov 1995 15:24:36 +0000 (15:24 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 9 Nov 1995 15:24:36 +0000 (15:24 +0000)
www/search.egw
www/showfull.egw
www/z39util.tcl

index 21af854..6687d24 100644 (file)
@@ -1,6 +1,6 @@
 <html>
 {
-# $Id: search.egw,v 1.11 1995/11/08 16:14:33 adam Exp $
+# $Id: search.egw,v 1.12 1995/11/09 15:24:36 adam Exp $
 
 proc buttons {setNo setMax startPos} {
     global sessionId
@@ -11,7 +11,8 @@ proc buttons {setNo setMax startPos} {
     if {$setMax < [z39.$setNo resultCount]} {
         html {<a href="http:} $env(SCRIPT_NAME)
         html / $sessionId {/search.egw/} $setNo + [expr $setMax + 1]
-        html + [expr $setMax + $hist($setNo,maxPresent)] {"> Next </a>} "| \n"
+        html + [expr $setMax + $hist($setNo,maxPresent)]
+        html {"> Next records </a>} "| \n"
     }
     if {$startPos != "" && $startPos != "1"} {
         html {<a href="http:} $env(SCRIPT_NAME)
@@ -20,7 +21,7 @@ proc buttons {setNo setMax startPos} {
             html + [expr $startPos - $hist($setNo,maxPresent)]
             html + [expr $startPos - 1]
         }
-        html {"> Prev </a>} "| \n"
+        html {"> Previous records </a>} "| \n"
     }
     html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/targets.egw"> New target </a>} " | \n"
index c2d11ce..efee05e 100644 (file)
@@ -1,8 +1,8 @@
 <html>
 {
-# $Id: showfull.egw,v 1.6 1995/11/08 16:14:34 adam Exp $
+# $Id: showfull.egw,v 1.7 1995/11/09 15:24:37 adam Exp $
 
-proc buttons {setNo no} {
+proc buttons {setNo no format} {
     global sessionId
     global env
     global hist
@@ -10,17 +10,26 @@ proc buttons {setNo no} {
     html "<p>\n"
     if {$no < [z39.$setNo resultCount]} {
         html {<a href="http:} $env(SCRIPT_NAME)
-        html / $sessionId {/showfull.egw/} $setNo + [expr $no + 1]
-        html {"> Next </a>} "| \n"
+        html / $sessionId {/showfull.egw/} $setNo + [expr $no + 1] + $format
+        html {"> Next record </a>} "| \n"
     }
     if {$no > 1} {
         html {<a href="http:} $env(SCRIPT_NAME)
-        html / $sessionId {/showfull.egw/} $setNo + [expr $no - 1]
-        html {"> Prev </a>} "| \n"
+        html / $sessionId {/showfull.egw/} $setNo + [expr $no - 1] + $format
+        html {"> Previous record </a>} "| \n"
     }
+
+    html {<a href="http:} $env(SCRIPT_NAME)
+    html / $sessionId {/showfull.egw/} $setNo + $no +
+    if {$format == "full"} {
+       html raw {">Raw format</a>} "| \n"
+    } else {
+       html full {">Full format</a>} "| \n"
+    }
+
     html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/search.egw/} $setNo + 1
-    html + [expr $hist($setNo,maxPresent) - 1]
+    html + $hist($setNo,maxPresent)
     html {"> Result </a>} "| \n"
        
     html {<a href="http:} $env(SCRIPT_NAME)
@@ -28,6 +37,7 @@ proc buttons {setNo no} {
     html {<a href="http:} $env(SCRIPT_NAME)
     html / $sessionId {/query.egw/} $hist($setNo,host) + $setNo 
     html {"> New query </a>} "<p>\n"
+
 }
 
     if {[info commands saveState] == ""} {
@@ -42,6 +52,7 @@ proc buttons {setNo no} {
 
     set sno [lindex $sessionParms 0]
     set no [lindex $sessionParms 1]
+    set format [lindex $sessionParms 2]
 
     set setNo $sno
     
@@ -51,11 +62,10 @@ proc buttons {setNo no} {
     set total [z39.$setNo resultCount]
     html "<h2>Record \#$no out of $total </h2><br>\n"
 
-    buttons $setNo $no
-
-    z39present $setNo $no $no display-full
+    buttons $setNo $no $format
 
-    buttons $setNo $no
+    eval {z39present $setNo $no $no display-$format}
+    buttons $setNo $no $format
 }
 </body>
 </html>
index 6b56df4..82380f1 100644 (file)
@@ -1,5 +1,5 @@
 #
-# $Id: z39util.tcl,v 1.5 1995/11/08 18:07:23 adam Exp $
+# $Id: z39util.tcl,v 1.6 1995/11/09 15:24:37 adam Exp $
 #
 proc saveState {} {
     uplevel #0 {
@@ -82,13 +82,13 @@ proc display-brief {zset no} {
         set year [lindex [$zset getMarc $no field 260 * c] 0]
     } ] } {
         html {<a href="http:} $env(SCRIPT_NAME) /
-        html $sessionId {/showfull.egw/} $setNo + $no {"> } $title {</a>}
-        html " <i> ${year} </i>"
+        html $sessionId {/showfull.egw/} $setNo + $no + full 
+        html {"> } $title {</a>} " <i> ${year} </i>"
     }
     html "<br>\n"
 }
 
-proc display-full {zset no} {
+proc display-raw {zset no} {
     set type [$zset type $no]
     if {$type == "SD"} {
         set err [lindex [$zset diag $no] 1]
@@ -103,7 +103,6 @@ proc display-full {zset no} {
     if {$type != "DB"} {
         return
     }
-    html "<h3>${no}</h3>\n"
     set rtype [$zset recordType $no]
     if {$rtype == "SUTRS"} {
         html [join [$zset getSutrs $no]] "<br>\n"
@@ -140,6 +139,164 @@ proc display-full {zset no} {
     }
 }
 
+proc put-marc-contents {cc} {
+    set ref ""
+    if {[string first :// $cc] > 0} {
+        foreach urltype {gopher http ftp mailto} {
+            if {[string first ${urltype}:// $cc] == 0} {
+                set ref $urltype
+                break
+            }
+        }
+    } 
+    if {$ref != ""} {
+        html {<a href="}
+    }
+    html $cc
+    if {$ref != ""} {
+        html {">} $urltype { reference</a>}
+    }
+}
+
+proc dl-marc-field {zset no tag id la lb sep} {
+    set n 0
+    set c [$zset getMarc $no field $tag * $id]
+    set len [llength $c]
+    if {$len == 0} {
+        return 0
+    }
+    if {$len > 1 && "x$lb" != "x"} {
+        html "<dt><b>$lb</b>\n<dd>"
+    } else {
+        html "<dt><b>$la</b>\n<dd>"
+    }
+    foreach cc $c {
+        if {$n > 0} {
+            html $sep
+        }
+        put-marc-contents $cc
+        incr n
+    }
+    return $n
+}
+
+proc dd-marc-field {zset no tag id start stop} {
+    set n 0
+    set c [$zset getMarc $no field $tag * $id]
+    set len [llength $c]
+    if {$len == 0} {
+        return 0
+    }
+    foreach cc $c {
+        html $start
+        put-marc-contents $cc
+        html $stop
+        incr n
+    }
+    return $n
+}
+
+proc dl-marc-field-rec {zset no tag lead start stop startid sep} {
+    set n 0
+    set lines [$zset getMarc $no line $tag * *]
+    foreach line $lines {
+        foreach field [lindex $line 2] {
+            if {$n == 0} {
+                html "<dt><b>$lead</b>"
+                html "\n<dd>"
+            }
+            set id [lindex $field 0]
+            if {$id == $startid} {
+                if {$n > 0} {
+                    html $stop
+                }
+                html $start
+                incr n
+                html [lindex $field 1]
+            } else {
+                html $sep
+                html [lindex $field 1]
+            }
+        }
+    }
+    if {$n > 0} {
+        html $stop
+    }
+}
+
+proc display-full {zset no} {
+    set type [$zset type $no]
+    if {$type == "SD"} {
+        set err [lindex [$zset diag $no] 1]
+        set add [lindex [$zset diag $no] 2]
+        if {$add != {}} {
+            set add " :${add}"
+        }
+        html "Error ${err}${add} <br>\n"
+        return
+    }
+    if {$type != "DB"} {
+        return
+    }
+    set rtype [$zset recordType $no]
+    if {$rtype == "SUTRS"} {
+        html [join [$zset getSutrs $no]] "<br>\n"
+        return
+    } 
+    if {[catch {set r [$zset getMarc $no line * * *]}]} {
+        html "Unknown record type: $rtype <br>\n"
+        return
+    }
+    html "<dl>\n"
+    set n [dl-marc-field $zset $no 700 a "Author" "Authors" "<br>\n"]
+    if {$n == 0} {
+        set n [dl-marc-field $zset $no 100 a "Author" "Authors" "<br>\n"]
+    }
+    set n [dl-marc-field $zset $no 710 a "Corporate Name" {} ", "]
+    if {$n == 0} {
+        set n [dl-marc-field $zset $no 710 a "Corporate Name" {} ", "]
+    }
+    set n [dl-marc-field $zset $no 245 {a} "Title" {} " "]
+    if {$n > 0} {
+        dd-marc-field $zset $no 245 b "<em>" "</em>"
+        dd-marc-field $zset $no 245 c " " ""
+    } else {
+        dl-marc-field $zset $no 245 {[ab]} "Title" {} " "
+    }
+    dl-marc-field $zset $no 520 a "Abstract" {} ", "
+    dl-marc-field $zset $no 072 * "Subject code" "Subject codes" ", "
+    dl-marc-field $zset $no 650 * "Subject" {} ", "
+    dl-marc-field $zset $no 260 * "Publisher" {} " "
+    dl-marc-field $zset $no 300 * "Physical Description" {} " "
+
+    dl-marc-field $zset $no 500 a "Notes" {} ", "
+
+    dl-marc-field-rec $zset $no 510 "References" "" "<br>\n" "a" ", "
+
+    dl-marc-field $zset $no 350 a "Price" {} ", "
+    dl-marc-field $zset $no 362 a "Dates of publication" {} ", "
+    dl-marc-field $zset $no 850 a "Holdings" {} ", "
+
+    dl-marc-field $zset $no 010 a "LC control number" {} ", "
+    dl-marc-field $zset $no 010 b "NUCMC control number" {} ", "
+    dl-marc-field $zset $no 020 a "ISBN" {} ", "
+    dl-marc-field $zset $no 022 a "ISSN" {} ", "
+    set url [$zset getMarc $no field 856 * u]
+    set sp [$zset getMarc $no field 856 * 3]
+    if {"x$url" != "x"} {
+        html "<dt><b>URL</b>\n"
+        if {"x$sp" == "x"} {
+            set sp reference
+        }
+        html {<dd><a href="} $url {">} [join $sp] "</a>\n"
+    }
+    dl-marc-field $zset $no 037 * "Acquisition" {} "<br>\n"
+    dl-marc-field $zset $no 787 {[rstw6]} "Related information" {} "<br>\n"
+    dl-marc-field $zset $no 001 * "Local control number" {} ", "
+    html "</dl>\n"
+}
+
+
 proc display-rec {from to dfunc zz} {
     global setNo
 
@@ -414,6 +571,9 @@ proc z39present {setNo setOffset setMax dfunc} {
                 break
             }
             set got [z39.$setNo numberOfRecordsReturned]
+            if {$got <= 0} {
+                break
+            }
         }
         display-rec $setOffset [expr $got + $setOffset - 1] $dfunc z39
         set setOffset [expr $got + $setOffset]