orf/simple

Needs to handle posts with the same title gracefully

Closed this issue · 5 comments

orf commented

Currently we don't check to see if there are any posts with the same title (and the same slug) when we save a post, which can lead to IntegrityError exceptions.
This should be handled somehow, perhaps telling the user to choose a different title or to generate a different slug?

Do the posts need to have their slugs created immediately? As it stands, if you click "New draft", your post will immediately generate the slug of "untitled". This makes it impossible to have two untitled posts (which would be silly anyway) in draft.

Do the slugs need to be calculated as soon as the post is created? Or when the post is published? After all, the slug doesn't come in to play at all (at least in terms of browsing the site) until the user views the published page.

The renaming/informing of the slug clash is interesting. The titles "A post" and "A post!" will be clearly different to the user, but the slugs will both be "a-post". Without moving too far from the initial style, how would you inform the user of a slug clash?

With that in mind, maybe it would be best to just automatically add a number to a post with the same title?

orf commented

Yeah, the slugs don't have to be created right away, I will defer them until the post is published I think. Postfixing a number seems to be the best way to go, I will work on it ASAP.

orf commented

Fixed. Whenever a title is changed a new slug is generated - if > 0 posts exist with the same slug then the number is appended onto the end.

Good stuff, I think you've got the best solution there. Let me know if there's anything I can do to help out.

orf commented

Well, Issue #1 is the only real one at the moment, if you are any good at CSS (which I am not) then you could give that a crack? Thanks!