specify correct doctype and fixed scan name generation
This commit is contained in:
parent
59de45dd22
commit
7a7cfb5707
2 changed files with 11 additions and 9 deletions
|
@ -33,7 +33,7 @@ func New(request *http.Request) scan {
|
||||||
var scan scan
|
var scan scan
|
||||||
data, _ := io.ReadAll(request.Body)
|
data, _ := io.ReadAll(request.Body)
|
||||||
json.Unmarshal(data, &scan)
|
json.Unmarshal(data, &scan)
|
||||||
scan.generateScanName()
|
scan.ScanName = scan.generateScanName()
|
||||||
return scan
|
return scan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,10 @@ func (scan scan) Execute() *result {
|
||||||
|
|
||||||
// unexported functions
|
// unexported functions
|
||||||
func (scan scan) generateScanName() string {
|
func (scan scan) generateScanName() string {
|
||||||
if len(scan.FileName) == 0 {
|
var scanName string
|
||||||
|
if len(scan.FileName) > 0 {
|
||||||
|
scanName = scan.FileName
|
||||||
|
} else {
|
||||||
day := fmt.Sprint(time.Now().Day())
|
day := fmt.Sprint(time.Now().Day())
|
||||||
if len(day) < 2 {
|
if len(day) < 2 {
|
||||||
day = "0" + day
|
day = "0" + day
|
||||||
|
@ -100,15 +103,14 @@ func (scan scan) generateScanName() string {
|
||||||
if len(second) < 2 {
|
if len(second) < 2 {
|
||||||
second = "0" + second
|
second = "0" + second
|
||||||
}
|
}
|
||||||
scan.FileName = day + month + fmt.Sprint(time.Now().Year()) + "-" + hour + minute + second
|
scanName = day + month + fmt.Sprint(time.Now().Year()) + "-" + hour + minute + second
|
||||||
}
|
}
|
||||||
if !strings.HasSuffix(scan.FileName, ".png") {
|
if !strings.HasSuffix(scanName, ".png") {
|
||||||
scan.FileName += ".png"
|
scanName += ".png"
|
||||||
}
|
}
|
||||||
error := os.MkdirAll(scannerConfig.OutputDirectory, 0755)
|
error := os.MkdirAll(scannerConfig.OutputDirectory, 0755)
|
||||||
if error != nil {
|
if error != nil {
|
||||||
log.Fatal("an error occurred creating the output directory", error.Error())
|
log.Fatal("an error occurred creating the output directory", error.Error())
|
||||||
}
|
}
|
||||||
scan.ScanName = scannerConfig.OutputDirectory + scan.FileName
|
return scannerConfig.OutputDirectory + scanName
|
||||||
return scan.ScanName
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<html>
|
<!DOCTYPE html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>go-scan</title>
|
<title>go-scan</title>
|
||||||
<link href="/fonts/firacode.ttf" rel="stylesheet">
|
<link href="/fonts/firacode.ttf">
|
||||||
<link href="/css/styles.css" rel="stylesheet">
|
<link href="/css/styles.css" rel="stylesheet">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue