Show More
@@ -1,238 +1,238 b'' | |||
|
1 | 1 | <%inherit file="/base/base.mako"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('%s Files Add') % c.repo_name} |
|
5 | 5 | %if c.rhodecode_name: |
|
6 | 6 | · ${h.branding(c.rhodecode_name)} |
|
7 | 7 | %endif |
|
8 | 8 | </%def> |
|
9 | 9 | |
|
10 | 10 | <%def name="menu_bar_nav()"> |
|
11 | 11 | ${self.menu_items(active='repositories')} |
|
12 | 12 | </%def> |
|
13 | 13 | |
|
14 | 14 | <%def name="breadcrumbs_links()"> |
|
15 | 15 | ${_('Add new file')} @ ${h.show_id(c.commit)} |
|
16 | 16 | </%def> |
|
17 | 17 | |
|
18 | 18 | <%def name="menu_bar_subnav()"> |
|
19 | 19 | ${self.repo_menu(active='files')} |
|
20 | 20 | </%def> |
|
21 | 21 | |
|
22 | 22 | <%def name="main()"> |
|
23 | 23 | <div class="box"> |
|
24 | 24 | <div class="title"> |
|
25 | 25 | ${self.repo_page_title(c.rhodecode_db_repo)} |
|
26 | 26 | </div> |
|
27 | 27 | <div class="edit-file-title"> |
|
28 | 28 | ${self.breadcrumbs()} |
|
29 | 29 | </div> |
|
30 | ${h.secure_form(h.route_path('repo_files_create_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path), id='eform', method='POST', enctype="multipart/form-data", class_="form-horizontal")} | |
|
30 | ${h.secure_form(h.route_path('repo_files_create_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path), id='eform', method='POST', enctype="multipart/form-data", class_="form-horizontal", request=request)} | |
|
31 | 31 | <div class="edit-file-fieldset"> |
|
32 | 32 | <div class="fieldset"> |
|
33 | 33 | <div id="destination-label" class="left-label"> |
|
34 | 34 | ${_('Path')}: |
|
35 | 35 | </div> |
|
36 | 36 | <div class="right-content"> |
|
37 | 37 | <div id="specify-custom-path-container"> |
|
38 | 38 | <span id="path-breadcrumbs">${h.files_breadcrumbs(c.repo_name,c.commit.raw_id,c.f_path)}</span> |
|
39 | 39 | <a class="custom-path-link" id="specify-custom-path" href="#">${_('Specify Custom Path')}</a> |
|
40 | 40 | </div> |
|
41 | 41 | <div id="remove-custom-path-container" style="display: none;"> |
|
42 | 42 | ${c.repo_name}/ |
|
43 | 43 | <input type="input-small" value="${c.f_path}" size="46" name="location" id="location"> |
|
44 | 44 | <a class="custom-path-link" id="remove-custom-path" href="#">${_('Remove Custom Path')}</a> |
|
45 | 45 | </div> |
|
46 | 46 | </div> |
|
47 | 47 | </div> |
|
48 | 48 | <div id="filename_container" class="fieldset"> |
|
49 | 49 | <div class="filename-label left-label"> |
|
50 | 50 | ${_('Filename')}: |
|
51 | 51 | </div> |
|
52 | 52 | <div class="right-content"> |
|
53 | 53 | <input class="input-small" type="text" value="" size="46" name="filename" id="filename"> |
|
54 | 54 | <p>${_('or')} <a id="upload_file_enable" href="#">${_('Upload File')}</a></p> |
|
55 | 55 | </div> |
|
56 | 56 | </div> |
|
57 | 57 | <div id="upload_file_container" class="fieldset" style="display: none;"> |
|
58 | 58 | <div class="filename-label left-label"> |
|
59 | 59 | ${_('Filename')}: |
|
60 | 60 | </div> |
|
61 | 61 | <div class="right-content"> |
|
62 | 62 | <input class="input-small" type="text" value="" size="46" name="filename_upload" id="filename_upload" placeholder="${_('No file selected')}"> |
|
63 | 63 | </div> |
|
64 | 64 | <div class="filename-label left-label file-upload-label"> |
|
65 | 65 | ${_('Upload file')}: |
|
66 | 66 | </div> |
|
67 | 67 | <div class="right-content file-upload-input"> |
|
68 | 68 | <label for="upload_file" class="btn btn-default">Browse</label> |
|
69 | 69 | |
|
70 | 70 | <input type="file" name="upload_file" id="upload_file"> |
|
71 | 71 | <p>${_('or')} <a id="file_enable" href="#">${_('Create New File')}</a></p> |
|
72 | 72 | </div> |
|
73 | 73 | </div> |
|
74 | 74 | </div> |
|
75 | 75 | <div class="table"> |
|
76 | 76 | <div id="files_data"> |
|
77 | 77 | <div id="codeblock" class="codeblock"> |
|
78 | 78 | <div class="code-header form" id="set_mode_header"> |
|
79 | 79 | <div class="fields"> |
|
80 | 80 | ${h.dropdownmenu('set_mode','plain',[('plain',_('plain'))],enable_filter=True)} |
|
81 | 81 | <label for="line_wrap">${_('line wraps')}</label> |
|
82 | 82 | ${h.dropdownmenu('line_wrap', 'off', [('on', _('on')), ('off', _('off')),])} |
|
83 | 83 | |
|
84 | 84 | <div id="render_preview" class="btn btn-small preview hidden" >${_('Preview')}</div> |
|
85 | 85 | </div> |
|
86 | 86 | </div> |
|
87 | 87 | <div id="editor_container"> |
|
88 | 88 | <pre id="editor_pre"></pre> |
|
89 | 89 | <textarea id="editor" name="content" ></textarea> |
|
90 | 90 | <div id="editor_preview"></div> |
|
91 | 91 | </div> |
|
92 | 92 | </div> |
|
93 | 93 | </div> |
|
94 | 94 | </div> |
|
95 | 95 | |
|
96 | 96 | <div class="edit-file-fieldset"> |
|
97 | 97 | <div class="fieldset"> |
|
98 | 98 | <div id="commit-message-label" class="commit-message-label left-label"> |
|
99 | 99 | ${_('Commit Message')}: |
|
100 | 100 | </div> |
|
101 | 101 | <div class="right-content"> |
|
102 | 102 | <div class="message"> |
|
103 | 103 | <textarea id="commit" name="message" placeholder="${c.default_message}"></textarea> |
|
104 | 104 | </div> |
|
105 | 105 | </div> |
|
106 | 106 | </div> |
|
107 | 107 | <div class="pull-right"> |
|
108 | 108 | ${h.reset('reset',_('Cancel'),class_="btn btn-small")} |
|
109 | 109 | ${h.submit('commit_btn',_('Commit changes'),class_="btn btn-small btn-success")} |
|
110 | 110 | </div> |
|
111 | 111 | </div> |
|
112 | 112 | ${h.end_form()} |
|
113 | 113 | </div> |
|
114 | 114 | <script type="text/javascript"> |
|
115 | 115 | |
|
116 | 116 | $('#commit_btn').on('click', function() { |
|
117 | 117 | var button = $(this); |
|
118 | 118 | if (button.hasClass('clicked')) { |
|
119 | 119 | button.attr('disabled', true); |
|
120 | 120 | } else { |
|
121 | 121 | button.addClass('clicked'); |
|
122 | 122 | } |
|
123 | 123 | }); |
|
124 | 124 | |
|
125 | 125 | $('#specify-custom-path').on('click', function(e){ |
|
126 | 126 | e.preventDefault(); |
|
127 | 127 | $('#specify-custom-path-container').hide(); |
|
128 | 128 | $('#remove-custom-path-container').show(); |
|
129 | 129 | $('#destination-label').css('margin-top', '13px'); |
|
130 | 130 | }); |
|
131 | 131 | |
|
132 | 132 | $('#remove-custom-path').on('click', function(e){ |
|
133 | 133 | e.preventDefault(); |
|
134 | 134 | $('#specify-custom-path-container').show(); |
|
135 | 135 | $('#remove-custom-path-container').hide(); |
|
136 | 136 | $('#location').val('${c.f_path}'); |
|
137 | 137 | $('#destination-label').css('margin-top', '0'); |
|
138 | 138 | }); |
|
139 | 139 | |
|
140 | 140 | var hide_upload = function(){ |
|
141 | 141 | $('#files_data').show(); |
|
142 | 142 | $('#upload_file_container').hide(); |
|
143 | 143 | $('#filename_container').show(); |
|
144 | 144 | }; |
|
145 | 145 | |
|
146 | 146 | $('#file_enable').on('click', function(e){ |
|
147 | 147 | e.preventDefault(); |
|
148 | 148 | hide_upload(); |
|
149 | 149 | }); |
|
150 | 150 | |
|
151 | 151 | $('#upload_file_enable').on('click', function(e){ |
|
152 | 152 | e.preventDefault(); |
|
153 | 153 | $('#files_data').hide(); |
|
154 | 154 | $('#upload_file_container').show(); |
|
155 | 155 | $('#filename_container').hide(); |
|
156 | 156 | if (detectIE() && detectIE() <= 9) { |
|
157 | 157 | $('#upload_file_container .file-upload-input label').hide(); |
|
158 | 158 | $('#upload_file_container .file-upload-input span').hide(); |
|
159 | 159 | $('#upload_file_container .file-upload-input input').show(); |
|
160 | 160 | } |
|
161 | 161 | }); |
|
162 | 162 | |
|
163 | 163 | $('#upload_file').on('change', function() { |
|
164 | 164 | if (this.files && this.files[0]) { |
|
165 | 165 | $('#filename_upload').val(this.files[0].name); |
|
166 | 166 | } |
|
167 | 167 | }); |
|
168 | 168 | |
|
169 | 169 | hide_upload(); |
|
170 | 170 | |
|
171 | 171 | var renderer = ""; |
|
172 | 172 | var reset_url = "${h.route_path('repo_files',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path)}"; |
|
173 | 173 | var myCodeMirror = initCodeMirror('editor', reset_url, false); |
|
174 | 174 | |
|
175 | 175 | var modes_select = $('#set_mode'); |
|
176 | 176 | fillCodeMirrorOptions(modes_select); |
|
177 | 177 | |
|
178 | 178 | var filename_selector = '#filename'; |
|
179 | 179 | var callback = function(filename, mimetype, mode){ |
|
180 | 180 | CodeMirrorPreviewEnable(mode); |
|
181 | 181 | }; |
|
182 | 182 | // on change of select field set mode |
|
183 | 183 | setCodeMirrorModeFromSelect( |
|
184 | 184 | modes_select, filename_selector, myCodeMirror, callback); |
|
185 | 185 | |
|
186 | 186 | // on entering the new filename set mode, from given extension |
|
187 | 187 | setCodeMirrorModeFromInput( |
|
188 | 188 | modes_select, filename_selector, myCodeMirror, callback); |
|
189 | 189 | |
|
190 | 190 | // if the file is renderable set line wraps automatically |
|
191 | 191 | if (renderer !== ""){ |
|
192 | 192 | var line_wrap = 'on'; |
|
193 | 193 | $($('#line_wrap option[value="'+line_wrap+'"]')[0]).attr("selected", "selected"); |
|
194 | 194 | setCodeMirrorLineWrap(myCodeMirror, true); |
|
195 | 195 | } |
|
196 | 196 | |
|
197 | 197 | // on select line wraps change the editor |
|
198 | 198 | $('#line_wrap').on('change', function(e){ |
|
199 | 199 | var selected = e.currentTarget; |
|
200 | 200 | var line_wraps = {'on': true, 'off': false}[selected.value]; |
|
201 | 201 | setCodeMirrorLineWrap(myCodeMirror, line_wraps) |
|
202 | 202 | }); |
|
203 | 203 | |
|
204 | 204 | // render preview/edit button |
|
205 | 205 | $('#render_preview').on('click', function(e){ |
|
206 | 206 | if($(this).hasClass('preview')){ |
|
207 | 207 | $(this).removeClass('preview'); |
|
208 | 208 | $(this).html("${_('Edit')}"); |
|
209 | 209 | $('#editor_preview').show(); |
|
210 | 210 | $(myCodeMirror.getWrapperElement()).hide(); |
|
211 | 211 | |
|
212 | 212 | var possible_renderer = { |
|
213 | 213 | 'rst':'rst', |
|
214 | 214 | 'markdown':'markdown', |
|
215 | 215 | 'gfm': 'markdown'}[myCodeMirror.getMode().name]; |
|
216 | 216 | var _text = myCodeMirror.getValue(); |
|
217 | 217 | var _renderer = possible_renderer || DEFAULT_RENDERER; |
|
218 | 218 | var post_data = {'text': _text, 'renderer': _renderer, 'csrf_token': CSRF_TOKEN}; |
|
219 | 219 | $('#editor_preview').html(_gettext('Loading ...')); |
|
220 | 220 | var url = pyroutes.url('repo_commit_comment_preview', |
|
221 | 221 | {'repo_name': '${c.repo_name}', |
|
222 | 222 | 'commit_id': '${c.commit.raw_id}'}); |
|
223 | 223 | |
|
224 | 224 | ajaxPOST(url, post_data, function(o){ |
|
225 | 225 | $('#editor_preview').html(o); |
|
226 | 226 | }) |
|
227 | 227 | } |
|
228 | 228 | else{ |
|
229 | 229 | $(this).addClass('preview'); |
|
230 | 230 | $(this).html("${_('Preview')}"); |
|
231 | 231 | $('#editor_preview').hide(); |
|
232 | 232 | $(myCodeMirror.getWrapperElement()).show(); |
|
233 | 233 | } |
|
234 | 234 | }); |
|
235 | 235 | $('#filename').focus(); |
|
236 | 236 | |
|
237 | 237 | </script> |
|
238 | 238 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now