#
# Copyright for the scripts in this file (c) 2005 - 2006
# by Gerald Banon - INPE. All rights reserved.
# This script processes the INPE Clipping submitted files
if 0 {
source ../../../../../iconet.com.br/banon/2005/12.29.23.16/doc/script.tcl
set homePath {C:/Gerald/URLib 2}
set URLibServiceRepository dpi.inpe.br/banon/1998/08.02.08.56
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/12.29.23.16 {
# >
# ----------------------------------------------------------------------
# Script
# reference example:
# {%0 Newspaper Article} {%B O Globo} {%3 clipping.html} {%T Exemplo}
# Script is executed in RunPostSubmissionScript (see DDDialog.tcl)
proc Script {rep reference} {
global homePath
global pwd
# upvar 0 rep currentRep ;# used by GetFrameName
set thisRepository iconet.com.br/banon/2005/12.29.23.16
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 [glob -nocomplain {*.[jJ][pP][gG]}]
set fileList [concat $fileList [glob -nocomplain {*.[pP][dD][fF]}]]
cd $pwd
Load $homePath/col/$thisRepository/doc/ClippingModel.tcl clippingFileContent
Load $homePath/col/$thisRepository/doc/HeaderModel.tcl headerFileContent
# Load $homePath/col/$thisRepository/doc/PageModel.tcl pageFileContent ;# for use with iframe - add one more scroll bar
if {[llength $fileList] == 1} {
set cuts {}
set height 95
set headerName header1.html
set fileName [join [lindex $fileList 0]]
if [regexp {\.jpg$} $fileName] {
Load $homePath/col/$thisRepository/doc/BodyModel.tcl bodyFileContent
set image $fileName
set fileContent [subst $bodyFileContent]
Store fileContent $docPath/body1.html
set fileName body1.html
set openComment {}
set closeComment {}
} else {
# .pdf
set fileName [ConvertURLToHexadecimal $fileName]
set openComment {}
}
# set fileContent [subst $pageFileContent]
set fileContent [subst $clippingFileContent]
Store fileContent $docPath/clipping1.html
set fileContent [subst $headerFileContent]
# Store fileContent $docPath/header1.html ;# commented by GJFB in 2015-12-15
Store fileContent $docPath/header1.html binary ;# added by GJFB in 2015-12-15 - binary solves the accent problem
} else {
set height 130
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 headerName header$i.html
set fileName [join [lindex $fileList [expr $i - 1]]]
if [regexp {\.jpg$} $fileName] {
Load $homePath/col/$thisRepository/doc/BodyModel.tcl bodyFileContent
set image $fileName
set fileContent [subst $bodyFileContent]
Store fileContent $docPath/body$i.html
set fileName body$i.html
set openComment {}
set closeComment {}
} else {
# .pdf
set fileName [ConvertURLToHexadecimal $fileName]
set openComment {}
}
# set fileContent [subst $pageFileContent]
set fileContent [subst $clippingFileContent]
Store fileContent $docPath/clipping$i.html
set fileContent [subst $headerFileContent]
# Store fileContent $docPath/header$i.html ;# commented by GJFB in 2015-12-1
Store fileContent $docPath/header$i.html binary ;# added by GJFB in 2015-12-15 - binary solves the accent problem
incr i
}
}
return clipping1.html ;# target file name
}
# Script - end
# ----------------------------------------------------------------------
# <
}
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/12.29.23.16::Script $rep $reference
}
#