diff --git a/readthedocs/core/static.py b/readthedocs/core/static.py new file mode 100644 index 00000000000..89cd883877e --- /dev/null +++ b/readthedocs/core/static.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import division, print_function, unicode_literals + +from django.contrib.staticfiles.finders import FileSystemFinder + + +class SelectiveFileSystemFinder(FileSystemFinder): + + """ + Add user media paths in ``media/`` to ignore patterns. + + This allows collectstatic inside ``media/`` without collecting all of the + paths that include user files + """ + + def list(self, ignore_patterns): + ignore_patterns.extend(['epub', 'pdf', 'htmlzip', 'json', 'man']) + return super(SelectiveFileSystemFinder, self).list(ignore_patterns) diff --git a/readthedocs/settings/base.py b/readthedocs/settings/base.py index f092cd7e6a3..a9113c7ee08 100644 --- a/readthedocs/settings/base.py +++ b/readthedocs/settings/base.py @@ -176,6 +176,10 @@ def USE_PROMOS(self): # noqa os.path.join(SITE_ROOT, 'readthedocs', 'static'), os.path.join(SITE_ROOT, 'media'), ] + STATICFILES_FINDERS = [ + 'readthedocs.core.static.SelectiveFileSystemFinder', + 'django.contrib.staticfiles.finders.AppDirectoriesFinder', + ] TEMPLATES = [ {