Skip to content

Commit e6a0381

Browse files
lukasbestlelunny
authored andcommitted
Extract header and footer content to separate tmpl (#4797)
This change makes it easier to customize the header and footer content. Before this change, the whole header and footer had to be overridden, including the meta, style and script tags. Signed-off-by: Lukas Bestle <[email protected]>
1 parent fab7937 commit e6a0381

File tree

4 files changed

+162
-159
lines changed

4 files changed

+162
-159
lines changed

templates/base/footer.tmpl

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,8 @@
1010

1111
{{template "custom/body_outer_post" .}}
1212

13-
<footer>
14-
<div class="ui container">
15-
<div class="ui left">
16-
© Gitea {{if (or .ShowFooterVersion .PageIsAdmin)}}{{.i18n.Tr "version"}}: {{AppVer}}{{end}} {{if ShowFooterTemplateLoadTime}}{{.i18n.Tr "page"}}: <strong>{{LoadTimes .PageStartTime}}</strong> {{.i18n.Tr "template"}}: <strong>{{call .TmplLoadTimes}}</strong>{{end}}
17-
</div>
18-
<div class="ui right links">
19-
{{if .ShowFooterBranding}}
20-
<a target="_blank" rel="noopener noreferrer" href="https://github.com/go-gitea/gitea"><i class="fa fa-github-square"></i><span class="sr-only">GitHub</span></a>
21-
{{end}}
22-
<div class="ui language bottom floating slide up dropdown link item">
23-
<i class="world icon"></i>
24-
<div class="text">{{.LangName}}</div>
25-
<div class="menu">
26-
{{range .AllLangs}}
27-
<a class="item {{if eq $.Lang .Lang}}active selected{{end}}" href="{{if eq $.Lang .Lang}}#{{else}}{{$.Link}}?lang={{.Lang}}{{end}}">{{.Name}}</a>
28-
{{end}}
29-
</div>
30-
</div>
31-
<a href="{{AppSubUrl}}/vendor/librejs.html" data-jslicense="1">JavaScript licenses</a>
32-
{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
33-
<a target="_blank" rel="noopener noreferrer" href="https://gitea.io">{{.i18n.Tr "website"}}</a>
34-
{{if (or .ShowFooterVersion .PageIsAdmin)}}<span class="version">{{GoVer}}</span>{{end}}
35-
</div>
36-
</div>
37-
</footer>
13+
{{template "base/footer_content" .}}
14+
3815
<script src="{{AppSubUrl}}/vendor/plugins/jquery/jquery.min.js"></script>
3916
<script src="{{AppSubUrl}}/vendor/plugins/jquery.areyousure/jquery.are-you-sure.js"></script>
4017
{{if .RequireSimpleMDE}}

templates/base/footer_content.tmpl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<footer>
2+
<div class="ui container">
3+
<div class="ui left">
4+
© Gitea {{if (or .ShowFooterVersion .PageIsAdmin)}}{{.i18n.Tr "version"}}: {{AppVer}}{{end}} {{if ShowFooterTemplateLoadTime}}{{.i18n.Tr "page"}}: <strong>{{LoadTimes .PageStartTime}}</strong> {{.i18n.Tr "template"}}: <strong>{{call .TmplLoadTimes}}</strong>{{end}}
5+
</div>
6+
<div class="ui right links">
7+
{{if .ShowFooterBranding}}
8+
<a target="_blank" rel="noopener noreferrer" href="https://github.com/go-gitea/gitea"><i class="fa fa-github-square"></i><span class="sr-only">GitHub</span></a>
9+
{{end}}
10+
<div class="ui language bottom floating slide up dropdown link item">
11+
<i class="world icon"></i>
12+
<div class="text">{{.LangName}}</div>
13+
<div class="menu">
14+
{{range .AllLangs}}
15+
<a class="item {{if eq $.Lang .Lang}}active selected{{end}}" href="{{if eq $.Lang .Lang}}#{{else}}{{$.Link}}?lang={{.Lang}}{{end}}">{{.Name}}</a>
16+
{{end}}
17+
</div>
18+
</div>
19+
<a href="{{AppSubUrl}}/vendor/librejs.html" data-jslicense="1">JavaScript licenses</a>
20+
{{if .EnableSwagger}}<a href="{{AppSubUrl}}/api/swagger">API</a>{{end}}
21+
<a target="_blank" rel="noopener noreferrer" href="https://gitea.io">{{.i18n.Tr "website"}}</a>
22+
{{if (or .ShowFooterVersion .PageIsAdmin)}}<span class="version">{{GoVer}}</span>{{end}}
23+
</div>
24+
</div>
25+
</footer>

templates/base/head.tmpl

Lines changed: 1 addition & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -142,140 +142,7 @@
142142

143143
{{if not .PageIsInstall}}
144144
<div class="ui top secondary stackable main menu following bar light">
145-
<div class="ui container" id="navbar">
146-
<div class="item brand" style="justify-content: space-between;">
147-
<a href="{{AppSubUrl}}/">
148-
<img class="ui mini image" src="{{AppSubUrl}}/img/gitea-sm.png">
149-
</a>
150-
<div class="ui basic icon button mobile-only" id="navbar-expand-toggle">
151-
<i class="sidebar icon"></i>
152-
</div>
153-
</div>
154-
155-
{{if .IsSigned}}
156-
<a class="item {{if .PageIsDashboard}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "dashboard"}}</a>
157-
<a class="item {{if .PageIsIssues}}active{{end}}" href="{{AppSubUrl}}/issues">{{.i18n.Tr "issues"}}</a>
158-
<a class="item {{if .PageIsPulls}}active{{end}}" href="{{AppSubUrl}}/pulls">{{.i18n.Tr "pull_requests"}}</a>
159-
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "explore"}}</a>
160-
{{else if .IsLandingPageHome}}
161-
<a class="item {{if .PageIsHome}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "home"}}</a>
162-
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "explore"}}</a>
163-
{{else if .IsLandingPageExplore}}
164-
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "home"}}</a>
165-
{{else if .IsLandingPageOrganizations}}
166-
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "home"}}</a>
167-
{{end}}
168-
169-
{{template "custom/extra_links" .}}
170-
171-
{{/*
172-
<div class="item">
173-
<div class="ui icon input">
174-
<input class="searchbox" type="text" placeholder="{{.i18n.Tr "search_project"}}">
175-
<i class="search icon"></i>
176-
</div>
177-
</div>
178-
*/}}
179-
180-
{{if .IsSigned}}
181-
<div class="right stackable menu">
182-
<a href="{{AppSubUrl}}/notifications" class="item poping up" data-content='{{.i18n.Tr "notifications"}}' data-variation="tiny inverted">
183-
<span class="text">
184-
<i class="fitted octicon octicon-bell"></i>
185-
<span class="sr-mobile-only">{{.i18n.Tr "notifications"}}</span>
186-
187-
{{if .NotificationUnreadCount}}
188-
<span class="ui red label">
189-
{{.NotificationUnreadCount}}
190-
</span>
191-
{{end}}
192-
</span>
193-
</a>
194-
195-
<div class="ui dropdown jump item poping up" data-content="{{.i18n.Tr "create_new"}}" data-variation="tiny inverted">
196-
<span class="text">
197-
<i class="fitted octicon octicon-plus"></i>
198-
<span class="sr-mobile-only">{{.i18n.Tr "create_new"}}</span>
199-
<i class="fitted octicon octicon-triangle-down not-mobile"></i>
200-
</span>
201-
<div class="menu">
202-
<a class="item" href="{{AppSubUrl}}/repo/create">
203-
<i class="fitted octicon octicon-plus"></i> {{.i18n.Tr "new_repo"}}
204-
</a>
205-
<a class="item" href="{{AppSubUrl}}/repo/migrate">
206-
<i class="fitted octicon octicon-repo-clone"></i> {{.i18n.Tr "new_migrate"}}
207-
</a>
208-
{{if .SignedUser.CanCreateOrganization}}
209-
<a class="item" href="{{AppSubUrl}}/org/create">
210-
<i class="fitted octicon octicon-organization"></i> {{.i18n.Tr "new_org"}}
211-
</a>
212-
{{end}}
213-
</div><!-- end content create new menu -->
214-
</div><!-- end dropdown menu create new -->
215-
216-
<div class="ui dropdown jump item poping up" tabindex="-1" data-content="{{.i18n.Tr "user_profile_and_more"}}" data-variation="tiny inverted">
217-
<span class="text">
218-
<img class="ui tiny avatar image" src="{{.SignedUser.RelAvatarLink}}">
219-
<span class="sr-only">{{.i18n.Tr "user_profile_and_more"}}</span>
220-
<span class="mobile-only">{{.SignedUser.Name}}</span>
221-
<i class="fitted octicon octicon-triangle-down not-mobile" tabindex="-1"></i>
222-
</span>
223-
<div class="menu" tabindex="-1">
224-
<div class="ui header">
225-
{{.i18n.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
226-
</div>
227-
228-
<div class="divider"></div>
229-
<a class="item" href="{{AppSubUrl}}/{{.SignedUser.Name}}">
230-
<i class="octicon octicon-person"></i>
231-
{{.i18n.Tr "your_profile"}}<!-- Your profile -->
232-
</a>
233-
<a class="item" href="{{AppSubUrl}}/{{.SignedUser.Name}}?tab=stars">
234-
<i class="octicon octicon-star"></i>
235-
{{.i18n.Tr "your_starred"}}
236-
</a>
237-
<a class="{{if .PageIsUserSettings}}active{{end}} item" href="{{AppSubUrl}}/user/settings">
238-
<i class="octicon octicon-settings"></i>
239-
{{.i18n.Tr "your_settings"}}<!-- Your settings -->
240-
</a>
241-
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">
242-
<i class="octicon octicon-question"></i>
243-
{{.i18n.Tr "help"}}<!-- Help -->
244-
</a>
245-
{{if .IsAdmin}}
246-
<div class="divider"></div>
247-
248-
<a class="{{if .PageIsAdmin}}active{{end}} item" href="{{AppSubUrl}}/admin">
249-
<i class="icon settings"></i>
250-
{{.i18n.Tr "admin_panel"}}<!-- Admin Panel -->
251-
</a>
252-
{{end}}
253-
254-
<div class="divider"></div>
255-
<a class="item" href="{{AppSubUrl}}/user/logout">
256-
<i class="octicon octicon-sign-out"></i>
257-
{{.i18n.Tr "sign_out"}}<!-- Sign Out -->
258-
</a>
259-
</div><!-- end content avatar menu -->
260-
</div><!-- end dropdown avatar menu -->
261-
</div><!-- end signed user right menu -->
262-
263-
{{else}}
264-
265-
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.i18n.Tr "help"}}</a>
266-
<div class="right stackable menu">
267-
{{if .ShowRegistrationButton}}
268-
<a class="item{{if .PageIsSignUp}} active{{end}}" href="{{AppSubUrl}}/user/sign_up">
269-
<i class="octicon octicon-person"></i> {{.i18n.Tr "register"}}
270-
</a>
271-
{{end}}
272-
<a class="item{{if .PageIsSignIn}} active{{end}}" href="{{AppSubUrl}}/user/login?redirect_to={{.Link}}">
273-
<i class="octicon octicon-sign-in"></i> {{.i18n.Tr "sign_in"}}
274-
</a>
275-
</div><!-- end anonymous right menu -->
276-
277-
{{end}}
278-
</div><!-- end container -->
145+
{{template "base/head_navbar" .}}
279146
</div><!-- end bar -->
280147
{{end}}
281148
{{/*

templates/base/head_navbar.tmpl

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<div class="ui container" id="navbar">
2+
<div class="item brand" style="justify-content: space-between;">
3+
<a href="{{AppSubUrl}}/">
4+
<img class="ui mini image" src="{{AppSubUrl}}/img/gitea-sm.png">
5+
</a>
6+
<div class="ui basic icon button mobile-only" id="navbar-expand-toggle">
7+
<i class="sidebar icon"></i>
8+
</div>
9+
</div>
10+
11+
{{if .IsSigned}}
12+
<a class="item {{if .PageIsDashboard}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "dashboard"}}</a>
13+
<a class="item {{if .PageIsIssues}}active{{end}}" href="{{AppSubUrl}}/issues">{{.i18n.Tr "issues"}}</a>
14+
<a class="item {{if .PageIsPulls}}active{{end}}" href="{{AppSubUrl}}/pulls">{{.i18n.Tr "pull_requests"}}</a>
15+
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "explore"}}</a>
16+
{{else if .IsLandingPageHome}}
17+
<a class="item {{if .PageIsHome}}active{{end}}" href="{{AppSubUrl}}/">{{.i18n.Tr "home"}}</a>
18+
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "explore"}}</a>
19+
{{else if .IsLandingPageExplore}}
20+
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.i18n.Tr "home"}}</a>
21+
{{else if .IsLandingPageOrganizations}}
22+
<a class="item {{if .PageIsExplore}}active{{end}}" href="{{AppSubUrl}}/explore/organizations">{{.i18n.Tr "home"}}</a>
23+
{{end}}
24+
25+
{{template "custom/extra_links" .}}
26+
27+
{{/*
28+
<div class="item">
29+
<div class="ui icon input">
30+
<input class="searchbox" type="text" placeholder="{{.i18n.Tr "search_project"}}">
31+
<i class="search icon"></i>
32+
</div>
33+
</div>
34+
*/}}
35+
36+
{{if .IsSigned}}
37+
<div class="right stackable menu">
38+
<a href="{{AppSubUrl}}/notifications" class="item poping up" data-content='{{.i18n.Tr "notifications"}}' data-variation="tiny inverted">
39+
<span class="text">
40+
<i class="fitted octicon octicon-bell"></i>
41+
<span class="sr-mobile-only">{{.i18n.Tr "notifications"}}</span>
42+
43+
{{if .NotificationUnreadCount}}
44+
<span class="ui red label">
45+
{{.NotificationUnreadCount}}
46+
</span>
47+
{{end}}
48+
</span>
49+
</a>
50+
51+
<div class="ui dropdown jump item poping up" data-content="{{.i18n.Tr "create_new"}}" data-variation="tiny inverted">
52+
<span class="text">
53+
<i class="fitted octicon octicon-plus"></i>
54+
<span class="sr-mobile-only">{{.i18n.Tr "create_new"}}</span>
55+
<i class="fitted octicon octicon-triangle-down not-mobile"></i>
56+
</span>
57+
<div class="menu">
58+
<a class="item" href="{{AppSubUrl}}/repo/create">
59+
<i class="fitted octicon octicon-plus"></i> {{.i18n.Tr "new_repo"}}
60+
</a>
61+
<a class="item" href="{{AppSubUrl}}/repo/migrate">
62+
<i class="fitted octicon octicon-repo-clone"></i> {{.i18n.Tr "new_migrate"}}
63+
</a>
64+
{{if .SignedUser.CanCreateOrganization}}
65+
<a class="item" href="{{AppSubUrl}}/org/create">
66+
<i class="fitted octicon octicon-organization"></i> {{.i18n.Tr "new_org"}}
67+
</a>
68+
{{end}}
69+
</div><!-- end content create new menu -->
70+
</div><!-- end dropdown menu create new -->
71+
72+
<div class="ui dropdown jump item poping up" tabindex="-1" data-content="{{.i18n.Tr "user_profile_and_more"}}" data-variation="tiny inverted">
73+
<span class="text">
74+
<img class="ui tiny avatar image" src="{{.SignedUser.RelAvatarLink}}">
75+
<span class="sr-only">{{.i18n.Tr "user_profile_and_more"}}</span>
76+
<span class="mobile-only">{{.SignedUser.Name}}</span>
77+
<i class="fitted octicon octicon-triangle-down not-mobile" tabindex="-1"></i>
78+
</span>
79+
<div class="menu" tabindex="-1">
80+
<div class="ui header">
81+
{{.i18n.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
82+
</div>
83+
84+
<div class="divider"></div>
85+
<a class="item" href="{{AppSubUrl}}/{{.SignedUser.Name}}">
86+
<i class="octicon octicon-person"></i>
87+
{{.i18n.Tr "your_profile"}}<!-- Your profile -->
88+
</a>
89+
<a class="item" href="{{AppSubUrl}}/{{.SignedUser.Name}}?tab=stars">
90+
<i class="octicon octicon-star"></i>
91+
{{.i18n.Tr "your_starred"}}
92+
</a>
93+
<a class="{{if .PageIsUserSettings}}active{{end}} item" href="{{AppSubUrl}}/user/settings">
94+
<i class="octicon octicon-settings"></i>
95+
{{.i18n.Tr "your_settings"}}<!-- Your settings -->
96+
</a>
97+
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">
98+
<i class="octicon octicon-question"></i>
99+
{{.i18n.Tr "help"}}<!-- Help -->
100+
</a>
101+
{{if .IsAdmin}}
102+
<div class="divider"></div>
103+
104+
<a class="{{if .PageIsAdmin}}active{{end}} item" href="{{AppSubUrl}}/admin">
105+
<i class="icon settings"></i>
106+
{{.i18n.Tr "admin_panel"}}<!-- Admin Panel -->
107+
</a>
108+
{{end}}
109+
110+
<div class="divider"></div>
111+
<a class="item" href="{{AppSubUrl}}/user/logout">
112+
<i class="octicon octicon-sign-out"></i>
113+
{{.i18n.Tr "sign_out"}}<!-- Sign Out -->
114+
</a>
115+
</div><!-- end content avatar menu -->
116+
</div><!-- end dropdown avatar menu -->
117+
</div><!-- end signed user right menu -->
118+
119+
{{else}}
120+
121+
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.i18n.Tr "help"}}</a>
122+
<div class="right stackable menu">
123+
{{if .ShowRegistrationButton}}
124+
<a class="item{{if .PageIsSignUp}} active{{end}}" href="{{AppSubUrl}}/user/sign_up">
125+
<i class="octicon octicon-person"></i> {{.i18n.Tr "register"}}
126+
</a>
127+
{{end}}
128+
<a class="item{{if .PageIsSignIn}} active{{end}}" href="{{AppSubUrl}}/user/login?redirect_to={{.Link}}">
129+
<i class="octicon octicon-sign-in"></i> {{.i18n.Tr "sign_in"}}
130+
</a>
131+
</div><!-- end anonymous right menu -->
132+
133+
{{end}}
134+
</div>

0 commit comments

Comments
 (0)