|
@ -53,39 +53,39 @@ def make_cards(filepath, db_path, side_a, side_b): |
|
|
|
|
|
|
|
|
def select_fields(fields, content, styles, book): |
|
|
def select_fields(fields, content, styles, book): |
|
|
if "title" in fields: |
|
|
if "title" in fields: |
|
|
tag = "<font size=12>{}</font>".format(book.title) |
|
|
tag = "<font size=12>{}</font>".format(strip_tags(book.title)) |
|
|
ptitle = Paragraph(strip_tags(tag), styles["Italic"]) |
|
|
ptitle = Paragraph(tag, styles["Italic"]) |
|
|
content.append(ptitle) |
|
|
content.append(ptitle) |
|
|
content.append(Spacer(1, 12)) |
|
|
content.append(Spacer(1, 12)) |
|
|
|
|
|
|
|
|
if "timestamp" in fields: |
|
|
if "timestamp" in fields: |
|
|
tag = "<font size=10>Timestamp: {}</font>".format(book.timestamp) |
|
|
tag = "<font size=10>Timestamp: {}</font>".format(strip_tags(book.timestamp)) |
|
|
ptime = Paragraph(strip_tags(tag), styles["Normal"]) |
|
|
ptime = Paragraph(tag, styles["Normal"]) |
|
|
content.append(ptime) |
|
|
content.append(ptime) |
|
|
content.append(Spacer(1, 12)) |
|
|
content.append(Spacer(1, 12)) |
|
|
|
|
|
|
|
|
if "comments" in fields: |
|
|
if "comments" in fields: |
|
|
trimmed = " ".join([c.text for c in book.comments]).split()[:NUM_WORDS_COMMENT] |
|
|
trimmed = " ".join([c.text for c in book.comments]).split()[:NUM_WORDS_COMMENT] |
|
|
comments = " ".join(trimmed) |
|
|
comments = "{}...".format(" ".join(trimmed)) |
|
|
tag = "<font size=10>{}</font>".format(comments) |
|
|
tag = "<font size=10>{}</font>".format(strip_tags(comments)) |
|
|
pcomments = Paragraph(strip_tags(tag)) |
|
|
pcomments = Paragraph(tag) |
|
|
content.append(pcomments) |
|
|
content.append(pcomments) |
|
|
|
|
|
|
|
|
if "authors" in fields: |
|
|
if "authors" in fields: |
|
|
format_string = "<font size=12>{}</font>" |
|
|
format_string = "<font size=12>{}</font>" |
|
|
all_authors = [author.name for author in book.authors] |
|
|
all_authors = [strip_tags(author.name) for author in book.authors] |
|
|
glued_together = format_string.format(", ".join(all_authors)) |
|
|
glued_together = format_string.format(", ".join(all_authors)) |
|
|
|
|
|
|
|
|
p = Paragraph(strip_tags(glued_together), styles["Normal"]) |
|
|
p = Paragraph(glued_together, styles["Normal"]) |
|
|
content.append(p) |
|
|
content.append(p) |
|
|
content.append(Spacer(6, 12)) |
|
|
content.append(Spacer(6, 12)) |
|
|
|
|
|
|
|
|
if "tags" in fields: |
|
|
if "tags" in fields: |
|
|
format_string = "<font size=10>{}</font>" |
|
|
format_string = "<font size=10>{}</font>" |
|
|
all_tags = [tag.name for tag in book.tags] |
|
|
all_tags = [strip_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)) |
|
|
|
|
|
|
|
|
p = Paragraph(strip_tags(tags_glued_together), styles["Normal"]) |
|
|
p = Paragraph(tags_glued_together, styles["Normal"]) |
|
|
content.append(p) |
|
|
content.append(p) |
|
|
content.append(Spacer(6, 12)) |
|
|
content.append(Spacer(6, 12)) |
|
|
|
|
|
|
|
|