diff --git a/wrp.go b/wrp.go
index a487f1e..25abdc4 100644
--- a/wrp.go
+++ b/wrp.go
@@ -32,10 +32,20 @@ import (
"github.com/chromedp/chromedp"
)
+// Ismap for server side processing
+type Ismap struct {
+ xmin int64
+ ymin int64
+ xmax int64
+ ymax int64
+ url string
+}
+
var (
ctx context.Context
cancel context.CancelFunc
gifmap = make(map[string]bytes.Buffer)
+ ismap = make(map[string][]Ismap)
)
func pageServer(out http.ResponseWriter, r *http.Request) {
@@ -106,7 +116,7 @@ func imgServer(out http.ResponseWriter, req *http.Request) {
}
func mapServer(out http.ResponseWriter, req *http.Request) {
- log.Printf("%s MAP Request for %s [%v]\n", req.RemoteAddr, req.URL.Path, req.URL.Query())
+ log.Printf("%s MAP Request for %s [%+v]\n", req.RemoteAddr, req.URL.Path, req.URL.RawQuery)
}
func haltServer(out http.ResponseWriter, req *http.Request) {
@@ -118,13 +128,14 @@ func haltServer(out http.ResponseWriter, req *http.Request) {
os.Exit(0)
}
-func capture(gourl string, w int64, h int64, s float64, p int64, ismap bool, out http.ResponseWriter) {
+func capture(gourl string, w int64, h int64, s float64, p int64, i bool, out http.ResponseWriter) {
var nodes []*cdp.Node
ctxx := chromedp.FromContext(ctx)
var pngbuf []byte
var gifbuf bytes.Buffer
var loc string
var res *runtime.RemoteObject
+ is := make([]Ismap, 0)
log.Printf("Processing Caputure Request for %s\n", gourl)
@@ -161,14 +172,17 @@ func capture(gourl string, w int64, h int64, s float64, p int64, ismap bool, out
fmt.Fprintf(out, "
Unable to encode GIF:
%s
\n", err)
return
}
- imgpath := fmt.Sprintf("/img/%04d.gif", rand.Intn(9999))
+ seq := rand.Intn(9999)
+ imgpath := fmt.Sprintf("/img/%04d.gif", seq)
+ mappath := fmt.Sprintf("/map/%04d.map", seq)
log.Printf("Encoded GIF image: %s, Size: %dKB\n", imgpath, len(gifbuf.Bytes())/1024)
gifmap[imgpath] = gifbuf
// Process Nodes
base, _ := url.Parse(loc)
- if ismap {
- fmt.Fprintf(out, "", imgpath)
+ if i {
+ fmt.Fprintf(out, "", mappath, imgpath)
+ is = append(is, Ismap{xmin: -1, xmax: -1, ymin: -1, ymax: -1, url: "default"})
} else {
fmt.Fprintf(out, "\n\n")
}
out.(http.Flusher).Flush()
log.Printf("Done with caputure for %s\n", gourl)
+ ismap[mappath] = is
}
func main() {