mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
Some modifications.
* Remove avatar cache * Handle empty repo open issue * Add SEAHUB_TITLE in settings.py
This commit is contained in:
@@ -8,9 +8,12 @@ RequestContext.
|
|||||||
"""
|
"""
|
||||||
import settings
|
import settings
|
||||||
|
|
||||||
def version(request):
|
def base(request):
|
||||||
"""
|
"""
|
||||||
Add seafile version to the context.
|
Add seahub base configure to the context.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return {'seafile_version': settings.SEAFILE_VERSION}
|
return {
|
||||||
|
'seafile_version': settings.SEAFILE_VERSION,
|
||||||
|
'seahub_title': settings.SEAHUB_TITLE,
|
||||||
|
}
|
||||||
|
@@ -88,7 +88,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
|||||||
'django.core.context_processors.media',
|
'django.core.context_processors.media',
|
||||||
'djblets.util.context_processors.siteRoot',
|
'djblets.util.context_processors.siteRoot',
|
||||||
'django.core.context_processors.request',
|
'django.core.context_processors.request',
|
||||||
'seahub.base.context_processors.version',
|
'seahub.base.context_processors.base',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -129,6 +129,8 @@ CCNET_APPLET_ROOT = "http://localhost:8081"
|
|||||||
|
|
||||||
SEAFILE_VERSION = '0.9.2'
|
SEAFILE_VERSION = '0.9.2'
|
||||||
|
|
||||||
|
SEAHUB_TITLE = 'SeaHub'
|
||||||
|
|
||||||
# Add supported file extensions and file icon name.
|
# Add supported file extensions and file icon name.
|
||||||
# Icons will show in repo page.
|
# Icons will show in repo page.
|
||||||
FILEEXT_ICON_MAP = {
|
FILEEXT_ICON_MAP = {
|
||||||
@@ -179,6 +181,7 @@ AVATAR_GRAVATAR_BACKUP = False
|
|||||||
AVATAR_DEFAULT_URL = '/avatars/default.png'
|
AVATAR_DEFAULT_URL = '/avatars/default.png'
|
||||||
AUTO_GENERATE_AVATAR_SIZES = (80, 16)
|
AUTO_GENERATE_AVATAR_SIZES = (80, 16)
|
||||||
AVATAR_MAX_AVATARS_PER_USER = 1
|
AVATAR_MAX_AVATARS_PER_USER = 1
|
||||||
|
AVATAR_CACHE_TIMEOUT = 0
|
||||||
|
|
||||||
LOGIN_URL = SITE_ROOT + 'accounts/login'
|
LOGIN_URL = SITE_ROOT + 'accounts/login'
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<title>SeaHub</title>
|
<title>{{ seahub_title }}</title>
|
||||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||||
<meta name="keywords" content="文件 共享" />
|
<meta name="keywords" content="文件 共享" />
|
||||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/ui-lightness/jquery-ui-1.8.16.custom.css" />
|
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/ui-lightness/jquery-ui-1.8.16.custom.css" />
|
||||||
|
63
views.py
63
views.py
@@ -137,18 +137,11 @@ def render_repo(request, repo_id, error=''):
|
|||||||
repo_ap = 'own'
|
repo_ap = 'own'
|
||||||
|
|
||||||
if not access_to_repo(request, repo_id, repo_ap):
|
if not access_to_repo(request, repo_id, repo_ap):
|
||||||
raise Http404
|
return go_permission_error(request, u'该同步目录未公开')
|
||||||
|
|
||||||
repo = get_repo(repo_id)
|
repo = get_repo(repo_id)
|
||||||
if not repo:
|
if not repo:
|
||||||
raise Http404
|
return go_error(request, u'该同步目录不存在')
|
||||||
|
|
||||||
latest_commit = get_commits(repo_id, 0, 1)[0]
|
|
||||||
|
|
||||||
is_owner = False
|
|
||||||
if request.user.is_authenticated():
|
|
||||||
if validate_owner(request, repo_id):
|
|
||||||
is_owner = True
|
|
||||||
|
|
||||||
password_set = False
|
password_set = False
|
||||||
if repo.props.encrypted:
|
if repo.props.encrypted:
|
||||||
@@ -160,6 +153,7 @@ def render_repo(request, repo_id, error=''):
|
|||||||
return go_error(request, e.msg)
|
return go_error(request, e.msg)
|
||||||
|
|
||||||
repo_size = seafserv_threaded_rpc.server_repo_size(repo_id)
|
repo_size = seafserv_threaded_rpc.server_repo_size(repo_id)
|
||||||
|
latest_commit = get_commits(repo_id, 0, 1)[0]
|
||||||
|
|
||||||
dirs = []
|
dirs = []
|
||||||
path = ''
|
path = ''
|
||||||
@@ -170,27 +164,38 @@ def render_repo(request, repo_id, error=''):
|
|||||||
path = request.GET.get('p', '/')
|
path = request.GET.get('p', '/')
|
||||||
if path[-1] != '/':
|
if path[-1] != '/':
|
||||||
path = path + '/'
|
path = path + '/'
|
||||||
|
|
||||||
try:
|
|
||||||
dirs = seafserv_rpc.list_dir_by_path(latest_commit.id,
|
|
||||||
path.encode('utf-8'))
|
|
||||||
except SearpcError, e:
|
|
||||||
return go_error(request, e.msg)
|
|
||||||
for dirent in dirs:
|
|
||||||
if stat.S_ISDIR(dirent.props.mode):
|
|
||||||
dir_list.append(dirent)
|
|
||||||
else:
|
|
||||||
file_list.append(dirent)
|
|
||||||
try:
|
|
||||||
dirent.file_size = seafserv_rpc.get_file_size(dirent.obj_id)
|
|
||||||
except:
|
|
||||||
dirent.file_size = 0
|
|
||||||
dir_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower()))
|
|
||||||
file_list.sort(lambda x, y : cmp(x.obj_name.lower(), y.obj_name.lower()))
|
|
||||||
|
|
||||||
# generate path and link
|
|
||||||
zipped = gen_path_link(path, repo.name)
|
|
||||||
|
|
||||||
|
if latest_commit.root_id == '0000000000000000000000000000000000000000':
|
||||||
|
dirs = []
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
dirs = seafserv_rpc.list_dir_by_path(latest_commit.id,
|
||||||
|
path.encode('utf-8'))
|
||||||
|
except SearpcError, e:
|
||||||
|
return go_error(request, e.msg)
|
||||||
|
for dirent in dirs:
|
||||||
|
if stat.S_ISDIR(dirent.props.mode):
|
||||||
|
dir_list.append(dirent)
|
||||||
|
else:
|
||||||
|
file_list.append(dirent)
|
||||||
|
try:
|
||||||
|
dirent.file_size = seafserv_rpc.get_file_size(dirent.obj_id)
|
||||||
|
except:
|
||||||
|
dirent.file_size = 0
|
||||||
|
dir_list.sort(lambda x, y : cmp(x.obj_name.lower(),
|
||||||
|
y.obj_name.lower()))
|
||||||
|
file_list.sort(lambda x, y : cmp(x.obj_name.lower(),
|
||||||
|
y.obj_name.lower()))
|
||||||
|
|
||||||
|
# generate path and link
|
||||||
|
zipped = gen_path_link(path, repo.name)
|
||||||
|
|
||||||
|
# check whether use is repo owner
|
||||||
|
is_owner = False
|
||||||
|
if request.user.is_authenticated():
|
||||||
|
if validate_owner(request, repo_id):
|
||||||
|
is_owner = True
|
||||||
|
|
||||||
# used to determin whether show repo content in repo.html
|
# used to determin whether show repo content in repo.html
|
||||||
# if a repo is shared to me, or repo shared to the group I joined,
|
# if a repo is shared to me, or repo shared to the group I joined,
|
||||||
# then I can view repo content on the web
|
# then I can view repo content on the web
|
||||||
|
Reference in New Issue
Block a user