~reesmichael1/chantpointer

58d34640158b33258c934ac90cdaa10197a681b2 — Michael Rees 2 years ago c8ab673
Move templates into separate directory
7 files changed, 7 insertions(+), 7 deletions(-)

M handlers.go
R error.html => templates/html/error.html
R index.html => templates/html/index.html
R psalm.sty => templates/tex/psalm.sty
R psalm.tem => templates/tex/psalm.tem
M writer.go
M writer_test.go
M handlers.go => handlers.go +2 -2
@@ 21,7 21,7 @@ var savedName = "chant.json"
// and nicely displays them to the user
type ErrorHandler func(http.ResponseWriter, *http.Request) error

var templates = template.Must(template.ParseFiles("index.html", "error.html"))
var templates = template.Must(template.ParseFiles("templates/html/index.html", "templates/html/error.html"))

// Page holds the link to the generated PDF, if it exists
type Page struct {


@@ 66,7 66,7 @@ func GenerateHandler(w http.ResponseWriter, r *http.Request) error {
	}

	stylePath := filepath.Join(dir, "psalm.sty")
	style, err := ioutil.ReadFile("psalm.sty")
	style, err := ioutil.ReadFile("templates/tex/psalm.sty")
	if err != nil {
		return err
	}

R error.html => templates/html/error.html +0 -0
R index.html => templates/html/index.html +1 -1
@@ 112,7 112,7 @@ The Lord of hosts,\\ he | is the | King of | glory.</pre>
                If you find this useful, you may also be interested in <a href="https://soubasse.com">Soubasse</a>.
                </p>
                <p>This website was built by <a href="https://reesmichael1.com">Michael Rees</a> on top of a <a href="https://github.com/gregrs-uk/anglican-chant-template">LaTeX template for typesetting Anglican chant</a> originally written by <a href="https://github.com/gregrs-uk">@gregrs-uk</a>.
                <p>If you are interested, the source <a href="https://gitlab.com/reesmichael1/chantpointer">is available on Gitlab</a>.</p>
                <p>If you are interested, the source <a href="https://git.sr.ht/~reesmichael1/chantpointer">is available on git.sr.ht</a>.</p>
            </div>
        </footer>
    </body>

R psalm.sty => templates/tex/psalm.sty +0 -0
R psalm.tem => templates/tex/psalm.tem +0 -0
M writer.go => writer.go +2 -3
@@ 8,13 8,12 @@ import (
// WriteTexForChant writes the given Chant to an io.Writer
// (in practice, a text file, or for testing, an in-memory buffer)
func WriteTexForChant(f io.Writer, c *Chant) error {
	templatePath := "psalm.tem"
	t, err := template.New(templatePath).Delims("((", "))").ParseFiles(templatePath)
	t, err := template.New("psalm.tem").Delims("((", "))").ParseFiles("templates/tex/psalm.tem")
	if err != nil {
		return err
	}

	err = t.Execute(f, c)
	err = t.ExecuteTemplate(f, "psalm.tem", c)
	if err != nil {
		return err
	}

M writer_test.go => writer_test.go +2 -1
@@ 73,6 73,7 @@ func TestWriteVerses(t *testing.T) {
		ScorePath: "/tmp/chant.png",
	}

	WriteTexForChant(buf, &c)
	err := WriteTexForChant(buf, &c)
	ok(t, err)
	equals(t, savedTeX, string(buf.Bytes()))
}