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

cmd-embedded.en-us.md 4.5 kB

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