mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 16:31:13 +00:00
Add file_icon_filter
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
from datetime import datetime
|
||||
from django import template
|
||||
|
||||
from seahub.settings import SUPPORTED_FILE_EXT
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.filter(name='tsstr_sec')
|
||||
@@ -11,3 +13,15 @@ def tsstr_sec(value):
|
||||
except:
|
||||
return datetime.fromtimestamp(value/1000000).strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
@register.filter(name='file_icon_filter')
|
||||
def file_icon_filter(value):
|
||||
"""Get file icon according to the file postfix"""
|
||||
if value.rfind('.') > 0:
|
||||
file_ext = value.split('.')[-1]
|
||||
else:
|
||||
file_ext = None
|
||||
|
||||
if file_ext and SUPPORTED_FILE_EXT.has_key(file_ext):
|
||||
return SUPPORTED_FILE_EXT.get(file_ext)
|
||||
else:
|
||||
return SUPPORTED_FILE_EXT.get('default')
|
||||
|
@@ -129,6 +129,14 @@ CCNET_APPLET_ROOT = "http://localhost:8081"
|
||||
|
||||
SEAFILE_VERSION = '0.9.2'
|
||||
|
||||
# Add supported file extensions and file icon name.
|
||||
# Icons will show in repo page.
|
||||
SUPPORTED_FILE_EXT = {
|
||||
'txt' : 'foo.jpg',
|
||||
'pdf' : '',
|
||||
'default' : '',
|
||||
}
|
||||
|
||||
try:
|
||||
import local_settings
|
||||
except ImportError:
|
||||
|
Reference in New Issue
Block a user