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

Generování EPUB #41

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

jacekszymanski
Copy link

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

Copy link
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?

@@ -13,6 +13,10 @@
from naucse.urlconverters import register_url_converters
from naucse.templates import setup_jinja_env

import mkepub
from bs4 import BeautifulSoup
Copy link
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 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
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.

)


# je nutné upravit adresy img
Copy link
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.

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
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/.


lesson_chapter_html = str(chap_tree)

epub_course.add_page(material.title or 'bez titulu',
Copy link
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 on lines +277 to +278

# logger.debug(image_path)
Copy link
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)


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

course_url = 'file://' + str(course.base_path)
Copy link
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.

None yet

2 participants