1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-14 06:11:16 +00:00

Add file icon

This commit is contained in:
xiez
2012-05-17 23:11:46 +08:00
parent 3ed66222f9
commit 27f714c4a8
12 changed files with 25 additions and 9 deletions

View File

@@ -1,7 +1,7 @@
from datetime import datetime from datetime import datetime
from django import template from django import template
from seahub.settings import SUPPORTED_FILE_EXT from seahub.settings import FILEEXT_ICON_MAP
register = template.Library() register = template.Library()
@@ -21,7 +21,7 @@ def file_icon_filter(value):
else: else:
file_ext = None file_ext = None
if file_ext and SUPPORTED_FILE_EXT.has_key(file_ext): if file_ext and FILEEXT_ICON_MAP.has_key(file_ext):
return SUPPORTED_FILE_EXT.get(file_ext) return FILEEXT_ICON_MAP.get(file_ext)
else: else:
return SUPPORTED_FILE_EXT.get('default') return FILEEXT_ICON_MAP.get('default')

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -131,10 +131,23 @@ SEAFILE_VERSION = '0.9.2'
# 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.
SUPPORTED_FILE_EXT = { FILEEXT_ICON_MAP = {
'txt' : 'foo.jpg', # pdf file
'pdf' : '', 'pdf' : 'file-extension-pdf-icon-24.png',
'default' : '', # document file
'doc' : 'document-word-icon-24.png',
'docx' : 'document-word-icon-24.png',
# ppt file
'ppt' : 'document-powerpoint-icon-24.png',
'pptx' : 'document-powerpoint-icon-24.png',
# music file
'mp3' : 'File-Music-icon-24.png',
# picture file
'jpg' : 'File-Pictures-icon-24.png',
'jpeg' : 'File-Pictures-icon-24.png',
'png' : 'File-Pictures-icon-24.png',
# normal file and unkown file
'default' : 'File-icon-default-24.png',
} }
try: try:

View File

@@ -46,16 +46,19 @@
{% else %} {% else %}
<table> <table>
<tr> <tr>
<th width="70%">名字</th> <th width="5%"></th>
<th width="65%">名字</th>
<th width="30%">操作</th> <th width="30%">操作</th>
</tr> </tr>
{% for dirent in dirs %} {% for dirent in dirs %}
<tr> <tr>
{% if dirent.is_dir %} {% if dirent.is_dir %}
<td><img src="{{ MEDIA_URL }}/img/favicon.png" /></td>
<td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/?root_id={{ dirent.props.obj_id }}">{{ dirent.props.obj_name }}</a></td> <td><a href="{{ SITE_ROOT }}repo/{{ repo.props.id }}/?root_id={{ dirent.props.obj_id }}">{{ dirent.props.obj_name }}</a></td>
<td></td> <td></td>
{% else %} {% else %}
<td><img src="{{ MEDIA_URL }}/img/{{ dirent.obj_name|file_icon_filter }}" /></td>
<td>{{ dirent.props.obj_name }}</td> <td>{{ dirent.props.obj_name }}</td>
<td> <td>
<a class="table-op" href="{{ SITE_ROOT }}repo/view/{{ repo.props.id }}/{{ dirent.props.obj_id }}/?file_name={{ dirent.props.obj_name }}">查看</a> <a class="table-op" href="{{ SITE_ROOT }}repo/view/{{ repo.props.id }}/{{ dirent.props.obj_id }}/?file_name={{ dirent.props.obj_name }}">查看</a>