|
@ -11,7 +11,7 @@ def make_cards(): |
|
|
"""The main entrypoint for card generation.""" |
|
|
"""The main entrypoint for card generation.""" |
|
|
# TODO: thread arguments into this logic |
|
|
# TODO: thread arguments into this logic |
|
|
doc = create_doc("text.pdf") |
|
|
doc = create_doc("text.pdf") |
|
|
content = get_fields(doc) |
|
|
content = get_fields() |
|
|
doc.build(content) |
|
|
doc.build(content) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,37 +22,39 @@ def get_fields(): |
|
|
session = init_session("sqlite:///metadata.db") |
|
|
session = init_session("sqlite:///metadata.db") |
|
|
|
|
|
|
|
|
for book in session.query(Book).all(): |
|
|
for book in session.query(Book).all(): |
|
|
ptitle = Paragraph( |
|
|
for comment in session.query(Comment).all(): |
|
|
"<font size=12>{}</font>".format(book.title), styles["Italic"] |
|
|
ptitle = Paragraph( |
|
|
) |
|
|
"<font size=12>{}</font>".format(book.title), styles["Italic"] |
|
|
ptime = Paragraph( |
|
|
) |
|
|
"<font size=10>Uploaded: {}</font>".format(book.timestamp), styles["Normal"] |
|
|
ptime = Paragraph( |
|
|
) |
|
|
"<font size=10>Uploaded: {}</font>".format(book.timestamp), |
|
|
pcomments = Paragraph("<font size=10>{}</font>".format(comment.text)) |
|
|
styles["Normal"], |
|
|
|
|
|
) |
|
|
|
|
|
pcomments = Paragraph("<font size=10>{}</font>".format(comment.text)) |
|
|
|
|
|
|
|
|
format_string = "<font size=12>{}</font>" |
|
|
format_string = "<font size=12>{}</font>" |
|
|
all_authors = [author.name for author in book.authors] |
|
|
all_authors = [author.name for author in book.authors] |
|
|
glued_together = format_string.format(", ".join(all_authors)) |
|
|
glued_together = format_string.format(", ".join(all_authors)) |
|
|
|
|
|
|
|
|
format_string = "<font size=10>{}</font>" |
|
|
format_string = "<font size=10>{}</font>" |
|
|
all_tags = [tag.name for tag in book.tags] |
|
|
all_tags = [tag.name for tag in book.tags] |
|
|
tags_glued_together = format_string.format(", ".join(all_tags)) |
|
|
tags_glued_together = format_string.format(", ".join(all_tags)) |
|
|
|
|
|
|
|
|
content.append(ptitle) |
|
|
content.append(ptitle) |
|
|
content.append(Spacer(1, 12)) |
|
|
content.append(Spacer(1, 12)) |
|
|
content.append(ptime) |
|
|
content.append(ptime) |
|
|
content.append(Spacer(1, 12)) |
|
|
content.append(Spacer(1, 12)) |
|
|
content.append(pcomments) |
|
|
content.append(pcomments) |
|
|
|
|
|
|
|
|
p = Paragraph(glued_together, styles["Normal"]) |
|
|
p = Paragraph(glued_together, styles["Normal"]) |
|
|
content.append(p) |
|
|
content.append(p) |
|
|
content.append(PageBreak()) |
|
|
content.append(PageBreak()) |
|
|
content.append(Spacer(6, 12)) |
|
|
content.append(Spacer(6, 12)) |
|
|
|
|
|
|
|
|
p = Paragraph(tags_glued_together, styles["Normal"]) |
|
|
p = Paragraph(tags_glued_together, styles["Normal"]) |
|
|
content.append(p) |
|
|
content.append(p) |
|
|
content.append(PageBreak()) |
|
|
content.append(PageBreak()) |
|
|
content.append(Spacer(6, 12)) |
|
|
content.append(Spacer(6, 12)) |
|
|
|
|
|
|
|
|
return content |
|
|
return content |
|
|
|
|
|
|
|
|