Slugs Updated again, Fixed some things, Version 0.5.0-0
Wednesday, 11 August 2021 14:18:35 by Khodok
3 min read
Okay well, this one is interesting
What’s new (for editors (so me))
- Added Cloning option
- Lets an editor (again… me) clone a post and have most of the fields already filled.
- Extremely useful for Wednesday.
- Just used it to make more Wednesday for the future weeks and bro… took literally a second.
What’s new (for all of us)
- Added again a thing I added a really long time ago, but that proved itself broken really fast… because of me being dumb, lemme explain.
Lil story and some code
A Long time ago, see post here, I added something allowing me to give the same title to two posts and both would have a different slug at creation.
The code for it was this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
So there’s one considerable problem with this code, it doesn’t test if the post already has a slug… so if I were to edit the post, it’d just recreate the slug… ultimately adding a 2, then a 3, etc.
That was obviously not the point… I wanted it to check at the CREATION of a post (not at the update) if the post had a slug, if not, it’d create one.
So how did I fix it ? Well again… I removed it all this time because I thought it was a MUCH more difficult thing to fix…
Here’s the fix:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
The difference ? this line:
if not self.slug:
Basically it will do all the thing below ONLY if the post doesn’t have a slug, else it’ll just not care about it.
I was dumb…
A few weeks ago I understood the problem, but let it slide for a while because I was kinda lazy to fix it.
- Fixed some bugs, mostly files named wrongly and I was always too lazy to name them correctly, so I kept them like that for literally months.
- And same for some code at different places.
Just before the conclusion a cool thing
- Yesterday I took way too much time adding a song in More song lyrics post, so go check it out.
- The reason why it took time is because there’s no lyrics for it online as it’s a mashup, takes too much effort, so nobody does it, but it’s probably my most listened song of the year, and I wanted to do it.
Well hope you had fun reading all this (it’s better than a big book isn’t it ?)
And hf in your life.
Till next time.