#
# Copyright for the scripts in this file (c) 2005
# by Gerald Banon - INPE. All rights reserved.
# Script processes the INPE CRI-Clipping submitted files
if 0 {
source ../../../../../iconet.com.br/banon/2005/09.07.19.12/doc/script.tcl
set homePath {C:/Gerald/URLib 2}
set pwd {C:/Gerald/URLib 2/col/dpi.inpe.br/banon/1998/08.02.08.56/doc}
source utilities1.tcl
source cgi/mirrorfind-.tcl
}
namespace eval iconet.com.br/banon/2005/09.07.19.12 {
# >
# ----------------------------------------------------------------------
# Script
# reference example:
# {%0 Newspaper Article} {%B O Globo} {%3 clipping.html} {%T Exemplo}
proc Script {rep reference} {
global homePath
global pwd
set thisRepository iconet.com.br/banon/2005/09.07.19.12
set docPath $homePath/col/$rep/doc
# set docPath $rep
# set xxx OK
# Store xxx $docPath/clipping.html
set newspaper {}
set pages {}
set issuedate {}
foreach field $reference {
if {[string compare {%B} [lindex $field 0]] == 0} {set newspaper [lrange $field 1 end]}
if {[string compare {%P} [lindex $field 0]] == 0} {set pages [lrange $field 1 end]}
if {[string compare {%8} [lindex $field 0]] == 0} {set issuedate [lrange $field 1 end]}
}
if [regexp {[-,;]} $pages] {
set pageFieldName Páginas
} else {
set pageFieldName Página
}
if [regexp {^(\d{4})-(\d{2})} $issuedate m year month] {
if [regexp {^\d{4}-\d{2}-(\d{2})$} $issuedate m day] {
set issuedate $day-$month-$year
} else {
set issuedate $month-$year
}
}
cd $docPath
set fileList [lsort [glob -nocomplain {clip[0-9]*}]]
cd $pwd
Load $homePath/col/$thisRepository/doc/PageModel.tcl fileContent
if {[llength $fileList] == 1} {
set cuts {}
set image [lindex $fileList 0]
set fileContent2 [subst $fileContent]
# Store fileContent2 $docPath/clipping1.html ;# commented by GJFB in 2015-12-15
Store fileContent2 $docPath/clipping1.html binary ;# added by GJFB in 2015-12-15 - binary solves the accent problem
} else {
set i 1
foreach file $fileList {
lappend fullPageList $i
incr i
}
set i 1
foreach file $fileList {
set j 1
set cutList {}
foreach file $fileList {
if {$i == $j} {
lappend cutList $j
} else {
lappend cutList "$j"
}
incr j
}
set cuts "Veja os recortes: [join $cutList { | }]
"
set image [lindex $fileList [expr $i - 1]]
set fileContent2 [subst $fileContent]
Store fileContent2 $docPath/clipping$i.html
incr i
}
}
return clipping1.html ;# target file name
}
# ----------------------------------------------------------------------
# <
}
if 0 {
set reference {{%0 Newspaper Article} {%B O Globo} {%3 clipping.html} {%T Exemplo}}
set rep iconet.com.br/banon/2005/12.29.22.47
iconet.com.br/banon/2005/09.07.19.12::Script $rep $reference
}
#