mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-10 19:29:56 +00:00
improved source file edit
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
{% load seahub_tags %}
|
{% load seahub_tags %}
|
||||||
|
|
||||||
{% block main_panel %}
|
{% block main_panel %}
|
||||||
<h2>{{ u_filename }}</h2>
|
<h2>编辑 {{ u_filename }}</h2>
|
||||||
<div class="w100 ovhd">
|
<div class="w100 ovhd">
|
||||||
<p class="path fleft">
|
<p class="path fleft">
|
||||||
当前路径:
|
当前路径:
|
||||||
@@ -24,10 +24,10 @@
|
|||||||
<p>文件内容读取中...</p>
|
<p>文件内容读取中...</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form action="post" method="post" id="file-edit-form">
|
<form action="post" method="post" id="file-edit-form" class="hide">
|
||||||
<input type="hidden" name="modified-file" />
|
<input type="hidden" name="modified-file" />
|
||||||
<label>修改信息:</label><br />
|
<label>修改信息:</label><br />
|
||||||
<input type="text" name="commit-msg" id="file-edit-commit-msg" /><br />
|
<input type="text" name="commit-msg" id="file-edit-commit-msg" value="修改了 {{ u_filename }}" /><br />
|
||||||
<label>更多描述:</label><br />
|
<label>更多描述:</label><br />
|
||||||
<textarea name="commit-details" id="file-edit-commit-details"></textarea><br />
|
<textarea name="commit-details" id="file-edit-commit-details"></textarea><br />
|
||||||
<input type="submit" class="submit" value="提交" />
|
<input type="submit" class="submit" value="提交" />
|
||||||
@@ -57,6 +57,7 @@ $.ajax({
|
|||||||
$('#docu-view').css({'position': 'relative', 'height': editor.session.getScreenLength() * parseInt($('#docu-view').css('line-height'))});
|
$('#docu-view').css({'position': 'relative', 'height': editor.session.getScreenLength() * parseInt($('#docu-view').css('line-height'))});
|
||||||
editor.session.setScrollLeft(0); // make bottom scrollbar start from the left-most
|
editor.session.setScrollLeft(0); // make bottom scrollbar start from the left-most
|
||||||
editor.resize(); // fix some problem for showing some file in ie8
|
editor.resize(); // fix some problem for showing some file in ie8
|
||||||
|
$('#file-edit-form').removeClass('hide');
|
||||||
},
|
},
|
||||||
error: function(xhr, ajaxOptions, thrownError) {
|
error: function(xhr, ajaxOptions, thrownError) {
|
||||||
var jsonVal = jQuery.parseJSON(xhr.responseText);
|
var jsonVal = jQuery.parseJSON(xhr.responseText);
|
||||||
@@ -64,6 +65,10 @@ $.ajax({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#file-edit-commit-msg').css('color', '#666').click(function() {
|
||||||
|
$(this).val('').css('color', '#000');
|
||||||
|
});
|
||||||
|
|
||||||
$('#file-edit-form').submit(function() {
|
$('#file-edit-form').submit(function() {
|
||||||
$(this).find('[name="modified-file"]').val(editor.session.getValue());
|
$(this).find('[name="modified-file"]').val(editor.session.getValue());
|
||||||
});
|
});
|
||||||
|
4
views.py
4
views.py
@@ -883,15 +883,12 @@ def repo_file_get(request, repo_id):
|
|||||||
data = json.dumps({'error': err})
|
data = json.dumps({'error': err})
|
||||||
return HttpResponse(data, status=400, content_type=content_type)
|
return HttpResponse(data, status=400, content_type=content_type)
|
||||||
else:
|
else:
|
||||||
# l, d = [], {}
|
|
||||||
try:
|
try:
|
||||||
u_content = content.decode('utf-8')
|
u_content = content.decode('utf-8')
|
||||||
except:
|
except:
|
||||||
# XXX: file in windows is encoded in gbk
|
# XXX: file in windows is encoded in gbk
|
||||||
u_content = content.decode('gbk')
|
u_content = content.decode('gbk')
|
||||||
from django.utils.html import escape
|
from django.utils.html import escape
|
||||||
# d['content'] = escape(u_content)
|
|
||||||
# l.append(d)
|
|
||||||
data = json.dumps({'content': u_content})
|
data = json.dumps({'content': u_content})
|
||||||
return HttpResponse(data, status=200, content_type=content_type)
|
return HttpResponse(data, status=200, content_type=content_type)
|
||||||
|
|
||||||
@@ -934,7 +931,6 @@ def repo_file_edit(request, repo_id):
|
|||||||
|
|
||||||
token = ''
|
token = ''
|
||||||
if access_to_repo(request, repo_id, ''):
|
if access_to_repo(request, repo_id, ''):
|
||||||
# Get a token to visit file
|
|
||||||
token = gen_token()
|
token = gen_token()
|
||||||
seafserv_rpc.web_save_access_token(token, repo_id, obj_id,
|
seafserv_rpc.web_save_access_token(token, repo_id, obj_id,
|
||||||
'view', request.user.username)
|
'view', request.user.username)
|
||||||
|
Reference in New Issue
Block a user