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
|
||||
|
||||
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',
|
||||
'djblets.util.context_processors.siteRoot',
|
||||
'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'
|
||||
|
||||
SEAHUB_TITLE = 'SeaHub'
|
||||
|
||||
# Add supported file extensions and file icon name.
|
||||
# Icons will show in repo page.
|
||||
FILEEXT_ICON_MAP = {
|
||||
@@ -179,6 +181,7 @@ AVATAR_GRAVATAR_BACKUP = False
|
||||
AVATAR_DEFAULT_URL = '/avatars/default.png'
|
||||
AUTO_GENERATE_AVATAR_SIZES = (80, 16)
|
||||
AVATAR_MAX_AVATARS_PER_USER = 1
|
||||
AVATAR_CACHE_TIMEOUT = 0
|
||||
|
||||
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">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>SeaHub</title>
|
||||
<title>{{ seahub_title }}</title>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<meta name="keywords" content="文件 共享" />
|
||||
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/ui-lightness/jquery-ui-1.8.16.custom.css" />
|
||||
|
59
views.py
59
views.py
@@ -137,18 +137,11 @@ def render_repo(request, repo_id, error=''):
|
||||
repo_ap = 'own'
|
||||
|
||||
if not access_to_repo(request, repo_id, repo_ap):
|
||||
raise Http404
|
||||
return go_permission_error(request, u'该同步目录未公开')
|
||||
|
||||
repo = get_repo(repo_id)
|
||||
if not repo:
|
||||
raise Http404
|
||||
|
||||
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
|
||||
return go_error(request, u'该同步目录不存在')
|
||||
|
||||
password_set = False
|
||||
if repo.props.encrypted:
|
||||
@@ -160,6 +153,7 @@ def render_repo(request, repo_id, error=''):
|
||||
return go_error(request, e.msg)
|
||||
|
||||
repo_size = seafserv_threaded_rpc.server_repo_size(repo_id)
|
||||
latest_commit = get_commits(repo_id, 0, 1)[0]
|
||||
|
||||
dirs = []
|
||||
path = ''
|
||||
@@ -171,25 +165,36 @@ def render_repo(request, repo_id, error=''):
|
||||
if path[-1] != '/':
|
||||
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()))
|
||||
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)
|
||||
# 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
|
||||
# if a repo is shared to me, or repo shared to the group I joined,
|
||||
|
Reference in New Issue
Block a user