Skip to content

Commit

Permalink
Merge branch 'temaput-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Jan 16, 2018
2 parents 6d80426 + 45dcdc6 commit 163b17d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
7 changes: 2 additions & 5 deletions bakery/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,5 @@
class BakeryConfig(AppConfig):
name = 'bakery'
verbose_name = "Bakery"

def ready(self):
self.filesystem_name = getattr(settings, 'BAKERY_FILESYSTEM', "osfs:///")
logger.debug("Loading filesystem at {}".format(self.filesystem_name))
self.filesystem = fs.open_fs(self.filesystem_name)
filesystem_name = getattr(settings, 'BAKERY_FILESYSTEM', "osfs:///")
filesystem = fs.open_fs(filesystem_name)
7 changes: 4 additions & 3 deletions bakery/management/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def build_static(self, *args, **options):
self.build_dir,
settings.STATIC_URL.lstrip('/')
)
target_dir = smart_text(target_dir)

if os.path.exists(self.static_root) and settings.STATIC_URL:
if getattr(settings, 'BAKERY_GZIP', False):
Expand Down Expand Up @@ -219,7 +220,7 @@ def build_media(self):
if os.path.exists(self.media_root) and settings.MEDIA_URL:
target_dir = path.join(self.fs_name, self.build_dir, settings.MEDIA_URL.lstrip('/'))
logger.debug("Copying {}{} to {}{}".format("osfs://", self.media_root, self.fs_name, target_dir))
copy.copy_dir("osfs:///", self.media_root, self.fs, target_dir)
copy.copy_dir("osfs:///", smart_text(self.media_root), self.fs, smart_text(target_dir))

def get_view_instance(self, view):
"""
Expand Down Expand Up @@ -304,7 +305,7 @@ def copyfile_and_gzip(self, source_path, target_path):
self.fs_name,
target_path
))
copy.copy_file("osfs:///", source_path, self.fs, target_path)
copy.copy_file("osfs:///", smart_text(source_path), self.fs, smart_text(target_path))

# # if the file is already gzipped
elif encoding == 'gzip':
Expand All @@ -314,7 +315,7 @@ def copyfile_and_gzip(self, source_path, target_path):
self.fs_name,
target_path
))
copy.copy_file("osfs:///", source_path, self.fs, target_path)
copy.copy_file("osfs:///", smart_text(source_path), self.fs, smart_text(target_path))

# If it is one we want to gzip...
else:
Expand Down
8 changes: 5 additions & 3 deletions bakery/management/commands/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,16 @@ def upload_to_s3(self, key, filename):
and upload the item to S3
"""
extra_args = {'ACL': self.acl}
# guess and add the mimetype to header
content_type = mimetypes.guess_type(filename)[0]
# determine the mimetype of the file
guess = mimetypes.guess_type(filename)
content_type = guess[0]
encoding = guess[1]

if content_type:
extra_args['ContentType'] = content_type

# add the gzip headers, if necessary
if self.gzip and content_type in self.gzip_content_types:
if (self.gzip and content_type in self.gzip_content_types) or encoding == 'gzip':
extra_args['ContentEncoding'] = 'gzip'

# add the cache-control headers if necessary
Expand Down
Binary file added example/date_views/static/dem-output.bin.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def run(self):

setup(
name='django-bakery',
version='0.12.1',
version='0.12.3',
description='A set of helpers for baking your Django site out as flat files',
author='The Los Angeles Times Data Desk',
author_email='datadesk@latimes.com',
Expand Down

0 comments on commit 163b17d

Please sign in to comment.