Convert tabs to spaces when displaying
This commit is contained in:
parent
d6539016d4
commit
f72073e6ef
@ -1,6 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/prologic/pastebin/client"
|
"github.com/prologic/pastebin/client"
|
||||||
@ -12,7 +13,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
defaultConfig = "pastebin.conf"
|
defaultConfig = "pastebin.conf"
|
||||||
defaultUserConfig = "~/.pastebin.conf"
|
defaultUserConfig = "~/.pastebin.conf"
|
||||||
defaultURL = "https://localhost:8000"
|
defaultURL = "http://localhost:8000"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getDefaultConfig() string {
|
func getDefaultConfig() string {
|
||||||
@ -36,5 +37,11 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
client.NewClient(url, insecure).Paste(os.Stdin)
|
cli := client.NewClient(url, insecure)
|
||||||
|
|
||||||
|
err := cli.Paste(os.Stdin)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("error posting paste: %s", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
11
server.go
11
server.go
@ -186,12 +186,15 @@ func (s *Server) ViewHandler() httprouter.Handle {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
blob, ok := s.store.Get(uuid)
|
rawBlob, ok := s.store.Get(uuid)
|
||||||
if !ok {
|
if !ok {
|
||||||
http.Error(w, "Not Found", http.StatusNotFound)
|
http.Error(w, "Not Found", http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blob := rawBlob.(string)
|
||||||
|
blob = strings.ReplaceAll(blob, "\t", " ")
|
||||||
|
|
||||||
switch accepts {
|
switch accepts {
|
||||||
case "text/html":
|
case "text/html":
|
||||||
s.render(
|
s.render(
|
||||||
@ -200,14 +203,14 @@ func (s *Server) ViewHandler() httprouter.Handle {
|
|||||||
Blob string
|
Blob string
|
||||||
UUID string
|
UUID string
|
||||||
}{
|
}{
|
||||||
Blob: blob.(string),
|
Blob: blob,
|
||||||
UUID: uuid,
|
UUID: uuid,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
case "text/plain":
|
case "text/plain":
|
||||||
w.Write([]byte(blob.(string)))
|
w.Write([]byte(blob))
|
||||||
default:
|
default:
|
||||||
w.Write([]byte(blob.(string)))
|
w.Write([]byte(blob))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user