From b82971dc3d50bbc41c118ac113f037c77536771f Mon Sep 17 00:00:00 2001 From: zhengxie Date: Wed, 5 Dec 2012 21:32:55 +0800 Subject: [PATCH] Move file extension icon map from settings to seahub_tags --- base/templatetags/seahub_tags.py | 26 +++++++++++++++++++++++++- settings.py | 27 --------------------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/base/templatetags/seahub_tags.py b/base/templatetags/seahub_tags.py index ef0825990f..058bb3a00e 100644 --- a/base/templatetags/seahub_tags.py +++ b/base/templatetags/seahub_tags.py @@ -14,7 +14,6 @@ from django.utils.translation import ungettext from profile.models import Profile from profile.settings import NICKNAME_CACHE_TIMEOUT, NICKNAME_CACHE_PREFIX from seahub.cconvert import CConvert -from seahub.settings import FILEEXT_ICON_MAP from seahub.po import TRANSLATION_MAP from seahub.shortcuts import get_first_object_or_none @@ -37,6 +36,31 @@ def tsstr_day(value): except: return datetime.fromtimestamp(value/1000000).strftime("%Y-%m-%d") +# Supported file extensions and file icon name. +FILEEXT_ICON_MAP = { + # pdf file + 'pdf' : 'pdf.png', + # document file + 'doc' : 'ms-word.png', + 'docx' : 'ms-word.png', + 'ppt' : 'ms-ppt.png', + 'pptx' : 'ms-ppt.png', + 'xls' : 'ms-excel.png', + 'xlsx' : 'ms-excel.png', + 'txt' : 'txt.png', + 'odf' : 'odf.png', + # music file + 'mp3' : 'music-icon-24.png', + # picture file + 'jpg' : 'pic-icon-24.png', + 'jpeg' : 'pic-icon-24.png', + 'png' : 'pic-icon-24.png', + 'svg' : 'pic-icon-24.png', + 'gif' : 'pic-icon-24.png', + 'bmp' : 'pic-icon-24.png', + # normal file and unkown file + 'default' : 'file-icon-24.png', +} @register.filter(name='file_icon_filter') def file_icon_filter(value): """Get file icon according to the file postfix""" diff --git a/settings.py b/settings.py index 9f2bed8295..8f00b96916 100644 --- a/settings.py +++ b/settings.py @@ -140,33 +140,6 @@ AUTHENTICATION_BACKENDS = ( ACCOUNT_ACTIVATION_DAYS = 7 -# Add supported file extensions and file icon name. -# Icons will show in repo page. -FILEEXT_ICON_MAP = { - # pdf file - 'pdf' : 'pdf.png', - # document file - 'doc' : 'ms-word.png', - 'docx' : 'ms-word.png', - 'ppt' : 'ms-ppt.png', - 'pptx' : 'ms-ppt.png', - 'xls' : 'ms-excel.png', - 'xlsx' : 'ms-excel.png', - 'txt' : 'txt.png', - 'odf' : 'odf.png', - # music file - 'mp3' : 'music-icon-24.png', - # picture file - 'jpg' : 'pic-icon-24.png', - 'jpeg' : 'pic-icon-24.png', - 'png' : 'pic-icon-24.png', - 'svg' : 'pic-icon-24.png', - 'gif' : 'pic-icon-24.png', - 'bmp' : 'pic-icon-24.png', - # normal file and unkown file - 'default' : 'file-icon-24.png', -} - # File preview FILE_PREVIEW_MAX_SIZE = 10 * 1024 * 1024