Skip to content

Commit f1eb378

Browse files
committed
refactor PageData to pageData
1 parent b0c0494 commit f1eb378

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

docs/content/doc/developers/guidelines-frontend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Guidelines specialized for Gitea:
3636
3. HTML ids and classes used in JavaScript should be unique for the whole project, and should contain 2-3 feature related keywords. We recommend to use the `js-` prefix for classes that are only used in JavaScript.
3737
4. jQuery events across different features should use their own namespaces.
3838
5. CSS styling for classes provided by frameworks should not be overwritten. Always use new class-names to overwrite framework styles. We recommend to use the `us-` prefix for user defined styles.
39-
6. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map{}`
39+
6. The backend can pass complex data to the frontend by using `ctx.PageData["myModuleData"] = map[]{}`
4040
7. Simple pages and SEO-related pages use Go HTML Template render to generate static Fomantic-UI HTML output. Complex pages can use Vue2 (or Vue3 in future).
4141

4242
## Legacy Problems and Solutions

modules/context/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type Context struct {
5151
Resp ResponseWriter
5252
Req *http.Request
5353
Data map[string]interface{} // data used by MVC templates
54-
PageData map[string]interface{} // data used by JavaScript modules in one page
54+
PageData map[string]interface{} // data used by JavaScript modules in one page, it's `window.config.pageData`
5555
Render Render
5656
translation.Locale
5757
Cache cache.Cache
@@ -648,7 +648,7 @@ func Contexter() func(next http.Handler) http.Handler {
648648
"IsProd": setting.IsProd(),
649649
},
650650
}
651-
// PageData is passed by reference, and it will be rendered to `window.config.PageData` in `head.tmpl` for JavaScript modules
651+
// PageData is passed by reference, and it will be rendered to `window.config.pageData` in `head.tmpl` for JavaScript modules
652652
ctx.PageData = map[string]interface{}{}
653653
ctx.Data["PageData"] = ctx.PageData
654654

templates/base/head.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
CustomEmojis: {{CustomEmojis}},
2727
UseServiceWorker: {{UseServiceWorker}},
2828
csrf: '{{.CsrfToken}}',
29-
PageData: {{ .PageData }},
29+
pageData: {{ .PageData }},
3030
HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
3131
SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
3232
Tribute: {{if .RequireTribute}}true{{else}}false{{end}},

templates/repo/issue/view_content.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
{{end}}
1010

1111
<!-- I know, there is probably a better way to do this (moved from sidebar.tmpl, original author: 6543 @ 2021-02-28) -->
12-
<!-- Agree, there should be a better way, eg: introduce window.config.PageData (original author: wxiaoguang @ 2021-09-05) -->
12+
<!-- Agree, there should be a better way, eg: introduce window.config.pageData (original author: wxiaoguang @ 2021-09-05) -->
1313
<input type="hidden" id="repolink" value="{{$.RepoRelPath}}">
1414
<input type="hidden" id="repoId" value="{{.Repository.ID}}">
1515
<input type="hidden" id="issueIndex" value="{{.Issue.Index}}"/>

web_src/js/components/DashboardRepoList.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue';
22
import {initVueSvg, vueDelimiters} from './VueComponentLoader.js';
33

4-
const {AppSubUrl, AssetUrlPrefix, PageData} = window.config;
4+
const {AppSubUrl, AssetUrlPrefix, pageData} = window.config;
55

66
function initVueComponents() {
77
Vue.component('repo-search', {
@@ -350,7 +350,7 @@ function initVueComponents() {
350350

351351
function initDashboardRepoList() {
352352
const el = document.getElementById('dashboard-repo-list');
353-
const dashboardRepoListData = PageData.dashboardRepoList || null;
353+
const dashboardRepoListData = pageData.dashboardRepoList || null;
354354
if (!el || !dashboardRepoListData) return;
355355

356356
initVueSvg();

web_src/js/components/RepoActivityTopAuthors.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const sfc = {
6868
// * home_link: (...)
6969
// * login: (...)
7070
// * name: (...)
71-
activityTopAuthors: window.config.PageData.repoActivityTopAuthors || [],
71+
activityTopAuthors: window.config.pageData.repoActivityTopAuthors || [],
7272
}),
7373
computed: {
7474
graphPoints() {

web_src/js/features/admin-users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export function initAdminUserListSearchForm() {
2-
const searchForm = window.config.PageData.adminUserListSearchForm;
2+
const searchForm = window.config.pageData.adminUserListSearchForm;
33
if (!searchForm) return;
44

55
const $form = $('#user-list-search-form');

0 commit comments

Comments
 (0)