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