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