##// END OF EJS Templates
js: workaround to avoid <option> tags inside <script>...
Mads Kiilerich -
r5957:5dfe741d default
parent child Browse files
Show More
@@ -1,679 +1,679 b''
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 <%inherit file="root.html"/>
2 <%inherit file="root.html"/>
3
3
4 <!-- CONTENT -->
4 <!-- CONTENT -->
5 <div id="content">
5 <div id="content">
6 ${self.flash_msg()}
6 ${self.flash_msg()}
7 <div id="main">
7 <div id="main">
8 ${next.main()}
8 ${next.main()}
9 </div>
9 </div>
10 </div>
10 </div>
11 <!-- END CONTENT -->
11 <!-- END CONTENT -->
12
12
13 <!-- FOOTER -->
13 <!-- FOOTER -->
14 <div id="footer">
14 <div id="footer">
15 <div id="footer-inner" class="title">
15 <div id="footer-inner" class="title">
16 <div>
16 <div>
17 <p class="footer-link">
17 <p class="footer-link">
18 ${_('Server instance: %s') % c.instance_id if c.instance_id else ''}
18 ${_('Server instance: %s') % c.instance_id if c.instance_id else ''}
19 </p>
19 </p>
20 <p class="footer-link-right">
20 <p class="footer-link-right">
21 This site is powered by
21 This site is powered by
22 %if c.visual.show_version:
22 %if c.visual.show_version:
23 <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a> ${c.kallithea_version},
23 <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a> ${c.kallithea_version},
24 %else:
24 %else:
25 <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a>,
25 <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a>,
26 %endif
26 %endif
27 which is
27 which is
28 <a href="${h.canonical_url('about')}#copyright">&copy; 2010&ndash;2016 by various authors &amp; licensed under GPLv3</a>.
28 <a href="${h.canonical_url('about')}#copyright">&copy; 2010&ndash;2016 by various authors &amp; licensed under GPLv3</a>.
29 %if c.issues_url:
29 %if c.issues_url:
30 &ndash; <a href="${c.issues_url}" target="_blank">${_('Support')}</a>
30 &ndash; <a href="${c.issues_url}" target="_blank">${_('Support')}</a>
31 %endif
31 %endif
32 </p>
32 </p>
33 </div>
33 </div>
34 </div>
34 </div>
35 </div>
35 </div>
36
36
37 <!-- END FOOTER -->
37 <!-- END FOOTER -->
38
38
39 ### MAKO DEFS ###
39 ### MAKO DEFS ###
40
40
41 <%block name="branding_title">
41 <%block name="branding_title">
42 %if c.site_name:
42 %if c.site_name:
43 &middot; ${c.site_name}
43 &middot; ${c.site_name}
44 %endif
44 %endif
45 </%block>
45 </%block>
46
46
47 <%def name="flash_msg()">
47 <%def name="flash_msg()">
48 <%include file="/base/flash_msg.html"/>
48 <%include file="/base/flash_msg.html"/>
49 </%def>
49 </%def>
50
50
51 <%def name="breadcrumbs()">
51 <%def name="breadcrumbs()">
52 <div class="breadcrumbs">
52 <div class="breadcrumbs">
53 ${self.breadcrumbs_links()}
53 ${self.breadcrumbs_links()}
54 </div>
54 </div>
55 </%def>
55 </%def>
56
56
57 <%def name="admin_menu()">
57 <%def name="admin_menu()">
58 <ul class="dropdown-menu" role="menu">
58 <ul class="dropdown-menu" role="menu">
59 <li><a href="${h.url('admin_home')}"><i class="icon-book"></i> ${_('Admin Journal')}</a></li>
59 <li><a href="${h.url('admin_home')}"><i class="icon-book"></i> ${_('Admin Journal')}</a></li>
60 <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li>
60 <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li>
61 <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li>
61 <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li>
62 <li><a href="${h.url('users')}"><i class="icon-user"></i> ${_('Users')}</a></li>
62 <li><a href="${h.url('users')}"><i class="icon-user"></i> ${_('Users')}</a></li>
63 <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li>
63 <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li>
64 <li><a href="${h.url('admin_permissions')}"><i class="icon-block"></i> ${_('Default Permissions')}</a></li>
64 <li><a href="${h.url('admin_permissions')}"><i class="icon-block"></i> ${_('Default Permissions')}</a></li>
65 <li><a href="${h.url('auth_home')}"><i class="icon-key"></i> ${_('Authentication')}</a></li>
65 <li><a href="${h.url('auth_home')}"><i class="icon-key"></i> ${_('Authentication')}</a></li>
66 <li><a href="${h.url('defaults')}"><i class="icon-wrench"></i> ${_('Repository Defaults')}</a></li>
66 <li><a href="${h.url('defaults')}"><i class="icon-wrench"></i> ${_('Repository Defaults')}</a></li>
67 <li class="last"><a href="${h.url('admin_settings')}"><i class="icon-gear"></i> ${_('Settings')}</a></li>
67 <li class="last"><a href="${h.url('admin_settings')}"><i class="icon-gear"></i> ${_('Settings')}</a></li>
68 </ul>
68 </ul>
69
69
70 </%def>
70 </%def>
71
71
72
72
73 ## admin menu used for people that have some admin resources
73 ## admin menu used for people that have some admin resources
74 <%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)">
74 <%def name="admin_menu_simple(repositories=None, repository_groups=None, user_groups=None)">
75 <ul class="dropdown-menu" role="menu">
75 <ul class="dropdown-menu" role="menu">
76 %if repositories:
76 %if repositories:
77 <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li>
77 <li><a href="${h.url('repos')}"><i class="icon-database"></i> ${_('Repositories')}</a></li>
78 %endif
78 %endif
79 %if repository_groups:
79 %if repository_groups:
80 <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li>
80 <li><a href="${h.url('repos_groups')}"><i class="icon-folder"></i> ${_('Repository Groups')}</a></li>
81 %endif
81 %endif
82 %if user_groups:
82 %if user_groups:
83 <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li>
83 <li><a href="${h.url('users_groups')}"><i class="icon-users"></i> ${_('User Groups')}</a></li>
84 %endif
84 %endif
85 </ul>
85 </ul>
86 </%def>
86 </%def>
87
87
88 <%def name="repotag(repo)">
88 <%def name="repotag(repo)">
89 %if h.is_hg(repo):
89 %if h.is_hg(repo):
90 <span class="repotag" title="${_('Mercurial repository')}">hg</span>
90 <span class="repotag" title="${_('Mercurial repository')}">hg</span>
91 %endif
91 %endif
92 %if h.is_git(repo):
92 %if h.is_git(repo):
93 <span class="repotag" title="${_('Git repository')}">git</span>
93 <span class="repotag" title="${_('Git repository')}">git</span>
94 %endif
94 %endif
95 </%def>
95 </%def>
96
96
97 <%def name="repo_context_bar(current=None, rev=None)">
97 <%def name="repo_context_bar(current=None, rev=None)">
98 <% rev = None if rev == 'tip' else rev %>
98 <% rev = None if rev == 'tip' else rev %>
99 <%
99 <%
100 def is_current(selected):
100 def is_current(selected):
101 if selected == current:
101 if selected == current:
102 return h.literal('class="current"')
102 return h.literal('class="current"')
103 %>
103 %>
104
104
105 <!--- CONTEXT BAR -->
105 <!--- CONTEXT BAR -->
106 <div id="context-bar" class="box">
106 <div id="context-bar" class="box">
107 <h2>
107 <h2>
108 ${repotag(c.db_repo)}
108 ${repotag(c.db_repo)}
109
109
110 ## public/private
110 ## public/private
111 %if c.db_repo.private:
111 %if c.db_repo.private:
112 <i class="icon-keyhole-circled"></i>
112 <i class="icon-keyhole-circled"></i>
113 %else:
113 %else:
114 <i class="icon-globe"></i>
114 <i class="icon-globe"></i>
115 %endif
115 %endif
116 ${h.repo_link(c.db_repo.groups_and_repo)}
116 ${h.repo_link(c.db_repo.groups_and_repo)}
117
117
118 %if current == 'createfork':
118 %if current == 'createfork':
119 - ${_('Create Fork')}
119 - ${_('Create Fork')}
120 %endif
120 %endif
121 </h2>
121 </h2>
122 <!--
122 <!--
123 <div id="breadcrumbs">
123 <div id="breadcrumbs">
124 ${h.link_to(_('Repositories'),h.url('home'))}
124 ${h.link_to(_('Repositories'),h.url('home'))}
125 &raquo;
125 &raquo;
126 ${h.repo_link(c.db_repo.groups_and_repo)}
126 ${h.repo_link(c.db_repo.groups_and_repo)}
127 </div>
127 </div>
128 -->
128 -->
129 <ul id="context-pages" class="horizontal-list">
129 <ul id="context-pages" class="horizontal-list">
130 <li ${is_current('summary')} data-context="summary"><a href="${h.url('summary_home', repo_name=c.repo_name)}"><i class="icon-doc-text"></i> ${_('Summary')}</a></li>
130 <li ${is_current('summary')} data-context="summary"><a href="${h.url('summary_home', repo_name=c.repo_name)}"><i class="icon-doc-text"></i> ${_('Summary')}</a></li>
131 %if rev:
131 %if rev:
132 <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_file_home', repo_name=c.repo_name, revision=rev, f_path='')}"><i class="icon-clock"></i> ${_('Changelog')}</a></li>
132 <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_file_home', repo_name=c.repo_name, revision=rev, f_path='')}"><i class="icon-clock"></i> ${_('Changelog')}</a></li>
133 %else:
133 %else:
134 <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_home', repo_name=c.repo_name)}"><i class="icon-clock"></i> ${_('Changelog')}</a></li>
134 <li ${is_current('changelog')} data-context="changelog"><a href="${h.url('changelog_home', repo_name=c.repo_name)}"><i class="icon-clock"></i> ${_('Changelog')}</a></li>
135 %endif
135 %endif
136 <li ${is_current('files')} data-context="files"><a href="${h.url('files_home', repo_name=c.repo_name, revision=rev or 'tip')}"><i class="icon-doc-inv"></i> ${_('Files')}</a></li>
136 <li ${is_current('files')} data-context="files"><a href="${h.url('files_home', repo_name=c.repo_name, revision=rev or 'tip')}"><i class="icon-doc-inv"></i> ${_('Files')}</a></li>
137 <li ${is_current('switch-to')} data-context="switch-to">
137 <li ${is_current('switch-to')} data-context="switch-to">
138 <input id="branch_switcher" name="branch_switcher" type="hidden">
138 <input id="branch_switcher" name="branch_switcher" type="hidden">
139 </li>
139 </li>
140 <li ${is_current('options')} data-context="options">
140 <li ${is_current('options')} data-context="options">
141 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
141 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
142 <a href="${h.url('edit_repo',repo_name=c.repo_name)}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a>
142 <a href="${h.url('edit_repo',repo_name=c.repo_name)}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a>
143 %else:
143 %else:
144 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a>
144 <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"><i class="icon-wrench"></i> ${_('Options')} <i class="caret"></i></a>
145 %endif
145 %endif
146 <ul class="dropdown-menu" role="menu">
146 <ul class="dropdown-menu" role="menu">
147 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
147 %if h.HasRepoPermissionAll('repository.admin')(c.repo_name):
148 <li><a href="${h.url('edit_repo',repo_name=c.repo_name)}"><i class="icon-gear"></i> ${_('Settings')}</a></li>
148 <li><a href="${h.url('edit_repo',repo_name=c.repo_name)}"><i class="icon-gear"></i> ${_('Settings')}</a></li>
149 %endif
149 %endif
150 %if c.db_repo.fork:
150 %if c.db_repo.fork:
151 <li><a href="${h.url('compare_url',repo_name=c.db_repo.fork.repo_name,org_ref_type=c.db_repo.landing_rev[0],org_ref_name=c.db_repo.landing_rev[1], other_repo=c.repo_name,other_ref_type='branch' if request.GET.get('branch') else c.db_repo.landing_rev[0],other_ref_name=request.GET.get('branch') or c.db_repo.landing_rev[1], merge=1)}">
151 <li><a href="${h.url('compare_url',repo_name=c.db_repo.fork.repo_name,org_ref_type=c.db_repo.landing_rev[0],org_ref_name=c.db_repo.landing_rev[1], other_repo=c.repo_name,other_ref_type='branch' if request.GET.get('branch') else c.db_repo.landing_rev[0],other_ref_name=request.GET.get('branch') or c.db_repo.landing_rev[1], merge=1)}">
152 <i class="icon-git-compare"></i> ${_('Compare Fork')}</a></li>
152 <i class="icon-git-compare"></i> ${_('Compare Fork')}</a></li>
153 %endif
153 %endif
154 <li><a href="${h.url('compare_home',repo_name=c.repo_name)}"><i class="icon-git-compare"></i> ${_('Compare')}</a></li>
154 <li><a href="${h.url('compare_home',repo_name=c.repo_name)}"><i class="icon-git-compare"></i> ${_('Compare')}</a></li>
155
155
156 <li><a href="${h.url('search_repo',repo_name=c.repo_name)}"><i class="icon-search"></i> ${_('Search')}</a></li>
156 <li><a href="${h.url('search_repo',repo_name=c.repo_name)}"><i class="icon-search"></i> ${_('Search')}</a></li>
157
157
158 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.db_repo.enable_locking:
158 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.db_repo.enable_locking:
159 %if c.db_repo.locked[0]:
159 %if c.db_repo.locked[0]:
160 <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock"></i> ${_('Unlock')}</a></li>
160 <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock"></i> ${_('Unlock')}</a></li>
161 %else:
161 %else:
162 <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock-open-alt"></i> ${_('Lock')}</li>
162 <li><a href="${h.url('toggle_locking', repo_name=c.repo_name)}"><i class="icon-lock-open-alt"></i> ${_('Lock')}</li>
163 %endif
163 %endif
164 %endif
164 %endif
165 ## TODO: this check feels wrong, it would be better to have a check for permissions
165 ## TODO: this check feels wrong, it would be better to have a check for permissions
166 ## also it feels like a job for the controller
166 ## also it feels like a job for the controller
167 %if c.authuser.username != 'default':
167 %if c.authuser.username != 'default':
168 <li>
168 <li>
169 <a class="${'following' if c.repository_following else 'follow'}" onclick="toggleFollowingRepo(this, ${c.db_repo.repo_id});">
169 <a class="${'following' if c.repository_following else 'follow'}" onclick="toggleFollowingRepo(this, ${c.db_repo.repo_id});">
170 <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span>
170 <span class="show-follow"><i class="icon-heart-empty"></i> ${_('Follow')}</span>
171 <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span>
171 <span class="show-following"><i class="icon-heart"></i> ${_('Unfollow')}</span>
172 </a>
172 </a>
173 </li>
173 </li>
174 <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Fork')}</a></li>
174 <li><a href="${h.url('repo_fork_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Fork')}</a></li>
175 <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Create Pull Request')}</a></li>
175 <li><a href="${h.url('pullrequest_home',repo_name=c.repo_name)}"><i class="icon-git-pull-request"></i> ${_('Create Pull Request')}</a></li>
176 %endif
176 %endif
177 </ul>
177 </ul>
178 </li>
178 </li>
179 <li ${is_current('showpullrequest')} data-context="showpullrequest">
179 <li ${is_current('showpullrequest')} data-context="showpullrequest">
180 <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests for %s') % c.repo_name}"> <i class="icon-git-pull-request"></i> ${_('Pull Requests')}
180 <a href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}" title="${_('Show Pull Requests for %s') % c.repo_name}"> <i class="icon-git-pull-request"></i> ${_('Pull Requests')}
181 %if c.repository_pull_requests:
181 %if c.repository_pull_requests:
182 <span class="badge">${c.repository_pull_requests}</span>
182 <span class="badge">${c.repository_pull_requests}</span>
183 %endif
183 %endif
184 </a>
184 </a>
185 </li>
185 </li>
186 </ul>
186 </ul>
187 </div>
187 </div>
188 <script type="text/javascript">
188 <script type="text/javascript">
189 $(document).ready(function() {
189 $(document).ready(function() {
190 var bcache = {};
190 var bcache = {};
191
191
192 $("#branch_switcher").select2({
192 $("#branch_switcher").select2({
193 placeholder: '<i class="icon-exchange"></i> ${_('Switch To')} <span class="caret"></span>',
193 placeholder: '<i class="icon-exchange"></i> ${_('Switch To')} <span class="caret"></span>',
194 dropdownAutoWidth: true,
194 dropdownAutoWidth: true,
195 sortResults: prefixFirstSort,
195 sortResults: prefixFirstSort,
196 formatResult: function(obj) {
196 formatResult: function(obj) {
197 return obj.text;
197 return obj.text;
198 },
198 },
199 formatSelection: function(obj) {
199 formatSelection: function(obj) {
200 return obj.text;
200 return obj.text;
201 },
201 },
202 formatNoMatches: function(term) {
202 formatNoMatches: function(term) {
203 return "${_('No matches found')}";
203 return "${_('No matches found')}";
204 },
204 },
205 escapeMarkup: function(m) {
205 escapeMarkup: function(m) {
206 // don't escape our custom placeholder
206 // don't escape our custom placeholder
207 if (m.substr(0, 29) == '<i class="icon-exchange"></i>') {
207 if (m.substr(0, 29) == '<i class="icon-exchange"></i>') {
208 return m;
208 return m;
209 }
209 }
210
210
211 return Select2.util.escapeMarkup(m);
211 return Select2.util.escapeMarkup(m);
212 },
212 },
213 containerCssClass: "repo-switcher",
213 containerCssClass: "repo-switcher",
214 dropdownCssClass: "repo-switcher-dropdown",
214 dropdownCssClass: "repo-switcher-dropdown",
215 query: function(query) {
215 query: function(query) {
216 var key = 'cache';
216 var key = 'cache';
217 var cached = bcache[key];
217 var cached = bcache[key];
218 if (cached) {
218 if (cached) {
219 var data = {
219 var data = {
220 results: []
220 results: []
221 };
221 };
222 // filter results
222 // filter results
223 $.each(cached.results, function() {
223 $.each(cached.results, function() {
224 var section = this.text;
224 var section = this.text;
225 var children = [];
225 var children = [];
226 $.each(this.children, function() {
226 $.each(this.children, function() {
227 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
227 if (query.term.length === 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0) {
228 children.push({
228 children.push({
229 'id': this.id,
229 'id': this.id,
230 'text': this.text,
230 'text': this.text,
231 'type': this.type,
231 'type': this.type,
232 'obj': this.obj
232 'obj': this.obj
233 });
233 });
234 }
234 }
235 });
235 });
236 if (children.length !== 0) {
236 if (children.length !== 0) {
237 data.results.push({
237 data.results.push({
238 'text': section,
238 'text': section,
239 'children': children
239 'children': children
240 });
240 });
241 }
241 }
242
242
243 });
243 });
244 query.callback(data);
244 query.callback(data);
245 } else {
245 } else {
246 $.ajax({
246 $.ajax({
247 url: pyroutes.url('repo_refs_data', {
247 url: pyroutes.url('repo_refs_data', {
248 'repo_name': '${c.repo_name}'
248 'repo_name': '${c.repo_name}'
249 }),
249 }),
250 data: {},
250 data: {},
251 dataType: 'json',
251 dataType: 'json',
252 type: 'GET',
252 type: 'GET',
253 success: function(data) {
253 success: function(data) {
254 bcache[key] = data;
254 bcache[key] = data;
255 query.callback(data);
255 query.callback(data);
256 }
256 }
257 });
257 });
258 }
258 }
259 }
259 }
260 });
260 });
261
261
262 $("#branch_switcher").on('select2-selecting', function(e) {
262 $("#branch_switcher").on('select2-selecting', function(e) {
263 e.preventDefault();
263 e.preventDefault();
264 var context = $('#context-bar .current').data('context');
264 var context = $('#context-bar .current').data('context');
265 if (context == 'files') {
265 if (context == 'files') {
266 window.location = pyroutes.url('files_home', {
266 window.location = pyroutes.url('files_home', {
267 'repo_name': REPO_NAME,
267 'repo_name': REPO_NAME,
268 'revision': e.choice.id,
268 'revision': e.choice.id,
269 'f_path': '',
269 'f_path': '',
270 'at': e.choice.text
270 'at': e.choice.text
271 });
271 });
272 } else if (context == 'changelog') {
272 } else if (context == 'changelog') {
273 if (e.choice.type == 'tag' || e.choice.type == 'book') {
273 if (e.choice.type == 'tag' || e.choice.type == 'book') {
274 $("#branch_filter").append($('<option/>').val(e.choice.text));
274 $("#branch_filter").append($('<'+'option/>').val(e.choice.text));
275 }
275 }
276 $("#branch_filter").val(e.choice.text).change();
276 $("#branch_filter").val(e.choice.text).change();
277 } else {
277 } else {
278 window.location = pyroutes.url('changelog_home', {
278 window.location = pyroutes.url('changelog_home', {
279 'repo_name': '${c.repo_name}',
279 'repo_name': '${c.repo_name}',
280 'branch': e.choice.text
280 'branch': e.choice.text
281 });
281 });
282 }
282 }
283 });
283 });
284 });
284 });
285 </script>
285 </script>
286 <!--- END CONTEXT BAR -->
286 <!--- END CONTEXT BAR -->
287 </%def>
287 </%def>
288
288
289 <%def name="menu(current=None)">
289 <%def name="menu(current=None)">
290 <%
290 <%
291 def is_current(selected):
291 def is_current(selected):
292 if selected == current:
292 if selected == current:
293 return h.literal('class="current"')
293 return h.literal('class="current"')
294 %>
294 %>
295
295
296 <ul id="quick" class="horizontal-list">
296 <ul id="quick" class="horizontal-list">
297 <!-- repo switcher -->
297 <!-- repo switcher -->
298 <li ${is_current('repositories')}>
298 <li ${is_current('repositories')}>
299 <input id="repo_switcher" name="repo_switcher" type="hidden">
299 <input id="repo_switcher" name="repo_switcher" type="hidden">
300 </li>
300 </li>
301
301
302 ##ROOT MENU
302 ##ROOT MENU
303 %if c.authuser.username != 'default':
303 %if c.authuser.username != 'default':
304 <li ${is_current('journal')}>
304 <li ${is_current('journal')}>
305 <a class="menu_link" title="${_('Show recent activity')}" href="${h.url('journal')}">
305 <a class="menu_link" title="${_('Show recent activity')}" href="${h.url('journal')}">
306 <i class="icon-book"></i> ${_('Journal')}
306 <i class="icon-book"></i> ${_('Journal')}
307 </a>
307 </a>
308 </li>
308 </li>
309 %else:
309 %else:
310 <li ${is_current('journal')}>
310 <li ${is_current('journal')}>
311 <a class="menu_link" title="${_('Public journal')}" href="${h.url('public_journal')}">
311 <a class="menu_link" title="${_('Public journal')}" href="${h.url('public_journal')}">
312 <i class="icon-book"></i> ${_('Public journal')}
312 <i class="icon-book"></i> ${_('Public journal')}
313 </a>
313 </a>
314 </li>
314 </li>
315 %endif
315 %endif
316 <li ${is_current('gists')} class="dropdown">
316 <li ${is_current('gists')} class="dropdown">
317 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Show public gists')}" href="${h.url('gists')}">
317 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Show public gists')}" href="${h.url('gists')}">
318 <i class="icon-clippy"></i> ${_('Gists')} <span class="caret"></span>
318 <i class="icon-clippy"></i> ${_('Gists')} <span class="caret"></span>
319 </a>
319 </a>
320 <ul class="dropdown-menu" role="menu">
320 <ul class="dropdown-menu" role="menu">
321 <li><a href="${h.url('new_gist', public=1)}"><i class="icon-paste"></i> ${_('Create New Gist')}</a></li>
321 <li><a href="${h.url('new_gist', public=1)}"><i class="icon-paste"></i> ${_('Create New Gist')}</a></li>
322 <li><a href="${h.url('gists')}"><i class="icon-globe"></i> ${_('All Public Gists')}</a></li>
322 <li><a href="${h.url('gists')}"><i class="icon-globe"></i> ${_('All Public Gists')}</a></li>
323 %if c.authuser.username != 'default':
323 %if c.authuser.username != 'default':
324 <li><a href="${h.url('gists', public=1)}"><i class="icon-user"></i> ${_('My Public Gists')}</a></li>
324 <li><a href="${h.url('gists', public=1)}"><i class="icon-user"></i> ${_('My Public Gists')}</a></li>
325 <li><a href="${h.url('gists', private=1)}"><i class="icon-keyhole-circled"></i> ${_('My Private Gists')}</a></li>
325 <li><a href="${h.url('gists', private=1)}"><i class="icon-keyhole-circled"></i> ${_('My Private Gists')}</a></li>
326 %endif
326 %endif
327 </ul>
327 </ul>
328 </li>
328 </li>
329 <li ${is_current('search')}>
329 <li ${is_current('search')}>
330 <a class="menu_link" title="${_('Search in repositories')}" href="${h.url('search')}">
330 <a class="menu_link" title="${_('Search in repositories')}" href="${h.url('search')}">
331 <i class="icon-search"></i> ${_('Search')}
331 <i class="icon-search"></i> ${_('Search')}
332 </a>
332 </a>
333 </li>
333 </li>
334 % if h.HasPermissionAll('hg.admin')('access admin main page'):
334 % if h.HasPermissionAll('hg.admin')('access admin main page'):
335 <li ${is_current('admin')} class="dropdown">
335 <li ${is_current('admin')} class="dropdown">
336 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}" href="${h.url('admin_home')}">
336 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}" href="${h.url('admin_home')}">
337 <i class="icon-gear"></i> ${_('Admin')} <span class="caret"></span>
337 <i class="icon-gear"></i> ${_('Admin')} <span class="caret"></span>
338 </a>
338 </a>
339 ${admin_menu()}
339 ${admin_menu()}
340 </li>
340 </li>
341 % elif c.authuser.repositories_admin or c.authuser.repository_groups_admin or c.authuser.user_groups_admin:
341 % elif c.authuser.repositories_admin or c.authuser.repository_groups_admin or c.authuser.user_groups_admin:
342 <li ${is_current('admin')} class="dropdown">
342 <li ${is_current('admin')} class="dropdown">
343 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}">
343 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" title="${_('Admin')}">
344 <i class="icon-gear"></i> ${_('Admin')}
344 <i class="icon-gear"></i> ${_('Admin')}
345 </a>
345 </a>
346 ${admin_menu_simple(c.authuser.repositories_admin,
346 ${admin_menu_simple(c.authuser.repositories_admin,
347 c.authuser.repository_groups_admin,
347 c.authuser.repository_groups_admin,
348 c.authuser.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())}
348 c.authuser.user_groups_admin or h.HasPermissionAny('hg.usergroup.create.true')())}
349 </li>
349 </li>
350 % endif
350 % endif
351
351
352 <li ${is_current('my_pullrequests')}>
352 <li ${is_current('my_pullrequests')}>
353 <a class="menu_link" title="${_('My Pull Requests')}" href="${h.url('my_pullrequests')}">
353 <a class="menu_link" title="${_('My Pull Requests')}" href="${h.url('my_pullrequests')}">
354 <i class="icon-git-pull-request"></i> ${_('My Pull Requests')}
354 <i class="icon-git-pull-request"></i> ${_('My Pull Requests')}
355 %if c.my_pr_count != 0:
355 %if c.my_pr_count != 0:
356 <span class="badge">${c.my_pr_count}</span>
356 <span class="badge">${c.my_pr_count}</span>
357 %endif
357 %endif
358 </a>
358 </a>
359 </li>
359 </li>
360
360
361 ## USER MENU
361 ## USER MENU
362 <li class="dropdown">
362 <li class="dropdown">
363 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" id="quick_login_link"
363 <a class="menu_link dropdown-toggle" data-toggle="dropdown" role="button" id="quick_login_link"
364 %if c.authuser.username != 'default':
364 %if c.authuser.username != 'default':
365 href="${h.url('notifications')}"
365 href="${h.url('notifications')}"
366 %endif
366 %endif
367 >
367 >
368 ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline")}
368 ${h.gravatar_div(c.authuser.email, size=20, div_class="icon", div_style="display:inline")}
369 %if c.authuser.username != 'default':
369 %if c.authuser.username != 'default':
370 <span class="menu_link_user">${c.authuser.username}</span>
370 <span class="menu_link_user">${c.authuser.username}</span>
371 %if c.unread_notifications != 0:
371 %if c.unread_notifications != 0:
372 <span class="badge">${c.unread_notifications}</span>
372 <span class="badge">${c.unread_notifications}</span>
373 %endif
373 %endif
374 %else:
374 %else:
375 <span>${_('Not Logged In')}</span>
375 <span>${_('Not Logged In')}</span>
376 %endif
376 %endif
377 </a>
377 </a>
378
378
379 <div class="user-menu">
379 <div class="user-menu">
380 <div id="quick_login">
380 <div id="quick_login">
381 %if c.authuser.username == 'default' or c.authuser.user_id is None:
381 %if c.authuser.username == 'default' or c.authuser.user_id is None:
382 <h4>${_('Login to Your Account')}</h4>
382 <h4>${_('Login to Your Account')}</h4>
383 ${h.form(h.url('login_home', came_from=request.path_qs))}
383 ${h.form(h.url('login_home', came_from=request.path_qs))}
384 <div class="form">
384 <div class="form">
385 <div class="fields">
385 <div class="fields">
386 <div class="field">
386 <div class="field">
387 <div class="label">
387 <div class="label">
388 <label for="username">${_('Username')}:</label>
388 <label for="username">${_('Username')}:</label>
389 </div>
389 </div>
390 <div class="input">
390 <div class="input">
391 ${h.text('username',class_='focus')}
391 ${h.text('username',class_='focus')}
392 </div>
392 </div>
393
393
394 </div>
394 </div>
395 <div class="field">
395 <div class="field">
396 <div class="label">
396 <div class="label">
397 <label for="password">${_('Password')}:</label>
397 <label for="password">${_('Password')}:</label>
398 </div>
398 </div>
399 <div class="input">
399 <div class="input">
400 ${h.password('password',class_='focus')}
400 ${h.password('password',class_='focus')}
401 </div>
401 </div>
402
402
403 </div>
403 </div>
404 <div class="buttons">
404 <div class="buttons">
405 <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div>
405 <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div>
406 <div class="register">
406 <div class="register">
407 %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
407 %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')():
408 ${h.link_to(_("Don't have an account ?"),h.url('register'))}
408 ${h.link_to(_("Don't have an account ?"),h.url('register'))}
409 %endif
409 %endif
410 </div>
410 </div>
411 <div class="submit">
411 <div class="submit">
412 ${h.submit('sign_in',_('Log In'),class_="btn btn-mini")}
412 ${h.submit('sign_in',_('Log In'),class_="btn btn-mini")}
413 </div>
413 </div>
414 </div>
414 </div>
415 </div>
415 </div>
416 </div>
416 </div>
417 ${h.end_form()}
417 ${h.end_form()}
418 %else:
418 %else:
419 <div class="links_left">
419 <div class="links_left">
420 ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")}
420 ${h.gravatar_div(c.authuser.email, size=48, div_class="big_gravatar")}
421 <div class="full_name">${c.authuser.full_name_or_username}</div>
421 <div class="full_name">${c.authuser.full_name_or_username}</div>
422 <div class="email">${c.authuser.email}</div>
422 <div class="email">${c.authuser.email}</div>
423 </div>
423 </div>
424 <div class="links_right">
424 <div class="links_right">
425 <ol class="links">
425 <ol class="links">
426 <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li>
426 <li><a href="${h.url('notifications')}">${_('Notifications')}: ${c.unread_notifications}</a></li>
427 <li>${h.link_to(_('My Account'),h.url('my_account'))}</li>
427 <li>${h.link_to(_('My Account'),h.url('my_account'))}</li>
428 %if not c.authuser.is_external_auth:
428 %if not c.authuser.is_external_auth:
429 ## Cannot log out if using external (container) authentication.
429 ## Cannot log out if using external (container) authentication.
430 <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li>
430 <li class="logout">${h.link_to(_('Log Out'), h.url('logout_home'))}</li>
431 %endif
431 %endif
432 </ol>
432 </ol>
433 </div>
433 </div>
434 %endif
434 %endif
435 </div>
435 </div>
436 </div>
436 </div>
437 </li>
437 </li>
438
438
439 <script type="text/javascript">
439 <script type="text/javascript">
440 $(document).ready(function(){
440 $(document).ready(function(){
441 var visual_show_public_icon = "${c.visual.show_public_icon}" == "True";
441 var visual_show_public_icon = "${c.visual.show_public_icon}" == "True";
442 var cache = {}
442 var cache = {}
443 /*format the look of items in the list*/
443 /*format the look of items in the list*/
444 var format = function(state){
444 var format = function(state){
445 if (!state.id){
445 if (!state.id){
446 return state.text; // optgroup
446 return state.text; // optgroup
447 }
447 }
448 var obj_dict = state.obj;
448 var obj_dict = state.obj;
449 var tmpl = '';
449 var tmpl = '';
450
450
451 if(obj_dict && state.type == 'repo'){
451 if(obj_dict && state.type == 'repo'){
452 tmpl += '<span class="repo-icons">';
452 tmpl += '<span class="repo-icons">';
453 if(obj_dict['repo_type'] === 'hg'){
453 if(obj_dict['repo_type'] === 'hg'){
454 tmpl += '<span class="repotag">hg</span> ';
454 tmpl += '<span class="repotag">hg</span> ';
455 }
455 }
456 else if(obj_dict['repo_type'] === 'git'){
456 else if(obj_dict['repo_type'] === 'git'){
457 tmpl += '<span class="repotag">git</span> ';
457 tmpl += '<span class="repotag">git</span> ';
458 }
458 }
459 if(obj_dict['private']){
459 if(obj_dict['private']){
460 tmpl += '<i class="icon-keyhole-circled"></i> ';
460 tmpl += '<i class="icon-keyhole-circled"></i> ';
461 }
461 }
462 else if(visual_show_public_icon){
462 else if(visual_show_public_icon){
463 tmpl += '<i class="icon-globe"></i> ';
463 tmpl += '<i class="icon-globe"></i> ';
464 }
464 }
465 tmpl += '</span>';
465 tmpl += '</span>';
466 }
466 }
467 if(obj_dict && state.type == 'group'){
467 if(obj_dict && state.type == 'group'){
468 tmpl += '<i class="icon-folder"></i> ';
468 tmpl += '<i class="icon-folder"></i> ';
469 }
469 }
470 tmpl += state.text;
470 tmpl += state.text;
471 return tmpl;
471 return tmpl;
472 }
472 }
473
473
474 $("#repo_switcher").select2({
474 $("#repo_switcher").select2({
475 placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>',
475 placeholder: '<i class="icon-database"></i> ${_('Repositories')} <span class="caret"></span>',
476 dropdownAutoWidth: true,
476 dropdownAutoWidth: true,
477 sortResults: prefixFirstSort,
477 sortResults: prefixFirstSort,
478 formatResult: format,
478 formatResult: format,
479 formatSelection: format,
479 formatSelection: format,
480 formatNoMatches: function(term){
480 formatNoMatches: function(term){
481 return "${_('No matches found')}";
481 return "${_('No matches found')}";
482 },
482 },
483 containerCssClass: "repo-switcher",
483 containerCssClass: "repo-switcher",
484 dropdownCssClass: "repo-switcher-dropdown",
484 dropdownCssClass: "repo-switcher-dropdown",
485 escapeMarkup: function(m){
485 escapeMarkup: function(m){
486 // don't escape our custom placeholder
486 // don't escape our custom placeholder
487 if(m.substr(0,29) == '<i class="icon-database"></i>'){
487 if(m.substr(0,29) == '<i class="icon-database"></i>'){
488 return m;
488 return m;
489 }
489 }
490
490
491 return Select2.util.escapeMarkup(m);
491 return Select2.util.escapeMarkup(m);
492 },
492 },
493 query: function(query){
493 query: function(query){
494 var key = 'cache';
494 var key = 'cache';
495 var cached = cache[key] ;
495 var cached = cache[key] ;
496 if(cached) {
496 if(cached) {
497 var data = {results: []};
497 var data = {results: []};
498 //filter results
498 //filter results
499 $.each(cached.results, function(){
499 $.each(cached.results, function(){
500 var section = this.text;
500 var section = this.text;
501 var children = [];
501 var children = [];
502 $.each(this.children, function(){
502 $.each(this.children, function(){
503 if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
503 if(query.term.length == 0 || this.text.toUpperCase().indexOf(query.term.toUpperCase()) >= 0 ){
504 children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj});
504 children.push({'id': this.id, 'text': this.text, 'type': this.type, 'obj': this.obj});
505 }
505 }
506 });
506 });
507 if(children.length !== 0){
507 if(children.length !== 0){
508 data.results.push({'text': section, 'children': children});
508 data.results.push({'text': section, 'children': children});
509 }
509 }
510
510
511 });
511 });
512 query.callback(data);
512 query.callback(data);
513 }else{
513 }else{
514 $.ajax({
514 $.ajax({
515 url: "${h.url('repo_switcher_data')}",
515 url: "${h.url('repo_switcher_data')}",
516 data: {},
516 data: {},
517 dataType: 'json',
517 dataType: 'json',
518 type: 'GET',
518 type: 'GET',
519 success: function(data) {
519 success: function(data) {
520 cache[key] = data;
520 cache[key] = data;
521 query.callback({results: data.results});
521 query.callback({results: data.results});
522 }
522 }
523 });
523 });
524 }
524 }
525 }
525 }
526 });
526 });
527
527
528 $("#repo_switcher").on('select2-selecting', function(e){
528 $("#repo_switcher").on('select2-selecting', function(e){
529 e.preventDefault();
529 e.preventDefault();
530 window.location = pyroutes.url('summary_home', {'repo_name': e.val});
530 window.location = pyroutes.url('summary_home', {'repo_name': e.val});
531 });
531 });
532 });
532 });
533
533
534 ## Global mouse bindings ##
534 ## Global mouse bindings ##
535
535
536 // general help "?"
536 // general help "?"
537 Mousetrap.bind(['?'], function(e) {
537 Mousetrap.bind(['?'], function(e) {
538 $('#help_kb').modal({});
538 $('#help_kb').modal({});
539 });
539 });
540
540
541 // / open the quick filter
541 // / open the quick filter
542 Mousetrap.bind(['/'], function(e) {
542 Mousetrap.bind(['/'], function(e) {
543 $("#repo_switcher").select2("open");
543 $("#repo_switcher").select2("open");
544
544
545 // return false to prevent default browser behavior
545 // return false to prevent default browser behavior
546 // and stop event from bubbling
546 // and stop event from bubbling
547 return false;
547 return false;
548 });
548 });
549
549
550 // ctrl/command+b, show the the main bar
550 // ctrl/command+b, show the the main bar
551 Mousetrap.bind(['command+b', 'ctrl+b'], function(e) {
551 Mousetrap.bind(['command+b', 'ctrl+b'], function(e) {
552 if($('#header-inner').hasClass('hover') && $('#content').hasClass('hover')){
552 if($('#header-inner').hasClass('hover') && $('#content').hasClass('hover')){
553 $('#header-inner').removeClass('hover');
553 $('#header-inner').removeClass('hover');
554 $('#content').removeClass('hover');
554 $('#content').removeClass('hover');
555 }
555 }
556 else{
556 else{
557 $('#header-inner').addClass('hover');
557 $('#header-inner').addClass('hover');
558 $('#content').addClass('hover');
558 $('#content').addClass('hover');
559 }
559 }
560 return false;
560 return false;
561 });
561 });
562
562
563 // general nav g + action
563 // general nav g + action
564 Mousetrap.bind(['g h'], function(e) {
564 Mousetrap.bind(['g h'], function(e) {
565 window.location = pyroutes.url('home');
565 window.location = pyroutes.url('home');
566 });
566 });
567 Mousetrap.bind(['g g'], function(e) {
567 Mousetrap.bind(['g g'], function(e) {
568 window.location = pyroutes.url('gists', {'private':1});
568 window.location = pyroutes.url('gists', {'private':1});
569 });
569 });
570 Mousetrap.bind(['g G'], function(e) {
570 Mousetrap.bind(['g G'], function(e) {
571 window.location = pyroutes.url('gists', {'public':1});
571 window.location = pyroutes.url('gists', {'public':1});
572 });
572 });
573 Mousetrap.bind(['n g'], function(e) {
573 Mousetrap.bind(['n g'], function(e) {
574 window.location = pyroutes.url('new_gist');
574 window.location = pyroutes.url('new_gist');
575 });
575 });
576 Mousetrap.bind(['n r'], function(e) {
576 Mousetrap.bind(['n r'], function(e) {
577 window.location = pyroutes.url('new_repo');
577 window.location = pyroutes.url('new_repo');
578 });
578 });
579
579
580 % if hasattr(c, 'repo_name') and hasattr(c, 'db_repo'):
580 % if hasattr(c, 'repo_name') and hasattr(c, 'db_repo'):
581 // nav in repo context
581 // nav in repo context
582 Mousetrap.bind(['g s'], function(e) {
582 Mousetrap.bind(['g s'], function(e) {
583 window.location = pyroutes.url('summary_home', {'repo_name': REPO_NAME});
583 window.location = pyroutes.url('summary_home', {'repo_name': REPO_NAME});
584 });
584 });
585 Mousetrap.bind(['g c'], function(e) {
585 Mousetrap.bind(['g c'], function(e) {
586 window.location = pyroutes.url('changelog_home', {'repo_name': REPO_NAME});
586 window.location = pyroutes.url('changelog_home', {'repo_name': REPO_NAME});
587 });
587 });
588 Mousetrap.bind(['g F'], function(e) {
588 Mousetrap.bind(['g F'], function(e) {
589 window.location = pyroutes.url('files_home', {'repo_name': REPO_NAME, 'revision': '${c.db_repo.landing_rev[1]}', 'f_path': '', 'search': '1'});
589 window.location = pyroutes.url('files_home', {'repo_name': REPO_NAME, 'revision': '${c.db_repo.landing_rev[1]}', 'f_path': '', 'search': '1'});
590 });
590 });
591 Mousetrap.bind(['g f'], function(e) {
591 Mousetrap.bind(['g f'], function(e) {
592 window.location = pyroutes.url('files_home', {'repo_name': REPO_NAME, 'revision': '${c.db_repo.landing_rev[1]}', 'f_path': ''});
592 window.location = pyroutes.url('files_home', {'repo_name': REPO_NAME, 'revision': '${c.db_repo.landing_rev[1]}', 'f_path': ''});
593 });
593 });
594 Mousetrap.bind(['g o'], function(e) {
594 Mousetrap.bind(['g o'], function(e) {
595 window.location = pyroutes.url('edit_repo', {'repo_name': REPO_NAME});
595 window.location = pyroutes.url('edit_repo', {'repo_name': REPO_NAME});
596 });
596 });
597 Mousetrap.bind(['g O'], function(e) {
597 Mousetrap.bind(['g O'], function(e) {
598 window.location = pyroutes.url('edit_repo_perms', {'repo_name': REPO_NAME});
598 window.location = pyroutes.url('edit_repo_perms', {'repo_name': REPO_NAME});
599 });
599 });
600 % endif
600 % endif
601
601
602 </script>
602 </script>
603 </%def>
603 </%def>
604
604
605 %if 0:
605 %if 0:
606 <div class="modal" id="help_kb" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
606 <div class="modal" id="help_kb" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
607 <div class="modal-dialog">
607 <div class="modal-dialog">
608 <div class="modal-content">
608 <div class="modal-content">
609 <div class="modal-header">
609 <div class="modal-header">
610 <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon-cancel-circled"></i></button>
610 <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="icon-cancel-circled"></i></button>
611 <h4 class="modal-title">${_('Keyboard shortcuts')}</h4>
611 <h4 class="modal-title">${_('Keyboard shortcuts')}</h4>
612 </div>
612 </div>
613 <div class="modal-body">
613 <div class="modal-body">
614 <div class="row">
614 <div class="row">
615 <div class="col-md-5">
615 <div class="col-md-5">
616 <table class="keyboard-mappings">
616 <table class="keyboard-mappings">
617 <tbody>
617 <tbody>
618 <tr>
618 <tr>
619 <th></th>
619 <th></th>
620 <th>${_('Site-wide shortcuts')}</th>
620 <th>${_('Site-wide shortcuts')}</th>
621 </tr>
621 </tr>
622 <%
622 <%
623 elems = [
623 elems = [
624 ('/', 'Open quick search box'),
624 ('/', 'Open quick search box'),
625 ('ctrl/cmd+b', 'Show main settings bar'),
625 ('ctrl/cmd+b', 'Show main settings bar'),
626 ('g h', 'Goto home page'),
626 ('g h', 'Goto home page'),
627 ('g g', 'Goto my private gists page'),
627 ('g g', 'Goto my private gists page'),
628 ('g G', 'Goto my public gists page'),
628 ('g G', 'Goto my public gists page'),
629 ('n r', 'New repository page'),
629 ('n r', 'New repository page'),
630 ('n g', 'New gist page'),
630 ('n g', 'New gist page'),
631 ]
631 ]
632 %>
632 %>
633 %for key, desc in elems:
633 %for key, desc in elems:
634 <tr>
634 <tr>
635 <td class="keys">
635 <td class="keys">
636 <span class="key">${key}</span>
636 <span class="key">${key}</span>
637 </td>
637 </td>
638 <td>${desc}</td>
638 <td>${desc}</td>
639 </tr>
639 </tr>
640 %endfor
640 %endfor
641 </tbody>
641 </tbody>
642 </table>
642 </table>
643 </div>
643 </div>
644 <div class="col-md-offset-5">
644 <div class="col-md-offset-5">
645 <table class="keyboard-mappings">
645 <table class="keyboard-mappings">
646 <tbody>
646 <tbody>
647 <tr>
647 <tr>
648 <th></th>
648 <th></th>
649 <th>${_('Repositories')}</th>
649 <th>${_('Repositories')}</th>
650 </tr>
650 </tr>
651 <%
651 <%
652 elems = [
652 elems = [
653 ('g s', 'Goto summary page'),
653 ('g s', 'Goto summary page'),
654 ('g c', 'Goto changelog page'),
654 ('g c', 'Goto changelog page'),
655 ('g f', 'Goto files page'),
655 ('g f', 'Goto files page'),
656 ('g F', 'Goto files page with file search activated'),
656 ('g F', 'Goto files page with file search activated'),
657 ('g o', 'Goto repository settings'),
657 ('g o', 'Goto repository settings'),
658 ('g O', 'Goto repository permissions settings'),
658 ('g O', 'Goto repository permissions settings'),
659 ]
659 ]
660 %>
660 %>
661 %for key, desc in elems:
661 %for key, desc in elems:
662 <tr>
662 <tr>
663 <td class="keys">
663 <td class="keys">
664 <span class="key">${key}</span>
664 <span class="key">${key}</span>
665 </td>
665 </td>
666 <td>${desc}</td>
666 <td>${desc}</td>
667 </tr>
667 </tr>
668 %endfor
668 %endfor
669 </tbody>
669 </tbody>
670 </table>
670 </table>
671 </div>
671 </div>
672 </div>
672 </div>
673 </div>
673 </div>
674 <div class="modal-footer">
674 <div class="modal-footer">
675 </div>
675 </div>
676 </div><!-- /.modal-content -->
676 </div><!-- /.modal-content -->
677 </div><!-- /.modal-dialog -->
677 </div><!-- /.modal-dialog -->
678 </div><!-- /.modal -->
678 </div><!-- /.modal -->
679 %endif
679 %endif
@@ -1,232 +1,232 b''
1 <%inherit file="/base/base.html"/>
1 <%inherit file="/base/base.html"/>
2
2
3 <%block name="title">
3 <%block name="title">
4 ${c.repo_name} ${_('New Pull Request')}
4 ${c.repo_name} ${_('New Pull Request')}
5 </%block>
5 </%block>
6
6
7 <%def name="breadcrumbs_links()">
7 <%def name="breadcrumbs_links()">
8 ${_('New Pull Request')}
8 ${_('New Pull Request')}
9 </%def>
9 </%def>
10
10
11 <%block name="header_menu">
11 <%block name="header_menu">
12 ${self.menu('repositories')}
12 ${self.menu('repositories')}
13 </%block>
13 </%block>
14
14
15 <%def name="main()">
15 <%def name="main()">
16 ${self.repo_context_bar('showpullrequest')}
16 ${self.repo_context_bar('showpullrequest')}
17 <div class="box">
17 <div class="box">
18 <!-- box / title -->
18 <!-- box / title -->
19 <div class="title">
19 <div class="title">
20 ${self.breadcrumbs()}
20 ${self.breadcrumbs()}
21 </div>
21 </div>
22
22
23 ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')}
23 ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')}
24 <div class="form">
24 <div class="form">
25 <!-- fields -->
25 <!-- fields -->
26
26
27 <div class="fields" style="float:left;width:50%;padding-right:30px;">
27 <div class="fields" style="float:left;width:50%;padding-right:30px;">
28
28
29 <div class="field">
29 <div class="field">
30 <div class="label">
30 <div class="label">
31 <label for="pullrequest_title">${_('Title')}:</label>
31 <label for="pullrequest_title">${_('Title')}:</label>
32 </div>
32 </div>
33 <div class="input">
33 <div class="input">
34 ${h.text('pullrequest_title',class_="large",placeholder=_('Summarize the changes - or leave empty'))}
34 ${h.text('pullrequest_title',class_="large",placeholder=_('Summarize the changes - or leave empty'))}
35 </div>
35 </div>
36 </div>
36 </div>
37
37
38 <div class="field">
38 <div class="field">
39 <div class="label label-textarea">
39 <div class="label label-textarea">
40 <label for="pullrequest_desc">${_('Description')}:</label>
40 <label for="pullrequest_desc">${_('Description')}:</label>
41 </div>
41 </div>
42 <div class="textarea text-area editor">
42 <div class="textarea text-area editor">
43 ${h.textarea('pullrequest_desc',size=30,placeholder=_('Write a short description on this pull request'))}
43 ${h.textarea('pullrequest_desc',size=30,placeholder=_('Write a short description on this pull request'))}
44 </div>
44 </div>
45 </div>
45 </div>
46
46
47 <div class="field">
47 <div class="field">
48 <div class="label label-textarea">
48 <div class="label label-textarea">
49 <label for="pullrequest_desc">${_('Changeset flow')}:</label>
49 <label for="pullrequest_desc">${_('Changeset flow')}:</label>
50 </div>
50 </div>
51 <div class="input">
51 <div class="input">
52 ##ORG
52 ##ORG
53 <div>
53 <div>
54 <div>
54 <div>
55 <div style="padding:5px 3px 3px 3px;">
55 <div style="padding:5px 3px 3px 3px;">
56 <b>${_('Origin repository')}:</b> <span id="org_repo_desc">${c.db_repo.description.split('\n')[0]}</span>
56 <b>${_('Origin repository')}:</b> <span id="org_repo_desc">${c.db_repo.description.split('\n')[0]}</span>
57 </div>
57 </div>
58 <div>
58 <div>
59 ${h.select('org_repo','',c.cs_repos,class_='refs')}:${h.select('org_ref',c.default_cs_ref,c.cs_refs,class_='refs')}
59 ${h.select('org_repo','',c.cs_repos,class_='refs')}:${h.select('org_ref',c.default_cs_ref,c.cs_refs,class_='refs')}
60 </div>
60 </div>
61 <div style="padding:5px 3px 3px 3px;">
61 <div style="padding:5px 3px 3px 3px;">
62 <b>${_('Revision')}:</b> <span id="org_rev_span">-</span>
62 <b>${_('Revision')}:</b> <span id="org_rev_span">-</span>
63 </div>
63 </div>
64 </div>
64 </div>
65 </div>
65 </div>
66
66
67 ##OTHER, most Probably the PARENT OF THIS FORK
67 ##OTHER, most Probably the PARENT OF THIS FORK
68 <div style="border-top: 1px solid #EEE; margin: 5px 0px 0px 0px">
68 <div style="border-top: 1px solid #EEE; margin: 5px 0px 0px 0px">
69 <div>
69 <div>
70 ## filled with JS
70 ## filled with JS
71 <div style="padding:5px 3px 3px 3px;">
71 <div style="padding:5px 3px 3px 3px;">
72 <b>${_('Destination repository')}:</b> <span id="other_repo_desc">${c.a_repo.description.split('\n')[0]}</span>
72 <b>${_('Destination repository')}:</b> <span id="other_repo_desc">${c.a_repo.description.split('\n')[0]}</span>
73 </div>
73 </div>
74 <div>
74 <div>
75 ${h.select('other_repo',c.a_repo.repo_name,c.a_repos,class_='refs')}:${h.select('other_ref',c.default_a_ref,c.a_refs,class_='refs')}
75 ${h.select('other_repo',c.a_repo.repo_name,c.a_repos,class_='refs')}:${h.select('other_ref',c.default_a_ref,c.a_refs,class_='refs')}
76 </div>
76 </div>
77 <div style="padding:5px 3px 3px 3px;">
77 <div style="padding:5px 3px 3px 3px;">
78 <b>${_('Revision')}:</b> <span id="other_rev_span">-</span>
78 <b>${_('Revision')}:</b> <span id="other_rev_span">-</span>
79 </div>
79 </div>
80 </div>
80 </div>
81 </div>
81 </div>
82 <div style="clear:both"></div>
82 <div style="clear:both"></div>
83 </div>
83 </div>
84 </div>
84 </div>
85
85
86 <div class="field">
86 <div class="field">
87 <div class="buttons">
87 <div class="buttons">
88 ${h.submit('save',_('Create Pull Request'),class_="btn")}
88 ${h.submit('save',_('Create Pull Request'),class_="btn")}
89 ${h.reset('reset',_('Reset'),class_="btn")}
89 ${h.reset('reset',_('Reset'),class_="btn")}
90 </div>
90 </div>
91 </div>
91 </div>
92
92
93 </div>
93 </div>
94
94
95 <div style="clear:both;padding: 0 0 30px 0;"></div>
95 <div style="clear:both;padding: 0 0 30px 0;"></div>
96
96
97 <h4>${_('Changesets')}</h4>
97 <h4>${_('Changesets')}</h4>
98 <div style="float:left;padding:0px 30px 30px 30px">
98 <div style="float:left;padding:0px 30px 30px 30px">
99 ## overview pulled by ajax
99 ## overview pulled by ajax
100 <div style="float:left" id="pull_request_overview"></div>
100 <div style="float:left" id="pull_request_overview"></div>
101 </div>
101 </div>
102 <div style="clear:both;"></div>
102 <div style="clear:both;"></div>
103
103
104 </div>
104 </div>
105
105
106 ${h.end_form()}
106 ${h.end_form()}
107
107
108 </div>
108 </div>
109
109
110 <script type="text/javascript" src="${h.url('/js/graph.js', ver=c.kallithea_version)}"></script>
110 <script type="text/javascript" src="${h.url('/js/graph.js', ver=c.kallithea_version)}"></script>
111 <script type="text/javascript">
111 <script type="text/javascript">
112 pyroutes.register('pullrequest_repo_info', "${url('pullrequest_repo_info',repo_name='%(repo_name)s')}", ['repo_name']);
112 pyroutes.register('pullrequest_repo_info', "${url('pullrequest_repo_info',repo_name='%(repo_name)s')}", ['repo_name']);
113
113
114 var pendingajax = undefined;
114 var pendingajax = undefined;
115 var otherrepoChanged = function(){
115 var otherrepoChanged = function(){
116 var $other_ref = $('#other_ref');
116 var $other_ref = $('#other_ref');
117 $other_ref.prop('disabled', true);
117 $other_ref.prop('disabled', true);
118 var repo_name = $('#other_repo').val();
118 var repo_name = $('#other_repo').val();
119 if (pendingajax) {
119 if (pendingajax) {
120 pendingajax.abort();
120 pendingajax.abort();
121 pendingajax = undefined;
121 pendingajax = undefined;
122 }
122 }
123 pendingajax = ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}),
123 pendingajax = ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}),
124 function(data){
124 function(data){
125 pendingajax = undefined;
125 pendingajax = undefined;
126 $('#other_repo_desc').html(data.description);
126 $('#other_repo_desc').html(data.description);
127
127
128 // replace options of other_ref with the ones for the current other_repo
128 // replace options of other_ref with the ones for the current other_repo
129 $other_ref.empty();
129 $other_ref.empty();
130 for(var i = 0; i < data.refs.length; i++)
130 for(var i = 0; i < data.refs.length; i++)
131 {
131 {
132 var $optgroup = $('<optgroup/>').prop('label', data.refs[i][1]);
132 var $optgroup = $('<optgroup/>').prop('label', data.refs[i][1]);
133 var options = data.refs[i][0];
133 var options = data.refs[i][0];
134 var length = options.length;
134 var length = options.length;
135 for(var j = 0; j < length; j++)
135 for(var j = 0; j < length; j++)
136 {
136 {
137 $optgroup.append($('<option/>').text(options[j][1]).val(options[j][0]));
137 $optgroup.append($('<'+'option/>').text(options[j][1]).val(options[j][0]));
138 }
138 }
139 $other_ref.append($optgroup);
139 $other_ref.append($optgroup);
140 }
140 }
141 $other_ref.val(data.selected_ref);
141 $other_ref.val(data.selected_ref);
142
142
143 // re-populate the select2 thingy
143 // re-populate the select2 thingy
144 $("#other_ref").select2({
144 $("#other_ref").select2({
145 dropdownAutoWidth: true
145 dropdownAutoWidth: true
146 });
146 });
147
147
148 $other_ref.prop('disabled', false);
148 $other_ref.prop('disabled', false);
149 loadPreview();
149 loadPreview();
150 });
150 });
151 };
151 };
152
152
153 var loadPreview = function(){
153 var loadPreview = function(){
154 //url template
154 //url template
155 var url = "${h.url('compare_url',
155 var url = "${h.url('compare_url',
156 repo_name='__other_repo__',
156 repo_name='__other_repo__',
157 org_ref_type='rev',
157 org_ref_type='rev',
158 org_ref_name='__other_ref_name__',
158 org_ref_name='__other_ref_name__',
159 other_repo='__org_repo__',
159 other_repo='__org_repo__',
160 other_ref_type='rev',
160 other_ref_type='rev',
161 other_ref_name='__org_ref_name__',
161 other_ref_name='__org_ref_name__',
162 as_form=True,
162 as_form=True,
163 merge=True,
163 merge=True,
164 )}";
164 )}";
165 var org_repo = $('#pull_request_form #org_repo').val();
165 var org_repo = $('#pull_request_form #org_repo').val();
166 var org_ref = $('#pull_request_form #org_ref').val().split(':');
166 var org_ref = $('#pull_request_form #org_ref').val().split(':');
167 ## TODO: make nice link like link_to_ref() do
167 ## TODO: make nice link like link_to_ref() do
168 $('#org_rev_span').html(org_ref[2].substr(0,12));
168 $('#org_rev_span').html(org_ref[2].substr(0,12));
169
169
170 var other_repo = $('#pull_request_form #other_repo').val();
170 var other_repo = $('#pull_request_form #other_repo').val();
171 var other_ref = $('#pull_request_form #other_ref').val().split(':');
171 var other_ref = $('#pull_request_form #other_ref').val().split(':');
172 $('#other_rev_span').html(other_ref[2].substr(0,12));
172 $('#other_rev_span').html(other_ref[2].substr(0,12));
173
173
174 var rev_data = {
174 var rev_data = {
175 '__org_repo__': org_repo,
175 '__org_repo__': org_repo,
176 '__org_ref_name__': org_ref[2],
176 '__org_ref_name__': org_ref[2],
177 '__other_repo__': other_repo,
177 '__other_repo__': other_repo,
178 '__other_ref_name__': other_ref[2]
178 '__other_ref_name__': other_ref[2]
179 }; // gather the org/other ref and repo here
179 }; // gather the org/other ref and repo here
180
180
181 for (k in rev_data){
181 for (k in rev_data){
182 url = url.replace(k,rev_data[k]);
182 url = url.replace(k,rev_data[k]);
183 }
183 }
184
184
185 if (pendingajax) {
185 if (pendingajax) {
186 pendingajax.abort();
186 pendingajax.abort();
187 pendingajax = undefined;
187 pendingajax = undefined;
188 }
188 }
189 pendingajax = asynchtml(url, $('#pull_request_overview'), function(o){
189 pendingajax = asynchtml(url, $('#pull_request_overview'), function(o){
190 pendingajax = undefined;
190 pendingajax = undefined;
191 var jsdata = eval('('+$('#jsdata').html()+')'); // TODO: just get json
191 var jsdata = eval('('+$('#jsdata').html()+')'); // TODO: just get json
192 var r = new BranchRenderer('graph_canvas', 'graph_content_pr', 'chg_');
192 var r = new BranchRenderer('graph_canvas', 'graph_content_pr', 'chg_');
193 r.render(jsdata,100);
193 r.render(jsdata,100);
194 });
194 });
195 }
195 }
196
196
197 $(document).ready(function(){
197 $(document).ready(function(){
198 $("#org_repo").select2({
198 $("#org_repo").select2({
199 dropdownAutoWidth: true
199 dropdownAutoWidth: true
200 });
200 });
201 ## (org_repo can't change)
201 ## (org_repo can't change)
202
202
203 $("#org_ref").select2({
203 $("#org_ref").select2({
204 dropdownAutoWidth: true,
204 dropdownAutoWidth: true,
205 sortResults: branchSort
205 sortResults: branchSort
206 });
206 });
207 $("#org_ref").on("change", function(e){
207 $("#org_ref").on("change", function(e){
208 loadPreview();
208 loadPreview();
209 });
209 });
210
210
211 $("#other_repo").select2({
211 $("#other_repo").select2({
212 dropdownAutoWidth: true
212 dropdownAutoWidth: true
213 });
213 });
214 $("#other_repo").on("change", function(e){
214 $("#other_repo").on("change", function(e){
215 otherrepoChanged();
215 otherrepoChanged();
216 });
216 });
217
217
218 $("#other_ref").select2({
218 $("#other_ref").select2({
219 dropdownAutoWidth: true,
219 dropdownAutoWidth: true,
220 sortResults: branchSort
220 sortResults: branchSort
221 });
221 });
222 $("#other_ref").on("change", function(e){
222 $("#other_ref").on("change", function(e){
223 loadPreview();
223 loadPreview();
224 });
224 });
225
225
226 //lazy load overview after 0.5s
226 //lazy load overview after 0.5s
227 setTimeout(loadPreview, 500);
227 setTimeout(loadPreview, 500);
228 });
228 });
229
229
230 </script>
230 </script>
231
231
232 </%def>
232 </%def>
General Comments 0
You need to be logged in to leave comments. Login now