diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-10-15 10:35:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 10:35:26 +0800 |
commit | 56362043d35d2542c6fe4ac7c0ac5aabb833a9ed (patch) | |
tree | d3dd12505e7dd1b2d854c61384e1088f6901bab6 /templates | |
parent | 96ff3e310f0ba1e94f4e8206758b583719a9b46c (diff) | |
download | gitea-56362043d35d2542c6fe4ac7c0ac5aabb833a9ed.tar.gz gitea-56362043d35d2542c6fe4ac7c0ac5aabb833a9ed.zip |
Frontend refactor: move Vue related code from `index.js` to `components` dir, and remove unused codes. (#17301)
* frontend refactor
* Apply suggestions from code review
Co-authored-by: delvh <dev.lh@web.de>
* Update templates/base/head.tmpl
Co-authored-by: delvh <dev.lh@web.de>
* Update docs/content/doc/developers/guidelines-frontend.md
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* fix typo
* fix typo
* refactor PageData to pageData
* Apply suggestions from code review
Co-authored-by: delvh <dev.lh@web.de>
* Simply for the visual difference.
Co-authored-by: delvh <dev.lh@web.de>
* Revert "Apply suggestions from code review"
This reverts commit 4d78ad9b0e96ca180e0823de17659a2e0814c099.
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/base/head.tmpl | 14 | ||||
-rw-r--r-- | templates/repo/activity.tmpl | 19 | ||||
-rw-r--r-- | templates/repo/issue/view_content.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/view_file.tmpl | 10 | ||||
-rw-r--r-- | templates/user/dashboard/repolist.tmpl | 13 |
5 files changed, 18 insertions, 40 deletions
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 817bdae288..80bb121c6b 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -1,6 +1,6 @@ <!DOCTYPE html> <html lang="{{.Lang}}" class="theme-{{.SignedUser.Theme}}"> -<head data-suburl="{{AppSubUrl}}"> +<head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>{{if .Title}}{{.Title | RenderEmojiPlain}} - {{end}} {{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} </title> @@ -12,15 +12,6 @@ <meta name="keywords" content="{{MetaKeywords}}"> <meta name="referrer" content="no-referrer" /> <meta name="_csrf" content="{{.CsrfToken}}" /> - {{if .IsSigned}} - <meta name="_uid" content="{{.SignedUser.ID}}" /> - {{end}} - {{if .ContextUser}} - <meta name="_context_uid" content="{{.ContextUser.ID}}" /> - {{end}} - {{if .SearchLimit}} - <meta name="_search_limit" content="{{.SearchLimit}}" /> - {{end}} {{if .GoGetImport}} <meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}"> <meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}"> @@ -31,10 +22,11 @@ AppVer: '{{AppVer}}', AppSubUrl: '{{AppSubUrl}}', AssetUrlPrefix: '{{AssetUrlPrefix}}', + IsProd: {{.IsProd}}, CustomEmojis: {{CustomEmojis}}, UseServiceWorker: {{UseServiceWorker}}, csrf: '{{.CsrfToken}}', - PageData: {{ .PageData }}, + pageData: {{ .PageData }}, HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}}, SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}}, Tribute: {{if .RequireTribute}}true{{else}}false{{end}}, diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl index 08e2a31115..d4cff880e5 100644 --- a/templates/repo/activity.tmpl +++ b/templates/repo/activity.tmpl @@ -108,11 +108,8 @@ {{.i18n.Tr "repo.activity.git_stats_and_deletions" }} <strong class="text red">{{.i18n.Tr (TrN .i18n.Lang .Activity.Code.Deletions "repo.activity.git_stats_deletion_1" "repo.activity.git_stats_deletion_n") .Activity.Code.Deletions }}</strong>. </div> - <div class="ui attached segment" id="app"> - <script type="text/javascript"> - var ActivityTopAuthors = {{Json .ActivityTopAuthors | SafeJS}}; - </script> - <activity-top-authors :data="activityTopAuthors" /> + <div class="ui attached segment"> + <div id="repo-activity-top-authors-chart"></div> </div> </div> {{end}} @@ -126,7 +123,7 @@ <div class="list"> {{range .Activity.PublishedReleases}} <p class="desc"> - <div class="ui green label">{{$.i18n.Tr "repo.activity.published_release_label"}}</div> + <span class="ui green label">{{$.i18n.Tr "repo.activity.published_release_label"}}</span> {{.TagName}} {{if not .IsTag}} <a class="title" href="{{$.RepoLink}}/src/{{.TagName | EscapePound}}">{{.Title | RenderEmoji}}</a> @@ -145,7 +142,7 @@ <div class="list"> {{range .Activity.MergedPRs}} <p class="desc"> - <div class="ui purple label">{{$.i18n.Tr "repo.activity.merged_prs_label"}}</div> + <span class="ui purple label">{{$.i18n.Tr "repo.activity.merged_prs_label"}}</span> #{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | RenderEmoji}}</a> {{TimeSinceUnix .MergedUnix $.Lang}} </p> @@ -161,7 +158,7 @@ <div class="list"> {{range .Activity.OpenedPRs}} <p class="desc"> - <div class="ui green label">{{$.i18n.Tr "repo.activity.opened_prs_label"}}</div> + <span class="ui green label">{{$.i18n.Tr "repo.activity.opened_prs_label"}}</span> #{{.Index}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Issue.Title | RenderEmoji}}</a> {{TimeSinceUnix .Issue.CreatedUnix $.Lang}} </p> @@ -177,7 +174,7 @@ <div class="list"> {{range .Activity.ClosedIssues}} <p class="desc"> - <div class="ui red label">{{$.i18n.Tr "repo.activity.closed_issue_label"}}</div> + <span class="ui red label">{{$.i18n.Tr "repo.activity.closed_issue_label"}}</span> #{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | RenderEmoji}}</a> {{TimeSinceUnix .ClosedUnix $.Lang}} </p> @@ -193,7 +190,7 @@ <div class="list"> {{range .Activity.OpenedIssues}} <p class="desc"> - <div class="ui green label">{{$.i18n.Tr "repo.activity.new_issue_label"}}</div> + <span class="ui green label">{{$.i18n.Tr "repo.activity.new_issue_label"}}</span> #{{.Index}} <a class="title" href="{{$.RepoLink}}/issues/{{.Index}}">{{.Title | RenderEmoji}}</a> {{TimeSinceUnix .CreatedUnix $.Lang}} </p> @@ -212,7 +209,7 @@ <div class="list"> {{range .Activity.UnresolvedIssues}} <p class="desc"> - <div class="ui green label">{{$.i18n.Tr "repo.activity.unresolved_conv_label"}}</div> + <span class="ui green label">{{$.i18n.Tr "repo.activity.unresolved_conv_label"}}</span> #{{.Index}} {{if .IsPull}} <a class="title" href="{{$.RepoLink}}/pulls/{{.Index}}">{{.Title | RenderEmoji}}</a> diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index 95c9296174..9ad6bee651 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -9,7 +9,7 @@ {{end}} <!-- I know, there is probably a better way to do this (moved from sidebar.tmpl, original author: 6543 @ 2021-02-28) --> - <!-- Agree, there should be a better way, eg: introduce window.config.PageData (original author: wxiaoguang @ 2021-09-05) --> + <!-- Agree, there should be a better way, eg: introduce window.config.pageData (original author: wxiaoguang @ 2021-09-05) --> <input type="hidden" id="repolink" value="{{$.RepoRelPath}}"> <input type="hidden" id="repoId" value="{{.Repository.ID}}"> <input type="hidden" id="issueIndex" value="{{.Issue.Index}}"/> diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 8e75bcb4ca..0c8990a4f5 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -131,13 +131,3 @@ </div> </div> </div> - -<script> -function submitDeleteForm() { - var message = prompt("{{.i18n.Tr "repo.delete_confirm_message"}}\n\n{{.i18n.Tr "repo.delete_commit_summary"}}", "Delete '{{.TreeName}}'"); - if (message != null) { - $("#delete-message").val(message); - $("#delete-file-form").submit() - } -} -</script> diff --git a/templates/user/dashboard/repolist.tmpl b/templates/user/dashboard/repolist.tmpl index f39d3711d4..e2cfa76e88 100644 --- a/templates/user/dashboard/repolist.tmpl +++ b/templates/user/dashboard/repolist.tmpl @@ -1,8 +1,7 @@ -<div id="app" class="six wide column"> +<div id="dashboard-repo-list" class="six wide column"> <repo-search :search-limit="searchLimit" - :suburl="suburl" - :uid="uid" + :sub-url="subUrl" {{if .Team}} :team-id="{{.Team.ID}}" {{end}} @@ -31,7 +30,7 @@ {{.i18n.Tr "home.my_repos"}} <span class="ui grey label ml-3">${reposTotalCount}</span> </div> - <a class="poping up" :href="suburl + '/repo/create'" data-content="{{.i18n.Tr "new_repo"}}" data-variation="tiny inverted" data-position="left center"> + <a class="poping up" :href="subUrl + '/repo/create'" data-content="{{.i18n.Tr "new_repo"}}" data-variation="tiny inverted" data-position="left center"> {{svg "octicon-plus"}} <span class="sr-only">{{.i18n.Tr "new_repo"}}</span> </a> @@ -122,7 +121,7 @@ <div v-if="repos.length" class="ui attached table segment rounded-bottom"> <ul class="repo-owner-name-list"> <li v-for="repo in repos" :class="{'private': repo.private || repo.internal}"> - <a class="repo-list-link df ac sb" :href="suburl + '/' + repo.full_name"> + <a class="repo-list-link df ac sb" :href="subUrl + '/' + repo.full_name"> <div class="text truncate item-name f1"> <component v-bind:is="repoIcon(repo)" size="16"></component> <strong>${repo.full_name}</strong> @@ -168,7 +167,7 @@ {{.i18n.Tr "home.my_orgs"}} <span class="ui grey label ml-3">${organizationsTotalCount}</span> </div> - <a v-if="canCreateOrganization" class="poping up" :href="suburl + '/org/create'" data-content="{{.i18n.Tr "new_org"}}" data-variation="tiny inverted" data-position="left center"> + <a v-if="canCreateOrganization" class="poping up" :href="subUrl + '/org/create'" data-content="{{.i18n.Tr "new_org"}}" data-variation="tiny inverted" data-position="left center"> {{svg "octicon-plus"}} <span class="sr-only">{{.i18n.Tr "new_org"}}</span> </a> @@ -176,7 +175,7 @@ <div v-if="organizations.length" class="ui attached table segment rounded-bottom"> <ul class="repo-owner-name-list"> <li v-for="org in organizations"> - <a class="repo-list-link df ac sb" :href="suburl + '/' + org.name"> + <a class="repo-list-link df ac sb" :href="subUrl + '/' + org.name"> <div class="text truncate item-name f1"> {{svg "octicon-organization" 16 "mr-2"}} <strong>${org.name}</strong> |