2012-07-11 22:39:36 +08:00
|
|
|
{% 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>
|
2012-07-11 22:39:36 +08:00
|
|
|
</div>
|
|
|
|
|
2012-07-14 15:19:09 +08:00
|
|
|
<div id="file-view">
|
|
|
|
<p>文件内容读取中...</p>
|
2012-07-11 22:39:36 +08:00
|
|
|
</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-11 22:39:36 +08:00
|
|
|
|
2012-07-14 15:19:09 +08:00
|
|
|
if (filetype == 'Document') {
|
2012-07-11 22:39:36 +08:00
|
|
|
$.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>');
|
2012-07-11 22:39:36 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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-11 22:39:36 +08:00
|
|
|
}
|
|
|
|
});
|
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>');
|
2012-07-11 22:39:36 +08:00
|
|
|
} 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>');
|
2012-07-11 22:39:36 +08:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|