Skip to content

Conversation

@guillep2k
Copy link
Member

@guillep2k guillep2k commented Jan 25, 2020

This PR adds a command for extracting static files from gitea. The purpose is to assist users in the customization process.

$ gitea embedded list '**openid**'
public/img/auth/openid_connect.png
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

$ gitea embedded extract --destination ~/work --overwrite '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

$ gitea embedded extract --custom 'templates/mail/issue/default.tmpl'
Extracting to /var/lib/gitea/custom
/var/lib/gitea/custom/templates/mail/issue/default.tmpl already exists; skipped.

$ gitea embedded extract --custom --rename 'templates/mail/issue/default.tmpl'
Extracting to /var/lib/gitea/custom
/var/lib/gitea/custom/templates/mail/issue/default.tmpl

$ ls /var/lib/gitea/custom/templates/mail/issue/
default.tmpl
default.tmpl.bak

Status

  • Basic functionality
  • Acknowledge Windows is a thing
  • Add docs

Other examples:

$ gitea embedded list '**sidebar**'
public/fomantic/components/sidebar.css
public/fomantic/components/sidebar.js
public/fomantic/components/sidebar.min.css
public/fomantic/components/sidebar.min.js
templates/org/team/sidebar.tmpl
templates/repo/issue/view_content/sidebar.tmpl

$ mkdir temp
$ gitea embedded extract --destination temp '**sidebar.tmpl'
Extracting to temp:
temp/templates/org/team/sidebar.tmpl
temp/templates/repo/issue/view_content/sidebar.tmpl
$

Closes #9413

@zeripath
Copy link
Contributor

I would allow extract to extract to the custom folder by default so that this can be used to prepopulate the templates folder.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 25, 2020
@codecov-io
Copy link

codecov-io commented Jan 25, 2020

Codecov Report

Merging #9982 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9982      +/-   ##
==========================================
- Coverage   43.49%   43.49%   -0.01%     
==========================================
  Files         568      568              
  Lines       79108    79108              
==========================================
- Hits        34408    34407       -1     
+ Misses      40453    40452       -1     
- Partials     4247     4249       +2
Impacted Files Coverage Δ
modules/queue/manager.go 60.51% <100%> (ø) ⬆️
services/pull/patch.go 67.92% <0%> (-1.89%) ⬇️
services/pull/check.go 55.24% <0%> (-1.4%) ⬇️
routers/repo/view.go 40% <0%> (+0.86%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5bbf476...5c94d66. Read the comment docs.

@lafriks
Copy link
Member

lafriks commented Jan 25, 2020

Probably should also add --force option to override already existing file

@guillep2k guillep2k changed the title WIP: Implement "embedded" command to extract static resources Implement "embedded" command to extract static resources Jan 26, 2020
@guillep2k
Copy link
Member Author

guillep2k commented Jan 26, 2020

Ready for review.

@lafriks I've implemented the --overwrite and --rename flags. --rename will create a .bak. I can change --overwrite to --force if it's preferred.

@zeripath I've included a --custom flag to extract directly into Gitea's custom directory. I've refrained from making it the default option for the following considerations:

  • Most extraction tools (e.g. unzip, tar -x, gzip -d, etc.) will extract to the current directory.
  • The location of the custom directory is easy for the command to establish.... provided that app.ini is in the expected location, relative paths play as intended, etc. I figured that when everything is "default", typing in --custom is easy, but if anything is not default, perhaps it's better to let the user enter --destination {dir} and figure the custom location by themselves.

@guillep2k
Copy link
Member Author

@lunny I've just realized that you've suggested a command syntax for this in #9413. This PR doesn't follow that syntax closely. Let me know if the new syntax is OK.

@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jan 26, 2020
@lunny lunny added this to the 1.12.0 milestone Jan 26, 2020
@lunny
Copy link
Member

lunny commented Jan 26, 2020

@guillep2k Great work!!! I'm OK with the syntax on this PR.

@lunny
Copy link
Member

lunny commented Feb 1, 2020

Could we view some files before we extract them?

@guillep2k
Copy link
Member Author

Could we view some files before we extract them?

Certainly! What about a --view flag? I would however give an error if many files match the pattern, in order to simplify things. Otherwise I'd need to deal with headers, separators, etc.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 1, 2020
@lunny
Copy link
Member

lunny commented Feb 1, 2020

How about gitea embedded view <filepath>?

Copy link
Member

@jolheiser jolheiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good so far, will re-review when the view command/flag is implemented.

@guillep2k
Copy link
Member Author

@lunny Done.

@guillep2k
Copy link
Member Author

@jolheiser Done.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 2, 2020
@lunny lunny merged commit bcb52ae into go-gitea:master Feb 2, 2020
@sapk sapk added the type/changelog Adds the changelog for a new Gitea version label Feb 2, 2020
@guillep2k guillep2k deleted the embedded branch February 3, 2020 02:27
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A new command to list and extract template files

10 participants