- Go 81.2%
- templ 14.6%
- CSS 4.1%
- Shell 0.1%
apply.coop
A job board for co-ops. More info about our hosted version is available at apply.coop.
Contributing
Since we are building this in public, we value any contributions from folks who find this project valuable. There are many ways to contribute to:
- Patches and pull requests
- Documentation
- Testing and bug finding/squashing
- Financially
Before you get started, please review our Code of Conduct. Our goal is to improve the world, and we cannot do that unless we treat each other with respect.
System Dependancies
Installing Go
Read the instructions for your platform at https://go.dev/doc/install.
Installing SQLite (optional)
Rust may complain if there are missing libraries for SQLite so if you need to install SQLite then you can use whatever system package manager is convenient to install it.
- Mac:
brew install sqlite. Note: if you have already installed Xcode command line tools, you can skip this, as you will already havesqlite3installed. - Ubuntu:
sudo apt install sqlite3
Configuration
The apply application can be configured via flags, environment variables, or TOML config file(s).
To see command line usage, run go run main.go -h
By default, the application looks for a config.toml file in the same directory
from which it is executed. An example config file can be found at .example.config.toml.
You can simply run the following for a minimal development configuration without the need for flags or environment variables:
% cp .example.config.toml config.toml
Running
You can easily run the app by using the following command:
% go run main.go
However, we use templ for HTML templating. If you modify any of
the templates/*.temp files you need to re-generate them to create their *.go versions.
Simply run:
% go generate ./...
Then you can run it as normal. You can even chain them together:
% go generate ./... && go run main.go
Load up the browser at http://0.0.0.0:8080
Seeding Database
By default, there will be no data in the database when migrations are run. If you would like to seed the database with an account and some podcasts then you can run the following:
% go run ./cmd/seed
Tools
We use Go 1.24's new tool directive in go.mod to declare any additional
tools we need for development.
Testing
Use go to run then.
% go test -race -cover ./...
Formatting
We use gofumpt to format the code. See the instructions there to set it up with your editor/IDE.
You run it to format the project with:
% go tool gofumpt -w .
Linting
We use golangci-lint to lint the code. You can install it with:
% curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.0.2
From their documentaion, it is not recommended to use go get to install it.
Then run it with:
% golangci-lint run
Localization
Tip: When localizing a string that is used in multiple places, make a constant.
Available Languages
This is controlled in two places:
translation/translation.go
//go:generate go tool gotext -srclang=en-US update -out=catalog.go -lang=en-US,es-419 applycoop/web/context applycoop/web/middleware applycoop/web/handler applycoop/templates
This lets the gotext tool know which languages we want to translate to and
picks up any usages of the message.Printer underneath our Localizer(s). If we
end up using localization in other packages, just add it to the list at the end
of the generate string.
localize/localize.go
var matcher language.Matcher
var locales map[language.Tag]*Localizer
These are used by our middleware to pick up the translated messages and use the correct language catalog.
Recognizing Newly-Added, Translatable Strings
% go generate ./...
This picks up any new calls to applycoop/web/context.Localize and generates new
files for each of our (currenly two) locales at translation/locales/{locale}/out.gotext.json
We then need to move the new out.gotext.json files to the messages.gotext.json files.
% mv -f ./translation/locales/en/{out,messages}.gotext.json
% mv -f ./translation/locales/es/{out,messages}.gotext.json
We only deal with messages.gotext.json files in the repository.
The out.gotext.json files are ignored.
Updating Translations
We would perform any necessary translations on the
translation/locales/{locale}/messages.gotext.json file(s).
Then run:
% go generate ./...
This updates the generated translation/catalog.go file.
Example Usage
Example from a *.templ file:
import (
webctx "applycoop/web/context"
)
// ...
templ Thing() {
<p>{ webctx.Localize(ctx, "This should be translated to multiple languages.") }</p>
}