From ea1b664541c11f16c6e71971903652e80d39334f Mon Sep 17 00:00:00 2001 From: xiez Date: Thu, 19 Jul 2012 11:30:12 +0800 Subject: [PATCH] Add new repo_file_get file and clean settings.py. --- media/css/seahub.css | 5 ++++- notifications/settings.py | 2 +- settings.py | 15 ++------------- share/templates/repo/share_admin.html | 6 +++--- templates/repo_file_get.html | 23 +++++++++++++++++++++++ templates/repo_view_file.html | 24 +----------------------- templates/view_shared_file.html | 26 ++------------------------ utils.py | 8 +++++++- 8 files changed, 43 insertions(+), 66 deletions(-) create mode 100644 templates/repo_file_get.html diff --git a/media/css/seahub.css b/media/css/seahub.css index 018645343b..47be562759 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -693,4 +693,7 @@ table img { min-height:500px;/*for ff*/ } - +/* shareadmin */ +.view-link-alert p { + display: inline-block; +} diff --git a/notifications/settings.py b/notifications/settings.py index 11060c3a76..d82a3c78fe 100644 --- a/notifications/settings.py +++ b/notifications/settings.py @@ -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) diff --git a/settings.py b/settings.py index 6eda4e7e13..461686e9bc 100644 --- a/settings.py +++ b/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' diff --git a/share/templates/repo/share_admin.html b/share/templates/repo/share_admin.html index c7217042e7..0eb8ef83ab 100644 --- a/share/templates/repo/share_admin.html +++ b/share/templates/repo/share_admin.html @@ -84,7 +84,7 @@

暂无

{% endif %} {% 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("共享链接为:

" + l + "

"); $("#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("该文件外链为:

" + l + "

"); $("#view-link").modal({appendTo: "#main", containerCss:{padding:18}}); return false; }); diff --git a/templates/repo_file_get.html b/templates/repo_file_get.html new file mode 100644 index 0000000000..0beeead7ff --- /dev/null +++ b/templates/repo_file_get.html @@ -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('
' + data[0]['content'] + '
'); + } + }, + error: function(xhr, ajaxOptions, thrownError) { + var jsonVal = jQuery.parseJSON(xhr.responseText); + $('#file-view').html('

' + jsonVal[0]['error'] + '

'); + } + }); + } else if (filetype == 'Image') { + $('#file-view').html('{{ u_filename}}').css({'text-align':'center', 'padding':'30px 0'}); + } else if (filetype == 'SVG') { + $('#file-view').html(''); + } else { + $('#file-view').html('

该类型文件无法在线查看。下载

'); + } \ No newline at end of file diff --git a/templates/repo_view_file.html b/templates/repo_view_file.html index abef1b6f5c..cad181ea62 100644 --- a/templates/repo_view_file.html +++ b/templates/repo_view_file.html @@ -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('
' + data[0]['content'] + '
'); - } - }, - error: function(xhr, ajaxOptions, thrownError) { - var jsonVal = jQuery.parseJSON(xhr.responseText); - $('#file-view').html('

' + jsonVal[0]['error'] + '

'); - } - }); - } else if (filetype == 'Image') { - $('#file-view').html('{{ u_filename}}').css({'text-align':'center', 'padding':'30px 0'}); - } else if (filetype == 'SVG') { - $('#file-view').html(''); - } else { - $('#file-view').html('

该类型文件无法在线查看。下载

'); - } + {% include "repo_file_get.html" %} }); $('#get-shared-link').click(function() { diff --git a/templates/view_shared_file.html b/templates/view_shared_file.html index af1075314f..30e9c66ebb 100644 --- a/templates/view_shared_file.html +++ b/templates/view_shared_file.html @@ -21,29 +21,7 @@ {% endblock %} diff --git a/utils.py b/utils.py index 0b26dcab57..a3253efa08 100644 --- a/utils.py +++ b/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.