Repos / pytaku / 60570d9e7d
commit 60570d9e7d9ec4741354910bbed388a98774c5a3
Author: Bùi Thành Nhân <hi@imnhan.com>
Date: Mon Aug 3 00:31:55 2020 +0700
render webtoon in long uninterrupted strip
diff --git a/pyproject.toml b/pyproject.toml
index 9477d30..ed83127 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytaku"
-version = "0.1.2"
+version = "0.1.3"
description = ""
authors = ["Bùi Thành Nhân <hi@imnhan.com>"]
license = "AGPL-3.0-only"
diff --git a/src/mangoapi/__init__.py b/src/mangoapi/__init__.py
index d975b16..50ff31c 100644
--- a/src/mangoapi/__init__.py
+++ b/src/mangoapi/__init__.py
@@ -76,6 +76,7 @@ def get_chapter(chapter_id):
"name": md_json["title"],
"pages": [f"{img_path}/{page}" for page in md_json["page_array"]],
"groups": _extract_groups(md_json),
+ "is_webtoon": md_json["long_strip"] == 1,
**_parse_chapter_number(md_json["chapter"]),
}
return chapter
diff --git a/src/pytaku/database/migrations/latest_schema.sql b/src/pytaku/database/migrations/latest_schema.sql
index 18089c6..92857ab 100644
--- a/src/pytaku/database/migrations/latest_schema.sql
+++ b/src/pytaku/database/migrations/latest_schema.sql
@@ -22,7 +22,7 @@ CREATE TABLE chapter (
name text,
pages text,
groups text,
- updated_at text default (datetime('now')),
+ updated_at text default (datetime('now')), is_webtoon boolean,
foreign key (title_id, site) references title (id, site),
unique(id, title_id, site),
diff --git a/src/pytaku/database/migrations/m0002.sql b/src/pytaku/database/migrations/m0002.sql
new file mode 100644
index 0000000..442f3d8
--- /dev/null
+++ b/src/pytaku/database/migrations/m0002.sql
@@ -0,0 +1 @@
+alter table chapter add column is_webtoon boolean;
diff --git a/src/pytaku/persistence.py b/src/pytaku/persistence.py
index 6587b73..e12c15e 100644
--- a/src/pytaku/persistence.py
+++ b/src/pytaku/persistence.py
@@ -86,7 +86,8 @@ def save_chapter(chapter):
num_minor,
name,
pages,
- groups
+ groups,
+ is_webtoon
) VALUES (
:id,
:title_id,
@@ -95,7 +96,8 @@ def save_chapter(chapter):
:num_minor,
:name,
:pages,
- :groups
+ :groups,
+ :is_webtoon
);
""",
{
@@ -107,6 +109,7 @@ def save_chapter(chapter):
"name": chapter["name"],
"pages": json.dumps(chapter["pages"]),
"groups": json.dumps(chapter["groups"]),
+ "is_webtoon": chapter["is_webtoon"],
},
)
@@ -116,7 +119,7 @@ def load_chapter(chapter_id):
result = list(
conn.cursor().execute(
"""
- SELECT id, title_id, num_major, num_minor, name, pages, groups
+ SELECT id, title_id, num_major, num_minor, name, pages, groups, is_webtoon
FROM chapter
WHERE id = ?;
""",
@@ -137,6 +140,7 @@ def load_chapter(chapter_id):
"name": chapter[4],
"pages": json.loads(chapter[5]),
"groups": json.loads(chapter[6]),
+ "is_webtoon": chapter[7],
}
diff --git a/src/pytaku/templates/chapter.html b/src/pytaku/templates/chapter.html
index 866a446..b6a5665 100644
--- a/src/pytaku/templates/chapter.html
+++ b/src/pytaku/templates/chapter.html
@@ -30,7 +30,10 @@
.pages img {
display: block;
- margin: 0 auto 1rem auto;
+ margin: 0 auto .7rem auto;
+ }
+ .pages.webtoon img {
+ margin: 0 auto;
}
.buttons {
@@ -74,7 +77,7 @@ <h1>{{ self.title() }}</h1>
</div>
{% endblock %}
-<div class="pages">
+<div class="pages {% if is_webtoon %}webtoon{% endif %}">
{% for page in pages %}
<img src="{{ page }}" crossorigin="anonymous" referrerpolicy="no-referrer"/>
{% endfor %}