Ticket #62 (closed enhancement: wontfix)

Opened 2 years ago

Last modified 23 months ago

Post preview

Reported by: dottedmag Owned by:
Priority: major Milestone:
Component: blog Version:
Keywords: Cc:

Description (last modified by dottedmag) (diff)

It would be nice to have a "post preview" button when post is created/edited.

Attachments

preview.patch (2.4 kB) - added by benjaminwarfield 2 years ago.
Preview a post.

Change History

follow-up: ↓ 2   Changed 2 years ago by dottedmag

  • description modified (diff)

in reply to: ↑ 1   Changed 2 years ago by benjaminwarfield

Replying to dottedmag:

I typically use 'Post would act as draft' the view it from there. I'll see if I can come up with something as I would like a cleaner way to preview as well.

  Changed 2 years ago by benjaminwarfield

So, what I've come up with as a quick hack is simple. In apps/blog/models.py add a boolean model called 'is_preview', check for it and then set is_draft to true. Save the new post, then use RedirectException? to send the user to the draft page (may be more useful to pop-up, but that's annoying on most browsers). On the draft page, check to see if 'is_preview' is true, then maybe display an overlay via css stating it's a draft and to click through to edit it, or post it, which would remove it's draft and preview status. I've got a POC that I'll post a diff for later.

I'm thinking that if there are any javascript hackers in the bunch, it might be doable, and faster to do it client side. My only beef with that would be not saving it as a draft, which I find useful. Say someone starts a blog, previews it, then gets distracted and navigates away.

Opinions?

benjaminwarfield@…

  Changed 2 years ago by benjaminwarfield

I forgot to mention that my POC also requires patching apps/blog/views.py, and does add an extra column to the DB.

Will post it later this evening (EST)

  Changed 2 years ago by benjaminwarfield

See attached export for a quick POC on how this could work. You could use this in a template by testing for is_preview and acting accordingly like this:

{% if object.is_preview %}
  <div id="post-draft">THIS IS A PREVIEW <a href="/admin/blog/post/{{ object.id }}/">Continue Editing</a></div>
{% endif %}

Changed 2 years ago by benjaminwarfield

Preview a post.

  Changed 2 years ago by piranha

Hmm... I think 'Post would act as draft' is enough now, just because we have plans to make custom admin, which will simplify things a lot.

What do you think?

  Changed 2 years ago by benjaminwarfield

I agree completely, I just wanted to give an alternative implementation. The patch I posted uses the draft option anyway :).

  Changed 23 months ago by piranha

  • status changed from new to closed
  • resolution set to wontfix

Use is_draft for that.

Note: See TracTickets for help on using tickets.