X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=blobdiff_plain;f=unfold%2Fstatic.py;h=ad38a9ef33cf5c2a99ba1f04e10c06a723013047;hp=815e8e228649d4294a51169aa75c13b620ca4ae5;hb=ed18f1b119ffd1796522ea4b53d84449d30ec854;hpb=5abab265d806d9de899ead6e896feb4afdf20540 diff --git a/unfold/static.py b/unfold/static.py index 815e8e22..ad38a9ef 100644 --- a/unfold/static.py +++ b/unfold/static.py @@ -4,6 +4,16 @@ from django.utils.datastructures import SortedDict from django.contrib.staticfiles.finders import BaseFinder, FileSystemFinder from django.core.files.storage import FileSystemStorage +# DEPRECATED # # http://nicks-liquid-soapbox.blogspot.fr/2011/03/splitting-path-to-list-in-python.html +# DEPRECATED # def splitpath(path, maxdepth=20): +# DEPRECATED # ( head, tail ) = os.path.split(path) +# DEPRECATED # return splitpath(head, maxdepth - 1) + [ tail ] \ +# DEPRECATED # if maxdepth and head and head != path \ +# DEPRECATED # else [ head or tail ] + +# The plugin finder is responsible for collecting JS, CSS and PNG files from +# the plugins, which are not declared in the myslice.settings file unlike +# applications. class PluginFinder(FileSystemFinder): """ A static files finder that looks in the directory of each plugin as @@ -75,27 +85,57 @@ class ThirdPartyFinder(BaseFinder): a two item iterable consisting of the relative path and storage instance. """ - for (path, dirs, files) in os.walk(settings.THIRDPARTY_DIR): - for file in files: - name, extension = os.path.splitext(file) - for type, extensions in self.extensions.items(): - if not extension in extensions: - continue - filesystem_storage = FileSystemStorage(location=path) - filesystem_storage.prefix = type - yield file, filesystem_storage + for component in os.listdir(settings.THIRDPARTY_DIR): + # We are looking forward symlinks only + component_path = os.path.join(settings.THIRDPARTY_DIR, component) + if not os.path.islink(component_path) or not os.path.isdir(component_path): + continue + + for (path, dirs, files) in os.walk(component_path): + for file in files: + name, extension = os.path.splitext(file) -class BaseFinder(object): - """ - A base file finder to be used for custom staticfiles finder classes. - """ + for type, extensions in self.extensions.items(): + if not extension in extensions: + continue + filesystem_storage = FileSystemStorage(location=path) + filesystem_storage.prefix = type + yield file, filesystem_storage + +# DEPRECATED # for (path, dirs, files) in os.walk(settings.THIRDPARTY_DIR): +# DEPRECATED # component_path = path[len(settings.THIRDPARTY_DIR)+1:] +# DEPRECATED # component_name = splitpath(component_path)[0] +# DEPRECATED # print "PATH", path, " -- COMPONENT", component_name +# DEPRECATED # if not os.path.islink(os.path.join(path, component_name)): +# DEPRECATED # print "IGNORED", component_name +# DEPRECATED # continue +# DEPRECATED # print "COMPONENT ADDED: ", component_name +# DEPRECATED # print "==" +# DEPRECATED # +# DEPRECATED # +# DEPRECATED # for file in files: +# DEPRECATED # name, extension = os.path.splitext(file) +# DEPRECATED # +# DEPRECATED # for type, extensions in self.extensions.items(): +# DEPRECATED # if not extension in extensions: +# DEPRECATED # continue +# DEPRECATED # filesystem_storage = FileSystemStorage(location=path) +# DEPRECATED # filesystem_storage.prefix = type +# DEPRECATED # yield file, filesystem_storage - def list(self, ignore_patterns): - """ - Given an optional list of paths to ignore, this should return - a two item iterable consisting of the relative path and storage - instance. - """ - raise NotImplementedError() +# XXX I commented this since it should be imported from django.contrib.staticfiles.finders -- jordan + +#class BaseFinder(object): +# """ +# A base file finder to be used for custom staticfiles finder classes. +# """ +# +# def list(self, ignore_patterns): +# """ +# Given an optional list of paths to ignore, this should return +# a two item iterable consisting of the relative path and storage +# instance. +# """ +# raise NotImplementedError()