Add the skeleton of the web application
It does nothing more than to server a single page that does nothing
interesting.
This time i do not use a router. Instead, i am trying out a technique
i have seen in an article[0] that i have tried in other, smaller,
projects and seems to work surprisingly well: it just “cuts off” the
URI path by path, passing the request from handler to handler until
it finds its way to a handler that actually serves the request.
That helps to loosen the coupling between the application and lower
handlers, and makes dependencies explicit, because i need to pass the
locale, company, etc. down instead of storing them in contexts. Let’s
see if i do not regret it on a later date.
I also made a lot more packages that in Numerus. In Numerus i actually
only have the single pkg package, and it works, kind of, but i notice
how i name my methods to avoid clashing instead of using packages for
that. That is, instead of pkg.NewApp i now have app.New.
Initially i thought that Locale should be inside app, but then there was
a circular dependency between app and template. That is why i created a
separate package, but now i am wondering if template should be inside
app too, but then i would have app.MustRenderTemplate instead of
template.MustRender.
The CSS is the most bare-bones file i could write because i am focusing
in markup right now; Oriol will fill in the file once the application is
working.
[0]: https://blog.merovius.de/posts/2017-06-18-how-not-to-use-an-http-router/
2023-07-22 22:11:00 +00:00
|
|
|
HTML_FILES := $(shell find web -name *.gohtml)
|
|
|
|
GO_FILES := $(shell find . -name *.go)
|
|
|
|
DEFAULT_DOMAIN = camper
|
|
|
|
POT_FILE = po/$(DEFAULT_DOMAIN).pot
|
|
|
|
LINGUAS = ca es
|
|
|
|
MO_FILES = $(patsubst %,locale/%/LC_MESSAGES/$(DEFAULT_DOMAIN).mo,$(LINGUAS))
|
|
|
|
XGETTEXTFLAGS = --no-wrap --from-code=UTF-8 --package-name=camper --msgid-bugs-address=jordi@tandem.blog
|
|
|
|
|
|
|
|
locales: $(MO_FILES)
|
|
|
|
|
|
|
|
locale/%/LC_MESSAGES/camper.mo: po/%.po
|
|
|
|
mkdir -p $(@D)
|
|
|
|
msgfmt -o $@ $<
|
|
|
|
|
|
|
|
po/%.po: $(POT_FILE)
|
|
|
|
msgmerge --no-wrap --update --backup=off $@ $<
|
|
|
|
|
|
|
|
$(POT_FILE): $(HTML_FILES) $(GO_FILES)
|
|
|
|
xgettext $(XGETTEXTFLAGS) --language=Scheme --output=$@ --keyword=pgettext:1,2c $(HTML_FILES)
|
|
|
|
xgettext $(XGETTEXTFLAGS) --language=C --output=$@ --join-existing $(GO_FILES)
|
|
|
|
|
2023-07-22 21:56:16 +00:00
|
|
|
test-deploy:
|
|
|
|
sqitch deploy --db-name $(PGDATABASE)
|
|
|
|
pg_prove test/*
|
|
|
|
|
Add the skeleton of the web application
It does nothing more than to server a single page that does nothing
interesting.
This time i do not use a router. Instead, i am trying out a technique
i have seen in an article[0] that i have tried in other, smaller,
projects and seems to work surprisingly well: it just “cuts off” the
URI path by path, passing the request from handler to handler until
it finds its way to a handler that actually serves the request.
That helps to loosen the coupling between the application and lower
handlers, and makes dependencies explicit, because i need to pass the
locale, company, etc. down instead of storing them in contexts. Let’s
see if i do not regret it on a later date.
I also made a lot more packages that in Numerus. In Numerus i actually
only have the single pkg package, and it works, kind of, but i notice
how i name my methods to avoid clashing instead of using packages for
that. That is, instead of pkg.NewApp i now have app.New.
Initially i thought that Locale should be inside app, but then there was
a circular dependency between app and template. That is why i created a
separate package, but now i am wondering if template should be inside
app too, but then i would have app.MustRenderTemplate instead of
template.MustRender.
The CSS is the most bare-bones file i could write because i am focusing
in markup right now; Oriol will fill in the file once the application is
working.
[0]: https://blog.merovius.de/posts/2017-06-18-how-not-to-use-an-http-router/
2023-07-22 22:11:00 +00:00
|
|
|
.PHONY: locales test-db
|