Allow for marked up file thumbnails to be shown and uploaded.
This commit is contained in:
5
web/data/alpine.js
Normal file
5
web/data/alpine.js
Normal file
File diff suppressed because one or more lines are too long
@@ -23,7 +23,8 @@
|
||||
<button @click="skip_upload(ul.id)" type="button" class="btn btn-primary">reject</button>
|
||||
</td>
|
||||
<td>
|
||||
<td><a x-bind:href="'/editor.html?id='+ul.id"><img x-bind:src="'/rest/image/'+ul.id+'/thumb'"></a></td>
|
||||
<a x-bind:href="'/editor.html?id='+ul.id"><img x-bind:src="'/rest/image/'+ul.id+'/thumb'"></a>
|
||||
<a x-show="ul.markedup_file" x-bind:href="'/editor.html?id='+ul.id"><img x-bind:src="'/rest/image/'+ul.id+'/markedup_thumb'"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</template>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
|
||||
<script src="//unpkg.com/alpinejs" defer></script>
|
||||
<script src="/alpine.js" defer></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/fabric@4.6.0/dist/fabric.min.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -189,7 +189,31 @@ func (ws *WebService) imageThumb(w http.ResponseWriter, r *http.Request) {
|
||||
returnJSONError(w, "bad id")
|
||||
return
|
||||
}
|
||||
err = processor.ThumbPNG(ul, w)
|
||||
err = processor.ThumbPNG(ul, "orig", w)
|
||||
if err != nil {
|
||||
returnJSONError(w, "could not create thumb")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (ws *WebService) imageMarkedupThumb(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "image/png")
|
||||
processor := imageprocess.Processor{}
|
||||
|
||||
vars := mux.Vars(r)
|
||||
id, err := strconv.ParseInt(vars["id"], 10, 32)
|
||||
if err != nil {
|
||||
returnJSONError(w, "bad id")
|
||||
return
|
||||
}
|
||||
|
||||
ul := ws.Uploader.UploadById(int32(id))
|
||||
if ul == nil {
|
||||
returnJSONError(w, "bad id")
|
||||
return
|
||||
}
|
||||
err = processor.ThumbPNG(ul, "markedup", w)
|
||||
if err != nil {
|
||||
returnJSONError(w, "could not create thumb")
|
||||
return
|
||||
@@ -268,7 +292,22 @@ func (ws *WebService) modifyUpload(w http.ResponseWriter, r *http.Request) {
|
||||
returnJSONError(w, err.Error())
|
||||
return
|
||||
}
|
||||
fmt.Printf("YAY %v", b)
|
||||
|
||||
// write to a temporary file
|
||||
tempfile, err := ioutil.TempFile("", "dau_markup")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
n, err := tempfile.Write(b)
|
||||
if n != len(b) {
|
||||
log.Fatalf("only wrote %d bytes??", n)
|
||||
}
|
||||
if err != nil {
|
||||
log.Fatalf("Could not write temp file: %v", err)
|
||||
}
|
||||
|
||||
tempfile.Close()
|
||||
anUpload.MarkedUpFilename = tempfile.Name()
|
||||
|
||||
} else {
|
||||
returnJSONError(w, "bad change type")
|
||||
@@ -294,6 +333,8 @@ func (ws *WebService) StartWebServer() {
|
||||
r.HandleFunc("/rest/upload/{id:[0-9]+}/{change}", ws.modifyUpload)
|
||||
|
||||
r.HandleFunc("/rest/image/{id:[0-9]+}/thumb", ws.imageThumb)
|
||||
r.HandleFunc("/rest/image/{id:[0-9]+}/markedup_thumb", ws.imageMarkedupThumb)
|
||||
|
||||
r.HandleFunc("/rest/image/{id:[0-9]+}", ws.image)
|
||||
|
||||
r.HandleFunc("/rest/config", ws.handleConfig)
|
||||
|
||||
Reference in New Issue
Block a user