Show More
@@ -1,174 +1,174 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="/base/base.html"/> |
|
2 | <%inherit file="/base/base.html"/> | |
3 |
|
3 | |||
4 | <%block name="title"> |
|
4 | <%block name="title"> | |
5 | ${_('Edit Gist')} · ${c.gist.gist_access_id} |
|
5 | ${_('Edit Gist')} · ${c.gist.gist_access_id} | |
6 | </%block> |
|
6 | </%block> | |
7 |
|
7 | |||
8 | <%block name="js_extra"> |
|
8 | <%block name="js_extra"> | |
9 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> |
|
9 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> | |
10 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> |
|
10 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> | |
11 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> |
|
11 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> | |
12 | </%block> |
|
12 | </%block> | |
13 | <%block name="css_extra"> |
|
13 | <%block name="css_extra"> | |
14 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> |
|
14 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> | |
15 | </%block> |
|
15 | </%block> | |
16 |
|
16 | |||
17 | <%def name="breadcrumbs_links()"> |
|
17 | <%def name="breadcrumbs_links()"> | |
18 | ${_('Edit Gist')} · ${c.gist.gist_access_id} |
|
18 | ${_('Edit Gist')} · ${c.gist.gist_access_id} | |
19 | </%def> |
|
19 | </%def> | |
20 |
|
20 | |||
21 | <%block name="header_menu"> |
|
21 | <%block name="header_menu"> | |
22 | ${self.menu('gists')} |
|
22 | ${self.menu('gists')} | |
23 | </%block> |
|
23 | </%block> | |
24 |
|
24 | |||
25 | <%def name="main()"> |
|
25 | <%def name="main()"> | |
26 | <div class="panel panel-primary"> |
|
26 | <div class="panel panel-primary"> | |
27 | <div class="panel-heading clearfix"> |
|
27 | <div class="panel-heading clearfix"> | |
28 | ${self.breadcrumbs()} |
|
28 | ${self.breadcrumbs()} | |
29 | </div> |
|
29 | </div> | |
30 |
|
30 | |||
31 | <div class="panel-body"> |
|
31 | <div class="panel-body"> | |
32 | <div id="edit_error" style="display: none" class="flash_msg"> |
|
32 | <div id="edit_error" style="display: none" class="flash_msg"> | |
33 | <div class="alert alert-dismissable alert-warning"> |
|
33 | <div class="alert alert-dismissable alert-warning"> | |
34 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><i class="icon-cancel-circled"></i></button> |
|
34 | <button type="button" class="close" data-dismiss="alert" aria-hidden="true"><i class="icon-cancel-circled"></i></button> | |
35 | ${h.literal(_('Gist was update since you started editing. Copy your changes and click %(here)s to reload new version.') |
|
35 | ${h.literal(_('Gist was update since you started editing. Copy your changes and click %(here)s to reload new version.') | |
36 | % {'here': h.link_to('here',h.url('edit_gist', gist_id=c.gist.gist_access_id))})} |
|
36 | % {'here': h.link_to('here',h.url('edit_gist', gist_id=c.gist.gist_access_id))})} | |
37 | </div> |
|
37 | </div> | |
38 | <script> |
|
38 | <script> | |
39 | if (typeof jQuery != 'undefined') { |
|
39 | if (typeof jQuery != 'undefined') { | |
40 | $(".alert").alert(); |
|
40 | $(".alert").alert(); | |
41 | } |
|
41 | } | |
42 | </script> |
|
42 | </script> | |
43 | </div> |
|
43 | </div> | |
44 |
|
44 | |||
45 | <div id="files_data"> |
|
45 | <div id="files_data"> | |
46 | ${h.form(h.url('edit_gist', gist_id=c.gist.gist_access_id), method='post', id='eform')} |
|
46 | ${h.form(h.url('edit_gist', gist_id=c.gist.gist_access_id), method='post', id='eform')} | |
47 | <div> |
|
47 | <div> | |
48 | <input type="hidden" value="${c.file_changeset.raw_id}" name="parent_hash"> |
|
48 | <input type="hidden" value="${c.file_changeset.raw_id}" name="parent_hash"> | |
49 |
<textarea class="form-control |
|
49 | <textarea class="form-control" | |
50 | id="description" name="description" |
|
50 | id="description" name="description" | |
51 | placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea> |
|
51 | placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea> | |
52 | <div> |
|
52 | <div> | |
53 | <label> |
|
53 | <label> | |
54 | ${_('Gist lifetime')} |
|
54 | ${_('Gist lifetime')} | |
55 | ${h.select('lifetime', '0', c.lifetime_options)} |
|
55 | ${h.select('lifetime', '0', c.lifetime_options)} | |
56 | </label> |
|
56 | </label> | |
57 | <span class="text-muted"> |
|
57 | <span class="text-muted"> | |
58 | %if c.gist.gist_expires == -1: |
|
58 | %if c.gist.gist_expires == -1: | |
59 | ${_('Expires')}: ${_('Never')} |
|
59 | ${_('Expires')}: ${_('Never')} | |
60 | %else: |
|
60 | %else: | |
61 | ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))} |
|
61 | ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))} | |
62 | %endif |
|
62 | %endif | |
63 | </span> |
|
63 | </span> | |
64 | </div> |
|
64 | </div> | |
65 | </div> |
|
65 | </div> | |
66 |
|
66 | |||
67 | % for cnt, file in enumerate(c.files): |
|
67 | % for cnt, file in enumerate(c.files): | |
68 | <div id="body" class="panel panel-default form-inline"> |
|
68 | <div id="body" class="panel panel-default form-inline"> | |
69 | <div class="panel-heading"> |
|
69 | <div class="panel-heading"> | |
70 | <input type="hidden" value="${h.safe_unicode(file.path)}" name="org_files"> |
|
70 | <input type="hidden" value="${h.safe_unicode(file.path)}" name="org_files"> | |
71 | <input class="form-control" id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${h.safe_unicode(file.path)}"> |
|
71 | <input class="form-control" id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${h.safe_unicode(file.path)}"> | |
72 | <select class="form-control" id="mimetype_${h.FID('f',file.path)}" name="mimetypes"></select> |
|
72 | <select class="form-control" id="mimetype_${h.FID('f',file.path)}" name="mimetypes"></select> | |
73 | </div> |
|
73 | </div> | |
74 | <div class="panel-body no-padding"> |
|
74 | <div class="panel-body no-padding"> | |
75 | <div id="editor_container"> |
|
75 | <div id="editor_container"> | |
76 | <textarea id="editor_${h.FID('f',file.path)}" name="contents" style="display:none">${file.content}</textarea> |
|
76 | <textarea id="editor_${h.FID('f',file.path)}" name="contents" style="display:none">${file.content}</textarea> | |
77 | </div> |
|
77 | </div> | |
78 | </div> |
|
78 | </div> | |
79 | </div> |
|
79 | </div> | |
80 |
|
80 | |||
81 | ## dynamic edit box. |
|
81 | ## dynamic edit box. | |
82 | <script type="text/javascript"> |
|
82 | <script type="text/javascript"> | |
83 | $(document).ready(function(){ |
|
83 | $(document).ready(function(){ | |
84 | var myCodeMirror = initCodeMirror(${h.js('editor_' + h.FID('f',file.path))}, ${h.jshtml(request.script_name)}, ''); |
|
84 | var myCodeMirror = initCodeMirror(${h.js('editor_' + h.FID('f',file.path))}, ${h.jshtml(request.script_name)}, ''); | |
85 |
|
85 | |||
86 | //inject new modes |
|
86 | //inject new modes | |
87 | var $mimetype_select = $(${h.js('#mimetype_' + h.FID('f',file.path))}); |
|
87 | var $mimetype_select = $(${h.js('#mimetype_' + h.FID('f',file.path))}); | |
88 | $mimetype_select.each(function(){ |
|
88 | $mimetype_select.each(function(){ | |
89 | var modes_select = this; |
|
89 | var modes_select = this; | |
90 | var index = 1; |
|
90 | var index = 1; | |
91 | for(var i=0;i<CodeMirror.modeInfo.length;i++) { |
|
91 | for(var i=0;i<CodeMirror.modeInfo.length;i++) { | |
92 | var m = CodeMirror.modeInfo[i]; |
|
92 | var m = CodeMirror.modeInfo[i]; | |
93 | var opt = new Option(m.name, m.mime); |
|
93 | var opt = new Option(m.name, m.mime); | |
94 | $(opt).attr('mode', m.mode); |
|
94 | $(opt).attr('mode', m.mode); | |
95 | if (m.mime == 'text/plain') { |
|
95 | if (m.mime == 'text/plain') { | |
96 | // default plain text |
|
96 | // default plain text | |
97 | $(opt).prop('selected', true); |
|
97 | $(opt).prop('selected', true); | |
98 | modes_select.options[0] = opt; |
|
98 | modes_select.options[0] = opt; | |
99 | } else { |
|
99 | } else { | |
100 | modes_select.options[index++] = opt; |
|
100 | modes_select.options[index++] = opt; | |
101 | } |
|
101 | } | |
102 | } |
|
102 | } | |
103 | }); |
|
103 | }); | |
104 |
|
104 | |||
105 | var $filename_input = $(${h.js('#filename_' + h.FID('f',file.path))}); |
|
105 | var $filename_input = $(${h.js('#filename_' + h.FID('f',file.path))}); | |
106 | // on select change set new mode |
|
106 | // on select change set new mode | |
107 | $mimetype_select.change(function(e){ |
|
107 | $mimetype_select.change(function(e){ | |
108 | var selected = e.currentTarget; |
|
108 | var selected = e.currentTarget; | |
109 | var node = selected.options[selected.selectedIndex]; |
|
109 | var node = selected.options[selected.selectedIndex]; | |
110 | var detected_mode = CodeMirror.findModeByMIME(node.value); |
|
110 | var detected_mode = CodeMirror.findModeByMIME(node.value); | |
111 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
111 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
112 |
|
112 | |||
113 | var proposed_ext = CodeMirror.findExtensionByMode(detected_mode); |
|
113 | var proposed_ext = CodeMirror.findExtensionByMode(detected_mode); | |
114 | var file_data = CodeMirror.getFilenameAndExt($filename_input.val()); |
|
114 | var file_data = CodeMirror.getFilenameAndExt($filename_input.val()); | |
115 | var filename = file_data['filename'] || 'filename1'; |
|
115 | var filename = file_data['filename'] || 'filename1'; | |
116 | $filename_input.val(filename + '.' + proposed_ext); |
|
116 | $filename_input.val(filename + '.' + proposed_ext); | |
117 | }); |
|
117 | }); | |
118 |
|
118 | |||
119 | // on type the new filename set mode |
|
119 | // on type the new filename set mode | |
120 | $filename_input.keyup(function(e){ |
|
120 | $filename_input.keyup(function(e){ | |
121 | var file_data = CodeMirror.getFilenameAndExt(this.value); |
|
121 | var file_data = CodeMirror.getFilenameAndExt(this.value); | |
122 | if(file_data['ext'] != null){ |
|
122 | if(file_data['ext'] != null){ | |
123 | var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain'); |
|
123 | var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain'); | |
124 |
|
124 | |||
125 | if (detected_mode){ |
|
125 | if (detected_mode){ | |
126 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
126 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
127 | $mimetype_select.val(detected_mode.mime); |
|
127 | $mimetype_select.val(detected_mode.mime); | |
128 | } |
|
128 | } | |
129 | } |
|
129 | } | |
130 | }); |
|
130 | }); | |
131 |
|
131 | |||
132 | // set mode on page load |
|
132 | // set mode on page load | |
133 | var detected_mode = CodeMirror.findModeByExtension(${h.js(file.extension)}); |
|
133 | var detected_mode = CodeMirror.findModeByExtension(${h.js(file.extension)}); | |
134 |
|
134 | |||
135 | if (detected_mode){ |
|
135 | if (detected_mode){ | |
136 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
136 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
137 | $mimetype_select.val(detected_mode.mime); |
|
137 | $mimetype_select.val(detected_mode.mime); | |
138 | } |
|
138 | } | |
139 | }); |
|
139 | }); | |
140 | </script> |
|
140 | </script> | |
141 |
|
141 | |||
142 | %endfor |
|
142 | %endfor | |
143 |
|
143 | |||
144 | <div> |
|
144 | <div> | |
145 | ${h.submit('update',_('Update Gist'),class_="btn btn-success")} |
|
145 | ${h.submit('update',_('Update Gist'),class_="btn btn-success")} | |
146 | <a class="btn btn-default" href="${h.url('gist', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a> |
|
146 | <a class="btn btn-default" href="${h.url('gist', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a> | |
147 | </div> |
|
147 | </div> | |
148 | ${h.end_form()} |
|
148 | ${h.end_form()} | |
149 | <script> |
|
149 | <script> | |
150 | $('#update').on('click', function(e){ |
|
150 | $('#update').on('click', function(e){ | |
151 | e.preventDefault(); |
|
151 | e.preventDefault(); | |
152 |
|
152 | |||
153 | // check for newer version. |
|
153 | // check for newer version. | |
154 | $.ajax({ |
|
154 | $.ajax({ | |
155 | url: ${h.js(h.url('edit_gist_check_revision', gist_id=c.gist.gist_access_id))}, |
|
155 | url: ${h.js(h.url('edit_gist_check_revision', gist_id=c.gist.gist_access_id))}, | |
156 | data: {'revision': ${h.js(c.file_changeset.raw_id)}, '_authentication_token': _authentication_token}, |
|
156 | data: {'revision': ${h.js(c.file_changeset.raw_id)}, '_authentication_token': _authentication_token}, | |
157 | dataType: 'json', |
|
157 | dataType: 'json', | |
158 | type: 'POST', |
|
158 | type: 'POST', | |
159 | success: function(data) { |
|
159 | success: function(data) { | |
160 | if(data.success == false){ |
|
160 | if(data.success == false){ | |
161 | $('#edit_error').show(); |
|
161 | $('#edit_error').show(); | |
162 | } |
|
162 | } | |
163 | else{ |
|
163 | else{ | |
164 | $('#eform').submit(); |
|
164 | $('#eform').submit(); | |
165 | } |
|
165 | } | |
166 | } |
|
166 | } | |
167 | }); |
|
167 | }); | |
168 | }); |
|
168 | }); | |
169 | </script> |
|
169 | </script> | |
170 | </div> |
|
170 | </div> | |
171 | </div> |
|
171 | </div> | |
172 |
|
172 | |||
173 | </div> |
|
173 | </div> | |
174 | </%def> |
|
174 | </%def> |
@@ -1,112 +1,112 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="/base/base.html"/> |
|
2 | <%inherit file="/base/base.html"/> | |
3 |
|
3 | |||
4 | <%block name="title"> |
|
4 | <%block name="title"> | |
5 | ${_('New Gist')} |
|
5 | ${_('New Gist')} | |
6 | </%block> |
|
6 | </%block> | |
7 |
|
7 | |||
8 | <%block name="js_extra"> |
|
8 | <%block name="js_extra"> | |
9 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> |
|
9 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> | |
10 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> |
|
10 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> | |
11 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> |
|
11 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> | |
12 | </%block> |
|
12 | </%block> | |
13 | <%block name="css_extra"> |
|
13 | <%block name="css_extra"> | |
14 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> |
|
14 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> | |
15 | </%block> |
|
15 | </%block> | |
16 |
|
16 | |||
17 | <%def name="breadcrumbs_links()"> |
|
17 | <%def name="breadcrumbs_links()"> | |
18 | ${_('New Gist')} |
|
18 | ${_('New Gist')} | |
19 | </%def> |
|
19 | </%def> | |
20 |
|
20 | |||
21 | <%block name="header_menu"> |
|
21 | <%block name="header_menu"> | |
22 | ${self.menu('gists')} |
|
22 | ${self.menu('gists')} | |
23 | </%block> |
|
23 | </%block> | |
24 |
|
24 | |||
25 | <%def name="main()"> |
|
25 | <%def name="main()"> | |
26 | <div class="panel panel-primary"> |
|
26 | <div class="panel panel-primary"> | |
27 | <div class="panel-heading clearfix"> |
|
27 | <div class="panel-heading clearfix"> | |
28 | ${self.breadcrumbs()} |
|
28 | ${self.breadcrumbs()} | |
29 | </div> |
|
29 | </div> | |
30 |
|
30 | |||
31 | <div class="panel-body"> |
|
31 | <div class="panel-body"> | |
32 | <div id="files_data"> |
|
32 | <div id="files_data"> | |
33 | ${h.form(h.url('gists'), method='post',id='eform')} |
|
33 | ${h.form(h.url('gists'), method='post',id='eform')} | |
34 | <div> |
|
34 | <div> | |
35 |
<textarea class="form-control |
|
35 | <textarea class="form-control" id="description" name="description" placeholder="${_('Gist description ...')}"></textarea> | |
36 | <div> |
|
36 | <div> | |
37 | <label> |
|
37 | <label> | |
38 | ${_('Gist lifetime')} |
|
38 | ${_('Gist lifetime')} | |
39 | ${h.select('lifetime', '', c.lifetime_options)} |
|
39 | ${h.select('lifetime', '', c.lifetime_options)} | |
40 | </label> |
|
40 | </label> | |
41 | </div> |
|
41 | </div> | |
42 | </div> |
|
42 | </div> | |
43 | <div id="body" class="panel panel-default form-inline"> |
|
43 | <div id="body" class="panel panel-default form-inline"> | |
44 | <div class="panel-heading"> |
|
44 | <div class="panel-heading"> | |
45 | ${h.text('filename', size=30, placeholder=_('Name this gist ...'), class_='form-control')} |
|
45 | ${h.text('filename', size=30, placeholder=_('Name this gist ...'), class_='form-control')} | |
46 | <select class="form-control" id="mimetype" name="mimetype"></select> |
|
46 | <select class="form-control" id="mimetype" name="mimetype"></select> | |
47 | </div> |
|
47 | </div> | |
48 | <div class="panel-body no-padding"> |
|
48 | <div class="panel-body no-padding"> | |
49 | <textarea id="editor" name="content"></textarea> |
|
49 | <textarea id="editor" name="content"></textarea> | |
50 | </div> |
|
50 | </div> | |
51 | </div> |
|
51 | </div> | |
52 | <div> |
|
52 | <div> | |
53 | ${h.submit('private',_('Create Private Gist'),class_="btn btn-success btn-xs")} |
|
53 | ${h.submit('private',_('Create Private Gist'),class_="btn btn-success btn-xs")} | |
54 | ${h.submit('public',_('Create Public Gist'),class_="btn btn-default btn-xs")} |
|
54 | ${h.submit('public',_('Create Public Gist'),class_="btn btn-default btn-xs")} | |
55 | ${h.reset('reset',_('Reset'),class_="btn btn-default btn-xs")} |
|
55 | ${h.reset('reset',_('Reset'),class_="btn btn-default btn-xs")} | |
56 | </div> |
|
56 | </div> | |
57 | ${h.end_form()} |
|
57 | ${h.end_form()} | |
58 | <script type="text/javascript"> |
|
58 | <script type="text/javascript"> | |
59 | $(document).ready(function(){ |
|
59 | $(document).ready(function(){ | |
60 | var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, ''); |
|
60 | var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, ''); | |
61 |
|
61 | |||
62 | //inject new modes |
|
62 | //inject new modes | |
63 | var $mimetype_select = $('#mimetype'); |
|
63 | var $mimetype_select = $('#mimetype'); | |
64 | $mimetype_select.each(function(){ |
|
64 | $mimetype_select.each(function(){ | |
65 | var modes_select = this; |
|
65 | var modes_select = this; | |
66 | var index = 1; |
|
66 | var index = 1; | |
67 | for(var i=0;i<CodeMirror.modeInfo.length;i++) { |
|
67 | for(var i=0;i<CodeMirror.modeInfo.length;i++) { | |
68 | var m = CodeMirror.modeInfo[i]; |
|
68 | var m = CodeMirror.modeInfo[i]; | |
69 | var opt = new Option(m.name, m.mime); |
|
69 | var opt = new Option(m.name, m.mime); | |
70 | $(opt).attr('mode', m.mode); |
|
70 | $(opt).attr('mode', m.mode); | |
71 | if (m.mime == 'text/plain') { |
|
71 | if (m.mime == 'text/plain') { | |
72 | // default plain text |
|
72 | // default plain text | |
73 | $(opt).prop('selected', true); |
|
73 | $(opt).prop('selected', true); | |
74 | modes_select.options[0] = opt; |
|
74 | modes_select.options[0] = opt; | |
75 | } else { |
|
75 | } else { | |
76 | modes_select.options[index++] = opt; |
|
76 | modes_select.options[index++] = opt; | |
77 | } |
|
77 | } | |
78 | } |
|
78 | } | |
79 | }); |
|
79 | }); | |
80 |
|
80 | |||
81 | var $filename_input = $('#filename'); |
|
81 | var $filename_input = $('#filename'); | |
82 | // on select change set new mode |
|
82 | // on select change set new mode | |
83 | $mimetype_select.change(function(e){ |
|
83 | $mimetype_select.change(function(e){ | |
84 | var selected = e.currentTarget; |
|
84 | var selected = e.currentTarget; | |
85 | var node = selected.options[selected.selectedIndex]; |
|
85 | var node = selected.options[selected.selectedIndex]; | |
86 | var detected_mode = CodeMirror.findModeByMIME(node.value); |
|
86 | var detected_mode = CodeMirror.findModeByMIME(node.value); | |
87 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
87 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
88 |
|
88 | |||
89 | var proposed_ext = CodeMirror.findExtensionByMode(detected_mode); |
|
89 | var proposed_ext = CodeMirror.findExtensionByMode(detected_mode); | |
90 | var file_data = CodeMirror.getFilenameAndExt($filename_input.val()); |
|
90 | var file_data = CodeMirror.getFilenameAndExt($filename_input.val()); | |
91 | var filename = file_data['filename'] || 'filename1'; |
|
91 | var filename = file_data['filename'] || 'filename1'; | |
92 | $filename_input.val(filename + '.' + proposed_ext); |
|
92 | $filename_input.val(filename + '.' + proposed_ext); | |
93 | }); |
|
93 | }); | |
94 |
|
94 | |||
95 | // on type the new filename set mode |
|
95 | // on type the new filename set mode | |
96 | $filename_input.keyup(function(e){ |
|
96 | $filename_input.keyup(function(e){ | |
97 | var file_data = CodeMirror.getFilenameAndExt(this.value); |
|
97 | var file_data = CodeMirror.getFilenameAndExt(this.value); | |
98 | if(file_data['ext'] != null){ |
|
98 | if(file_data['ext'] != null){ | |
99 | var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain'); |
|
99 | var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain'); | |
100 | if (detected_mode){ |
|
100 | if (detected_mode){ | |
101 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
101 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
102 | $mimetype_select.val(detected_mode.mime); |
|
102 | $mimetype_select.val(detected_mode.mime); | |
103 | } |
|
103 | } | |
104 | } |
|
104 | } | |
105 | }); |
|
105 | }); | |
106 | }); |
|
106 | }); | |
107 | </script> |
|
107 | </script> | |
108 | </div> |
|
108 | </div> | |
109 | </div> |
|
109 | </div> | |
110 |
|
110 | |||
111 | </div> |
|
111 | </div> | |
112 | </%def> |
|
112 | </%def> |
@@ -1,125 +1,125 b'' | |||||
1 | <%inherit file="/base/base.html"/> |
|
1 | <%inherit file="/base/base.html"/> | |
2 |
|
2 | |||
3 | <%block name="title"> |
|
3 | <%block name="title"> | |
4 | ${_('%s Files Add') % c.repo_name} |
|
4 | ${_('%s Files Add') % c.repo_name} | |
5 | </%block> |
|
5 | </%block> | |
6 |
|
6 | |||
7 | <%block name="js_extra"> |
|
7 | <%block name="js_extra"> | |
8 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> |
|
8 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> | |
9 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> |
|
9 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> | |
10 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> |
|
10 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> | |
11 | </%block> |
|
11 | </%block> | |
12 | <%block name="css_extra"> |
|
12 | <%block name="css_extra"> | |
13 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> |
|
13 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> | |
14 | </%block> |
|
14 | </%block> | |
15 |
|
15 | |||
16 | <%block name="header_menu"> |
|
16 | <%block name="header_menu"> | |
17 | ${self.menu('repositories')} |
|
17 | ${self.menu('repositories')} | |
18 | </%block> |
|
18 | </%block> | |
19 |
|
19 | |||
20 | <%def name="breadcrumbs_links()"> |
|
20 | <%def name="breadcrumbs_links()"> | |
21 | ${_('Add New File')} @ ${h.show_id(c.cs)} |
|
21 | ${_('Add New File')} @ ${h.show_id(c.cs)} | |
22 | </%def> |
|
22 | </%def> | |
23 |
|
23 | |||
24 | <%def name="main()"> |
|
24 | <%def name="main()"> | |
25 | ${self.repo_context_bar('files')} |
|
25 | ${self.repo_context_bar('files')} | |
26 | <div class="panel panel-primary"> |
|
26 | <div class="panel panel-primary"> | |
27 | <div class="panel-heading clearfix"> |
|
27 | <div class="panel-heading clearfix"> | |
28 | <div class="pull-left"> |
|
28 | <div class="pull-left"> | |
29 | ${self.breadcrumbs()} |
|
29 | ${self.breadcrumbs()} | |
30 | </div> |
|
30 | </div> | |
31 | <div class="pull-right"> |
|
31 | <div class="pull-right"> | |
32 | <a href="#">${_('Branch')}: ${c.cs.branch}</a> |
|
32 | <a href="#">${_('Branch')}: ${c.cs.branch}</a> | |
33 | </div> |
|
33 | </div> | |
34 | </div> |
|
34 | </div> | |
35 | <div class="panel-body" id="edit"> |
|
35 | <div class="panel-body" id="edit"> | |
36 | <div id="files_data"> |
|
36 | <div id="files_data"> | |
37 | ${h.form(h.url.current(),method='post',id='eform',enctype="multipart/form-data", class_="form-inline")} |
|
37 | ${h.form(h.url.current(),method='post',id='eform',enctype="multipart/form-data", class_="form-inline")} | |
38 | <h3 class="files_location"> |
|
38 | <h3 class="files_location"> | |
39 | ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.f_path)} / |
|
39 | ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.f_path)} / | |
40 | <span id="filename_container" class="file"> |
|
40 | <span id="filename_container" class="file"> | |
41 | <input class="form-control input-small" type="text" value="" size="30" name="filename" id="filename" placeholder="${_('Enter filename...')}"> |
|
41 | <input class="form-control input-small" type="text" value="" size="30" name="filename" id="filename" placeholder="${_('Enter filename...')}"> | |
42 | <input type="hidden" value="${c.f_path}" name="location" id="location"> |
|
42 | <input type="hidden" value="${c.f_path}" name="location" id="location"> | |
43 | ${_('or')} <button type="button" class="btn btn-default btn-sm" id="upload_file_enable">${_('Upload File')}</button> |
|
43 | ${_('or')} <button type="button" class="btn btn-default btn-sm" id="upload_file_enable">${_('Upload File')}</button> | |
44 | </span> |
|
44 | </span> | |
45 | <span id="upload_file_container" style="display:none"> |
|
45 | <span id="upload_file_container" style="display:none"> | |
46 | <input class="form-control" type="file" size="20" name="upload_file" id="upload_file"> |
|
46 | <input class="form-control" type="file" size="20" name="upload_file" id="upload_file"> | |
47 | ${_('or')} <button type="button" class="btn btn-default btn-sm" id="file_enable">${_('Create New File')}</button> |
|
47 | ${_('or')} <button type="button" class="btn btn-default btn-sm" id="file_enable">${_('Create New File')}</button> | |
48 | </span> |
|
48 | </span> | |
49 | </h3> |
|
49 | </h3> | |
50 | <div id="body" class="panel panel-default"> |
|
50 | <div id="body" class="panel panel-default"> | |
51 | <div class="panel-heading clearfix"> |
|
51 | <div class="panel-heading clearfix"> | |
52 | <div class="pull-left"> |
|
52 | <div class="pull-left"> | |
53 | <label>${_('New file type')} |
|
53 | <label>${_('New file type')} | |
54 | <select class="form-control" id="mimetype" name="mimetype"></select> |
|
54 | <select class="form-control" id="mimetype" name="mimetype"></select> | |
55 | </label> |
|
55 | </label> | |
56 | </div> |
|
56 | </div> | |
57 | </div> |
|
57 | </div> | |
58 | <div class="panel-body no-padding"> |
|
58 | <div class="panel-body no-padding"> | |
59 | <textarea id="editor" name="content" style="display:none"></textarea> |
|
59 | <textarea id="editor" name="content" style="display:none"></textarea> | |
60 | </div> |
|
60 | </div> | |
61 | </div> |
|
61 | </div> | |
62 | <div> |
|
62 | <div> | |
63 | <div> |
|
63 | <div> | |
64 | <div>${_('Commit Message')}</div> |
|
64 | <div>${_('Commit Message')}</div> | |
65 |
<textarea class="form-control |
|
65 | <textarea class="form-control" name="message" placeholder="${c.default_message}"></textarea> | |
66 | </div> |
|
66 | </div> | |
67 | <div class="buttons"> |
|
67 | <div class="buttons"> | |
68 | ${h.submit('commit',_('Commit Changes'),class_="btn btn-success")} |
|
68 | ${h.submit('commit',_('Commit Changes'),class_="btn btn-success")} | |
69 | ${h.reset('reset',_('Reset'),class_="btn btn-default")} |
|
69 | ${h.reset('reset',_('Reset'),class_="btn btn-default")} | |
70 | </div> |
|
70 | </div> | |
71 | </div> |
|
71 | </div> | |
72 | ${h.end_form()} |
|
72 | ${h.end_form()} | |
73 | <script type="text/javascript"> |
|
73 | <script type="text/javascript"> | |
74 | $(document).ready(function(){ |
|
74 | $(document).ready(function(){ | |
75 | var reset_url = ${h.jshtml(h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path))}; |
|
75 | var reset_url = ${h.jshtml(h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path))}; | |
76 | var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, reset_url); |
|
76 | var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, reset_url); | |
77 |
|
77 | |||
78 | //inject new modes, based on codeMirrors modeInfo object |
|
78 | //inject new modes, based on codeMirrors modeInfo object | |
79 | var $mimetype_select = $('#mimetype'); |
|
79 | var $mimetype_select = $('#mimetype'); | |
80 | $mimetype_select.each(function(){ |
|
80 | $mimetype_select.each(function(){ | |
81 | var modes_select = this; |
|
81 | var modes_select = this; | |
82 | var index = 1; |
|
82 | var index = 1; | |
83 | for(var i=0;i<CodeMirror.modeInfo.length;i++){ |
|
83 | for(var i=0;i<CodeMirror.modeInfo.length;i++){ | |
84 | var m = CodeMirror.modeInfo[i]; |
|
84 | var m = CodeMirror.modeInfo[i]; | |
85 | var opt = new Option(m.name, m.mime); |
|
85 | var opt = new Option(m.name, m.mime); | |
86 | $(opt).attr('mode', m.mode); |
|
86 | $(opt).attr('mode', m.mode); | |
87 | if (m.mime == 'text/plain') { |
|
87 | if (m.mime == 'text/plain') { | |
88 | // default plain text |
|
88 | // default plain text | |
89 | $(opt).prop('selected', true); |
|
89 | $(opt).prop('selected', true); | |
90 | modes_select.options[0] = opt; |
|
90 | modes_select.options[0] = opt; | |
91 | } else { |
|
91 | } else { | |
92 | modes_select.options[index++] = opt; |
|
92 | modes_select.options[index++] = opt; | |
93 | } |
|
93 | } | |
94 | } |
|
94 | } | |
95 | }); |
|
95 | }); | |
96 | var $filename_input = $('#filename'); |
|
96 | var $filename_input = $('#filename'); | |
97 | $mimetype_select.change(function(e){ |
|
97 | $mimetype_select.change(function(e){ | |
98 | var selected = e.currentTarget; |
|
98 | var selected = e.currentTarget; | |
99 | var node = selected.options[selected.selectedIndex]; |
|
99 | var node = selected.options[selected.selectedIndex]; | |
100 | var detected_mode = CodeMirror.findModeByMIME(node.value); |
|
100 | var detected_mode = CodeMirror.findModeByMIME(node.value); | |
101 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
101 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
102 |
|
102 | |||
103 | var proposed_ext = CodeMirror.findExtensionByMode(detected_mode); |
|
103 | var proposed_ext = CodeMirror.findExtensionByMode(detected_mode); | |
104 | var file_data = CodeMirror.getFilenameAndExt($filename_input.val()); |
|
104 | var file_data = CodeMirror.getFilenameAndExt($filename_input.val()); | |
105 | var filename = file_data['filename'] || 'filename1'; |
|
105 | var filename = file_data['filename'] || 'filename1'; | |
106 | $filename_input.val(filename + '.' + proposed_ext); |
|
106 | $filename_input.val(filename + '.' + proposed_ext); | |
107 | }); |
|
107 | }); | |
108 |
|
108 | |||
109 | // on type the new filename set mode |
|
109 | // on type the new filename set mode | |
110 | $filename_input.keyup(function(e){ |
|
110 | $filename_input.keyup(function(e){ | |
111 | var file_data = CodeMirror.getFilenameAndExt(this.value); |
|
111 | var file_data = CodeMirror.getFilenameAndExt(this.value); | |
112 | if(file_data['ext'] != null){ |
|
112 | if(file_data['ext'] != null){ | |
113 | var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain'); |
|
113 | var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain'); | |
114 | if (detected_mode){ |
|
114 | if (detected_mode){ | |
115 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
115 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
116 | $mimetype_select.val(detected_mode.mime); |
|
116 | $mimetype_select.val(detected_mode.mime); | |
117 | } |
|
117 | } | |
118 | } |
|
118 | } | |
119 | }); |
|
119 | }); | |
120 | }); |
|
120 | }); | |
121 | </script> |
|
121 | </script> | |
122 | </div> |
|
122 | </div> | |
123 | </div> |
|
123 | </div> | |
124 | </div> |
|
124 | </div> | |
125 | </%def> |
|
125 | </%def> |
@@ -1,47 +1,47 b'' | |||||
1 | <%inherit file="/base/base.html"/> |
|
1 | <%inherit file="/base/base.html"/> | |
2 |
|
2 | |||
3 | <%block name="title"> |
|
3 | <%block name="title"> | |
4 | ${_('%s Files Delete') % c.repo_name} |
|
4 | ${_('%s Files Delete') % c.repo_name} | |
5 | </%block> |
|
5 | </%block> | |
6 |
|
6 | |||
7 | <%block name="header_menu"> |
|
7 | <%block name="header_menu"> | |
8 | ${self.menu('repositories')} |
|
8 | ${self.menu('repositories')} | |
9 | </%block> |
|
9 | </%block> | |
10 |
|
10 | |||
11 | <%def name="breadcrumbs_links()"> |
|
11 | <%def name="breadcrumbs_links()"> | |
12 | ${_('Delete file')} @ ${h.show_id(c.cs)} |
|
12 | ${_('Delete file')} @ ${h.show_id(c.cs)} | |
13 | </%def> |
|
13 | </%def> | |
14 |
|
14 | |||
15 | <%def name="main()"> |
|
15 | <%def name="main()"> | |
16 | ${self.repo_context_bar('files')} |
|
16 | ${self.repo_context_bar('files')} | |
17 | <div class="panel panel-primary"> |
|
17 | <div class="panel panel-primary"> | |
18 | <div class="panel-heading clearfix"> |
|
18 | <div class="panel-heading clearfix"> | |
19 | <div class="pull-left"> |
|
19 | <div class="pull-left"> | |
20 | ${self.breadcrumbs()} |
|
20 | ${self.breadcrumbs()} | |
21 | </div> |
|
21 | </div> | |
22 | <div class="pull-right"> |
|
22 | <div class="pull-right"> | |
23 | <a href="#">${_('Branch')}: ${c.cs.branch}</a> |
|
23 | <a href="#">${_('Branch')}: ${c.cs.branch}</a> | |
24 | </div> |
|
24 | </div> | |
25 | </div> |
|
25 | </div> | |
26 | <div class="panel-body" id="edit"> |
|
26 | <div class="panel-body" id="edit"> | |
27 | <div id="files_data"> |
|
27 | <div id="files_data"> | |
28 | ${h.form(h.url.current(),method='post')} |
|
28 | ${h.form(h.url.current(),method='post')} | |
29 | <h3 class="files_location"> |
|
29 | <h3 class="files_location"> | |
30 | ${_('Delete file')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.f_path)} |
|
30 | ${_('Delete file')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.f_path)} | |
31 | </h3> |
|
31 | </h3> | |
32 |
|
32 | |||
33 | <div id="body" class="panel panel-default"> |
|
33 | <div id="body" class="panel panel-default"> | |
34 | <div class="panel-heading">${_('Commit Message')}</div> |
|
34 | <div class="panel-heading">${_('Commit Message')}</div> | |
35 | <div class="panel-body"> |
|
35 | <div class="panel-body"> | |
36 |
<textarea class="form-control |
|
36 | <textarea class="form-control" name="message" placeholder="${c.default_message}"></textarea> | |
37 | </div> |
|
37 | </div> | |
38 | </div> |
|
38 | </div> | |
39 | <div> |
|
39 | <div> | |
40 | ${h.submit('commit',_('Commit Changes'),class_="btn btn-success btn-sm")} |
|
40 | ${h.submit('commit',_('Commit Changes'),class_="btn btn-success btn-sm")} | |
41 | ${h.reset('reset',_('Reset'),class_="btn btn-default btn-sm")} |
|
41 | ${h.reset('reset',_('Reset'),class_="btn btn-default btn-sm")} | |
42 | </div> |
|
42 | </div> | |
43 | ${h.end_form()} |
|
43 | ${h.end_form()} | |
44 | </div> |
|
44 | </div> | |
45 | </div> |
|
45 | </div> | |
46 | </div> |
|
46 | </div> | |
47 | </%def> |
|
47 | </%def> |
@@ -1,118 +1,118 b'' | |||||
1 | <%inherit file="/base/base.html"/> |
|
1 | <%inherit file="/base/base.html"/> | |
2 |
|
2 | |||
3 | <%block name="title"> |
|
3 | <%block name="title"> | |
4 | ${_('%s File Edit') % c.repo_name} |
|
4 | ${_('%s File Edit') % c.repo_name} | |
5 | </%block> |
|
5 | </%block> | |
6 |
|
6 | |||
7 | <%block name="js_extra"> |
|
7 | <%block name="js_extra"> | |
8 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> |
|
8 | <script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script> | |
9 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> |
|
9 | <script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script> | |
10 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> |
|
10 | <script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script> | |
11 | </%block> |
|
11 | </%block> | |
12 | <%block name="css_extra"> |
|
12 | <%block name="css_extra"> | |
13 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> |
|
13 | <link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/> | |
14 | </%block> |
|
14 | </%block> | |
15 |
|
15 | |||
16 | <%block name="header_menu"> |
|
16 | <%block name="header_menu"> | |
17 | ${self.menu('repositories')} |
|
17 | ${self.menu('repositories')} | |
18 | </%block> |
|
18 | </%block> | |
19 |
|
19 | |||
20 | <%def name="breadcrumbs_links()"> |
|
20 | <%def name="breadcrumbs_links()"> | |
21 | ${_('Edit file')} @ ${h.show_id(c.cs)} |
|
21 | ${_('Edit file')} @ ${h.show_id(c.cs)} | |
22 | </%def> |
|
22 | </%def> | |
23 |
|
23 | |||
24 | <%def name="main()"> |
|
24 | <%def name="main()"> | |
25 | ${self.repo_context_bar('files')} |
|
25 | ${self.repo_context_bar('files')} | |
26 | <div class="panel panel-primary"> |
|
26 | <div class="panel panel-primary"> | |
27 | <div class="panel-heading clearfix"> |
|
27 | <div class="panel-heading clearfix"> | |
28 | <div class="pull-left"> |
|
28 | <div class="pull-left"> | |
29 | ${self.breadcrumbs()} |
|
29 | ${self.breadcrumbs()} | |
30 | </div> |
|
30 | </div> | |
31 | <div class="pull-right"> |
|
31 | <div class="pull-right"> | |
32 | <a href="#">${_('Branch')}: ${c.cs.branch}</a> |
|
32 | <a href="#">${_('Branch')}: ${c.cs.branch}</a> | |
33 | </div> |
|
33 | </div> | |
34 | </div> |
|
34 | </div> | |
35 | <div class="panel-body" id="edit"> |
|
35 | <div class="panel-body" id="edit"> | |
36 | <div id="files_data"> |
|
36 | <div id="files_data"> | |
37 | ${h.form(h.url.current(),method='post',id='eform')} |
|
37 | ${h.form(h.url.current(),method='post',id='eform')} | |
38 | <h3 class="files_location"> |
|
38 | <h3 class="files_location"> | |
39 | ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.file.path)} |
|
39 | ${_('Location')}: ${h.files_breadcrumbs(c.repo_name,c.cs.raw_id,c.file.path)} | |
40 | </h3> |
|
40 | </h3> | |
41 | <div id="body" class="panel panel-default"> |
|
41 | <div id="body" class="panel panel-default"> | |
42 | <div class="panel-heading clearfix form-inline form-group-sm"> |
|
42 | <div class="panel-heading clearfix form-inline form-group-sm"> | |
43 | <span> |
|
43 | <span> | |
44 | <span><i class="icon-doc-inv"></i></span> |
|
44 | <span><i class="icon-doc-inv"></i></span> | |
45 | <span>${h.link_to(h.show_id(c.file.changeset),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id))}</span> |
|
45 | <span>${h.link_to(h.show_id(c.file.changeset),h.url('changeset_home',repo_name=c.repo_name,revision=c.file.changeset.raw_id))}</span> | |
46 | <span>${h.format_byte_size(c.file.size,binary=True)}</span> |
|
46 | <span>${h.format_byte_size(c.file.size,binary=True)}</span> | |
47 | <span>${c.file.mimetype}</span> |
|
47 | <span>${c.file.mimetype}</span> | |
48 | <select class="form-control" id="mimetype" name="mimetype"></select> |
|
48 | <select class="form-control" id="mimetype" name="mimetype"></select> | |
49 | </span> |
|
49 | </span> | |
50 | <span class="pull-right buttons"> |
|
50 | <span class="pull-right buttons"> | |
51 | ${h.link_to(_('Show Annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} |
|
51 | ${h.link_to(_('Show Annotation'),h.url('files_annotate_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} | |
52 | ${h.link_to(_('Show as Raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} |
|
52 | ${h.link_to(_('Show as Raw'),h.url('files_raw_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} | |
53 | ${h.link_to(_('Download as Raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} |
|
53 | ${h.link_to(_('Download as Raw'),h.url('files_rawfile_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} | |
54 | % if h.HasRepoPermissionLevel('write')(c.repo_name): |
|
54 | % if h.HasRepoPermissionLevel('write')(c.repo_name): | |
55 | % if not c.file.is_binary: |
|
55 | % if not c.file.is_binary: | |
56 | ${h.link_to(_('Source'),h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} |
|
56 | ${h.link_to(_('Source'),h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")} | |
57 | % endif |
|
57 | % endif | |
58 | % endif |
|
58 | % endif | |
59 | </span> |
|
59 | </span> | |
60 | </div> |
|
60 | </div> | |
61 | <div class="panel-body no-padding"> |
|
61 | <div class="panel-body no-padding"> | |
62 | <textarea id="editor" name="content" style="display:none">${h.escape(c.file.content)|n}</textarea> |
|
62 | <textarea id="editor" name="content" style="display:none">${h.escape(c.file.content)|n}</textarea> | |
63 | </div> |
|
63 | </div> | |
64 | </div> |
|
64 | </div> | |
65 | <div> |
|
65 | <div> | |
66 | <div class="form-group"> |
|
66 | <div class="form-group"> | |
67 | <label>${_('Commit Message')}</label> |
|
67 | <label>${_('Commit Message')}</label> | |
68 |
<textarea class="form-control |
|
68 | <textarea class="form-control" id="commit" name="message" placeholder="${c.default_message}"></textarea> | |
69 | </div> |
|
69 | </div> | |
70 | <div class="form-group buttons"> |
|
70 | <div class="form-group buttons"> | |
71 | ${h.submit('commit',_('Commit Changes'),class_="btn btn-success")} |
|
71 | ${h.submit('commit',_('Commit Changes'),class_="btn btn-success")} | |
72 | ${h.reset('reset',_('Reset'),class_="btn btn-default")} |
|
72 | ${h.reset('reset',_('Reset'),class_="btn btn-default")} | |
73 | </div> |
|
73 | </div> | |
74 | </div> |
|
74 | </div> | |
75 | ${h.end_form()} |
|
75 | ${h.end_form()} | |
76 | </div> |
|
76 | </div> | |
77 | </div> |
|
77 | </div> | |
78 | </div> |
|
78 | </div> | |
79 |
|
79 | |||
80 | <script type="text/javascript"> |
|
80 | <script type="text/javascript"> | |
81 | $(document).ready(function(){ |
|
81 | $(document).ready(function(){ | |
82 | var reset_url = ${h.jshtml(h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.file.path))}; |
|
82 | var reset_url = ${h.jshtml(h.url('files_home',repo_name=c.repo_name,revision=c.cs.raw_id,f_path=c.file.path))}; | |
83 | var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, reset_url); |
|
83 | var myCodeMirror = initCodeMirror('editor', ${h.jshtml(request.script_name)}, reset_url); | |
84 |
|
84 | |||
85 | //inject new modes, based on codeMirrors modeInfo object |
|
85 | //inject new modes, based on codeMirrors modeInfo object | |
86 | var $mimetype_select = $('#mimetype'); |
|
86 | var $mimetype_select = $('#mimetype'); | |
87 | $mimetype_select.each(function(){ |
|
87 | $mimetype_select.each(function(){ | |
88 | var modes_select = this; |
|
88 | var modes_select = this; | |
89 | var index = 1; |
|
89 | var index = 1; | |
90 | for(var i=0;i<CodeMirror.modeInfo.length;i++){ |
|
90 | for(var i=0;i<CodeMirror.modeInfo.length;i++){ | |
91 | var m = CodeMirror.modeInfo[i]; |
|
91 | var m = CodeMirror.modeInfo[i]; | |
92 | var opt = new Option(m.name, m.mime); |
|
92 | var opt = new Option(m.name, m.mime); | |
93 | $(opt).attr('mode', m.mode); |
|
93 | $(opt).attr('mode', m.mode); | |
94 | if (m.mime == 'text/plain') { |
|
94 | if (m.mime == 'text/plain') { | |
95 | // default plain text |
|
95 | // default plain text | |
96 | $(opt).prop('selected', true); |
|
96 | $(opt).prop('selected', true); | |
97 | modes_select.options[0] = opt; |
|
97 | modes_select.options[0] = opt; | |
98 | } else { |
|
98 | } else { | |
99 | modes_select.options[index++] = opt; |
|
99 | modes_select.options[index++] = opt; | |
100 | } |
|
100 | } | |
101 | } |
|
101 | } | |
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 = CodeMirror.findModeByExtension(${h.js(c.file.extension)}); |
|
104 | var detected_mode = CodeMirror.findModeByExtension(${h.js(c.file.extension)}); | |
105 | if(detected_mode){ |
|
105 | if(detected_mode){ | |
106 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
106 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
107 | $($mimetype_select.find('option[value="'+detected_mode.mime+'"]')[0]).prop('selected', true); |
|
107 | $($mimetype_select.find('option[value="'+detected_mode.mime+'"]')[0]).prop('selected', true); | |
108 | } |
|
108 | } | |
109 |
|
109 | |||
110 | $mimetype_select.on('change', function(e){ |
|
110 | $mimetype_select.on('change', function(e){ | |
111 | var selected = e.currentTarget; |
|
111 | var selected = e.currentTarget; | |
112 | var node = selected.options[selected.selectedIndex]; |
|
112 | var node = selected.options[selected.selectedIndex]; | |
113 | var detected_mode = CodeMirror.findModeByMIME(node.value); |
|
113 | var detected_mode = CodeMirror.findModeByMIME(node.value); | |
114 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
114 | setCodeMirrorMode(myCodeMirror, detected_mode); | |
115 | }); |
|
115 | }); | |
116 | }); |
|
116 | }); | |
117 | </script> |
|
117 | </script> | |
118 | </%def> |
|
118 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now