Navigation Menu

Skip to content

Commit

Permalink
Add some icon rules for autoindex.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Heung-sub committed Sep 4, 2010
1 parent 63bf6dc commit 5a3eaab
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion subleekr/labs/__init__.py
@@ -1,6 +1,6 @@
import os.path
from flask import Module
from flaskext.autoindex import AutoIndexModule
from flaskext.autoindex import AutoIndexModule, RootFolder, Folder
from subleekr import FlaskModule


Expand All @@ -9,5 +9,24 @@
idx = AutoIndexModule(app, browse_root)


def get_favicon(ent):
favicon_paths = "favicon.ico", "resources/favicon.ico", \
"artwork/favicon.ico", "static/favicon.ico", \
"docs/_static/favicon.ico"
favicon_paths = sorted(favicon_paths,
lambda x, y: -cmp(x.count("/"), y.count("/")))
if type(ent) is Folder and ent.name != "build":
for favicon_path in favicon_paths:
dirname = os.path.dirname(favicon_path)
if dirname and ent.path.endswith(dirname):
return False
favicon = os.path.join(ent.path, favicon_path)
if os.path.isfile(os.path.join(ent.root, favicon)):
return "/" + favicon
return False


idx.add_icon_rule("folder_brick.png", foldername="forks")
idx.add_icon_rule("/favicon.ico", cls=RootFolder)
idx.add_icon_rule(get_favicon)

0 comments on commit 5a3eaab

Please sign in to comment.