##// END OF EJS Templates
fix(gists): fixed bytes content returned in edit/copy content items§
super-admin -
r5232:8b86360e default
parent child Browse files
Show More
@@ -1,136 +1,136 b''
1 <%inherit file="/base/base.mako"/>
1 <%inherit file="/base/base.mako"/>
2
2
3 <%def name="title()">
3 <%def name="title()">
4 ${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
4 ${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
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="breadcrumbs_links()"></%def>
10 <%def name="breadcrumbs_links()"></%def>
11
11
12 <%def name="menu_bar_nav()">
12 <%def name="menu_bar_nav()">
13 ${self.menu_items(active='gists')}
13 ${self.menu_items(active='gists')}
14 </%def>
14 </%def>
15
15
16 <%def name="main()">
16 <%def name="main()">
17 <div class="box">
17 <div class="box">
18 <!-- box / title -->
18 <!-- box / title -->
19 <div class="title">
19 <div class="title">
20
20
21 </div>
21 </div>
22
22
23 <div class="table">
23 <div class="table">
24 <div id="files_data">
24 <div id="files_data">
25 ${h.secure_form(h.route_path('gist_update', gist_id=c.gist.gist_access_id), id='eform', request=request)}
25 ${h.secure_form(h.route_path('gist_update', gist_id=c.gist.gist_access_id), id='eform', request=request)}
26 <div>
26 <div>
27 <input type="hidden" value="${c.file_last_commit.raw_id}" name="parent_hash">
27 <input type="hidden" value="${c.file_last_commit.raw_id}" name="parent_hash">
28 <div>
28 <div>
29 <span class="gist-gravatar">
29 <span class="gist-gravatar">
30 ${self.gravatar(h.email_or_none(c.rhodecode_user.full_contact), 30)}
30 ${self.gravatar(h.email_or_none(c.rhodecode_user.full_contact), 30)}
31 </span>
31 </span>
32 <label for='lifetime'>${_('Gist lifetime')}</label>
32 <label for='lifetime'>${_('Gist lifetime')}</label>
33 ${h.dropdownmenu('lifetime', '0', c.lifetime_options)}
33 ${h.dropdownmenu('lifetime', '0', c.lifetime_options)}
34
34
35 <label for='gist_acl_level'>${_('Gist access level')}</label>
35 <label for='gist_acl_level'>${_('Gist access level')}</label>
36 ${h.dropdownmenu('gist_acl_level', c.gist.acl_level, c.acl_options)}
36 ${h.dropdownmenu('gist_acl_level', c.gist.acl_level, c.acl_options)}
37
37
38 <textarea style="margin-top: 5px; border-color: #dbd9da" id="description" name="description"
38 <textarea style="margin-top: 5px; border-color: #dbd9da" id="description" name="description"
39 placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea>
39 placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea>
40 </div>
40 </div>
41 </div>
41 </div>
42
42
43 ## peppercorn schema
43 ## peppercorn schema
44 <input type="hidden" name="__start__" value="nodes:sequence"/>
44 <input type="hidden" name="__start__" value="nodes:sequence"/>
45 % for cnt, file in enumerate(c.files):
45 % for cnt, file in enumerate(c.files):
46 <input type="hidden" name="__start__" value="file:mapping"/>
46 <input type="hidden" name="__start__" value="file:mapping"/>
47 <div id="codeblock" class="codeblock" >
47 <div id="codeblock" class="codeblock" >
48 <div class="code-header">
48 <div class="code-header">
49 <div class="form">
49 <div class="form">
50 <div class="fields">
50 <div class="fields">
51 <input type="hidden" name="filename_org" value="${file.path}" >
51 <input type="hidden" name="filename_org" value="${file.path}" >
52 <input id="filename_${h.FID('f',file.path)}" name="filename" size="30" type="text" value="${file.path}">
52 <input id="filename_${h.FID('f',file.path)}" name="filename" size="30" type="text" value="${file.path}">
53 ${h.dropdownmenu('mimetype' ,'plain',[('plain',_('plain'))],enable_filter=True, id='mimetype_'+h.FID('f',file.path))}
53 ${h.dropdownmenu('mimetype' ,'plain',[('plain',_('plain'))],enable_filter=True, id='mimetype_'+h.FID('f',file.path))}
54 </div>
54 </div>
55 </div>
55 </div>
56 </div>
56 </div>
57 <div class="editor_container">
57 <div class="editor_container">
58 <pre id="editor_pre"></pre>
58 <pre id="editor_pre"></pre>
59 <textarea id="editor_${h.FID('f',file.path)}" name="content" >${file.content}</textarea>
59 <textarea id="editor_${h.FID('f',file.path)}" name="content" >${file.str_content}</textarea>
60 </div>
60 </div>
61 </div>
61 </div>
62 <input type="hidden" name="__end__" />
62 <input type="hidden" name="__end__" />
63
63
64 ## dynamic edit box.
64 ## dynamic edit box.
65 <script type="text/javascript">
65 <script type="text/javascript">
66 $(document).ready(function(){
66 $(document).ready(function(){
67 var myCodeMirror = initCodeMirror(
67 var myCodeMirror = initCodeMirror(
68 "editor_${h.FID('f',file.path)}", '');
68 "editor_${h.FID('f',file.path)}", '');
69
69
70 var modes_select = $("#mimetype_${h.FID('f',file.path)}");
70 var modes_select = $("#mimetype_${h.FID('f',file.path)}");
71 fillCodeMirrorOptions(modes_select);
71 fillCodeMirrorOptions(modes_select);
72
72
73 // try to detect the mode based on the file we edit
73 // try to detect the mode based on the file we edit
74 var mimetype = "${file.mimetype}";
74 var mimetype = "${file.mimetype}";
75 var detected_mode = detectCodeMirrorMode(
75 var detected_mode = detectCodeMirrorMode(
76 "${file.path}", mimetype);
76 "${file.path}", mimetype);
77
77
78 if(detected_mode){
78 if(detected_mode){
79 $(modes_select).select2("val", mimetype);
79 $(modes_select).select2("val", mimetype);
80 $(modes_select).change();
80 $(modes_select).change();
81 setCodeMirrorMode(myCodeMirror, detected_mode);
81 setCodeMirrorMode(myCodeMirror, detected_mode);
82 }
82 }
83
83
84 var filename_selector = "#filename_${h.FID('f',file.path)}";
84 var filename_selector = "#filename_${h.FID('f',file.path)}";
85 // on change of select field set mode
85 // on change of select field set mode
86 setCodeMirrorModeFromSelect(
86 setCodeMirrorModeFromSelect(
87 modes_select, filename_selector, myCodeMirror, null);
87 modes_select, filename_selector, myCodeMirror, null);
88
88
89 // on entering the new filename set mode, from given extension
89 // on entering the new filename set mode, from given extension
90 setCodeMirrorModeFromInput(
90 setCodeMirrorModeFromInput(
91 modes_select, filename_selector, myCodeMirror, null);
91 modes_select, filename_selector, myCodeMirror, null);
92 });
92 });
93 </script>
93 </script>
94 %endfor
94 %endfor
95 <input type="hidden" name="__end__" />
95 <input type="hidden" name="__end__" />
96
96
97 <div class="pull-left">
97 <div class="pull-left">
98 ${h.submit('update',_('Update Gist'),class_="btn btn-success")}
98 ${h.submit('update',_('Update Gist'),class_="btn btn-success")}
99 <a class="btn" href="${h.route_path('gist_show', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a>
99 <a class="btn" href="${h.route_path('gist_show', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a>
100 </div>
100 </div>
101 ${h.end_form()}
101 ${h.end_form()}
102 </div>
102 </div>
103 </div>
103 </div>
104
104
105 </div>
105 </div>
106 <script>
106 <script>
107 $('#update').on('click', function(e){
107 $('#update').on('click', function(e){
108 e.preventDefault();
108 e.preventDefault();
109
109
110 $(this).val('Updating...');
110 $(this).val('Updating...');
111 $(this).attr('disabled', 'disabled');
111 $(this).attr('disabled', 'disabled');
112 // check for newer version.
112 // check for newer version.
113 $.ajax({
113 $.ajax({
114 url: "${h.route_path('gist_edit_check_revision', gist_id=c.gist.gist_access_id)}",
114 url: "${h.route_path('gist_edit_check_revision', gist_id=c.gist.gist_access_id)}",
115 data: {
115 data: {
116 'revision': '${c.file_last_commit.raw_id}'
116 'revision': '${c.file_last_commit.raw_id}'
117 },
117 },
118 dataType: 'json',
118 dataType: 'json',
119 type: 'GET',
119 type: 'GET',
120 success: function(data) {
120 success: function(data) {
121 if(data.success === false){
121 if(data.success === false){
122 message = '${h.literal(_('Gist was updated since you started editing. Copy your changes and click %(here)s to reload the new version.')
122 message = '${h.literal(_('Gist was updated since you started editing. Copy your changes and click %(here)s to reload the new version.')
123 % {'here': h.link_to('here', h.route_path('gist_edit', gist_id=c.gist.gist_access_id))})}'
123 % {'here': h.link_to('here', h.route_path('gist_edit', gist_id=c.gist.gist_access_id))})}'
124 alertMessage = [{"message": {
124 alertMessage = [{"message": {
125 "message": message, "force": "true", "level": "warning"}}];
125 "message": message, "force": "true", "level": "warning"}}];
126 $.Topic('/notifications').publish(alertMessage[0]);
126 $.Topic('/notifications').publish(alertMessage[0]);
127 }
127 }
128 else{
128 else{
129 $('#eform').submit();
129 $('#eform').submit();
130 }
130 }
131 }
131 }
132 });
132 });
133 })
133 })
134
134
135 </script>
135 </script>
136 </%def>
136 </%def>
@@ -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].str_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.str_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>
General Comments 0
You need to be logged in to leave comments. Login now