-
Notifications
You must be signed in to change notification settings - Fork 9
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
base: master
Are you sure you want to change the base?
Generování EPUB #41
Conversation
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
epub_path = str(course.base_path) + '/' + course.slug + '.epub' | ||
|
||
if (os.path.exists(epub_path)): | ||
os.remove(epub_path) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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ý.
|
||
# logger.debug(image_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# logger.debug(image_path) |
|
||
epub_course = mkepub.Book(course.title, language='cs') | ||
|
||
course_url = 'file://' + str(course.base_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tohle není potřeba?
EPUB z kurzů, zatím bez odkazů z ostatních stránek.