2020-02-02 10:17:44 +08:00
|
|
|
---
|
|
|
|
date: "2020-01-25T21:00:00-03:00"
|
|
|
|
title: "Embedded data extraction tool"
|
|
|
|
slug: "cmd-embedded"
|
2023-04-04 21:47:31 +08:00
|
|
|
weight: 20
|
2020-12-09 14:47:06 +08:00
|
|
|
toc: false
|
2020-02-02 10:17:44 +08:00
|
|
|
draft: false
|
Refactor docs (#23752)
This was intended to be a small followup for
https://github.com/go-gitea/gitea/pull/23712, but...here we are.
1. Our docs currently use `slug` as the entire URL, which makes
refactoring tricky (see https://github.com/go-gitea/gitea/pull/23712).
Instead, this PR attempts to make future refactoring easier by using
slugs as an extension of the section. (Hugo terminology)
- What the above boils down to is this PR attempts to use directory
organization as URL management. e.g. `usage/comparison.en-us.md` ->
`en-us/usage/comparison/`, `usage/packages/overview.en-us.md` ->
`en-us/usage/packages/overview/`
- Technically we could even remove `slug`, as Hugo defaults to using
filename, however at least with this PR it means `slug` only needs to be
the name for the **current file** rather than an entire URL
2. This PR adds appropriate aliases (redirects) for pages, so anything
on the internet that links to our docs should hopefully not break.
3. A minor nit I've had for a while, renaming `seek-help` to `support`.
It's a minor thing, but `seek-help` has a strange connotation to it.
4. The commits are split such that you can review the first which is the
"actual" change, and the second is added redirects so that the first
doesn't break links elsewhere.
---------
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-04-28 11:33:41 +08:00
|
|
|
aliases:
|
|
|
|
- /en-us/cmd-embedded
|
2020-02-02 10:17:44 +08:00
|
|
|
menu:
|
|
|
|
sidebar:
|
2023-03-23 23:18:24 +08:00
|
|
|
parent: "administration"
|
2020-02-02 10:17:44 +08:00
|
|
|
name: "Embedded data extraction tool"
|
2023-03-23 23:18:24 +08:00
|
|
|
weight: 20
|
2020-02-02 10:17:44 +08:00
|
|
|
identifier: "cmd-embedded"
|
|
|
|
---
|
|
|
|
|
|
|
|
# Embedded data extraction tool
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
**Table of Contents**
|
|
|
|
|
|
|
|
{{< toc >}}
|
|
|
|
|
2020-02-02 10:17:44 +08:00
|
|
|
Gitea's executable contains all the resources required to run: templates, images, style-sheets
|
|
|
|
and translations. Any of them can be overridden by placing a replacement in a matching path
|
2023-03-23 23:18:24 +08:00
|
|
|
inside the `custom` directory (see [Customizing Gitea]({{< relref "doc/administration/customizing-gitea.en-us.md" >}})).
|
2020-02-02 10:17:44 +08:00
|
|
|
|
|
|
|
To obtain a copy of the embedded resources ready for editing, the `embedded` command from the CLI
|
|
|
|
can be used from the OS shell interface.
|
|
|
|
|
2020-02-13 03:30:48 +08:00
|
|
|
**NOTE:** The embedded data extraction tool is included in Gitea versions 1.12 and above.
|
|
|
|
|
2020-02-02 10:17:44 +08:00
|
|
|
## Listing resources
|
|
|
|
|
|
|
|
To list resources embedded in Gitea's executable, use the following syntax:
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
```sh
|
2020-02-02 10:17:44 +08:00
|
|
|
gitea embedded list [--include-vendored] [patterns...]
|
|
|
|
```
|
|
|
|
|
|
|
|
The `--include-vendored` flag makes the command include vendored files, which are
|
|
|
|
normally excluded; that is, files from external libraries that are required for Gitea
|
2023-05-02 01:25:54 +08:00
|
|
|
(e.g. [octicons](https://octicons.github.com/), etc).
|
2020-02-02 10:17:44 +08:00
|
|
|
|
|
|
|
A list of file search patterns can be provided. Gitea uses [gobwas/glob](https://github.com/gobwas/glob)
|
|
|
|
for its glob syntax. Here are some examples:
|
|
|
|
|
|
|
|
- List all template files, in any virtual directory: `**.tmpl`
|
|
|
|
- List all mail template files: `templates/mail/**.tmpl`
|
|
|
|
- List all files inside `public/img`: `public/img/**`
|
|
|
|
|
|
|
|
Don't forget to use quotes for the patterns, as spaces, `*` and other characters might have
|
|
|
|
a special meaning for your command shell.
|
|
|
|
|
|
|
|
If no pattern is provided, all files are listed.
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
### Example
|
2020-02-02 10:17:44 +08:00
|
|
|
|
|
|
|
Listing all embedded files with `openid` in their path:
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
```sh
|
2020-02-02 10:17:44 +08:00
|
|
|
$ gitea embedded list '**openid**'
|
2020-05-10 22:55:22 +08:00
|
|
|
public/img/auth/openid_connect.svg
|
2020-02-02 10:17:44 +08:00
|
|
|
public/img/openid-16x16.png
|
|
|
|
templates/user/auth/finalize_openid.tmpl
|
|
|
|
templates/user/auth/signin_openid.tmpl
|
|
|
|
templates/user/auth/signup_openid_connect.tmpl
|
|
|
|
templates/user/auth/signup_openid_navbar.tmpl
|
|
|
|
templates/user/auth/signup_openid_register.tmpl
|
|
|
|
templates/user/settings/security_openid.tmpl
|
|
|
|
```
|
|
|
|
|
|
|
|
## Extracting resources
|
|
|
|
|
|
|
|
To extract resources embedded in Gitea's executable, use the following syntax:
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
```sh
|
2020-02-02 10:17:44 +08:00
|
|
|
gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...}
|
|
|
|
```
|
|
|
|
|
2021-11-28 21:28:30 +08:00
|
|
|
The `--config` option tells Gitea the location of the `app.ini` configuration file if
|
2020-02-02 10:17:44 +08:00
|
|
|
it's not in its default location. This option is only used with the `--custom` flag.
|
|
|
|
|
2021-11-28 21:28:30 +08:00
|
|
|
The `--destination` option tells Gitea the directory where the files must be extracted to.
|
2020-02-02 10:17:44 +08:00
|
|
|
The default is the current directory.
|
|
|
|
|
2021-11-28 21:28:30 +08:00
|
|
|
The `--custom` flag tells Gitea to extract the files directly into the `custom` directory.
|
2020-02-02 10:17:44 +08:00
|
|
|
For this to work, the command needs to know the location of the `app.ini` configuration
|
|
|
|
file (`--config`) and, depending of the configuration, be ran from the directory where
|
2023-03-23 23:18:24 +08:00
|
|
|
Gitea normally starts. See [Customizing Gitea]({{< relref "doc/administration/customizing-gitea.en-us.md" >}}) for details.
|
2020-02-02 10:17:44 +08:00
|
|
|
|
|
|
|
The `--overwrite` flag allows any existing files in the destination directory to be overwritten.
|
|
|
|
|
2021-11-28 21:28:30 +08:00
|
|
|
The `--rename` flag tells Gitea to rename any existing files in the destination directory
|
2020-02-02 10:17:44 +08:00
|
|
|
as `filename.bak`. Previous `.bak` files are overwritten.
|
|
|
|
|
|
|
|
At least one file search pattern must be provided; see `list` subcomand above for pattern
|
|
|
|
syntax and examples.
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
### Important notice
|
2020-02-02 10:17:44 +08:00
|
|
|
|
|
|
|
Make sure to **only extract those files that require customization**. Files that
|
|
|
|
are present in the `custom` directory are not upgraded by Gitea's upgrade process.
|
|
|
|
When Gitea is upgraded to a new version (by replacing the executable), many of the
|
|
|
|
embedded files will suffer changes. Gitea will honor and use any files found
|
|
|
|
in the `custom` directory, even if they are old and incompatible.
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
### Example
|
2020-02-02 10:17:44 +08:00
|
|
|
|
|
|
|
Extracting mail templates to a temporary directory:
|
|
|
|
|
2020-12-09 14:47:06 +08:00
|
|
|
```sh
|
2020-02-02 10:17:44 +08:00
|
|
|
$ mkdir tempdir
|
|
|
|
$ gitea embedded extract --destination tempdir 'templates/mail/**.tmpl'
|
|
|
|
Extracting to tempdir:
|
|
|
|
tempdir/templates/mail/auth/activate.tmpl
|
|
|
|
tempdir/templates/mail/auth/activate_email.tmpl
|
|
|
|
tempdir/templates/mail/auth/register_notify.tmpl
|
|
|
|
tempdir/templates/mail/auth/reset_passwd.tmpl
|
|
|
|
tempdir/templates/mail/issue/assigned.tmpl
|
|
|
|
tempdir/templates/mail/issue/default.tmpl
|
|
|
|
tempdir/templates/mail/notify/collaborator.tmpl
|
|
|
|
```
|