Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Commit

Permalink
Always update post slug when publishing a post.
Browse files Browse the repository at this point in the history
This is similar to Ghost's in-built slug update logic since 0.8.0
(see TryGhost/Ghost#6631), with some differences:

- The slug is updated even if a post is unpublished and then published
  again with a new title

- The slug is only updated on publish, not on every save

- If a custom slug was set on the draft, it will be overridden upon
  publishing

Refs: #122, #130
  • Loading branch information
vickychijwani committed Aug 22, 2016
1 parent 4a118f5 commit da3974b
Showing 1 changed file with 7 additions and 3 deletions.
Expand Up @@ -13,7 +13,6 @@
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.PopupMenu;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -518,9 +517,14 @@ public void onPublishUnpublishClicked() {
Crashlytics.logException(new IllegalStateException("UI is messed up, " +
"desired post status is same as current status!"));
}
if (TextUtils.isEmpty(mPost.getSlug())
|| mPost.getSlug().startsWith(Post.DEFAULT_SLUG_PREFIX)) {
// This will not be triggered when updating a published post, that goes through
// onSaveClicked(). It is assumed the user will ALWAYS want to synchronize the
// slug with the title as long as it's being published now (even if it was
// published and then unpublished earlier).
if (Post.PUBLISHED.equals(finalTargetStatus)) {
try {
// update the title in memory first, from the latest value in UI
mPost.setTitle(mPostTitleEditView.getText().toString());
mPost.setSlug(new Slugify().slugify(mPost.getTitle()));
} catch (IOException e) {
Crashlytics.logException(e);
Expand Down

0 comments on commit da3974b

Please sign in to comment.