feat(cgi): add HTML 4.01 CDE frontend

Add a C99/POSIX CGI browser for bare Git-format repositories, using got for every read. Pages are HTML 4.01 Transitional with CSS1, table layout, no JavaScript, and a configurable CDE/Motif palette. The browser supports flat and owner-scoped repository layouts, tree, blob, raw, log, and commit views, and has tests plus generated-page validation.

Assisted-by: OpenCode:DeepSeek-V4.1-Flash
This commit is contained in:
lotherk committed 2026-11-22 12:14:26 +00:00
1 parent 1b490485ff
commit feda8568da
6 files changed
+2081 -194

No files matched your search

+175 -21
View File
@@ -1,21 +1,175 @@
- Never assume, verify before claiming
- List development targets with `make help`
- Read relevant developer documentation in the `docs` folder
- PR descriptions: minimal, only what and why, no task or file listings. Include screenshots for UI changes, before and after when modifying existing UI. Aim for less than 1000 characters
- Reference issues and PRs by full URL, not by number
- Use Conventional Commits for commit messages and PR titles, plus Gitea's `enhance` type for user-facing enhancements
- Add an `Assisted-by: AGENT_NAME:MODEL_VERSION` trailer to commit messages, never `Co-Authored-By` or `Signed-off-by`
- Attribute agent authorship on one trailing line in issue and PR comments, never as a PR description section
- Never rewrite git history unless asked, update PRs with new commits and normal push
- Comments: write almost none, short and preferably same-line, explaining why for a future reader. Never narrate code, the change or the prompt. Preserve existing ones that still apply. If you need to write a paragraph-long comment, rethink your implementation, it is likely too complicated
- Add the current year to copyright headers of new `.go` files
- In `options/locale`, only edit `locale_en-US.json`, other locales are synced automatically
- In TS, use `!` instead of `?.`/`??` when a value always exists
- In Go, prefer to use modern language features wherever possible
- Write sizes as multiplications like `64 * 1024`, not bit shifts like `64 << 10`
- Prefer `tw-*` utilities over inline `style` and `flex-*` helpers over per-child `tw-ml-*`/`tw-mr-*` margins, falling back to `tw-*` where specificity requires `!important`
- Run `make fmt` after `.go` edits, `make tidy` after `go.mod` edits, `make generate-swagger` after API changes, and lint what changed with `make lint-go`, `lint-js`, `lint-css` or `lint-templates`
- Fix the cause rather than disabling a linter or weakening a test. Where unavoidable, use the narrowest scope with a trailing comment giving the reason
- Run single tests with `go test -run '^TestName$' ./modulepath/` for Go, `pnpm exec vitest <path-filter>` for TS and `GITEA_TEST_E2E_FLAGS='<filepath>' make test-e2e` for e2e
- Write the fewest, fastest tests covering the behavior, extending an existing one where possible. Prefer unit tests where logic is testable in isolation
- Aim for sub-2s per integration test and sub-4s per e2e test. Wait on a deterministic condition rather than `sleep`, and prefer semantic locators in e2e tests
# gotea — AGENTS.md
Gotea is a fork of Gitea. The repository backend is moving from `git` to
[got](https://got.gameoftrees.org/) (Game of Trees), and the old-browser frontend
is a C99/POSIX CGI program serving HTML 4.01 with a CDE/Motif look. The Go forge
backend remains the source of truth for accounts, permissions, issues, API, and
storage.
## Current state
- Base: upstream Gitea v28.4.0, full history, `upstream` remote kept.
- Main module `gotea.dev`; binary `gotea`. Identity strings and the English locale
are renamed; upstream copyright notices stay.
- The Go backend still calls `modules/git`; the got migration is the main open
backend task. Do not claim it is finished.
- `cgi/gotea-cgi` is the read-only old-browser frontend. It browses bare
repositories with `got`; it does not authenticate and has no write path.
- Gotea Pages is planned, not implemented.
## Architecture rules
- **Do not rewrite the forge backend in C up front.** Authentication, permissions,
issues, pull requests, API, and migrations live in Go for good reasons. The C CGI
is a presentation tier over the same repositories and can take over UI features
incrementally.
- The CGI must not call Gotea over HTTP or read its database yet. Its contract is
`GOTEA_REPO_ROOT` plus `got`; keep it that way until an auth design exists.
- Keep the two tiers separable: the CGI must build and run with only libc, POSIX,
and `got`.
## Hard rules
- **Brand:** new code, UI strings, docs, and paths use *gotea* / *Gotea*, never
*gitea* / *Gitea*. Upstream attribution and compatibility names are exceptions.
- **Never blind-replace `git` with `got`.** Keep `git-lfs`, `.git`, `.gitignore`,
Git wire-protocol names, `github.com` URLs, and the fact that gotea stores
standard Git-format repositories. got is the engine, not a new object format.
- **Compatibility renames need an alias or migration, not `sed`:** `GITEA_*` env
overrides, `app.ini` keys, DB table/column prefixes, dump formats, and API JSON
fields are consumed by users and tooling.
- **No new direct `git` subprocesses in runtime code.** New or modified VCS code
goes through one got wrapper (`modules/got`). The existing `modules/git` calls are
migration debt, not a pattern to copy.
- If got genuinely cannot do an operation, stop and record the gap plus a proposed
design. Do not silently add a `git` fallback.
- **Copyright:** keep upstream Gitea/MIT notices intact. New Go files get
`// Copyright <year> The Gotea Authors.` and `// SPDX-License-Identifier: MIT`.
New C files use the same SPDX header in C comment form.
- **CGI security:** HTML-escape every repository string; never invoke a shell;
validate repository names and reject `..`; treat `GOTEA_REPO_ROOT` as public
data. Private-repository access needs an auth layer first.
## Frontend rules (cgi/)
- HTML 4.01 Transitional. No JavaScript, no `<script>`, no `javascript:` URLs,
no external fonts, CSS frameworks, or images required for layout.
- CSS1 is the ceiling. Prefer table layout and `bgcolor`/`<font>` fallbacks so a
pre-CSS browser still gets a usable page. Do not use flexbox, grid, CSS
variables, or rounded corners.
- The look is CDE/Motif: grey base, bevelled in/out borders, navy title bars, a
Front Panel sidebar. Colours come from the palette, not hard-coded literals.
- C99 + POSIX only (`-D_POSIX_C_SOURCE=200809L`), no third-party libraries.
Build with `-Wall -Wextra -Wpedantic -Werror`.
- Keep `make -C cgi check` green. Tests may use `git` only to create fixtures.
- `tidy -q -e` must accept generated pages; add table `summary` attributes rather
than suppressing warnings.
## Build and test
```sh
make gotea # Go backend binary
make build # full Gitea build (frontend needs pnpm/Node)
make -C cgi # CGI binary
make -C cgi check # CGI tests
make fmt # after .go edits
make tidy # after go.mod edits
make lint # or lint-backend / lint-frontend
make test-backend # single: make test-backend#TestName
make test-integration # needs git-lfs; SQLite default
make test-e2e # single: GITEA_TEST_E2E_FLAGS='<file>' make test-e2e
make generate-swagger # after API changes; verify with make swagger-check
make test-migration # after modelmigration changes
```
- Focused Go test: `go test -run '^TestName$' ./path/to/package/`.
- Raise `ulimit -n 12288` before `make watch`.
- The backend binary is `gotea`; run it from the repository root with
`./gotea web`.
## got integration
- Put every got invocation in `modules/got` (replacing `modules/git`). Nothing else
execs got or parses repository internals.
- File changes require a **work tree**, whose metadata is `.got/` (not `.git/`).
A bare repository cannot be edited in place: server-side edits and merges need a
temporary `got checkout` work tree and a `got commit`. Serialize per repository
and clean up.
- Commits take their author from `GOT_AUTHOR` (or `got.conf`/Git config). Gitea's
`GIT_AUTHOR_*` variables are ignored by got; pass `GOT_AUTHOR` per command rather
than mutating shared repository config.
- Transports: `got clone`/`got fetch` speak smart HTTP(S), but **`got send` is
SSH-only**. `gotd` is a Unix-socket daemon behind `gotsh`/SSH with no HTTP
listener; `gotwebd` is a read-only web UI. got therefore cannot serve HTTP
`git push`. Settle the transport design before rewriting push and HTTP handlers.
- Maintenance is `gotadmin`: `init`, `pack`, `cleanup` (there is no `git gc`),
`info`, `dump`, `load`. got has no fast-export/fast-import equivalent, so mirrors,
imports, and exports that relied on them need a new design.
- got writes remotes to `.got/got.conf` as well as `.git/config`; keep both in sync
when gotea changes a remote.
- got has no documented Git-hook support; assume hooks do not run and invoke
pre-receive/update-style hooks from gotea itself.
- `gotd` cannot serve SHA-256 repositories. Keep SHA-1 until the whole serving path
supports it.
- Pin the minimum got version and test against it: got is pre-1.0 and flags drift
(0.126 is current in Debian testing; 0.111 is in trixie).
- Wikis are repositories too; route them through the same got wrapper.
## Gotea Pages
- Publish a configured branch and directory (GitHub Pages model), materialized
from the committed tree with got — never from an editor's live working copy.
- **Never serve user HTML on the main app origin.** Pages content is
attacker-controlled; same-origin means stored XSS against sessions and CSRF
tokens. Use a dedicated pages hostname, send `X-Content-Type-Options: nosniff`,
and resolve paths safely (reject `..` and symlink escapes).
- Pages inherit repository visibility: a private repository's site must not be
readable anonymously, even via a guessed URL.
- Config and state belong in `models/` with a `modelmigration/` migration; published
files belong in the storage layer, never `public/` or `custom/public/`.
- Publishing must be atomic and idempotent: stage aside, swap in, keep the last
good version on failure.
## Layout
- Backend: `routers/` (HTTP), `services/` (logic), `models/` + `modelmigration/`
(DB), `modules/` (infrastructure), `templates/`.
- Frontend: `web_src/` (Vue + Vite) for the Gitea UI; `cgi/` for the HTML 4.01
frontend.
- Tests: `*_test.go` beside code, `tests/integration/`, `_mock_data/` recordings;
CGI tests in `cgi/tests/`.
- In `options/locale`, edit only `locale_en-US.json`; other locales are synced
automatically.
## Repository conventions
- Never assume; verify before claiming. List targets with `make help`.
- Read relevant developer documentation in `docs/`.
- PR descriptions: minimal, what and why, no task or file listings. Screenshots for
UI changes, before and after when modifying existing UI, under 1000 characters.
- Reference issues and PRs by full URL, not number.
- Conventional Commits for commit messages and PR titles, plus Gitea's `enhance`
type for user-facing enhancements.
- Add `Assisted-by: AGENT_NAME:MODEL_VERSION` to commit messages; never
`Co-Authored-By` or `Signed-off-by`.
- Attribute agent authorship on one trailing line in issue/PR comments, not as a
description section.
- Never rewrite history unless asked; update PRs with new commits and normal push.
- Comments: almost none, short, explaining why. Never narrate the code or prompt.
- In TypeScript use `!` instead of `?.`/`??` when a value always exists.
- In Go prefer modern language features; write sizes as `64 * 1024`, not `64 << 10`.
- For the Vue UI prefer `tw-*` utilities over inline styles; this does not apply to
`cgi/`, which stays CSS1/tables.
- Run `make fmt` after `.go` edits, `make tidy` after `go.mod` edits, and lint what
changed with `make lint-go`, `lint-js`, `lint-css`, or `lint-templates`.
- Fix the cause rather than disabling a linter or weakening a test. If unavoidable,
use the narrowest scope with a trailing reason comment.
- Write the fewest, fastest tests covering the behaviour. Aim for sub-2s integration
and sub-4s e2e tests; wait on deterministic conditions, not sleeps.
## Before calling work done
`make fmt`, `make -C cgi check`, `tidy -q -e` on generated HTML, and the relevant
test target must pass. Check that new runtime code does not add
`exec.Command("git"` (or `exec.CommandContext`) outside `modules/git`, tests, and
explicit compatibility shims.
+74 -173
View File
@@ -1,198 +1,99 @@
# Gitea
# gotea
[![](https://github.com/go-gitea/gitea/actions/workflows/release-nightly.yml/badge.svg?branch=main)](https://github.com/go-gitea/gitea/actions/workflows/release-nightly.yml?query=branch%3Amain "Release Nightly")
[![](https://img.shields.io/discord/322538954119184384.svg?logo=discord&logoColor=white&label=Discord&color=5865F2)](https://discord.gg/Gitea "Join the Discord chat at https://discord.gg/Gitea")
[![](https://pkg.go.dev/badge/gitea.dev?status.svg)](https://pkg.go.dev/gitea.dev "GoDoc")
[![](https://img.shields.io/github/release/go-gitea/gitea.svg)](https://github.com/go-gitea/gitea/releases/latest "GitHub release")
[![](https://www.codetriage.com/go-gitea/gitea/badges/users.svg)](https://www.codetriage.com/go-gitea/gitea "Help Contribute to Open Source")
[![](https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen)](https://opencollective.com/gitea "Become a backer/sponsor of gitea")
[![](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT "License: MIT")
[![](https://badges.crowdin.net/gitea/localized.svg)](https://translate.gitea.com "Crowdin")
Gotea is a fork of [Gitea](https://github.com/go-gitea/gitea) with two defining
changes:
[繁體中文](./README.zh-tw.md) | [简体中文](./README.zh-cn.md)
- repositories are read and maintained with [got](https://got.gameoftrees.org/)
(Game of Trees) instead of the `git` binary, and
- an HTML 4.01 frontend written in C99/POSIX serves repositories over CGI, with
no JavaScript and a CDE/Motif look.
## Purpose
The fork is based on Gitea v28.4.0. Upstream history and licensing are retained.
The goal of Gitea is to make the easiest, fastest, and most painless way of
setting up a self-hosted all-in-one software development service,
including Git hosting, code management, code review, issue tracking, project kanban, wiki,
team collaboration, package registry and CI/CD which can reuse GitHub Actions.
## Status
As Gitea is written in Go, it works across **all** the platforms and
architectures that are supported by Go, including Linux, macOS, FreeBSD/OpenBSD and Windows
on x86, amd64, ARM, RISC-V 64 and PowerPC architectures.
This tree is at the bootstrap milestone:
For online demonstrations, you can visit [demo.gitea.com](https://demo.gitea.com).
| Layer | State |
| --- | --- |
| Go backend | Imported and building as `gotea` (module `gotea.dev`). Still uses `git` internally; the got migration is in progress. |
| Legacy frontend | `cgi/gotea-cgi`: read-only browser over `got`, HTML 4.01 Transitional, no JavaScript, CDE palette. |
| Pages | Planned. |
| Auth and writes | Not yet implemented in the CGI frontend. |
For accessing free Gitea service (with a limited number of repositories), you can visit [gitea.com](https://gitea.com/user/login).
## Build
To quickly deploy your own dedicated Gitea instance on Gitea Cloud, you can start a free trial at [cloud.gitea.com](https://cloud.gitea.com),
or use container (docker/podman/etc) to deploy on your own server with the [official image](https://hub.docker.com/r/gitea/gitea).
```sh
make gotea # Go backend binary
make build # full Gitea build; needs pnpm and Node
make -C cgi # C99 CGI binary
make -C cgi check # CGI tests (git is used only to create fixtures)
```
## Documentation
## Run the CGI
You can find comprehensive documentation on our official [documentation website](https://docs.gitea.com/).
```sh
GOTEA_REPO_ROOT=/var/lib/gotea/data/gitea-repositories \
GOT_BIN=/usr/bin/got \
SCRIPT_NAME=/cgi-bin/gotea \
REQUEST_METHOD=GET PATH_INFO=/ \
./cgi/gotea-cgi
```
It includes installation, administration, usage, development, contributing guides, and more to help you get started and explore all features effectively.
Point `GOTEA_REPO_ROOT` at Gotea's `data/gitea-repositories`. Both flat
(`repo.git`) and owner-scoped (`owner/repo.git`) layouts are supported.
If you have any suggestions or would like to contribute to it, you can visit the [documentation repository](https://gitea.com/gitea/docs)
### Deploy with Apache
## Building
```apache
ScriptAlias /cgi-bin/gotea /usr/local/libexec/gotea-cgi
<Directory /usr/local/libexec>
Options +ExecCGI
SetHandler cgi-script
</Directory>
SetEnv GOTEA_REPO_ROOT /var/lib/gotea/data/gitea-repositories
SetEnv GOT_BIN /usr/bin/got
```
See [docs/build-setup.md](docs/build-setup.md) for prerequisites
and [docs/development.md](docs/development.md) for setting up a local development environment, linting, and testing.
For nginx, run the CGI through `fcgiwrap`; the binary does not need a daemon.
If you'd like to build from source or make a distribution package, see [docs/build-source.md](docs/build-source.md) for more information.
**Access control:** `gotea-cgi` is read-only and does not authenticate. It serves
every repository under `GOTEA_REPO_ROOT` to anyone who can reach it. Use it only
for public repositories, or put it behind web-server authentication, until the
auth layer lands.
After building, you can run `./gitea web` to start the server, or `./gitea help` to see all available commands.
## CGI configuration
## Contributing
| Variable | Default | Meaning |
| --- | --- | --- |
| `GOTEA_REPO_ROOT` | `./repositories` | Directory with bare Git-format repositories |
| `GOT_BIN` | `got` | got binary |
| `GOTEA_PALETTE` | built-in CDE palette | `key=value` colour file |
| `GOTEA_DEBUG` | unset | Show `got` stderr on error pages |
| `SCRIPT_NAME` | `/cgi-bin/gotea` | CGI mount point, set by the web server |
Expected workflow is: Fork -> Patch -> Push -> Pull Request
Palette keys: `base`, `light`, `white`, `dark`, `shadow`, `text`, `link`,
`visited`, `title_bg`, `title_fg`. Values must be `#rgb` or `#rrggbb`.
See `cgi/palettes/cde-default.palette`.
> [!NOTE]
>
> 1. **YOU MUST READ THE [CONTRIBUTORS GUIDE](CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST.**
> 2. New to the codebase? The [development guide](docs/development.md) walks through setting up a local environment and building from source.
> 3. If you have found a vulnerability in the project, please write privately to **security@gitea.io**. Thanks!
## Design notes
## Translating
- HTML 4.01 Transitional, CSS1, table layout, no JavaScript, no external assets.
- CDE/Motif cues: grey panels, bevelled borders, navy title bars, Front Panel
sidebar.
- The CGI is read-only; `got` is its only repository reader, with no shell
invocation and no `git` fallback.
- Routes: `/`, `/repo/<name>/tree[/path]`, `/repo/<name>/blob/<path>`,
`/repo/<name>/raw/<path>`, `/repo/<name>/log`, `/repo/<name>/commit/<rev>`.
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://translate.gitea.com)
## Why the backend is not rewritten in C
Translations are done through [Crowdin](https://translate.gitea.com). If you want to translate to a new language, ask one of the managers in the Crowdin project to add a new language there.
You can also just create an issue for adding a language or ask on Discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord.
Get more information from [the translation section of our contributing guide](CONTRIBUTING.md#translation).
## Official and Third-Party Projects
We provide an official [go-sdk](https://gitea.com/gitea/go-sdk), a CLI tool called [tea](https://gitea.com/gitea/tea) and an [action runner](https://gitea.com/gitea/runner) for Gitea Action.
We maintain a list of Gitea-related projects at [gitea/awesome-gitea](https://gitea.com/gitea/awesome-gitea), where you can discover more third-party projects, including SDKs, plugins, themes, and more.
## Communication
[![](https://img.shields.io/discord/322538954119184384.svg?logo=discord&logoColor=white&label=Discord&color=5865F2)](https://discord.gg/Gitea "Join the Discord chat at https://discord.gg/Gitea")
If you have questions that are not covered by the [documentation](https://docs.gitea.com/), you can get in contact with us on our [Discord server](https://discord.gg/Gitea) or create a post in the [discourse forum](https://forum.gitea.com/).
## Authors
- [Maintainers](https://github.com/orgs/go-gitea/people)
- [Contributors](https://github.com/go-gitea/gitea/graphs/contributors)
- [Translators](options/locale/TRANSLATORS)
## Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/gitea#backer)]
<a href="https://opencollective.com/gitea#backers" target="_blank"><img src="https://opencollective.com/gitea/backers.svg?width=890"></a>
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/gitea#sponsor)]
<a href="https://opencollective.com/gitea/sponsor/0/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/1/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/2/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/3/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/4/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/5/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/6/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/7/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/8/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/9/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/9/avatar.svg"></a>
## FAQ
**How do you pronounce Gitea?**
Gitea is pronounced [/ɡɪ’ti:/](https://youtu.be/EM71-2uDAoY) as in "gi-tea" with a hard g.
**How do I configure Gitea?**
For dynamic config options, you can change it on your admin panel's configuration section.
For static config options, you can edit your `app.ini` file and restart the instance.
See [app.example.ini](https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini) or [configuration documentation](https://docs.gitea.com/administration/config-cheat-sheet) for more details.
**Where can I find the security patches?**
Check the [release notes](https://github.com/go-gitea/gitea/releases) and [security advisories](https://github.com/go-gitea/gitea/security/advisories) for security patches.
(more FAQs are listed in [FAQ documentation](https://docs.gitea.com/help/faq))
Gitea's value is its forge backend: authentication, permissions, issues, pull
requests, API, and migrations. Rewriting that up front would discard working,
security-sensitive code and delay the interface the fork actually needs. The
old-browser interface is therefore a C99 CGI presentation tier over the same
repositories, and it can take over more of the UI incrementally.
## License
This project is licensed under the MIT License.
See the [LICENSE](https://github.com/go-gitea/gitea/blob/main/LICENSE) file
for the full license text.
## Further information
<details>
<summary>Looking for an overview of the interface? Check it out the screenshots!</summary>
### Login/Register Page
![Login](https://dl.gitea.com/screenshots/login.png)
![Register](https://dl.gitea.com/screenshots/register.png)
### User Dashboard
![Home](https://dl.gitea.com/screenshots/home.png)
![Issues](https://dl.gitea.com/screenshots/issues.png)
![Pull Requests](https://dl.gitea.com/screenshots/pull_requests.png)
![Milestones](https://dl.gitea.com/screenshots/milestones.png)
### User Profile
![Profile](https://dl.gitea.com/screenshots/user_profile.png)
### Explore
![Repos](https://dl.gitea.com/screenshots/explore_repos.png)
![Users](https://dl.gitea.com/screenshots/explore_users.png)
![Orgs](https://dl.gitea.com/screenshots/explore_orgs.png)
### Repository
![Home](https://dl.gitea.com/screenshots/repo_home.png)
![Commits](https://dl.gitea.com/screenshots/repo_commits.png)
![Branches](https://dl.gitea.com/screenshots/repo_branches.png)
![Labels](https://dl.gitea.com/screenshots/repo_labels.png)
![Milestones](https://dl.gitea.com/screenshots/repo_milestones.png)
![Releases](https://dl.gitea.com/screenshots/repo_releases.png)
![Tags](https://dl.gitea.com/screenshots/repo_tags.png)
#### Repository Issue
![List](https://dl.gitea.com/screenshots/repo_issues.png)
![Issue](https://dl.gitea.com/screenshots/repo_issue.png)
#### Repository Pull Requests
![List](https://dl.gitea.com/screenshots/repo_pull_requests.png)
![Pull Request](https://dl.gitea.com/screenshots/repo_pull_request.png)
![File](https://dl.gitea.com/screenshots/repo_pull_request_file.png)
![Commits](https://dl.gitea.com/screenshots/repo_pull_request_commits.png)
#### Repository Actions
![List](https://dl.gitea.com/screenshots/repo_actions.png)
![Details](https://dl.gitea.com/screenshots/repo_actions_run.png)
#### Repository Activity
![Activity](https://dl.gitea.com/screenshots/repo_activity.png)
![Contributors](https://dl.gitea.com/screenshots/repo_contributors.png)
![Code Frequency](https://dl.gitea.com/screenshots/repo_code_frequency.png)
![Recent Commits](https://dl.gitea.com/screenshots/repo_recent_commits.png)
### Organization
![Home](https://dl.gitea.com/screenshots/org_home.png)
</details>
MIT. Upstream copyright and license notices are retained; see `LICENSE`.
+25
View File
@@ -0,0 +1,25 @@
CC ?= cc
CFLAGS ?= -O2
CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wextra -Wpedantic -Werror
CPPFLAGS ?=
LDFLAGS ?=
PREFIX ?= /usr/local
LIBEXECDIR ?= $(PREFIX)/libexec
all: gotea-cgi
gotea-cgi: gotea.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ gotea.c $(LDFLAGS)
check: gotea-cgi
./tests/run.sh
install: gotea-cgi
install -d "$(DESTDIR)$(LIBEXECDIR)"
install -m 0755 gotea-cgi "$(DESTDIR)$(LIBEXECDIR)/gotea-cgi"
clean:
rm -f gotea-cgi
.PHONY: all check install clean
+1663
View File
File diff suppressed because it is too large. Load diff
+12
View File
@@ -0,0 +1,12 @@
# CDE/Motif default palette for gotea-cgi.
# Pass this file with GOTEA_PALETTE=/path/to/cde-default.palette.
base = #a0a0a0
light = #d0d0d0
white = #ffffff
dark = #808080
shadow = #404040
text = #000000
link = #000080
visited = #551a8b
title_bg = #000080
title_fg = #ffffff
+132
View File
@@ -0,0 +1,132 @@
#!/bin/sh
# Tests for gotea-cgi. git is used only to create fixtures.
set -eu
here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
cgi=$(dirname "$here")
bin="$cgi/gotea-cgi"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT HUP INT TERM
fail() {
echo "FAIL: $*" >&2
exit 1
}
contains() {
printf '%s' "$1" | grep -Fq -- "$2"
}
expect_contains() {
contains "$1" "$2" || fail "$3 (missing: $2)"
}
expect_no() {
if contains "$1" "$2"; then
fail "$3 (found: $2)"
fi
}
run() {
env -i PATH=/usr/bin:/bin HOME="$tmp" \
GOTEA_REPO_ROOT="$tmp/repos" GOT_BIN="${GOT_BIN:-/usr/bin/got}" \
SCRIPT_NAME=/cgi-bin/gotea REQUEST_METHOD="${2:-GET}" \
PATH_INFO="$1" "$bin"
}
run_palette() {
env -i PATH=/usr/bin:/bin HOME="$tmp" \
GOTEA_REPO_ROOT="$tmp/repos" GOT_BIN="${GOT_BIN:-/usr/bin/got}" \
GOTEA_PALETTE="$2" SCRIPT_NAME=/cgi-bin/gotea \
REQUEST_METHOD=GET PATH_INFO="$1" "$bin"
}
make -C "$cgi" >/dev/null
mkdir -p "$tmp/repos/owner"
git init -q -b main "$tmp/src"
cd "$tmp/src"
printf 'hello gotea\n' > README.md
mkdir src
printf 'int main(void){return 0;}\n' > src/main.c
printf '\000\001\002' > src/logo.bin
git add .
GIT_AUTHOR_NAME='Test User' GIT_AUTHOR_EMAIL='test@example.com' \
GIT_COMMITTER_NAME='Test User' GIT_COMMITTER_EMAIL='test@example.com' \
git commit -qm 'initial import'
cd "$cgi"
hash=$(git -C "$tmp/src" rev-parse HEAD)
git clone -q --bare "$tmp/src" "$tmp/repos/owner/demo.git"
git clone -q --bare "$tmp/src" "$tmp/repos/flat.git"
git init -q --bare "$tmp/repos/owner/empty.git"
home=$(run /)
expect_contains "$home" 'DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"' "home: HTML 4.01 doctype"
expect_contains "$home" 'GOTEA' "home: brand"
expect_contains "$home" 'owner/demo' "home: nested repository"
expect_contains "$home" 'flat' "home: flat repository"
expect_contains "$home" 'empty repository' "home: empty repository"
expect_no "$home" '<script' "home: no script tag"
expect_no "$home" 'javascript:' "home: no javascript URL"
echo "PASS home"
tree=$(run /repo/owner/demo/tree)
expect_contains "$tree" 'README.md' "tree: README"
expect_contains "$tree" '[src]' "tree: directory link"
expect_contains "$tree" '/repo/owner/demo/blob/README.md' "tree: blob link"
echo "PASS tree"
sub=$(run /repo/owner/demo/tree/src)
expect_contains "$sub" 'main.c' "subtree: file"
expect_contains "$sub" 'logo.bin' "subtree: binary file"
echo "PASS subtree"
blob=$(run /repo/owner/demo/blob/README.md)
expect_contains "$blob" '<pre>hello gotea' "blob: content"
expect_contains "$blob" '/raw/README.md' "blob: raw link"
echo "PASS blob"
raw=$(run /repo/owner/demo/raw/README.md)
expect_contains "$raw" 'Content-Type: text/plain; charset=UTF-8' "raw: content type"
expect_contains "$raw" 'hello gotea' "raw: content"
echo "PASS raw"
binblob=$(run /repo/owner/demo/blob/src/logo.bin)
expect_contains "$binblob" 'Binary file' "binary: notice"
echo "PASS binary"
log=$(run /repo/owner/demo/log)
expect_contains "$log" 'commit ' "log: commit line"
expect_contains "$log" 'initial import' "log: message"
expect_contains "$log" "$hash" "log: full hash"
echo "PASS log"
commit=$(run "/repo/owner/demo/commit/$hash")
expect_contains "$commit" 'initial import' "commit: message"
expect_contains "$commit" 'diff ' "commit: patch"
echo "PASS commit"
notfound=$(run /repo/nope/tree)
expect_contains "$notfound" 'Status: 404' "missing repo: 404"
echo "PASS 404"
badpath=$(run /repo/../tree)
expect_contains "$badpath" 'Status: 400' "traversal: 400"
echo "PASS traversal"
head=$(run /repo/owner/demo/tree HEAD)
expect_contains "$head" 'Content-Type: text/html; charset=UTF-8' "HEAD: headers"
expect_no "$head" '<!DOCTYPE' "HEAD: no body"
echo "PASS HEAD"
printf 'base = #123456\n' > "$tmp/pal.palette"
pal=$(run_palette / "$tmp/pal.palette")
expect_contains "$pal" '#123456' "palette: custom base colour"
expect_contains "$pal" 'bgcolor="#123456"' "palette: body fallback"
echo "PASS palette"
flat=$(run /repo/flat/tree)
expect_contains "$flat" 'README.md' "flat: tree"
echo "PASS flat"
echo "all gotea-cgi tests passed"