mirror of
https://github.com/haiwen/seahub.git
synced 2025-04-28 03:10:45 +00:00
Add new repo_file_get file and clean settings.py.
This commit is contained in:
parent
6eddec46ae
commit
ea1b664541
@ -693,4 +693,7 @@ table img {
|
||||
min-height:500px;/*for ff*/
|
||||
}
|
||||
|
||||
|
||||
/* shareadmin */
|
||||
.view-link-alert p {
|
||||
display: inline-block;
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
from django.conf import settings
|
||||
|
||||
NOTIFICATION_CACHE_TIMEOUT = getattr(settings, 'NOTIFICATION_CACHE_TIMEOUT', 24*60*60)
|
||||
NOTIFICATION_CACHE_TIMEOUT = getattr(settings, 'NOTIFICATION_CACHE_TIMEOUT', 0)
|
||||
|
15
settings.py
15
settings.py
@ -69,7 +69,6 @@ MIDDLEWARE_CLASSES = (
|
||||
'auth.middleware.AuthenticationMiddleware',
|
||||
'seahub.base.middleware.InfobarMiddleware',
|
||||
'seahub.subdomain.middleware.SubdomainMiddleware',
|
||||
# 'seahub.base.middleware.UseridMiddleware',
|
||||
)
|
||||
|
||||
SITE_ROOT_URLCONF = 'seahub.urls'
|
||||
@ -147,16 +146,9 @@ FILEEXT_ICON_MAP = {
|
||||
'default' : 'file-icon-24.png',
|
||||
}
|
||||
|
||||
|
||||
# File preview
|
||||
FILE_PREVIEW_MAX_SIZE = 10 * 1024 * 1024
|
||||
|
||||
PREVIEW_FILEEXT = {
|
||||
'Document': ('ac', 'am', 'bat', 'c', 'cc', 'cmake', 'cpp', 'css', 'diff', 'h', 'htm', 'html', 'xhtml', 'java', 'js', 'json', 'less', 'make', 'php', 'properties', 'py', 'rb', 'scala', 'script', 'sh', 'sql', 'txt','text', 'vi', 'vim', 'xml'),
|
||||
'Image': ('gif', 'jpeg', 'jpg', 'png'),
|
||||
'SVG':('svg',),
|
||||
}
|
||||
|
||||
# Avatar
|
||||
AVATAR_STORAGE_DIR = 'avatars'
|
||||
GROUP_AVATAR_STORAGE_DIR = 'avatars/groups'
|
||||
@ -166,11 +158,6 @@ GROUP_AVATAR_DEFAULT_URL = 'avatars/groups/default.png'
|
||||
AVATAR_MAX_AVATARS_PER_USER = 1
|
||||
AVATAR_CACHE_TIMEOUT = 0
|
||||
|
||||
# Info-bar notification cache
|
||||
NOTIFICATION_CACHE_TIMEOUT = 0
|
||||
|
||||
USER_TOTAL_SPACE = 2 * pow(2,30)
|
||||
|
||||
# File upload
|
||||
FILE_UPLOAD_MAX_MEMORY_SIZE = 0
|
||||
|
||||
@ -240,4 +227,6 @@ else:
|
||||
|
||||
LOGIN_URL = SITE_ROOT + 'accounts/login'
|
||||
|
||||
USER_TOTAL_SPACE = 2 * pow(2,30)
|
||||
|
||||
SEAFILE_VERSION = '0.9.4'
|
||||
|
@ -84,7 +84,7 @@
|
||||
<p>暂无</p>
|
||||
{% endif %}
|
||||
<div id="view-link" name="view-link" class="hide">
|
||||
<p><span class="view-link-alert" style="float:left; margin-left: 120px; "></span></p>
|
||||
<span class="view-link-alert" style="float:left; margin-left: 120px; "></span>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@ -108,7 +108,7 @@ $(".view-link").click(function() {
|
||||
|
||||
var t = $(this).attr('data');
|
||||
var l = '{{ protocol }}://' + '{{ domain }}{{ SITE_ROOT }}share/' + t + '/';
|
||||
$('.view-link-alert').text("共享链接为:" + l);
|
||||
$('.view-link-alert').html("共享链接为:<p>" + l + "</p>");
|
||||
$("#view-link").modal({appendTo: "#main", containerCss:{padding:18}});
|
||||
return false;
|
||||
});
|
||||
@ -117,7 +117,7 @@ $(".view-file-link").click(function() {
|
||||
|
||||
var t = $(this).attr('data');
|
||||
var l = '{{ protocol }}://' + '{{ domain }}{{ SITE_ROOT }}f/' + t + '/';
|
||||
$('.view-link-alert').text("该文件外链为:" + l);
|
||||
$('.view-link-alert').html("该文件外链为:<p>" + l + "</p>");
|
||||
$("#view-link").modal({appendTo: "#main", containerCss:{padding:18}});
|
||||
return false;
|
||||
});
|
||||
|
23
templates/repo_file_get.html
Normal file
23
templates/repo_file_get.html
Normal file
@ -0,0 +1,23 @@
|
||||
if (filetype == 'Document') {
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
success: function(data) {
|
||||
if (data.length > 0) {
|
||||
$('#file-view').html('<pre id="docu-view">' + data[0]['content'] + '</pre>');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
var jsonVal = jQuery.parseJSON(xhr.responseText);
|
||||
$('#file-view').html('<p class="error">' + jsonVal[0]['error'] + '</p>');
|
||||
}
|
||||
});
|
||||
} else if (filetype == 'Image') {
|
||||
$('#file-view').html('<img src="{{ raw_path }}" alt="{{ u_filename}}" id="image-view" />').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 {
|
||||
$('#file-view').html('<p>该类型文件无法在线查看。<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download">下载</a></p>');
|
||||
}
|
@ -93,29 +93,7 @@ $(window).load(function() {
|
||||
hideLink();
|
||||
}
|
||||
|
||||
if (filetype == 'Document') {
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
success: function(data) {
|
||||
if (data.length > 0) {
|
||||
$('#file-view').html('<pre id="docu-view">' + data[0]['content'] + '</pre>');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
var jsonVal = jQuery.parseJSON(xhr.responseText);
|
||||
$('#file-view').html('<p class="error">' + jsonVal[0]['error'] + '</p>');
|
||||
}
|
||||
});
|
||||
} else if (filetype == 'Image') {
|
||||
$('#file-view').html('<img src="{{ raw_path }}" alt="{{ u_filename}}" id="image-view" />').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 {
|
||||
$('#file-view').html('<p>该类型文件无法在线查看。<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download">下载</a></p>');
|
||||
}
|
||||
{% include "repo_file_get.html" %}
|
||||
});
|
||||
|
||||
$('#get-shared-link').click(function() {
|
||||
|
@ -21,29 +21,7 @@
|
||||
<script type="text/javascript">
|
||||
var url = '{{ SITE_ROOT }}repo/{{ repo.id }}/file/get/?t={{ access_token }}&p={{ path|urlencode }}&u={{ username }}',
|
||||
filetype = '{{ filetype }}';
|
||||
|
||||
if (filetype == 'Document') {
|
||||
$.ajax({
|
||||
url: url,
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
success: function(data) {
|
||||
if (data.length > 0) {
|
||||
$('#file-view').html('<pre id="docu-view">' + data[0]['content'] + '</pre>');
|
||||
}
|
||||
},
|
||||
error: function(xhr, ajaxOptions, thrownError) {
|
||||
var jsonVal = jQuery.parseJSON(xhr.responseText);
|
||||
$('#file-view').html('<p class="error">' + jsonVal[0]['error'] + '</p>');
|
||||
}
|
||||
});
|
||||
} 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 {
|
||||
$('#file-view').html('<p>该类型文件无法在线查看。<a href="{{ SITE_ROOT }}repo/{{ repo.id }}/{{ obj_id }}/?file_name={{ file_name }}&op=download">下载文件</a><p>');
|
||||
}
|
||||
|
||||
{% include "repo_file_get.html" %}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
8
utils.py
8
utils.py
@ -15,10 +15,16 @@ from django.core.cache import cache
|
||||
from seaserv import seafserv_rpc, ccnet_threaded_rpc, seafserv_threaded_rpc, \
|
||||
get_repo, get_commits, get_group_repoids
|
||||
import settings
|
||||
from settings import PREVIEW_FILEEXT
|
||||
|
||||
EMPTY_SHA1 = '0000000000000000000000000000000000000000'
|
||||
|
||||
PREVIEW_FILEEXT = {
|
||||
'Document': ('ac', 'am', 'bat', 'c', 'cc', 'cmake', 'cpp', 'css', 'diff', 'h', 'htm', 'html', 'xhtml', 'java', 'js', 'json', 'less', 'make', 'php', 'properties', 'py', 'rb', 'scala', 'script', 'sh', 'sql', 'txt','text', 'vi', 'vim', 'xml'),
|
||||
'Image': ('gif', 'jpeg', 'jpg', 'png'),
|
||||
'SVG':('svg',),
|
||||
}
|
||||
|
||||
|
||||
def go_permission_error(request, msg=None):
|
||||
"""
|
||||
Return permisson error page.
|
||||
|
Loading…
Reference in New Issue
Block a user