Add prettier config and format files (#319)

Reviewed-on: https://codeberg.org/Codeberg/pages-server/pulls/319
Reviewed-by: crapStone <codeberg@crapstone.dev>
Co-authored-by: pat-s <patrick.schratz@gmail.com>
Co-committed-by: pat-s <patrick.schratz@gmail.com>
This commit is contained in:
pat-s 2024-04-28 20:47:04 +00:00 committed by Patrick Schratz
parent 89800d4f36
commit f407fd3ae4
8 changed files with 60 additions and 60 deletions

8
.prettierrc.json Normal file
View File

@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2,
"endOfLine": "lf"
}

View File

@ -48,7 +48,7 @@ steps:
- go version - go version
- just build-tag ${CI_COMMIT_TAG##v} - just build-tag ${CI_COMMIT_TAG##v}
when: when:
- event: ["tag"] - event: ['tag']
branch: branch:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
@ -92,7 +92,7 @@ steps:
- CI_BUILD_EVENT=${CI_BUILD_EVENT} - CI_BUILD_EVENT=${CI_BUILD_EVENT}
- CI_COMMIT_REF=${CI_COMMIT_REF} - CI_COMMIT_REF=${CI_COMMIT_REF}
when: when:
- event: ["tag"] - event: ['tag']
branch: branch:
- ${CI_REPO_DEFAULT_BRANCH} - ${CI_REPO_DEFAULT_BRANCH}
@ -109,7 +109,7 @@ steps:
password: password:
from_secret: bot_token from_secret: bot_token
when: when:
- event: ["push"] - event: ['push']
branch: ${CI_REPO_DEFAULT_BRANCH} branch: ${CI_REPO_DEFAULT_BRANCH}
docker-tag: docker-tag:
@ -119,11 +119,11 @@ steps:
registry: codeberg.org registry: codeberg.org
dockerfile: Dockerfile dockerfile: Dockerfile
repo: codeberg.org/codeberg/pages-server repo: codeberg.org/codeberg/pages-server
tags: [latest, "${CI_COMMIT_TAG}"] tags: [latest, '${CI_COMMIT_TAG}']
username: username:
from_secret: bot_user from_secret: bot_user
password: password:
from_secret: bot_token from_secret: bot_token
when: when:
- event: ["push"] - event: ['push']
branch: ${CI_REPO_DEFAULT_BRANCH} branch: ${CI_REPO_DEFAULT_BRANCH}

View File

@ -24,3 +24,9 @@ steps:
- event: pull_request - event: pull_request
- event: push - event: push
branch: renovate/* branch: renovate/*
prettier:
image: docker.io/woodpeckerci/plugin-prettier:0.1.0
depends_on: []
settings:
version: 3.2.5

View File

@ -19,16 +19,16 @@ Redirects can be created with a `_redirects` file with the following format:
from to [status] from to [status]
``` ```
* Lines starting with `#` are ignored - Lines starting with `#` are ignored
* `from` - the path to redirect from (Note: repository and branch names are removed from request URLs) - `from` - the path to redirect from (Note: repository and branch names are removed from request URLs)
* `to` - the path or URL to redirect to - `to` - the path or URL to redirect to
* `status` - status code to use when redirecting (default 301) - `status` - status code to use when redirecting (default 301)
### Status codes ### Status codes
* `200` - returns content from specified path (no external URLs) without changing the URL (rewrite) - `200` - returns content from specified path (no external URLs) without changing the URL (rewrite)
* `301` - Moved Permanently (Permanent redirect) - `301` - Moved Permanently (Permanent redirect)
* `302` - Found (Temporary redirect) - `302` - Found (Temporary redirect)
### Examples ### Examples

View File

@ -3,7 +3,7 @@
[![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue)](https://opensource.org/license/eupl-1-2/) [![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue)](https://opensource.org/license/eupl-1-2/)
[![status-badge](https://ci.codeberg.org/api/badges/Codeberg/pages-server/status.svg)](https://ci.codeberg.org/Codeberg/pages-server) [![status-badge](https://ci.codeberg.org/api/badges/Codeberg/pages-server/status.svg)](https://ci.codeberg.org/Codeberg/pages-server)
<a href="https://matrix.to/#/#gitea-pages-server:matrix.org" title="Join the Matrix room at https://matrix.to/#/#gitea-pages-server:matrix.org"> <a href="https://matrix.to/#/#gitea-pages-server:matrix.org" title="Join the Matrix room at https://matrix.to/#/#gitea-pages-server:matrix.org">
<img src="https://img.shields.io/matrix/gitea-pages-server:matrix.org?label=matrix"> <img src="https://img.shields.io/matrix/gitea-pages-server:matrix.org?label=matrix">
</a> </a>
Gitea lacks the ability to host static pages from Git. Gitea lacks the ability to host static pages from Git.
@ -21,17 +21,17 @@ and the [Codeberg Documentation](https://docs.codeberg.org/codeberg-pages/).
This is the new Codeberg Pages server, a solution for serving static pages from Gitea repositories. This is the new Codeberg Pages server, a solution for serving static pages from Gitea repositories.
Mapping custom domains is not static anymore, but can be done with DNS: Mapping custom domains is not static anymore, but can be done with DNS:
1) add a `.domains` text file to your repository, containing the allowed domains, separated by new lines. The 1. add a `.domains` text file to your repository, containing the allowed domains, separated by new lines. The
first line will be the canonical domain/URL; all other occurrences will be redirected to it. first line will be the canonical domain/URL; all other occurrences will be redirected to it.
2) add a CNAME entry to your domain, pointing to `[[{branch}.]{repo}.]{owner}.codeberg.page` (repo defaults to 2. add a CNAME entry to your domain, pointing to `[[{branch}.]{repo}.]{owner}.codeberg.page` (repo defaults to
"pages", "branch" defaults to the default branch if "repo" is "pages", or to "pages" if "repo" is something else. "pages", "branch" defaults to the default branch if "repo" is "pages", or to "pages" if "repo" is something else.
If the branch name contains slash characters, you need to replace "/" in the branch name to "~"): If the branch name contains slash characters, you need to replace "/" in the branch name to "~"):
`www.example.org. IN CNAME main.pages.example.codeberg.page.` `www.example.org. IN CNAME main.pages.example.codeberg.page.`
3) if a CNAME is set for "www.example.org", you can redirect there from the naked domain by adding an ALIAS record 3. if a CNAME is set for "www.example.org", you can redirect there from the naked domain by adding an ALIAS record
for "example.org" (if your provider allows ALIAS or similar records, otherwise use A/AAAA), together with a TXT for "example.org" (if your provider allows ALIAS or similar records, otherwise use A/AAAA), together with a TXT
record that points to your repo (just like the CNAME record): record that points to your repo (just like the CNAME record):
`example.org IN ALIAS codeberg.page.` `example.org IN ALIAS codeberg.page.`
`example.org IN TXT main.pages.example.codeberg.page.` `example.org IN TXT main.pages.example.codeberg.page.`
@ -44,6 +44,7 @@ Certificates are generated, updated and cleaned up automatically via Let's Encry
## Deployment ## Deployment
**Warning: Some Caveats Apply** **Warning: Some Caveats Apply**
> Currently, the deployment requires you to have some knowledge of system administration as well as understanding and building code, > Currently, the deployment requires you to have some knowledge of system administration as well as understanding and building code,
> so you can eventually edit non-configurable and codeberg-specific settings. > so you can eventually edit non-configurable and codeberg-specific settings.
> In the future, we'll try to reduce these and make hosting Codeberg Pages as easy as setting up Gitea. > In the future, we'll try to reduce these and make hosting Codeberg Pages as easy as setting up Gitea.

View File

@ -1,8 +1,9 @@
# HAProxy with SNI & Host-based rules # HAProxy with SNI & Host-based rules
This is a proof of concept, enabling HAProxy to use *either* SNI to redirect to backends with their own HTTPS certificates (which are then fully exposed to the client; HAProxy only proxies on a TCP level in that case), *as well as* to terminate HTTPS and use the Host header to redirect to backends that use HTTP (or a new HTTPS connection). This is a proof of concept, enabling HAProxy to use _either_ SNI to redirect to backends with their own HTTPS certificates (which are then fully exposed to the client; HAProxy only proxies on a TCP level in that case), _as well as_ to terminate HTTPS and use the Host header to redirect to backends that use HTTP (or a new HTTPS connection).
## How it works ## How it works
1. The `http_redirect_frontend` is only there to listen on port 80 and redirect every request to HTTPS. 1. The `http_redirect_frontend` is only there to listen on port 80 and redirect every request to HTTPS.
2. The `https_sni_frontend` listens on port 443 and chooses a backend based on the SNI hostname of the TLS connection. 2. The `https_sni_frontend` listens on port 443 and chooses a backend based on the SNI hostname of the TLS connection.
3. The `https_termination_backend` passes all requests to a unix socket (using the plain TCP data). 3. The `https_termination_backend` passes all requests to a unix socket (using the plain TCP data).
@ -11,6 +12,7 @@ This is a proof of concept, enabling HAProxy to use *either* SNI to redirect to
In the example (see [haproxy.cfg](haproxy.cfg)), the `pages_backend` is listening via HTTPS and is providing its own HTTPS certificates, while the `gitea_backend` only provides HTTP. In the example (see [haproxy.cfg](haproxy.cfg)), the `pages_backend` is listening via HTTPS and is providing its own HTTPS certificates, while the `gitea_backend` only provides HTTP.
## How to test ## How to test
```bash ```bash
docker-compose up & docker-compose up &
./test.sh ./test.sh

View File

@ -1,8 +1,8 @@
version: "3" version: '3'
services: services:
haproxy: haproxy:
image: haproxy image: haproxy
ports: ["443:443"] ports: ['443:443']
volumes: volumes:
- ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro - ./haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
- ./dhparam.pem:/etc/ssl/dhparam.pem:ro - ./dhparam.pem:/etc/ssl/dhparam.pem:ro
@ -19,4 +19,3 @@ services:
volumes: volumes:
- ./pages-www:/srv:ro - ./pages-www:/srv:ro
- ./pages.Caddyfile:/etc/caddy/Caddyfile:ro - ./pages.Caddyfile:/etc/caddy/Caddyfile:ro

View File

@ -1,18 +1,12 @@
<!DOCTYPE html> <!doctype html>
<html class="codeberg-design"> <html class="codeberg-design">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width" /> <meta name="viewport" content="width=device-width" />
<title>{{.StatusText}}</title> <title>{{.StatusText}}</title>
<link <link rel="stylesheet" href="https://design.codeberg.org/design-kit/codeberg.css" />
rel="stylesheet" <link rel="stylesheet" href="https://fonts.codeberg.org/dist/inter/Inter%20Web/inter.css" />
href="https://design.codeberg.org/design-kit/codeberg.css"
/>
<link
rel="stylesheet"
href="https://fonts.codeberg.org/dist/inter/Inter%20Web/inter.css"
/>
<style> <style>
body { body {
@ -34,12 +28,7 @@
</style> </style>
</head> </head>
<body> <body>
<svg <svg xmlns="http://www.w3.org/2000/svg" height="10em" viewBox="0 0 24 24" fill="var(--blue-color)">
xmlns="http://www.w3.org/2000/svg"
height="10em"
viewBox="0 0 24 24"
fill="var(--blue-color)"
>
<path <path
d="M 9 2 C 5.1458514 2 2 5.1458514 2 9 C 2 12.854149 5.1458514 16 9 16 C 10.747998 16 12.345009 15.348024 13.574219 14.28125 L 14 14.707031 L 14 16 L 19.585938 21.585938 C 20.137937 22.137937 21.033938 22.137938 21.585938 21.585938 C 22.137938 21.033938 22.137938 20.137938 21.585938 19.585938 L 16 14 L 14.707031 14 L 14.28125 13.574219 C 15.348024 12.345009 16 10.747998 16 9 C 16 5.1458514 12.854149 2 9 2 z M 9 4 C 11.773268 4 14 6.2267316 14 9 C 14 11.773268 11.773268 14 9 14 C 6.2267316 14 4 11.773268 4 9 C 4 6.2267316 6.2267316 4 9 4 z" d="M 9 2 C 5.1458514 2 2 5.1458514 2 9 C 2 12.854149 5.1458514 16 9 16 C 10.747998 16 12.345009 15.348024 13.574219 14.28125 L 14 14.707031 L 14 16 L 19.585938 21.585938 C 20.137937 22.137937 21.033938 22.137938 21.585938 21.585938 C 22.137938 21.033938 22.137938 20.137938 21.585938 19.585938 L 16 14 L 14.707031 14 L 14.28125 13.574219 C 15.348024 12.345009 16 10.747998 16 9 C 16 5.1458514 12.854149 2 9 2 z M 9 4 C 11.773268 4 14 6.2267316 14 9 C 14 11.773268 11.773268 14 9 14 C 6.2267316 14 4 11.773268 4 9 C 4 6.2267316 6.2267316 4 9 4 z"
/> />
@ -50,18 +39,13 @@
<p><b>"{{.Message}}"</b></p> <p><b>"{{.Message}}"</b></p>
<p> <p>
We hope this isn't a problem on our end ;) - Make sure to check the We hope this isn't a problem on our end ;) - Make sure to check the
<a <a href="https://docs.codeberg.org/codeberg-pages/troubleshooting/" target="_blank"
href="https://docs.codeberg.org/codeberg-pages/troubleshooting/"
target="_blank"
>troubleshooting section in the Docs</a >troubleshooting section in the Docs</a
>! >!
</p> </p>
</h5> </h5>
<small class="text-muted"> <small class="text-muted">
<img <img src="https://design.codeberg.org/logo-kit/icon.svg" class="align-top" />
src="https://design.codeberg.org/logo-kit/icon.svg"
class="align-top"
/>
Static pages made easy - Static pages made easy -
<a href="https://codeberg.page">Codeberg Pages</a> <a href="https://codeberg.page">Codeberg Pages</a>
</small> </small>