Files
@ 556e98fd06d2
Branch filter:
Location: kallithea/kallithea/templates/admin/gists/edit.html
556e98fd06d2
7.4 KiB
text/html
pullrequests on different repos: default to same destination/source branch
When a pull request is initiated between two different repositories, instead
of using the current tip as destination branch, use the same branch as on
the source repository.
When a pull request is initiated between two different repositories, instead
of using the current tip as destination branch, use the same branch as on
the source repository.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | ## -*- coding: utf-8 -*-
<%inherit file="/base/base.html"/>
<%block name="title">
${_('Edit Gist')} · ${c.gist.gist_access_id}
%if c.site_name:
· ${c.site_name}
%endif
</%block>
<%block name="js_extra">
<script type="text/javascript" src="${h.url('/codemirror/lib/codemirror.js')}"></script>
<script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script>
<script type="text/javascript" src="${h.url('/codemirror/mode/meta.js')}"></script>
</%block>
<%block name="css_extra">
<link rel="stylesheet" type="text/css" href="${h.url('/codemirror/lib/codemirror.css')}"/>
</%block>
<%def name="breadcrumbs_links()">
${_('Edit Gist')} · ${c.gist.gist_access_id}
</%def>
<%block name="header_menu">
${self.menu('gists')}
</%block>
<%def name="main()">
<div class="box">
<!-- box / title -->
<div class="title">
${self.breadcrumbs()}
</div>
<div class="table">
<div id="edit_error" style="display: none" class="flash_msg">
<div class="alert alert-dismissable alert-warning">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true"><i class="icon-cancel-circled"></i></button>
${h.literal(_('Gist was update since you started editing. Copy your changes and click %(here)s to reload new version.')
% {'here': h.link_to('here',h.url('edit_gist', gist_id=c.gist.gist_access_id))})}
</div>
<script>
if (typeof jQuery != 'undefined') {
$(".alert").alert();
}
</script>
</div>
<div id="files_data">
${h.form(h.url('edit_gist', gist_id=c.gist.gist_access_id), method='post', id='eform')}
<div>
<div class="gravatar">
${h.gravatar(c.authuser.email, size=32)}
</div>
<input type="hidden" value="${c.file_changeset.raw_id}" name="parent_hash">
<textarea style="resize:vertical; width:400px;border: 1px solid #ccc;border-radius: 3px;"
id="description" name="description"
placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea>
<div style="padding:0px 0px 0px 42px">
<label for='lifetime'>${_('Gist lifetime')}</label>
${h.select('lifetime', '0', c.lifetime_options)}
<span class="" style="color: #AAA">
%if c.gist.gist_expires == -1:
${_('Expires')}: ${_('never')}
%else:
${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))}
%endif
</span>
</div>
</div>
% for cnt, file in enumerate(c.files):
<div id="body" class="codeblock" style="margin-bottom: 4px">
<div style="padding: 10px 10px 10px 26px;color:#666666">
<input type="hidden" value="${file.path}" name="org_files">
<input id="filename_${h.FID('f',file.path)}" name="files" size="30" type="text" value="${file.path}">
<select id="mimetype_${h.FID('f',file.path)}" name="mimetypes"/>
</div>
<div class="editor_container">
<pre id="editor_pre"></pre>
<textarea id="editor_${h.FID('f',file.path)}" name="contents" style="display:none">${file.content}</textarea>
</div>
</div>
## dynamic edit box.
<script type="text/javascript">
var myCodeMirror = initCodeMirror("editor_${h.FID('f',file.path)}", '');
//inject new modes
var $modes_select = $('#mimetype_${h.FID('f',file.path)}');
$modes_select.each(function(){
var modes_select = this;
var index = 1;
for(var i=0;i<CodeMirror.modeInfo.length;i++) {
var m = CodeMirror.modeInfo[i];
var opt = new Option(m.name, m.mime);
$(opt).attr('mode', m.mode);
if (m.mime == 'text/plain') {
// default plain text
$(opt).attr('selected', 'selected');
modes_select.options[0] = opt;
} else {
modes_select.options[index++] = opt;
}
}
});
var $filename = $('#filename_${h.FID('f',file.path)}');
// on select change set new mode
$modes_select.change(function(e){
var selected = e.currentTarget;
var node = selected.options[selected.selectedIndex];
var detected_mode = CodeMirror.findModeByMIME(node.value);
setCodeMirrorMode(myCodeMirror, detected_mode);
var proposed_ext = CodeMirror.findExtensionByMode(detected_mode);
var file_data = CodeMirror.getFilenameAndExt($filename.val());
var filename = file_data['filename'] || 'filename1';
$filename.val(filename + '.' + proposed_ext);
});
// on type the new filename set mode
$filename.keyup(function(e){
var file_data = CodeMirror.getFilenameAndExt(this.value);
if(file_data['ext'] != null){
var detected_mode = CodeMirror.findModeByExtension(file_data['ext']) || CodeMirror.findModeByMIME('text/plain');
if (detected_mode){
setCodeMirrorMode(myCodeMirror, detected_mode);
$modes_select.val(detected_mode.mime);
}
}
});
// set mode on page load
var detected_mode = CodeMirror.findModeByExtension("${file.extension}");
if (detected_mode){
setCodeMirrorMode(myCodeMirror, detected_mode);
$modes_select.val(detected_mode.mime);
}
</script>
%endfor
<div style="padding-top: 5px">
${h.submit('update',_('Update Gist'),class_="btn btn-mini btn-success")}
<a class="btn btn-mini" href="${h.url('gist', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a>
</div>
${h.end_form()}
<script>
$('#update').on('click', function(e){
e.preventDefault();
// check for newer version.
$.ajax({
url: "${h.url('edit_gist_check_revision', gist_id=c.gist.gist_access_id)}",
data: {'revision': '${c.file_changeset.raw_id}'},
dataType: 'json',
type: 'POST',
success: function(data) {
if(data.success == false){
$('#edit_error').show();
}
else{
$('#eform').submit();
}
}
})
});
</script>
</div>
</div>
</div>
</%def>
|