You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmd-embedded.en-us.md 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. ---
  2. date: "2020-01-25T21:00:00-03:00"
  3. title: "Embedded data extraction tool"
  4. slug: "cmd-embedded"
  5. weight: 20
  6. toc: false
  7. draft: false
  8. aliases:
  9. - /en-us/cmd-embedded
  10. menu:
  11. sidebar:
  12. parent: "administration"
  13. name: "Embedded data extraction tool"
  14. weight: 20
  15. identifier: "cmd-embedded"
  16. ---
  17. # Embedded data extraction tool
  18. **Table of Contents**
  19. {{< toc >}}
  20. Gitea's executable contains all the resources required to run: templates, images, style-sheets
  21. and translations. Any of them can be overridden by placing a replacement in a matching path
  22. inside the `custom` directory (see [Customizing Gitea]({{< relref "doc/administration/customizing-gitea.en-us.md" >}})).
  23. To obtain a copy of the embedded resources ready for editing, the `embedded` command from the CLI
  24. can be used from the OS shell interface.
  25. **NOTE:** The embedded data extraction tool is included in Gitea versions 1.12 and above.
  26. ## Listing resources
  27. To list resources embedded in Gitea's executable, use the following syntax:
  28. ```sh
  29. gitea embedded list [--include-vendored] [patterns...]
  30. ```
  31. The `--include-vendored` flag makes the command include vendored files, which are
  32. normally excluded; that is, files from external libraries that are required for Gitea
  33. (e.g. [octicons](https://octicons.github.com/), etc).
  34. A list of file search patterns can be provided. Gitea uses [gobwas/glob](https://github.com/gobwas/glob)
  35. for its glob syntax. Here are some examples:
  36. - List all template files, in any virtual directory: `**.tmpl`
  37. - List all mail template files: `templates/mail/**.tmpl`
  38. - List all files inside `public/assets/img`: `public/assets/img/**`
  39. Don't forget to use quotes for the patterns, as spaces, `*` and other characters might have
  40. a special meaning for your command shell.
  41. If no pattern is provided, all files are listed.
  42. ### Example
  43. Listing all embedded files with `openid` in their path:
  44. ```sh
  45. $ gitea embedded list '**openid**'
  46. public/assets/img/auth/openid_connect.svg
  47. public/assets/img/openid-16x16.png
  48. templates/user/auth/finalize_openid.tmpl
  49. templates/user/auth/signin_openid.tmpl
  50. templates/user/auth/signup_openid_connect.tmpl
  51. templates/user/auth/signup_openid_navbar.tmpl
  52. templates/user/auth/signup_openid_register.tmpl
  53. templates/user/settings/security_openid.tmpl
  54. ```
  55. ## Extracting resources
  56. To extract resources embedded in Gitea's executable, use the following syntax:
  57. ```sh
  58. gitea [--config {file}] embedded extract [--destination {dir}|--custom] [--overwrite|--rename] [--include-vendored] {patterns...}
  59. ```
  60. The `--config` option tells Gitea the location of the `app.ini` configuration file if
  61. it's not in its default location. This option is only used with the `--custom` flag.
  62. The `--destination` option tells Gitea the directory where the files must be extracted to.
  63. The default is the current directory.
  64. The `--custom` flag tells Gitea to extract the files directly into the `custom` directory.
  65. For this to work, the command needs to know the location of the `app.ini` configuration
  66. file (`--config`) and, depending of the configuration, be ran from the directory where
  67. Gitea normally starts. See [Customizing Gitea]({{< relref "doc/administration/customizing-gitea.en-us.md" >}}) for details.
  68. The `--overwrite` flag allows any existing files in the destination directory to be overwritten.
  69. The `--rename` flag tells Gitea to rename any existing files in the destination directory
  70. as `filename.bak`. Previous `.bak` files are overwritten.
  71. At least one file search pattern must be provided; see `list` subcomand above for pattern
  72. syntax and examples.
  73. ### Important notice
  74. Make sure to **only extract those files that require customization**. Files that
  75. are present in the `custom` directory are not upgraded by Gitea's upgrade process.
  76. When Gitea is upgraded to a new version (by replacing the executable), many of the
  77. embedded files will suffer changes. Gitea will honor and use any files found
  78. in the `custom` directory, even if they are old and incompatible.
  79. ### Example
  80. Extracting mail templates to a temporary directory:
  81. ```sh
  82. $ mkdir tempdir
  83. $ gitea embedded extract --destination tempdir 'templates/mail/**.tmpl'
  84. Extracting to tempdir:
  85. tempdir/templates/mail/auth/activate.tmpl
  86. tempdir/templates/mail/auth/activate_email.tmpl
  87. tempdir/templates/mail/auth/register_notify.tmpl
  88. tempdir/templates/mail/auth/reset_passwd.tmpl
  89. tempdir/templates/mail/issue/assigned.tmpl
  90. tempdir/templates/mail/issue/default.tmpl
  91. tempdir/templates/mail/notify/collaborator.tmpl
  92. ```