aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÖzgür Kesim <oec@codeblau.de>2019-06-14 11:21:20 +0200
committerÖzgür Kesim <oec@codeblau.de>2019-06-14 11:21:20 +0200
commit7e4fa87020cf6d04a19a20c3a3151f2c78b57085 (patch)
tree88a57cd3a6ac00442044cee3fbd7793ea42723c3
parent4d20598a28a3139cea545736eca90df88a608e1b (diff)
download link added
-rw-r--r--index.html5
-rw-r--r--main.go4
2 files changed, 5 insertions, 4 deletions
diff --git a/index.html b/index.html
index 37ab4aa..3739c6f 100644
--- a/index.html
+++ b/index.html
@@ -155,7 +155,7 @@ window.onhashchange = hashloc;
function run() {
var data = editor.getValue().trim();
if (!data) return;
- link.innerHtml = "";
+ link.innerHTML = "";
var req = new XMLHttpRequest();
req.open("POST", "/{{$name}}/c", false);
req.onreadystatechange = function() {
@@ -182,7 +182,8 @@ function share() {
req.onreadystatechange = function() {
switch (req.status) {
case 200:
- link.innerHTML = "<i>saved as</i> <a href=\"/{{$name}}/#"+req.responseText+"!\">#"+req.responseText+"!</a>";
+ link.innerHTML = "<i>saved as</i> <a href=\"/{{$name}}/#"+req.responseText+"!\">#"+req.responseText+"!</a>" +
+ " or <a href=\"/{{$name}}/d/"+req.responseText+"\">download</a>";
document.title= "{{$name}}#"+req.responseText;
document.location.hash=req.responseText+"!";
break;
diff --git a/main.go b/main.go
index 07e15b1..de87066 100644
--- a/main.go
+++ b/main.go
@@ -92,7 +92,7 @@ func (t *Tool) compile() func(http.ResponseWriter, *http.Request) {
}
}
-func (t *Tool) svg() func(http.ResponseWriter, *http.Request) {
+func (t *Tool) download() func(http.ResponseWriter, *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
name := filepath.Base(r.URL.Path)
if file, err := os.Open(filepath.Join(*savedir, name+t.Suffix)); err != nil {
@@ -184,7 +184,7 @@ func main() {
http.HandleFunc(pre+"c", tool.compile())
http.HandleFunc(pre+"s", tool.save())
http.HandleFunc(pre+"l/", tool.load())
- http.HandleFunc(pre+"svg/", tool.svg())
+ http.HandleFunc(pre+"d/", tool.download())
http.HandleFunc(pre, tool.index(tmpl, tools))
log.Println("handler for", pre, "registered")
}