##// END OF EJS Templates
templates: use string content when possible
super-admin -
r5044:4c5924a0 default
parent child Browse files
Show More
@@ -1,112 +1,112 b''
1 <%inherit file="/base/base.mako"/>
1 <%inherit file="/base/base.mako"/>
2 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
2 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
3
3
4 <%def name="robots()">
4 <%def name="robots()">
5 %if c.gist.gist_type != 'public':
5 %if c.gist.gist_type != 'public':
6 <meta name="robots" content="noindex, nofollow">
6 <meta name="robots" content="noindex, nofollow">
7 %else:
7 %else:
8 ${parent.robots()}
8 ${parent.robots()}
9 %endif
9 %endif
10 </%def>
10 </%def>
11
11
12 <%def name="title()">
12 <%def name="title()">
13 ${_('Gist')} &middot; ${c.gist.gist_access_id}
13 ${_('Gist')} &middot; ${c.gist.gist_access_id}
14 %if c.rhodecode_name:
14 %if c.rhodecode_name:
15 &middot; ${h.branding(c.rhodecode_name)}
15 &middot; ${h.branding(c.rhodecode_name)}
16 %endif
16 %endif
17 </%def>
17 </%def>
18
18
19 <%def name="breadcrumbs_links()">
19 <%def name="breadcrumbs_links()">
20 ${_('Gist')} &middot; ${c.gist.gist_access_id}
20 ${_('Gist')} &middot; ${c.gist.gist_access_id}
21 </%def>
21 </%def>
22
22
23 <%def name="menu_bar_nav()">
23 <%def name="menu_bar_nav()">
24 ${self.menu_items(active='gists')}
24 ${self.menu_items(active='gists')}
25 </%def>
25 </%def>
26
26
27 <%def name="main()">
27 <%def name="main()">
28 <div class="box">
28 <div class="box">
29 <!-- box / title -->
29 <!-- box / title -->
30
30
31 <div class="table">
31 <div class="table">
32 <div id="files_data">
32 <div id="files_data">
33 <div id="codeblock" class="codeblock">
33 <div id="codeblock" class="codeblock">
34 <div class="code-header">
34 <div class="code-header">
35 <div class="gist_url">
35 <div class="gist_url">
36 <div class="pull-left">
36 <div class="pull-left">
37 <code>
37 <code>
38 ${dt.gist_type(c.gist.gist_type)}
38 ${dt.gist_type(c.gist.gist_type)}
39 <span class="tag disabled">${c.gist.gist_access_id}</span>
39 <span class="tag disabled">${c.gist.gist_access_id}</span>
40 ${c.gist.gist_url()} <span class="icon-clipboard clipboard-action" data-clipboard-text="${c.gist.gist_url()}" title="${_('Copy the url')}"></span>
40 ${c.gist.gist_url()} <span class="icon-clipboard clipboard-action" data-clipboard-text="${c.gist.gist_url()}" title="${_('Copy the url')}"></span>
41 </code>
41 </code>
42 </div>
42 </div>
43
43
44 <div class="pull-right buttons">
44 <div class="pull-right buttons">
45 ## only owner should see that
45 ## only owner should see that
46 <a href="#copySource" onclick="return false;" class="btn btn-mini icon-clipboard no-grey clipboard-action" data-clipboard-text="${c.files[0].content}">${_('Copy content')}</a>
46 <a href="#copySource" onclick="return false;" class="btn btn-mini icon-clipboard no-grey clipboard-action" data-clipboard-text="${c.files[0].content}">${_('Copy content')}</a>
47
47
48 %if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id:
48 %if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id:
49 ${h.link_to(_('Edit'), h.route_path('gist_edit', gist_id=c.gist.gist_access_id), class_="btn btn-mini")}
49 ${h.link_to(_('Edit'), h.route_path('gist_edit', gist_id=c.gist.gist_access_id), class_="btn btn-mini")}
50 %endif
50 %endif
51 ${h.link_to(_('Show as Raw'), h.route_path('gist_show_formatted', gist_id=c.gist.gist_access_id, revision='tip', format='raw'), class_="btn btn-mini")}
51 ${h.link_to(_('Show as Raw'), h.route_path('gist_show_formatted', gist_id=c.gist.gist_access_id, revision='tip', format='raw'), class_="btn btn-mini")}
52
52
53 %if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id:
53 %if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id:
54 <div class="pull-right remove_gist">
54 <div class="pull-right remove_gist">
55 ${h.secure_form(h.route_path('gist_delete', gist_id=c.gist.gist_access_id), request=request)}
55 ${h.secure_form(h.route_path('gist_delete', gist_id=c.gist.gist_access_id), request=request)}
56 <input class="btn btn-mini btn-danger" id="remove_gist" name="remove_gist"
56 <input class="btn btn-mini btn-danger" id="remove_gist" name="remove_gist"
57 onclick="submitConfirm(event, this, _gettext('Confirm to delete this gist'), _gettext('Delete'), '${c.gist.gist_access_id}')"
57 onclick="submitConfirm(event, this, _gettext('Confirm to delete this gist'), _gettext('Delete'), '${c.gist.gist_access_id}')"
58 type="submit" value="${_('Delete')}"
58 type="submit" value="${_('Delete')}"
59 >
59 >
60 ${h.end_form()}
60 ${h.end_form()}
61 </div>
61 </div>
62 %endif
62 %endif
63 </div>
63 </div>
64 </div>
64 </div>
65
65
66 <div class="gist-desc">
66 <div class="gist-desc">
67 <code>${c.gist.gist_description}</code>
67 <code>${c.gist.gist_description}</code>
68 </div>
68 </div>
69
69
70 <div class="author">
70 <div class="author">
71 <div title="${h.tooltip(c.file_last_commit.author)}">
71 <div title="${h.tooltip(c.file_last_commit.author)}">
72 ${self.gravatar_with_user(c.file_last_commit.author, 16, tooltip=True)} - ${_('created')} ${h.age_component(c.file_last_commit.date)},
72 ${self.gravatar_with_user(c.file_last_commit.author, 16, tooltip=True)} - ${_('created')} ${h.age_component(c.file_last_commit.date)},
73 ${_('expires')}:
73 ${_('expires')}:
74 %if c.gist.gist_expires == -1:
74 %if c.gist.gist_expires == -1:
75 ${_('never')}
75 ${_('never')}
76 %else:
76 %else:
77 ${h.age_component(h.time_to_utcdatetime(c.gist.gist_expires))}
77 ${h.age_component(h.time_to_utcdatetime(c.gist.gist_expires))}
78 %endif
78 %endif
79 </span>
79 </span>
80 </div>
80 </div>
81
81
82 </div>
82 </div>
83 <div class="commit">${h.urlify_commit_message(c.file_last_commit.message, None)}</div>
83 <div class="commit">${h.urlify_commit_message(c.file_last_commit.message, None)}</div>
84 </div>
84 </div>
85
85
86 ## iterate over the files
86 ## iterate over the files
87 % for gist_file in c.files:
87 % for gist_file in c.files:
88 <% renderer = c.render and h.renderer_from_filename(gist_file.path, exclude=['.txt', '.TXT'])%>
88 <% renderer = c.render and h.renderer_from_filename(gist_file.path, exclude=['.txt', '.TXT'])%>
89 <!--
89 <!--
90 <div id="${h.FID('G', gist_file.path)}" class="stats" >
90 <div id="${h.FID('G', gist_file.path)}" class="stats" >
91 <a href="${c.gist.gist_url()}">ΒΆ</a>
91 <a href="${c.gist.gist_url()}">ΒΆ</a>
92 <b >${gist_file.path}</b>
92 <b >${gist_file.path}</b>
93 <div>
93 <div>
94 ${h.link_to(_('Show as raw'), h.route_path('gist_show_formatted_path', gist_id=c.gist.gist_access_id, revision=gist_file.commit.raw_id, format='raw', f_path=gist_file.path), class_="btn btn-mini")}
94 ${h.link_to(_('Show as raw'), h.route_path('gist_show_formatted_path', gist_id=c.gist.gist_access_id, revision=gist_file.commit.raw_id, format='raw', f_path=gist_file.path), class_="btn btn-mini")}
95 </div>
95 </div>
96 </div>
96 </div>
97 -->
97 -->
98 <div class="code-body textarea text-area editor">
98 <div class="code-body textarea text-area editor">
99 %if renderer:
99 %if renderer:
100 ${h.render(gist_file.content, renderer=renderer)}
100 ${h.render(gist_file.str_content, renderer=renderer)}
101 %else:
101 %else:
102 ${h.pygmentize(gist_file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
102 ${h.pygmentize(gist_file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
103 %endif
103 %endif
104 </div>
104 </div>
105 %endfor
105 %endfor
106 </div>
106 </div>
107 </div>
107 </div>
108 </div>
108 </div>
109
109
110
110
111 </div>
111 </div>
112 </%def>
112 </%def>
@@ -1,64 +1,63 b''
1 ## -*- coding: utf-8 -*-
2 ##usage:
1 ##usage:
3 ## <%namespace name="diff_block" file="/changeset/diff_block.mako"/>
2 ## <%namespace name="diff_block" file="/changeset/diff_block.mako"/>
4 ## ${diff_block.diff_block_changeset_table(change)}
3 ## ${diff_block.diff_block_changeset_table(change)}
5 ##
4 ##
6 <%def name="changeset_message()">
5 <%def name="changeset_message()">
7 <h5>${_('The requested commit is too big and content was truncated.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
6 <h5>${_('The requested commit is too big and content was truncated.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
8 </%def>
7 </%def>
9 <%def name="file_message()">
8 <%def name="file_message()">
10 <h5>${_('The requested file is too big and its content is not shown.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
9 <h5>${_('The requested file is too big and its content is not shown.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
11 </%def>
10 </%def>
12
11
13 <%def name="diff_block_changeset_table(change)">
12 <%def name="diff_block_changeset_table(change)">
14 <div class="diff-container" id="${'diff-container-%s' % (id(change))}">
13 <div class="diff-container" id="${'diff-container-%s' % (id(change))}">
15 %for FID,(cs1, cs2, change, filenode_path, diff, stats, file_data) in change.items():
14 %for FID,(cs1, cs2, change, filenode_path, diff, stats, file_data) in change.items():
16 <div id="${h.FID('',filenode_path)}_target" ></div>
15 <div id="${h.FID('',filenode_path)}_target" ></div>
17 <div id="${h.FID('',filenode_path)}" class="diffblock margined comm">
16 <div id="${h.FID('',filenode_path)}" class="diffblock margined comm">
18 <div class="code-body">
17 <div class="code-body">
19 <div class="full_f_path" path="${h.safe_unicode(filenode_path)}" style="display: none"></div>
18 <div class="full_f_path" path="${h.safe_str(filenode_path)}" style="display: none"></div>
20 ${diff|n}
19 ${diff|n}
21 % if file_data["is_limited_diff"]:
20 % if file_data["is_limited_diff"]:
22 % if file_data["exceeds_limit"]:
21 % if file_data["exceeds_limit"]:
23 ${self.file_message()}
22 ${self.file_message()}
24 % else:
23 % else:
25 <h5>${_('Diff was truncated. File content available only in full diff.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
24 <h5>${_('Diff was truncated. File content available only in full diff.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
26 % endif
25 % endif
27 % endif
26 % endif
28 </div>
27 </div>
29 </div>
28 </div>
30 %endfor
29 %endfor
31 </div>
30 </div>
32 </%def>
31 </%def>
33
32
34 <%def name="diff_block_simple(change)">
33 <%def name="diff_block_simple(change)">
35 <div class="diff-container" id="${'diff-container-%s' % (id(change))}">
34 <div class="diff-container" id="${'diff-container-%s' % (id(change))}">
36 %for op,filenode_path,diff,file_data in change:
35 %for op,filenode_path,diff,file_data in change:
37 <div id="${h.FID('',filenode_path)}_target" ></div>
36 <div id="${h.FID('',filenode_path)}_target" ></div>
38 <div id="${h.FID('',filenode_path)}" class="diffblock margined comm" >
37 <div id="${h.FID('',filenode_path)}" class="diffblock margined comm" >
39 <div class="code-body">
38 <div class="code-body">
40 <div class="full_f_path" path="${h.safe_unicode(filenode_path)}" style="display: none;"></div>
39 <div class="full_f_path" path="${h.safe_str(filenode_path)}" style="display: none;"></div>
41 ${diff|n}
40 ${diff|n}
42 % if file_data["is_limited_diff"]:
41 % if file_data["is_limited_diff"]:
43 % if file_data["exceeds_limit"]:
42 % if file_data["exceeds_limit"]:
44 ${self.file_message()}
43 ${self.file_message()}
45 % else:
44 % else:
46 <h5>${_('Diff was truncated. File content available only in full diff.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
45 <h5>${_('Diff was truncated. File content available only in full diff.')} <a href="${h.current_route_path(request, fulldiff=1)}" onclick="return confirm('${_("Showing a big diff might take some time and resources, continue?")}')">${_('Show full diff')}</a></h5>
47 % endif
46 % endif
48 % endif
47 % endif
49 </div>
48 </div>
50 </div>
49 </div>
51 %endfor
50 %endfor
52 </div>
51 </div>
53 </%def>
52 </%def>
54
53
55
54
56 <%def name="diff_summary_text(changed_files, lines_added, lines_deleted, limited_diff=False)">
55 <%def name="diff_summary_text(changed_files, lines_added, lines_deleted, limited_diff=False)">
57 % if limited_diff:
56 % if limited_diff:
58 ${_ungettext('%(num)s file changed', '%(num)s files changed', changed_files) % {'num': changed_files}}
57 ${_ungettext('%(num)s file changed', '%(num)s files changed', changed_files) % {'num': changed_files}}
59 % else:
58 % else:
60 ${_ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted',
59 ${_ungettext('%(num)s file changed: %(linesadd)s inserted, ''%(linesdel)s deleted',
61 '%(num)s files changed: %(linesadd)s inserted, %(linesdel)s deleted', changed_files) % {'num': changed_files, 'linesadd': lines_added, 'linesdel': lines_deleted}}
60 '%(num)s files changed: %(linesadd)s inserted, %(linesdel)s deleted', changed_files) % {'num': changed_files, 'linesadd': lines_added, 'linesdel': lines_deleted}}
62 %endif
61 %endif
63 </%def>
62 </%def>
64
63
@@ -1,128 +1,128 b''
1 <%inherit file="/base/base.mako"/>
1 <%inherit file="/base/base.mako"/>
2
2
3 <%def name="title()">
3 <%def name="title()">
4 ${_('{} Files Edit').format(c.repo_name)}
4 ${_('{} Files Edit').format(c.repo_name)}
5 %if c.rhodecode_name:
5 %if c.rhodecode_name:
6 &middot; ${h.branding(c.rhodecode_name)}
6 &middot; ${h.branding(c.rhodecode_name)}
7 %endif
7 %endif
8 </%def>
8 </%def>
9
9
10 <%def name="menu_bar_nav()">
10 <%def name="menu_bar_nav()">
11 ${self.menu_items(active='repositories')}
11 ${self.menu_items(active='repositories')}
12 </%def>
12 </%def>
13
13
14 <%def name="breadcrumbs_links()"></%def>
14 <%def name="breadcrumbs_links()"></%def>
15
15
16 <%def name="menu_bar_subnav()">
16 <%def name="menu_bar_subnav()">
17 ${self.repo_menu(active='files')}
17 ${self.repo_menu(active='files')}
18 </%def>
18 </%def>
19
19
20 <%def name="main()">
20 <%def name="main()">
21
21
22 <div class="box">
22 <div class="box">
23
23
24 <div class="edit-file-title">
24 <div class="edit-file-title">
25 <span class="title-heading">${_('Edit file')} @ <code>${h.show_id(c.commit)}</code></span>
25 <span class="title-heading">${_('Edit file')} @ <code>${h.show_id(c.commit)}</code></span>
26 % if c.commit.branch:
26 % if c.commit.branch:
27 <span class="tag branchtag">
27 <span class="tag branchtag">
28 <i class="icon-branch"></i> ${c.commit.branch}
28 <i class="icon-branch"></i> ${c.commit.branch}
29 </span>
29 </span>
30 % endif
30 % endif
31 </div>
31 </div>
32
32
33 ${h.secure_form(h.route_path('repo_files_update_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path), id='eform', request=request)}
33 ${h.secure_form(h.route_path('repo_files_update_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path), id='eform', request=request)}
34 <div class="edit-file-fieldset">
34 <div class="edit-file-fieldset">
35 <div class="path-items">
35 <div class="path-items">
36 <ul>
36 <ul>
37 <li class="breadcrumb-path">
37 <li class="breadcrumb-path">
38 <div>
38 <div>
39 ${h.files_breadcrumbs(c.repo_name, c.rhodecode_db_repo.repo_type, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True, hide_last_item=True, copy_path_icon=False)} /
39 ${h.files_breadcrumbs(c.repo_name, c.rhodecode_db_repo.repo_type, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'), limit_items=True, hide_last_item=True, copy_path_icon=False)} /
40 </div>
40 </div>
41 </li>
41 </li>
42 <li class="location-path">
42 <li class="location-path">
43 <input type="hidden" value="${c.f_path}" name="root_path">
43 <input type="hidden" value="${c.f_path}" name="root_path">
44 <input class="file-name-input input-small" type="text" value="${c.file.name}" name="filename" id="filename" placeholder="${_('Filename e.g example.py, or docs/readme.md')}">
44 <input class="file-name-input input-small" type="text" value="${c.file.name}" name="filename" id="filename" placeholder="${_('Filename e.g example.py, or docs/readme.md')}">
45 </li>
45 </li>
46 </ul>
46 </ul>
47 </div>
47 </div>
48
48
49 </div>
49 </div>
50
50
51 <div class="table">
51 <div class="table">
52 <div>
52 <div>
53
53
54 <div id="codeblock" class="codeblock">
54 <div id="codeblock" class="codeblock">
55 <div class="editor-items">
55 <div class="editor-items">
56 <div class="editor-action active show-editor pull-left" onclick="fileEditor.showEditor(); return false">
56 <div class="editor-action active show-editor pull-left" onclick="fileEditor.showEditor(); return false">
57 ${_('Edit')}
57 ${_('Edit')}
58 </div>
58 </div>
59
59
60 <div class="editor-action show-preview pull-left" onclick="fileEditor.showPreview(); return false">
60 <div class="editor-action show-preview pull-left" onclick="fileEditor.showPreview(); return false">
61 ${_('Preview')}
61 ${_('Preview')}
62 </div>
62 </div>
63
63
64 <div class="pull-right">
64 <div class="pull-right">
65 ${h.dropdownmenu('line_wrap', 'off', [('on', _('Line wraps on')), ('off', _('line wraps off')),])}
65 ${h.dropdownmenu('line_wrap', 'off', [('on', _('Line wraps on')), ('off', _('line wraps off')),])}
66 </div>
66 </div>
67 <div class="pull-right">
67 <div class="pull-right">
68 ${h.dropdownmenu('set_mode','plain',[('plain', _('plain'))],enable_filter=True)}
68 ${h.dropdownmenu('set_mode','plain',[('plain', _('plain'))],enable_filter=True)}
69 </div>
69 </div>
70 </div>
70 </div>
71
71
72 <div id="editor_container">
72 <div id="editor_container">
73 <pre id="editor_pre"></pre>
73 <pre id="editor_pre"></pre>
74 <textarea id="editor" name="content" >${h.escape(c.file.content)|n}</textarea>
74 <textarea id="editor" name="content" >${h.escape(c.file.str_content)|n}</textarea>
75 <div id="editor_preview" ></div>
75 <div id="editor_preview" ></div>
76 </div>
76 </div>
77 </div>
77 </div>
78 </div>
78 </div>
79 </div>
79 </div>
80
80
81 <div class="edit-file-fieldset">
81 <div class="edit-file-fieldset">
82 <div class="fieldset">
82 <div class="fieldset">
83 <div class="message">
83 <div class="message">
84 <textarea id="commit" name="message" placeholder="${c.default_message}"></textarea>
84 <textarea id="commit" name="message" placeholder="${c.default_message}"></textarea>
85 </div>
85 </div>
86 </div>
86 </div>
87 <div class="pull-left">
87 <div class="pull-left">
88 ${h.submit('commit_btn',_('Commit changes'), class_="btn btn-small btn-success")}
88 ${h.submit('commit_btn',_('Commit changes'), class_="btn btn-small btn-success")}
89 </div>
89 </div>
90 </div>
90 </div>
91 ${h.end_form()}
91 ${h.end_form()}
92 </div>
92 </div>
93
93
94 <script type="text/javascript">
94 <script type="text/javascript">
95
95
96 $(document).ready(function() {
96 $(document).ready(function() {
97 var modes_select = $('#set_mode');
97 var modes_select = $('#set_mode');
98 var filename_selector = '#filename';
98 var filename_selector = '#filename';
99 fillCodeMirrorOptions(modes_select);
99 fillCodeMirrorOptions(modes_select);
100
100
101 fileEditor = new FileEditor('#editor');
101 fileEditor = new FileEditor('#editor');
102
102
103 // try to detect the mode based on the file we edit
103 // try to detect the mode based on the file we edit
104 var detected_mode = detectCodeMirrorMode("${c.file.name}", "${c.file.mimetype}");
104 var detected_mode = detectCodeMirrorMode("${c.file.name}", "${c.file.mimetype}");
105
105
106 if (detected_mode) {
106 if (detected_mode) {
107 setCodeMirrorMode(fileEditor.cm, detected_mode);
107 setCodeMirrorMode(fileEditor.cm, detected_mode);
108
108
109 var mimetype = $(modes_select).find("option[mode={0}]".format(detected_mode)).val();
109 var mimetype = $(modes_select).find("option[mode={0}]".format(detected_mode)).val();
110 $(modes_select).select2("val", mimetype).trigger('change');
110 $(modes_select).select2("val", mimetype).trigger('change');
111 }
111 }
112
112
113 // on change of select field set mode
113 // on change of select field set mode
114 setCodeMirrorModeFromSelect(modes_select, filename_selector, fileEditor.cm, null);
114 setCodeMirrorModeFromSelect(modes_select, filename_selector, fileEditor.cm, null);
115
115
116 // on entering the new filename set mode, from given extension
116 // on entering the new filename set mode, from given extension
117 setCodeMirrorModeFromInput(modes_select, filename_selector, fileEditor.cm, null);
117 setCodeMirrorModeFromInput(modes_select, filename_selector, fileEditor.cm, null);
118
118
119 var commit_id = "${c.commit.raw_id}";
119 var commit_id = "${c.commit.raw_id}";
120 var f_path = "${c.f_path}";
120 var f_path = "${c.f_path}";
121
121
122 checkFileHead($('#eform'), commit_id, f_path, 'edit')
122 checkFileHead($('#eform'), commit_id, f_path, 'edit')
123
123
124 });
124 });
125
125
126
126
127 </script>
127 </script>
128 </%def>
128 </%def>
@@ -1,189 +1,189 b''
1 <%namespace name="sourceblock" file="/codeblocks/source.mako"/>
1 <%namespace name="sourceblock" file="/codeblocks/source.mako"/>
2
2
3 <%
3 <%
4 at_ref = request.GET.get('at')
4 at_ref = request.GET.get('at')
5 if at_ref:
5 if at_ref:
6 query={'at': at_ref}
6 query={'at': at_ref}
7 default_commit_id = at_ref or c.rhodecode_db_repo.landing_ref_name
7 default_commit_id = at_ref or c.rhodecode_db_repo.landing_ref_name
8 else:
8 else:
9 query=None
9 query=None
10 default_commit_id = c.commit.raw_id
10 default_commit_id = c.commit.raw_id
11 %>
11 %>
12
12
13 <div id="codeblock" class="browserblock">
13 <div id="codeblock" class="browserblock">
14 <div class="browser-header">
14 <div class="browser-header">
15 <div class="browser-nav">
15 <div class="browser-nav">
16 <div class="pull-left">
16 <div class="pull-left">
17 ## loads the history for a file
17 ## loads the history for a file
18 ${h.hidden('file_refs_filter')}
18 ${h.hidden('file_refs_filter')}
19 </div>
19 </div>
20
20
21 <div class="pull-right">
21 <div class="pull-right">
22
22
23 ## Download
23 ## Download
24 % if c.lf_node:
24 % if c.lf_node:
25 <a class="btn btn-default" href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path, _query=dict(lf=1))}">
25 <a class="btn btn-default" href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path, _query=dict(lf=1))}">
26 ${_('Download largefile')}
26 ${_('Download largefile')}
27 </a>
27 </a>
28 % else:
28 % else:
29 <a class="btn btn-default" href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}">
29 <a class="btn btn-default" href="${h.route_path('repo_file_download',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}">
30 ${_('Download file')}
30 ${_('Download file')}
31 </a>
31 </a>
32 % endif
32 % endif
33
33
34 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
34 %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name):
35 ## on branch head, can edit files
35 ## on branch head, can edit files
36 %if c.on_branch_head and c.branch_or_raw_id:
36 %if c.on_branch_head and c.branch_or_raw_id:
37 ## binary files are delete only
37 ## binary files are delete only
38 % if c.file.is_binary:
38 % if c.file.is_binary:
39 ${h.link_to(_('Edit'), '#Edit', class_="btn btn-default disabled tooltip", title=_('Editing binary files not allowed'))}
39 ${h.link_to(_('Edit'), '#Edit', class_="btn btn-default disabled tooltip", title=_('Editing binary files not allowed'))}
40 ${h.link_to(_('Delete'), h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query),class_="btn btn-danger")}
40 ${h.link_to(_('Delete'), h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query),class_="btn btn-danger")}
41 % else:
41 % else:
42 <a class="btn btn-default" href="${h.route_path('repo_files_edit_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query)}">
42 <a class="btn btn-default" href="${h.route_path('repo_files_edit_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query)}">
43 ${_('Edit on branch: ')}<code>${c.branch_name}</code>
43 ${_('Edit on branch: ')}<code>${c.branch_name}</code>
44 </a>
44 </a>
45
45
46 <a class="btn btn-danger" href="${h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query)}">
46 <a class="btn btn-danger" href="${h.route_path('repo_files_remove_file',repo_name=c.repo_name,commit_id=c.branch_or_raw_id,f_path=c.f_path, _query=query)}">
47 ${_('Delete')}
47 ${_('Delete')}
48 </a>
48 </a>
49 % endif
49 % endif
50 ## not on head, forbid all
50 ## not on head, forbid all
51 % else:
51 % else:
52 ${h.link_to(_('Edit'), '#Edit', class_="btn btn-default disabled tooltip", title=_('Editing files allowed only when on branch head commit'))}
52 ${h.link_to(_('Edit'), '#Edit', class_="btn btn-default disabled tooltip", title=_('Editing files allowed only when on branch head commit'))}
53 ${h.link_to(_('Delete'), '#Delete', class_="btn btn-default btn-danger disabled tooltip", title=_('Deleting files allowed only when on branch head commit'))}
53 ${h.link_to(_('Delete'), '#Delete', class_="btn btn-default btn-danger disabled tooltip", title=_('Deleting files allowed only when on branch head commit'))}
54 % endif
54 % endif
55 %endif
55 %endif
56
56
57 </div>
57 </div>
58 </div>
58 </div>
59 <div id="file_history_container"></div>
59 <div id="file_history_container"></div>
60
60
61 </div>
61 </div>
62 </div>
62 </div>
63
63
64 <div class="codeblock">
64 <div class="codeblock">
65 <div class=" codeblock-header">
65 <div class=" codeblock-header">
66 <div class="file-filename">
66 <div class="file-filename">
67 <i class="icon-file"></i> ${c.file.name}
67 <i class="icon-file"></i> ${c.file.name}
68 </div>
68 </div>
69
69
70 <div class="file-stats">
70 <div class="file-stats">
71
71
72 <div class="stats-info">
72 <div class="stats-info">
73 <span class="stats-first-item">
73 <span class="stats-first-item">
74 % if c.file_size_too_big:
74 % if c.file_size_too_big:
75 0 ${(_('lines'))}
75 0 ${(_('lines'))}
76 % else:
76 % else:
77 ${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}
77 ${c.file.lines()[0]} ${_ungettext('line', 'lines', c.file.lines()[0])}
78 % endif
78 % endif
79 </span>
79 </span>
80
80
81 <span> | ${h.format_byte_size_binary(c.file.size)}</span>
81 <span> | ${h.format_byte_size_binary(c.file.size)}</span>
82 % if c.lf_node:
82 % if c.lf_node:
83 <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span>
83 <span title="${_('This file is a pointer to large binary file')}"> | ${_('LargeFile')} ${h.format_byte_size_binary(c.lf_node.size)} </span>
84 % endif
84 % endif
85 <span>
85 <span>
86 | ${c.file.mimetype}
86 | ${c.file.mimetype}
87 </span>
87 </span>
88
88
89 % if not c.file_size_too_big:
89 % if not c.file_size_too_big:
90 <span> |
90 <span> |
91 ${h.get_lexer_for_filenode(c.file).__class__.__name__}
91 ${h.get_lexer_for_filenode(c.file).__class__.__name__}
92 </span>
92 </span>
93 % endif
93 % endif
94
94
95 </div>
95 </div>
96 </div>
96 </div>
97 </div>
97 </div>
98
98
99 <div class="path clear-fix">
99 <div class="path clear-fix">
100 <div class="pull-left">
100 <div class="pull-left">
101 ${h.files_breadcrumbs(c.repo_name, c.rhodecode_db_repo.repo_type, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'))}
101 ${h.files_breadcrumbs(c.repo_name, c.rhodecode_db_repo.repo_type, c.commit.raw_id, c.file.path, c.rhodecode_db_repo.landing_ref_name, request.GET.get('at'))}
102 </div>
102 </div>
103
103
104 <div class="pull-right stats">
104 <div class="pull-right stats">
105 <a id="file_history_overview" href="#loadHistory">
105 <a id="file_history_overview" href="#loadHistory">
106 ${_('History')}
106 ${_('History')}
107 </a>
107 </a>
108 |
108 |
109 %if c.annotate:
109 %if c.annotate:
110 ${h.link_to(_('Source'), h.route_path('repo_files', repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
110 ${h.link_to(_('Source'), h.route_path('repo_files', repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
111 %else:
111 %else:
112 ${h.link_to(_('Annotation'), h.route_path('repo_files:annotated',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
112 ${h.link_to(_('Annotation'), h.route_path('repo_files:annotated',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
113 %endif
113 %endif
114 | ${h.link_to(_('Raw'), h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
114 | ${h.link_to(_('Raw'), h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
115 % if not c.file.is_binary:
115 % if not c.file.is_binary:
116 |<a href="#copySource" onclick="return false;" class="no-grey clipboard-action" data-clipboard-text="${c.file.content}">${_('Copy content')}</a>
116 |<a href="#copySource" onclick="return false;" class="no-grey clipboard-action" data-clipboard-text="${c.file.content}">${_('Copy content')}</a>
117 |<a href="#copyPermaLink" onclick="return false;" class="no-grey clipboard-action" data-clipboard-text="${h.route_url('repo_files', repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}">${_('Copy permalink')}</a>
117 |<a href="#copyPermaLink" onclick="return false;" class="no-grey clipboard-action" data-clipboard-text="${h.route_url('repo_files', repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}">${_('Copy permalink')}</a>
118 % endif
118 % endif
119
119
120 </div>
120 </div>
121 <div class="clear-fix"></div>
121 <div class="clear-fix"></div>
122 </div>
122 </div>
123
123
124 <div class="code-body clear-fix ">
124 <div class="code-body clear-fix ">
125 %if c.file.is_binary:
125 %if c.file.is_binary:
126 <% rendered_binary = h.render_binary(c.repo_name, c.file)%>
126 <% rendered_binary = h.render_binary(c.repo_name, c.file)%>
127 % if rendered_binary:
127 % if rendered_binary:
128 <div class="text-center">
128 <div class="text-center">
129 ${rendered_binary}
129 ${rendered_binary}
130 </div>
130 </div>
131 % else:
131 % else:
132 <div>
132 <div>
133 ${_('Binary file ({})').format(c.file.mimetype)}
133 ${_('Binary file ({})').format(c.file.mimetype)}
134 </div>
134 </div>
135 % endif
135 % endif
136 %else:
136 %else:
137 % if c.file_size_too_big:
137 % if c.file_size_too_big:
138 ${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'),
138 ${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'),
139 h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
139 h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))}
140 % else:
140 % else:
141 %if c.renderer and not c.annotate:
141 %if c.renderer and not c.annotate:
142 ## pick relative url based on renderer
142 ## pick relative url based on renderer
143 <%
143 <%
144 relative_urls = {
144 relative_urls = {
145 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
145 'raw': h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
146 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
146 'standard': h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path),
147 }
147 }
148 %>
148 %>
149 ${h.render(c.file.content, renderer=c.renderer, relative_urls=relative_urls)}
149 ${h.render(c.file.str_content, renderer=c.renderer, relative_urls=relative_urls)}
150 %else:
150 %else:
151 <table class="cb codehilite">
151 <table class="cb codehilite">
152 %if c.annotate:
152 %if c.annotate:
153 <% color_hasher = h.color_hasher() %>
153 <% color_hasher = h.color_hasher() %>
154 %for annotation, lines in c.annotated_lines:
154 %for annotation, lines in c.annotated_lines:
155 ${sourceblock.render_annotation_lines(annotation, lines, color_hasher)}
155 ${sourceblock.render_annotation_lines(annotation, lines, color_hasher)}
156 %endfor
156 %endfor
157 %else:
157 %else:
158 %for line_num, tokens in enumerate(c.lines, 1):
158 %for line_num, tokens in enumerate(c.lines, 1):
159 ${sourceblock.render_line(line_num, tokens)}
159 ${sourceblock.render_line(line_num, tokens)}
160 %endfor
160 %endfor
161 %endif
161 %endif
162 </table>
162 </table>
163 %endif
163 %endif
164 % endif
164 % endif
165 %endif
165 %endif
166 </div>
166 </div>
167
167
168 </div>
168 </div>
169
169
170 <script type="text/javascript">
170 <script type="text/javascript">
171 % if request.GET.get('mark'):
171 % if request.GET.get('mark'):
172
172
173 $(function(){
173 $(function(){
174 $(".codehilite").mark(
174 $(".codehilite").mark(
175 "${request.GET.get('mark')}",
175 "${request.GET.get('mark')}",
176 {
176 {
177 "className": 'match',
177 "className": 'match',
178 "accuracy": "complementary",
178 "accuracy": "complementary",
179 "ignorePunctuation": ":._(){}[]!'+=".split(""),
179 "ignorePunctuation": ":._(){}[]!'+=".split(""),
180 "each": function(el) {
180 "each": function(el) {
181 // and also highlight lines !
181 // and also highlight lines !
182 $($(el).closest('tr')).find('td.cb-lineno').addClass('cb-line-selected');
182 $($(el).closest('tr')).find('td.cb-lineno').addClass('cb-line-selected');
183 }
183 }
184 }
184 }
185 );
185 );
186
186
187 });
187 });
188 % endif
188 % endif
189 </script>
189 </script>
General Comments 0
You need to be logged in to leave comments. Login now