Skip to content

Generování EPUB#41

Open
jcszymansk wants to merge 6 commits into
pyvec:masterfrom
jcszymansk:epub
Open

Generování EPUB#41
jcszymansk wants to merge 6 commits into
pyvec:masterfrom
jcszymansk:epub

Conversation

@jcszymansk
Copy link
Copy Markdown

EPUB z kurzů, zatím bez odkazů z ostatních stránek.

Copy link
Copy Markdown
Member

@encukou encukou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omlouvám se, že jsem se k review nedostal dříve – tenhle pull request jsem nezapsal správně do poznámek :(

Vypadá to jako dobrý začátek, ale mám spoustu otázek. A taky nevím jak přesně funguje ten epub; abych mohl udělat dobré review taksi to budu muset nastudovat.

S jakým kurzem jsi testoval?

Comment thread naucse/views.py
from naucse.templates import setup_jinja_env

import mkepub
from bs4 import BeautifulSoup
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naucse už používá lxml, které by mělo stačit – další knihovna by neměla být potřeba. Ale jestli lxml neznáš, můžu to pak převést.

Comment thread naucse/views.py
Comment on lines +229 to +232
epub_path = str(course.base_path) + '/' + course.slug + '.epub'

if (os.path.exists(epub_path)):
os.remove(epub_path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

course.base_path by mělo být jen pro čtení; použij např. tempfile.TemporaryDirectory.

Comment thread naucse/views.py
)


# je nutné upravit adresy img
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ostatní soubory?
Např. na https://naucse.python.cz/course/mi-pyt/intro/numpy/ je zvuk, který se v porhlížeči dá přehrát.

Comment thread naucse/views.py
images = chap_tree.find_all('img')
for image in images:
img_base_name = os.path.basename(image['src'])
static = lesson.static_files[img_base_name]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ne všechny obrázky z <img> jsou v static_files, některé jsou přímo v kódu. Třeba opět u https://naucse.python.cz/course/mi-pyt/intro/numpy/.

Comment thread naucse/views.py

lesson_chapter_html = str(chap_tree)

epub_course.add_page(material.title or 'bez titulu',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Použij radši lesson.title, ten je povinný.

Comment thread naucse/views.py
Comment on lines +277 to +278

# logger.debug(image_path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# logger.debug(image_path)

Comment thread naucse/views.py

epub_course = mkepub.Book(course.title, language='cs')

course_url = 'file://' + str(course.base_path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tohle není potřeba?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants