1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-27 07:44:50 +00:00
Files
seahub/templates/view_shared_file.html

50 lines
2.0 KiB
HTML
Raw Normal View History

{% extends "myhome_base.html" %}
{% load seahub_tags %}
{% block main_panel %}
2012-07-14 15:19:09 +08:00
<h2>{{ file_name }}</h2>
<div class="w100 ovhd">
<p class="file-share-from fleft">共享者:{{ username }}</p>
<div class="file-op fright">
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=view&t={{ shared_token }}" target="_blank">查看原始文件</a>
<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download&t={{ shared_token }}" target="_blank">下载文件</a>
</div>
</div>
2012-07-14 15:19:09 +08:00
<div id="file-view">
<p>文件内容读取中...</p>
</div>
{% endblock %}
{% block extra_script %}
<script type="text/javascript">
2012-07-14 15:19:09 +08:00
var url = '{{ SITE_ROOT }}repo/{{ repo.id }}/file/get/?t={{ access_token }}&p={{ path|urlencode }}&u={{ username }}',
filetype = '{{ filetype }}';
2012-07-14 15:19:09 +08:00
if (filetype == 'Document') {
$.ajax({
url: url,
dataType: 'json',
cache: false,
contentType: 'application/json; charset=utf-8',
success: function(data) {
if (data.length > 0) {
2012-07-14 15:19:09 +08:00
$('#file-view').html('<pre id="docu-view">' + data[0]['content'] + '</pre>');
}
},
error: function(xhr, ajaxOptions, thrownError) {
var jsonVal = jQuery.parseJSON(xhr.responseText);
2012-07-14 15:19:09 +08:00
$('#file-view').html('<p class="error">' + jsonVal[0]['error'] + '</p>');
}
});
2012-07-14 15:19:09 +08:00
} else if (filetype == 'Image') {
$('#file-view').html('<img id="image-view" src="{{ raw_path }}" alt="{{ file_name }}" />').css({'text-align':'center', 'padding':'30px 0'});
} else if (filetype == 'SVG') {
$('#file-view').html('<iframe src="{{ raw_path }}" frameborder="0" width="940" id="svg-view"></iframe>');
} else {
2012-07-14 15:19:09 +08:00
$('#file-view').html('<p>该类型文件无法在线查看。<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download">下载文件</a><p>');
}
</script>
{% endblock %}