diff options
author | John Olheiser <42128690+jolheiser@users.noreply.github.com> | 2019-11-11 09:15:29 -0600 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-11-11 23:15:29 +0800 |
commit | 74a6add4d90beb8133bcbf8ca6b43de35e0aa983 (patch) | |
tree | 868e452d41d71094c5b2cccce67f4211fd14e77b /templates/repo | |
parent | 74bb292fe3f4c02fc1dc5f32622c74d820cadd78 (diff) | |
download | gitea-74a6add4d90beb8133bcbf8ca6b43de35e0aa983.tar.gz gitea-74a6add4d90beb8133bcbf8ca6b43de35e0aa983.zip |
Template Repositories (#8768)
* Start work on templates
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Continue work
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix IsTemplate vs IsGenerated
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix tabs vs spaces
* Tabs vs Spaces
* Add templates to API & start adding tests
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix integration tests
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Remove unused User
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Move template tests to existing repos
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Minor re-check updates and cleanup
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* make fmt
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Test cleanup
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix optionalbool
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* make fmt
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Test fixes and icon change
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Add new user and repo for tests
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix tests (finally)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Update meta repo with env variables
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Move generation to create page
Combine with repo create template
Modify API search to prioritize owner for repo
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix tests and coverage
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix swagger and JS lint
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix API searching for own private repos
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Change wording
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Fix repo search test. User had a private repo that didn't show up
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Another search test fix
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Clarify git content
Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Feedback updates
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Add topics WIP
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Finish adding topics
Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Update locale
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'templates/repo')
-rw-r--r-- | templates/repo/create.tmpl | 119 | ||||
-rw-r--r-- | templates/repo/header.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/home.tmpl | 11 | ||||
-rw-r--r-- | templates/repo/settings/options.tmpl | 7 |
4 files changed, 94 insertions, 45 deletions
diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 1a53e3c893..f728a93631 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -55,68 +55,97 @@ <label for="description">{{.i18n.Tr "repo.repo_desc"}}</label> <textarea id="description" name="description">{{.description}}</textarea> </div> - <div class="inline field"> - <label>{{.i18n.Tr "repo.issue_labels"}}</label> - <div class="ui search normal selection dropdown"> - <input type="hidden" name="issue_labels" value="{{.issueLabels}}"> - <div class="default text">{{.i18n.Tr "repo.issue_labels_helper"}}</div> + <label>{{.i18n.Tr "repo.template"}}</label> + <div id="repo_template_search" class="ui search normal selection dropdown"> + <input type="hidden" id="repo_template" name="repo_template" value="{{.repo_template}}"> + <div class="default text">{{.repo_template_name}}</div> <div class="menu"> - <div class="item" data-value="">{{.i18n.Tr "repo.issue_labels_helper"}}</div> - {{range .LabelTemplates}} - <div class="item" data-value="{{.}}">{{.}}</div> - {{end}} </div> </div> </div> - <div class="ui divider"></div> - - <div class="inline field"> - <label>.gitignore</label> - <div class="ui multiple search normal selection dropdown"> - <input type="hidden" name="gitignores" value="{{.gitignores}}"> - <div class="default text">{{.i18n.Tr "repo.repo_gitignore_helper"}}</div> - <div class="menu"> - {{range .Gitignores}} - <div class="item" data-value="{{.}}">{{.}}</div> - {{end}} + <div id="template_units" style="display: none;"> + <div class="inline field"> + <label>{{.i18n.Tr "repo.template.items"}}</label> + <div class="ui checkbox"> + <input class="hidden" name="git_content" type="checkbox" tabindex="0" {{if .git_content}}checked{{end}}> + <label>{{.i18n.Tr "repo.template.git_content"}}</label> </div> </div> - </div> - <div class="inline field"> - <label>{{.i18n.Tr "repo.license"}}</label> - <div class="ui search selection dropdown"> - <input type="hidden" name="license" value="{{.license}}"> - <div class="default text">{{.i18n.Tr "repo.license_helper"}}</div> - <div class="menu"> - <div class="item" data-value="">{{.i18n.Tr "repo.license_helper"}}</div> - {{range .Licenses}} - <div class="item" data-value="{{.}}">{{.}}</div> - {{end}} + <div class="inline field"> + <label></label> + <div class="ui checkbox"> + <input class="hidden" name="topics" type="checkbox" tabindex="0" {{if .topics}}checked{{end}}> + <label>{{.i18n.Tr "repo.template.topics"}}</label> </div> </div> </div> - <div class="inline field"> - <label>{{.i18n.Tr "repo.readme"}}</label> - <div class="ui selection dropdown"> - <input type="hidden" name="readme" value="{{.readme}}"> - <div class="default text">{{.i18n.Tr "repo.readme_helper"}}</div> - <div class="menu"> - {{range .Readmes}} - <div class="item" data-value="{{.}}">{{.}}</div> - {{end}} + <div id="non_template"> + <div class="inline field"> + <label>{{.i18n.Tr "repo.issue_labels"}}</label> + <div class="ui search normal selection dropdown"> + <input type="hidden" name="issue_labels" value="{{.issueLabels}}"> + <div class="default text">{{.i18n.Tr "repo.issue_labels_helper"}}</div> + <div class="menu"> + <div class="item" data-value="">{{.i18n.Tr "repo.issue_labels_helper"}}</div> + {{range .LabelTemplates}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> </div> </div> - </div> - <div class="inline field"> - <div class="ui checkbox" id="auto-init"> - <input class="hidden" name="auto_init" type="checkbox" tabindex="0" {{if .auto_init}}checked{{end}}> - <label>{{.i18n.Tr "repo.auto_init"}}</label> + + <div class="ui divider"></div> + + <div class="inline field"> + <label>.gitignore</label> + <div class="ui multiple search normal selection dropdown"> + <input type="hidden" name="gitignores" value="{{.gitignores}}"> + <div class="default text">{{.i18n.Tr "repo.repo_gitignore_helper"}}</div> + <div class="menu"> + {{range .Gitignores}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + </div> + <div class="inline field"> + <label>{{.i18n.Tr "repo.license"}}</label> + <div class="ui search selection dropdown"> + <input type="hidden" name="license" value="{{.license}}"> + <div class="default text">{{.i18n.Tr "repo.license_helper"}}</div> + <div class="menu"> + <div class="item" data-value="">{{.i18n.Tr "repo.license_helper"}}</div> + {{range .Licenses}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + </div> + + <div class="inline field"> + <label>{{.i18n.Tr "repo.readme"}}</label> + <div class="ui selection dropdown"> + <input type="hidden" name="readme" value="{{.readme}}"> + <div class="default text">{{.i18n.Tr "repo.readme_helper"}}</div> + <div class="menu"> + {{range .Readmes}} + <div class="item" data-value="{{.}}">{{.}}</div> + {{end}} + </div> + </div> + </div> + <div class="inline field"> + <div class="ui checkbox" id="auto-init"> + <input class="hidden" name="auto_init" type="checkbox" tabindex="0" {{if .auto_init}}checked{{end}}> + <label>{{.i18n.Tr "repo.auto_init"}}</label> + </div> </div> </div> + <br/> <div class="inline field"> <label></label> <button class="ui green button"> diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 111609efef..b1b31183c4 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -12,9 +12,11 @@ <div class="divider"> / </div> <a href="{{$.RepoLink}}">{{.Name}}</a> {{if and .RelAvatarLink .IsPrivate}}<i class="mega-octicon octicon-lock"></i>{{end}} + {{if .IsTemplate}}<i class="icon fa-copy"></i>{{end}} {{if .IsArchived}}<i class="archive icon archived-icon"></i>{{end}} {{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{MirrorAddress $.Mirror}}">{{MirrorAddress $.Mirror}}</a></div>{{end}} {{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{SubStr .BaseRepo.RelLink 1 -1}}</a></div>{{end}} + {{if .IsGenerated}}<div class="fork-flag">{{$.i18n.Tr "repo.generated_from"}} <a href="{{.TemplateRepo.Link}}">{{SubStr .TemplateRepo.RelLink 1 -1}}</a></div>{{end}} </div> {{if not .IsBeingCreated}} <div class="repo-buttons"> diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index b23e851139..19989bbe06 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -95,6 +95,17 @@ </div> <div class="fitted item"> + {{if eq $n 0}} + {{if .Repository.IsTemplate}} + <div class="ui tiny blue buttons"> + <a href="{{AppSubUrl}}/repo/create?template_id={{.Repository.ID}}" class="ui button"> + {{.i18n.Tr "repo.use_template"}} + </a> + </div> + {{end}} + {{end}} + </div> + <div class="fitted item"> <!-- Only show clone panel in repository home page --> {{if eq $n 0}} diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index a93efb8d25..7ded98206c 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -15,6 +15,13 @@ <label for="repo_name">{{.i18n.Tr "repo.repo_name"}}</label> <input id="repo_name" name="repo_name" value="{{.Repository.Name}}" data-repo-name="{{.Repository.Name}}" autofocus required> </div> + <div class="inline field"> + <label>{{.i18n.Tr "repo.template"}}</label> + <div class="ui checkbox"> + <input name="template" type="checkbox" {{if .Repository.IsTemplate}}checked{{end}}> + <label>{{.i18n.Tr "repo.template_helper"}}</label> + </div> + </div> {{if not .Repository.IsFork}} <div class="inline field"> <label>{{.i18n.Tr "repo.visibility"}}</label> |