From 674807304804d922e862ad66d743a91e7a2cac47 Mon Sep 17 00:00:00 2001 From: klemek Date: Fri, 1 May 2020 13:05:17 +0200 Subject: [PATCH] new docs separating templates / reactions --- docs/README.md | 64 ++++++++++++------------------------ docs/build.py | 88 +++++++++++++++++++++++++++++--------------------- 2 files changed, 71 insertions(+), 81 deletions(-) diff --git a/docs/README.md b/docs/README.md index 0d596e0..89a8212 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,10 @@ +* [Commands](#commands) +* [Discord features](#discord-features) +* [CLI features](#cli-features) +* [List of templates](#list-of-templates) +* [List of reactions](#list-of-templates) + + ## Commands You can generate memes by using the following arguments: @@ -49,47 +56,16 @@ Each one has extra info and an image showing how texts are placed. Click on an image to enlarge it. - -|||| -|:---:|:---:|:---:| -|**aliens**
more info|**alive**
alt: no_brain
more info|**argument**
alt: wrestlers
more info| -|enlarge|enlarge|enlarge| -|**bender**
alt: hookers, blackjack
more info|**born_cool**
more info|**brain3**| -|enlarge|enlarge|enlarge| -|**brain4**
alt: brains
more info|**brain5**|**buff**
alt: tom, jerry
more info| -|enlarge|enlarge|enlarge| -|**burn**
alt: paper
more info|**button**
alt: nut
more info|**bye_mom**
alt: google
more info| -|enlarge|enlarge|enlarge| -|**clock**
more info|**culture**
alt: anime
more info|**disappointed**
more info| -|enlarge|enlarge|enlarge| -|**distracted**
alt: boyfried, cheating, girlfriend
more info|**dont_look**
alt: ricky, mom, influenced
more info|**drake**
more info| -|enlarge|enlarge|enlarge| -|**drift**
alt: exit
more info|**everywhere**
alt: buzz, woody
more info|**everywhere2**
alt: angry, diapers
more info| -|enlarge|enlarge|enlarge| -|**fight**
alt: vaping
more info|**fine**
alt: fire, dog
more info|**flex_tape**
alt: flex, tape
more info| -|enlarge|enlarge|enlarge| -|**gate**
more info|**girl_cat**
more info|**grandma**
more info| -|enlarge|enlarge|enlarge| -|**gru**
alt: plan
more info|**guys**
alt: explain, paid
more info|**handshake**
more info| -|enlarge|enlarge|enlarge| -|**handshake2**
alt: scott
more info|**idea**
alt: gentlemen
more info|**lion**
alt: shadowy, king, light
more info| -|enlarge|enlarge|enlarge| -|**meeting**
alt: boardroom, suggestion
more info|**mini**
alt: joker
more info|**nobody_cares**
alt: nobody, jurassic, park, jurassic_park
more info| -|enlarge|enlarge|enlarge| -|**nope**
more info|**overconfident**
alt: alcohol, depressed
more info|**patrick**
alt: wallet, id
more info| -|enlarge|enlarge|enlarge| -|**pigeon**
alt: butterfly
more info|**pills**
alt: swallow
more info|**pleasure3**
alt: satisfied3| -|enlarge|enlarge|enlarge| -|**pleasure4**
alt: pleasure, satisfied, satisfied4
more info|**salt_bae**
alt: salt
more info|**scary**
alt: spongebob, fearless
more info| -|enlarge|enlarge|enlarge| -|**seagull2**
alt: seagull, screaming
more info|**seagull4**|**see_that_guy**
more info| -|enlarge|enlarge|enlarge| -|**sleeping**
alt: brain
more info|**spiderman**
alt: same
more info|**struggle**
alt: choice, hero
more info| -|enlarge|enlarge|enlarge| -|**t_pose**
alt: dominance, monika
more info|**tom_cousins**
alt: cousins, backup, goons
more info|**tough2**
alt: tough, fight
more info| -|enlarge|enlarge|enlarge| -|**tough2bis**|**tough3**|**trump**
alt: law
more info| -|enlarge|enlarge|enlarge| -|**trust_nobody**
alt: yourself, gun
more info|**truth**
alt: scroll
more info|**winnie2**
alt: winnie
more info| -|enlarge|enlarge|enlarge||| - + + + + +## List of reactions + +You can find here the full list of reactions (templates without texts). +Each one has extra info. +Click on an image to enlarge it. + + + + diff --git a/docs/build.py b/docs/build.py index 3e1651e..85c8202 100644 --- a/docs/build.py +++ b/docs/build.py @@ -31,51 +31,65 @@ def make_empty(target_dir: str): make_empty(templates_dir) make_empty(preview_dir) -id_list = sorted(meme_db.LIST) -doc_content = "|" * (COLUMNS + 1) \ - + "\n|" + ":---:|" * COLUMNS +def produce_doc(id_list): + if len(id_list) == 0: + return "" + doc_content = "|" * (COLUMNS + 1) \ + + "\n|" + ":---:|" * COLUMNS + info_line = None + img_line = None + i = None + for i, meme_id in enumerate(id_list): + meme = meme_db.get_meme(meme_id) + img = img_factory.build_from_template(meme.template, meme.texts, debug=True) + if img is not None: + img.save(path.join(templates_dir, meme.template)) + size = (round(img.size[0] * IMG_HEIGHT / img.size[1]), IMG_HEIGHT) + img2 = img.resize(size, resample=PIL.Image.LANCZOS) + img2.save(path.join(preview_dir, meme.template)) + if i % COLUMNS == 0: + if info_line is not None and img_line is not None: + doc_content += info_line + img_line + info_line = "\n|" + img_line = "\n|" + info_line += f"**{meme_id}**" + if len(meme.aliases) > 0: + info_line += f"
alt: {', '.join(meme.aliases)}" + if meme.info is not None: + info_line += f"
more info" + info_line += "|" + img_line += f"" \ + f"" \ + f"enlarge" \ + f"|" + print(i, meme_id) + doc_content += "|" * (COLUMNS - (i % COLUMNS)) + return doc_content -info_line = None -img_line = None -i = None -for i, meme_id in enumerate(id_list): - meme = meme_db.get_meme(meme_id) - img = img_factory.build_from_template(meme.template, meme.texts, debug=True) - if img is not None: - img.save(path.join(templates_dir, meme.template)) - size = (round(img.size[0] * IMG_HEIGHT / img.size[1]), IMG_HEIGHT) - img2 = img.resize(size, resample=PIL.Image.LANCZOS) - img2.save(path.join(preview_dir, meme.template)) - if i % COLUMNS == 0: - if info_line is not None and img_line is not None: - doc_content += info_line + img_line - info_line = "\n|" - img_line = "\n|" - info_line += f"**{meme_id}**" - if len(meme.aliases) > 0: - info_line += f"
alt: {', '.join(meme.aliases)}" - if meme.info is not None: - info_line += f"
more info" - info_line += "|" - img_line += f"" \ - f"" \ - f"enlarge" \ - f"|" - print(i, meme_id) +full_list = sorted(meme_db.LIST) +template_list = [meme_id for meme_id in full_list if len(meme_db.get_meme(meme_id).texts) > 0] +reaction_list = [meme_id for meme_id in full_list if meme_id not in template_list] -doc_content += "|" * (COLUMNS - (i % COLUMNS)) +doc_content1 = produce_doc(template_list) +doc_content2 = produce_doc(reaction_list) with open(doc_file, mode='r') as f: content = "".join(f.readlines()) -i0 = content.index("") -i1 = content.index("") + len("") +i0 = content.index("") +i1 = content.index("") + len("") +i2 = content.index("") +i3 = content.index("") + len("") with open(doc_file, mode='w') as f: f.write(content[:i0]) - f.write("\n") - f.write(doc_content) - f.write("\n") - f.write(content[i1:]) + f.write("\n") + f.write(doc_content1) + f.write("\n") + f.write(content[i1:i2]) + f.write("\n") + f.write(doc_content2) + f.write("\n") + f.write(content[i3:])