Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compile epub scss during normal process #1576

Merged
merged 2 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions indigo_api/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,16 @@ def create_book(self):
def add_css(self):
self.stylesheets = []

# compile scss and add the file
processor = SassProcessor()
processor.processor_enabled = True
path = processor('stylesheets/export-epub.scss')
with processor.source_storage.open(path) as f:
path = 'stylesheets/export-epub.css'
static_path = find_static(path)
if not static_path:
# compile the scss, this is mostly only for unit tests, because the sass is compiled with compilescss
# in production
processor = SassProcessor()
processor.processor_enabled = True
static_path = find_static(processor('stylesheets/export-epub.scss'))

with open(static_path) as f:
css = f.read()
self.book.add_item(epub.EpubItem(file_name=path, media_type="text/css", content=css))
self.stylesheets.append(path)
Expand Down
1 change: 1 addition & 0 deletions indigo_api/templates/indigo_api/akn/export/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{% block head-css %}
{# this ensure thas the stylesheet is built during compilescss #}
<!-- {% sass_src 'stylesheets/export.scss' %} -->
<!-- {% sass_src 'stylesheets/export-epub.scss' %} -->
<style type="text/css">{% inline_scss 'stylesheets/export.scss' %}</style>
{% endblock %}

Expand Down