camper/Makefile

53 lines
1.6 KiB
Makefile
Raw Normal View History

HTML_FILES := $(shell find web -name *.gohtml -o -name *.svg -o -name *.gotxt)
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
GO_FILES := $(shell find . -name *.go)
DEFAULT_DOMAIN = camper
POT_FILE = po/$(DEFAULT_DOMAIN).pot
LINGUAS = ca es fr
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
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
DEMO_SQL = demo.sql
all: locales $(DEMO_SQL)
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
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=$@ --keyword=Gettext:1 --keyword=GettextNoop:1 --keyword=Pgettext:1,2c --keyword=PgettextNoop:1,2c --join-existing $(GO_FILES)
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
test-deploy:
sqitch deploy --db-name $(PGDATABASE)
pg_prove test/*
$(DEMO_SQL): demo/demo.sql demo/plots.avif demo/safari_tents.avif demo/bungalows.avif demo/wooden_lodges.avif
m4 --prefix-builtins $< > $@
Add Debian package Although it is way too soon to install the application on any server, i use build.opensuse.org as a kind of CI/CD server: it runs the migration and executes the test suite on each commit. For that, i need to build *some* package, and Debian suits be better because it has all the Go packages i use; i would have to create the RPM for many libraries if i were to use openSUSE, for instance. According to the de facto project layout for Go[0], these files should go into a `build/package` folder, but since i already broke the rules with Sqitch’s folders, i do not see why i have to go against Debian’s conventions of placing them into a `debian` subfolder of the root. I have spit the package into the binary and the Sqitch migration files because it is possible to want the PostgreSQL into a separate server, and there is little point of having Sqitch and all its dependencies installed on the front-end server where the Go program runs. The demo package is probably harder to justify, as it is just a single file, however i will not run out of packages, will i? Lintian detects htmx@1.9.3.min.js as a “source-less” file, which is practically true as nobody is ever going to edit a minified source. I did not want to include the source in the distribution package, that’s why i included it in the “missing sources” file, even thought this is a native debian package and, thus, can not have missing sources. git-buildpackage creates a lot of extra files that have to be removed to build it again, otherwise the process detects the new files in the directory and refuses to build the tarball. I was getting tired of doing it manually and added a Makefile rule. Closes #20
2023-07-27 17:20:29 +00:00
clean:
$(RM) $(DEMO_SQL)
Add Debian package Although it is way too soon to install the application on any server, i use build.opensuse.org as a kind of CI/CD server: it runs the migration and executes the test suite on each commit. For that, i need to build *some* package, and Debian suits be better because it has all the Go packages i use; i would have to create the RPM for many libraries if i were to use openSUSE, for instance. According to the de facto project layout for Go[0], these files should go into a `build/package` folder, but since i already broke the rules with Sqitch’s folders, i do not see why i have to go against Debian’s conventions of placing them into a `debian` subfolder of the root. I have spit the package into the binary and the Sqitch migration files because it is possible to want the PostgreSQL into a separate server, and there is little point of having Sqitch and all its dependencies installed on the front-end server where the Go program runs. The demo package is probably harder to justify, as it is just a single file, however i will not run out of packages, will i? Lintian detects htmx@1.9.3.min.js as a “source-less” file, which is practically true as nobody is ever going to edit a minified source. I did not want to include the source in the distribution package, that’s why i included it in the “missing sources” file, even thought this is a native debian package and, thus, can not have missing sources. git-buildpackage creates a lot of extra files that have to be removed to build it again, otherwise the process detects the new files in the directory and refuses to build the tarball. I was getting tired of doing it manually and added a Makefile rule. Closes #20
2023-07-27 17:20:29 +00:00
$(RM) $(MO_FILES)
$(RM) $(POT_FILE)
$(RM) debian/debhelper-build-stamp
$(RM) debian/camper-demo.substvars
$(RM) debian/camper-sqitch.substvars
$(RM) debian/camper.postrm.debhelper
$(RM) debian/camper.substvars
$(RM) debian/files
$(RM) debian/golang-tandem-camper-dev.substvars
$(RM) -r _build/
$(RM) -r debian/.debhelper/
$(RM) -r debian/camper/
$(RM) -r debian/golang-tandem-camper-dev/
$(RM) -r debian/tmp/
$(RM) -r debian/camper-demo/
$(RM) -r debian/camper-sqitch/
.PHONY: locales test-db clean