github.com/pbberlin/tools@v0.0.0-20160910141205-7aa5421c2169/appengine/backend/backend2.go (about) 1 package backend 2 3 import ( 4 "net/http" 5 6 sc "github.com/pbberlin/tools/dsu/distributed_unancestored" 7 "github.com/pbberlin/tools/net/http/loghttp" 8 "github.com/pbberlin/tools/net/http/tplx" 9 "google.golang.org/appengine" 10 ) 11 12 type link struct { 13 Linktext string 14 Url string 15 Target string 16 } 17 18 var blocks2 = map[string]interface{}{ 19 "01 Diverse": []interface{}{ 20 link{Linktext: "Login", Url: "/login"}, 21 link{Linktext: "Schreib-Methoden", Url: "/write-methods"}, 22 link{Linktext: "Letzte Email", Url: "/email-view"}, 23 link{Linktext: "Blob List", Url: "/blob/list"}, 24 link{Linktext: "Template Demo 1", Url: "/tpl/demo1"}, 25 link{Linktext: "Template Demo 2", Url: "/tpl/demo2"}, 26 link{Linktext: "Http fetch", Url: "/fetch-url"}, 27 link{Linktext: "Instance Info", Url: "/instance-info/view"}, 28 link{Linktext: "Gob encode decode", Url: "/big-query/test-gob-codec"}, 29 30 link{Linktext: "JSON encode", Url: "/json-encode"}, 31 link{Linktext: "JSON decode", Url: "/json-decode"}, 32 33 link{Linktext: "Fulltext put", Url: "/fulltext-search/put"}, 34 link{Linktext: "Fulltext get", Url: "/fulltext-search/get"}, 35 }, 36 "02 Guestbook": []interface{}{ 37 link{Linktext: "Eintrag hinzufügen", Url: "/guest-entry"}, 38 link{Linktext: "Einträge auflisten", Url: "/guest-view"}, 39 link{Linktext: "Einträge auflisten - paged - serialized cursor", Url: "/guest-view-cursor"}, 40 }, 41 "03 Drawing": []interface{}{ 42 link{Linktext: "Drawing a static chart", Url: "/image/draw-lines-example"}, 43 }, 44 "04 Big Query": []interface{}{ 45 link{Linktext: "Get real data", Url: "/big-query/query-into-datastore"}, 46 link{Linktext: "Get mocked data", Url: "/big-query/mock-data-into-datastore"}, 47 }, 48 "05 ... with Chart": []interface{}{ 49 link{Linktext: "Process Data 1 (mock=1},", Url: "/big-query/regroup-data-01?mock=0"}, 50 link{Linktext: "Process Data 2", Url: "/big-query/regroup-data-02?f=table"}, 51 link{Linktext: "Show as Table", Url: "/big-query/show-table"}, 52 link{Linktext: "Show as Chart", Url: "/big-query/show-chart"}, 53 link{Linktext: "As HTML", Url: "/big-query/html"}, 54 }, 55 "06 Request Images": []interface{}{ 56 link{Linktext: "WrapBlob from Datastore", Url: "/image/img-from-datastore?p=chart1"}, 57 link{Linktext: "base64 from Datastore", Url: "/image/base64-from-datastore?p=chart1"}, 58 link{Linktext: "base64 from Variable", Url: "/image/base64-from-var?p=1"}, 59 link{Linktext: "base64 from File", Url: "/image/base64-from-file?p=static/pberg1.png"}, 60 }, 61 "07 Namespaces + Task Queues": []interface{}{ 62 link{Linktext: "Increment", Url: "/namespaced-counters/increment"}, 63 link{Linktext: "Read", Url: "/namespaced-counters/read"}, 64 link{Linktext: "Push to task-queue", Url: "/namespaced-counters/queue-push"}, 65 }, 66 "08 URLs with/without ancestors": []interface{}{ 67 link{Linktext: "Backend", Url: "/save-url/backend"}, 68 }, 69 } 70 71 func backend2(w http.ResponseWriter, r *http.Request, m map[string]interface{}) { 72 73 c := appengine.NewContext(r) 74 75 path := m["dir"].(string) + m["base"].(string) 76 cntr, _ := sc.Count(c, path) 77 78 add, tplExec := tplx.FuncTplBuilder(w, r) 79 add("n_html_title", "Backend", nil) 80 //add("n_cont_0", c_link, links) 81 add("n_cont_0", tplx.PrefixLff+"backend_body", blocks2) 82 add("tpl_legend", tplx.PrefixLff+"backend_body_embed01", "") 83 84 //add("n_cont_1", "<pre>{{.}}</pre>", "pure text") 85 add("n_cont_2", "<p>{{.}} views</p>", cntr) 86 87 tplExec(w, r) 88 89 } 90 91 func init() { 92 http.HandleFunc("/backend2", loghttp.Adapter(backend2)) 93 94 }