##// END OF EJS Templates
Migrate to Mergely 3.3.4....
Migrate to Mergely 3.3.4. RhodeCode 2.2.5 distributed Mergely 3.3.4 with some of the changes that Mergely 3.3.3 in RhodeCode 1.7.2 also had. That do however not seem to be changes we want for Kallithea this way and we take the 3.3.4 files as they are. I've also included the Mergely license file, as downloaded from: http://www.mergely.com/license.php That LICENSE file is kept in HTML just as it was downloaded from their website. While it's a bit annoying to keep the license file in HTML, this is the way it came from upstream so we'll leave it that way. Since the Javascript code is used with other GPLv3 Javascript, we are using the GPL option of Mergely's tri-license. Finally, note that previously, this was incorrectly called "mergerly", so the opportunity is taken here to correct the name. That required changes to diff_2way.html. As commands:: $ wget -N --output-document LICENSE-MERGELY.html http://www.mergely.com/license.php $ hg add LICENSE-MERGELY.html $ hg mv rhodecode/public/css/mergerly.css rhodecode/public/css/mergely.css $ hg mv rhodecode/public/js/mergerly.js rhodecode/public/js/mergely.js $ sed -i 's,mergerly\.,mergely,g' rhodecode/templates/files/diff_2way.html $ ( cd /tmp; \ wget -N http://www.mergely.com/releases/mergely-3.3.4.zip; \ unzip mergely-3.3.4.zip ) $ sha256sum /tmp/mergely-3.3.4.zip 87415d30494bbe829c248881aa7cdc0303f7e70b458a5f687615564d4498cc82 mergely-3.3.4.zip $ cp /tmp/mergely-3.3.4/lib/mergely.js rhodecode/public/js/mergely.js $ cp /tmp/mergely-3.3.4/lib/mergely.css rhodecode/public/css/mergely.css $ sed -i -e '/^ \* Version/a\ *\n * NOTE by bkuhn@sfconservancy.org for Kallithea:\n * Mergely license appears at http://www.mergely.com/license.php and in LICENSE-MERGELY.html' rhodecode/public/js/mergely.js rhodecode/public/css/mergely.css

File last commit:

r4116:ffd45b18 rhodecode-2.2.5-gpl
r4125:aa3b5594 rhodecode-2.2.5-gpl
Show More
edit.html
176 lines | 7.3 KiB | text/html | HtmlLexer
## -*- coding: utf-8 -*-
<%inherit file="/base/base.html"/>
<%def name="title()">
${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
%if c.rhodecode_name:
&middot; ${c.rhodecode_name}
%endif
</%def>
<%def name="js_extra()">
<script type="text/javascript" src="${h.url('/js/codemirror.js')}"></script>
<script type="text/javascript" src="${h.url('/js/codemirror_loadmode.js')}"></script>
<script type="text/javascript" src="${h.url('/js/mode/meta.js')}"></script>
<script type="text/javascript" src="${h.url('/js/mode/meta_ext.js')}"></script>
</%def>
<%def name="css_extra()">
<link rel="stylesheet" type="text/css" href="${h.url('/css/codemirror.css')}"/>
</%def>
<%def name="breadcrumbs_links()">
${_('Edit Gist')} &middot; ${c.gist.gist_access_id}
</%def>
<%def name="page_nav()">
${self.menu('gists')}
</%def>
<%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">×</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">
<img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.rhodecode_user.full_contact),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">
<option selected="selected" value="plain">${_('plain')}</option>
</select>
</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)}", '');
CodeMirror.modeURL = "${h.url('/js/mode/%N/%N.js')}";
//inject new modes
var modes_select = $('#mimetype_${h.FID('f',file.path)}');
for(var i=0;i<CodeMirror.modeInfo.length;i++){
var m = CodeMirror.modeInfo[i];
var opt = new Option(m.name, m.mime);
YUD.setAttribute(opt, 'mode', m.mode)
modes_select[0].options[i+1] = opt;
}
var filename_selector = '#filename_${h.FID('f',file.path)}';
// on select change set new mode
modes_select.on('change', function(e){
var selected = e.currentTarget;
var node = selected.options[selected.selectedIndex];
var mimetype = node.value;
var new_mode = YUD.getAttribute(node, 'mode')
setCodeMirrorMode(myCodeMirror, new_mode);
var proposed_ext = getExtFromMimeType(mimetype);
var file_data = getFilenameAndExt($(filename_selector).val());
var filename = file_data['filename'] || 'filename1';
$(filename_selector).val(filename + proposed_ext);
})
// on type the new filename set mode
$(filename_selector).on('keyup', function(e){
var file_data = getFilenameAndExt(this.value);
if(file_data['ext'] != null){
var mimetype = getMimeTypeFromExt(file_data['ext']);
var detected_mode = detectCodeMirrorMode(this.value, mimetype);
if (detected_mode){
setCodeMirrorMode(myCodeMirror, detected_mode);
modes_select.val(mimetype)
}
}
})
// set mode on page load
var mimetype = getMimeTypeFromExt("${file.extension}");
var detected_mode = detectCodeMirrorMode("${file.path}", mimetype);
if (detected_mode){
setCodeMirrorMode(myCodeMirror, detected_mode);
modes_select.val(mimetype)
}
</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>