diff options
author | kvakanet <kvakanet@users.noreply.github.com> | 2017-02-12 10:50:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-12 10:50:35 +0300 |
commit | f42f21e910b3d08a612c815c71bf0727a2738553 (patch) | |
tree | c5c2d62d6e5a9be9dac4d4222d6837c68edbcdfc | |
parent | 8cd076fe9f58bdab7e45c54a6d5a035eb4fb2264 (diff) |
Add files via upload
-rwxr-xr-x | habraparse.py | 22 | ||||
-rw-r--r-- | requirements.txt | 6 |
2 files changed, 19 insertions, 9 deletions
diff --git a/habraparse.py b/habraparse.py index 2f3f8e6..c455089 100755 --- a/habraparse.py +++ b/habraparse.py @@ -55,16 +55,23 @@ def prepare_html(topic, with_comments=False): <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta charset="UTF-8"> <title>{title}</title> + <meta name="author" content="{author}"> + <meta name="generator" content="habraparse"> + <meta name="description" content="{desc}"> + <meta name="keywords" content="{keywords}"> </head> <body> <div id="layout"> <div class="inner"> <div class="content_left"> - <div class="post_show"> - <div class="post shortcuts_item"> + <!-- <div class="post_show"> --> + <div class="post__body post__body_full"> + <!-- <div class="post shortcuts_item"> --> + <div class="content html_format"> <h1 class="title"><span class="post_title">{title}</span></h1> <div class="author"> - <a title="Автор текста" href="http://habrahabr.ru/users/{author}/" >{author}</a> + <!-- <a title="Автор текста" href="http://habrahabr.ru/users/{author}/" >{author}</a> --> + <a title="Автор текста" href="{author_url}" >{author}</a> </div> {text} </div> @@ -89,11 +96,13 @@ def prepare_html(topic, with_comments=False): ''' if with_comments: html_format = html_head + html_cmnts + html_foot - html = html_format.format(title=t.title(), author=t.author(), text=t.text(), + html = html_format.format(title=t.title(), author=t.author(), author_url=t.author_url(), desc=t.desc(), text=t.text(), + addstyle=t.styles(), keywords=t.keywords(), comments=generate_comments(t.comments(), 0), cmnts_count=t.comments_count()) else: html_format = html_head + html_foot - html = html_format.format(title=t.title(), author=t.author(), text=t.text()) + html = html_format.format(title=t.title(), author=t.author(), author_url=t.author_url(), desc=t.desc(), text=t.text(), + addstyle=t.styles(), keywords=t.keywords() ) html = str(html).replace('"//habrastorage.org', '"https://habrastorage.org') return html @@ -137,7 +146,8 @@ def save_pdf(topic_id: int, filename: str, with_comments: bool = False, project: ht = HabraTopic(topic_id) html = prepare_html(ht, with_comments=with_comments) - css = CSS(string='@page { size: A4; margin: 1cm !important}') + css = CSS(string='@page { size: A4; margin: 1cm; !important;} img { width: 100%; height: auto; !important; }') + #css = CSS(string='@page { size: A4 landscape; margin: 1cm !important}') HTML(string=html).write_pdf(filename, stylesheets=[css]) diff --git a/requirements.txt b/requirements.txt index ddad416..83aed1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -cairocffi==0.7.2 -CairoSVG==2.0.0 +cairocffi>=0.7.2 +CairoSVG>=2.0.0 cffi==1.9.1 cssselect==1.0.0 docopt==0.6.2 @@ -11,5 +11,5 @@ Pyphen==0.9.4 requests==2.12.3 six==1.10.0 tinycss==0.4 -WeasyPrint==0.33 +WeasyPrint>=0.34 webencodings==0.5 |