From a1070fb7679fbcc4b8ca2fbc6bd8acb132f115c9 Mon Sep 17 00:00:00 2001 From: Matt Jibson Date: Fri, 19 Oct 2018 02:52:24 -0400 Subject: [PATCH] link to binaries and blog post --- main.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index a68d2771..caaf8feb 100644 --- a/main.go +++ b/main.go @@ -145,6 +145,7 @@ func serveHTTP(spec Specification) { base := template.Must(template.New("base").Parse(Base)) index := template.Must(template.Must(base.Clone()).Parse(Index)) about := template.Must(template.Must(base.Clone()).Parse(About)) + editor := template.Must(template.Must(base.Clone()).Parse(Editor)) mux := http.NewServeMux() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -159,6 +160,12 @@ func serveHTTP(spec Specification) { http.Error(w, err.Error(), 500) } }) + mux.HandleFunc("/editor", func(w http.ResponseWriter, r *http.Request) { + if err := editor.Execute(w, nil); err != nil { + fmt.Println(err) + http.Error(w, err.Error(), 500) + } + }) mux.HandleFunc("/fmt", wrap(Fmt)) srv := &http.Server{ Addr: spec.Addr, @@ -363,12 +370,21 @@ a { -

sequel fumpt

{{block "content" .}}{{end}} ` + Editor = `{{define "content"}} +

editor configuration

+sqlfmt is available as a standalone binary. You can configure your editor to run it on .sql files on save, or over selected text. + +
+index +about +{{end}}` + About = `{{define "content"}} +

about

sqlfmt is an online SQL formatter. It is pronounced sequel fumpt. @@ -429,13 +445,19 @@ SELECT a       OR d +

Background

+ +sqlfmt was inspired by prettier. It is based on a paper describing a layout algorithm. A blog post describes a bit more. +
index +editor config
by @mjibson
code: github.com/mjibson/sqlfmt {{end}}` Index = `{{define "content"}} +

sequel fumpt

Type some SQL. Move the slider to set output width.

@@ -469,6 +491,7 @@ target line width: , actual width: +editor config about