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.4 kB

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