Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate templates automatically #530

Merged
merged 3 commits into from Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/models.py
Expand Up @@ -68,6 +68,16 @@ def __str__(self):

@property
def valid(self) -> bool:
if settings.DEBUG:
styles = []
for path in self.directory.iterdir():
if path.stem != "config":
styles.append(path.stem)
if "default" in self.styles:
styles.remove("default")
styles.sort()
if styles != self.styles:
self.styles = styles
return not self.key.startswith("_") and self.image.suffix != ".img"

@property
Expand Down
9 changes: 9 additions & 0 deletions templates/_error/config.yml
@@ -1,13 +1,22 @@
name: Error
source:
text:
- color: white
style: upper
anchor_x: 0.1
anchor_y: 0.1
angle: 0.0
scale_x: 0.8
scale_y: 0.2
- color: white
style: upper
anchor_x: 0.1
anchor_y: 0.7
angle: 0.0
scale_x: 0.8
scale_y: 0.2
styles:
-
sample:
- YOUR TEXT
- GOES HERE
21 changes: 21 additions & 0 deletions templates/_test/config.yml
@@ -1 +1,22 @@
name: Test
source:
text:
- color: white
style: upper
anchor_x: 0.0
anchor_y: 0.0
angle: 0.0
scale_x: 1.0
scale_y: 0.2
- color: white
style: upper
anchor_x: 0.0
anchor_y: 0.8
angle: 0.0
scale_x: 1.0
scale_y: 0.2
styles:
-
sample:
- YOUR TEXT
- GOES HERE
2 changes: 1 addition & 1 deletion templates/aag/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
- ALIENS
2 changes: 1 addition & 1 deletion templates/ackbar/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
- IT'S A TRAP!
2 changes: 1 addition & 1 deletion templates/afraid/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- I DON'T KNOW WHAT THIS MEME IS FOR
- AND AT THIS POINT I'M TOO AFRAID TO ASK
2 changes: 1 addition & 1 deletion templates/aint-got-time/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- MEMES?
- AIN'T NOBODY GOT TIME FO' THAT
2 changes: 1 addition & 1 deletion templates/ants/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- DO YOU WANT ANTS?
- BECAUSE THAT'S HOW YOU GET ANTS
2 changes: 1 addition & 1 deletion templates/apcr/config.yml
Expand Up @@ -16,6 +16,6 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
2 changes: 1 addition & 1 deletion templates/atis/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- AND THEN I SAID
- THE EXAM WILL ONLY CONTAIN WHAT WE'VE COVERED IN LECTURES
2 changes: 1 addition & 1 deletion templates/awesome/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- SAY A WORD WRONG
- CREATE HILARIOUS INSIDE JOKE
2 changes: 1 addition & 1 deletion templates/awkward/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- START TELLING JOKE
- FORGET PUNCHLINE
2 changes: 1 addition & 1 deletion templates/bad/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- YOUR MEME IS BAD
- AND YOU SHOULD FEEL BAD
2 changes: 1 addition & 1 deletion templates/badchoice/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- MILK
- WAS A BAD CHOICE
2 changes: 1 addition & 1 deletion templates/bd/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- CAN'T WORKOUT
- DON'T WANT TO GET TOO BUFF
2 changes: 1 addition & 1 deletion templates/bender/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- I'M GOING TO BUILD MY OWN THEME PARK
- WITH BLACKJACK AND HOOKERS
2 changes: 1 addition & 1 deletion templates/bihw/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- IT AIN'T MUCH
- BUT IT'S HONEST WORK
2 changes: 1 addition & 1 deletion templates/biw/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- GETS ICED COFFEE
- IN THE WINTER
2 changes: 1 addition & 1 deletion templates/blb/config.yml
Expand Up @@ -16,6 +16,6 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
2 changes: 1 addition & 1 deletion templates/boat/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
- I SHOULD BUY A BOAT
2 changes: 1 addition & 1 deletion templates/bs/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- WHAT A SURPRISE...
- YOU CAUGHT ME AGAIN
2 changes: 1 addition & 1 deletion templates/buzz/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- MEMES
- MEMES EVERYWHERE
2 changes: 1 addition & 1 deletion templates/cb/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- I STOLE
- THE PIC-I-NIC BASKET
2 changes: 1 addition & 1 deletion templates/center/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- WHAT IS THIS
- A CENTER FOR ANTS
2 changes: 1 addition & 1 deletion templates/ch/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- IF YOU WANTED TO AVOID THE FRIEND ZONE
- YOU SHOULD HAVE MADE YOUR INTENTIONS KNOWN FROM THE START
2 changes: 1 addition & 1 deletion templates/chosen/config.yml
Expand Up @@ -16,6 +16,6 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- YOU WERE THE CHOSEN ONE!
2 changes: 1 addition & 1 deletion templates/crazypills/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
- I FEEL LIKE I'M TAKING CRAZY PILLS
2 changes: 1 addition & 1 deletion templates/cryingfloor/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- IT'S OKAY
- LETS JUST RESCHEDULE DRINKING
2 changes: 1 addition & 1 deletion templates/db/config.yml
Expand Up @@ -23,7 +23,7 @@ text:
scale_x: 0.2
scale_y: 0.1
styles:
- default
-
sample:
- Socialism
- The Youth
Expand Down
2 changes: 1 addition & 1 deletion templates/disastergirl/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- WHAT DID YOU SAY?
- ''
2 changes: 1 addition & 1 deletion templates/dodgson/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- WE’VE GOT DODGSON HERE!
- SEE? NOBODY CARES
7 changes: 6 additions & 1 deletion templates/doge/config.yml
Expand Up @@ -16,7 +16,12 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
- bark
- bite
- full
- growl
- pet
- roll
sample:
- SUCH MEME
- VERY SKILL
5 changes: 4 additions & 1 deletion templates/drake/config.yml
Expand Up @@ -16,6 +16,9 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
- beat
- no
- padding
- yes
sample:
- ''
2 changes: 1 addition & 1 deletion templates/dsm/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- THEY WILL NEVER FIND YOUR BODY
- AS ATTRACTIVE AS I DO
2 changes: 1 addition & 1 deletion templates/dwight/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- LOVE IS ALL YOU NEED?
- FALSE. YOU NEED WATER AND RATIONS.
2 changes: 1 addition & 1 deletion templates/elf/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
- YOU SIT ON A THRONE OF LIES
2 changes: 1 addition & 1 deletion templates/ermg/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ERMAHGERD
- MEMES
2 changes: 1 addition & 1 deletion templates/fa/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- FOREVER
- ALONE
2 changes: 1 addition & 1 deletion templates/facepalm/config.yml
Expand Up @@ -16,6 +16,6 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- ''
2 changes: 1 addition & 1 deletion templates/fbf/config.yml
Expand Up @@ -16,7 +16,7 @@ text:
scale_x: 1.0
scale_y: 0.2
styles:
- default
-
sample:
- PAPER TOWEL
- THE PLATE THAT CLEANS UP AFTER ITSELF