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

when --verbose is on and future=false (now default), a message should be logged when a post is skipped for publishing #4178

Closed
untra opened this issue Nov 24, 2015 · 6 comments

Comments

@untra
Copy link
Contributor

untra commented Nov 24, 2015

Minor feature request, title says it all:

If I am running --verbose and --future is false (which is now the default), I should at least get a message in the verbose logs informing me that a post is being skipped for publishing.

@untra untra changed the title when --verbose is on and future=false (now default), a message should be displayed when --verbose is on and future=false (now default), a message should be logged when a post is skipped for publishing Nov 24, 2015
@untra
Copy link
Contributor Author

untra commented Nov 24, 2015

IMHO, a message should be delivered if a post is skipped for future publishing, whether or not verbose is on. I intend to write a hook to do just this though.

At the very least though, if I have turned on --verbose, and my post has been skipped for publishing, I should see a message in the logs telling me the post was skipped because of the future date.

@parkr
Copy link
Member

parkr commented Nov 24, 2015

Great idea!

@envygeeks
Copy link
Contributor

For verbose it's understandable and was probably an oversight, I agree, we need a fix and I'm sure @jekyll/core will agree, for non-verbose the simple answer should be "no", we don't show you when a unique post is processed when not verbose, why would we show you when a unique post is not processed when not verbose?

@parkr parkr added the Bug label Nov 24, 2015
@untra
Copy link
Contributor Author

untra commented Nov 24, 2015

@envygeeks you're right about non-verbose. Still, my application needs a warning for when a blogpost is timestamped in the future and won't be published. Eh, I can write a hook to do just that. Except...

I'm having trouble writing a hook that will leave a warning about posts not being published. Presume I have a post with a future date, and --future is false. consider the following hook:

Jekyll::Hooks.register :posts, :post_init do |post|
    if post.respond_to?(:date) && post.site.future
      puts post.date
    end
end

after running this hook, the printed date on all of the posts is current timestamp. This makes sense considering the date hasn't been loaded in from the frontmatter. Frontmatter is loaded during document.read, but after reading the document with the future date, it gets kicked out of the collection by the publisher!

This means I can't write a convenient hook to look for posts with the future set. I can probably write a plugin that alias_methods collection.read to print my message, but that's a tad hacky.

edit: I got creative:

Jekyll::Hooks.register :documents, :post_init do |doc|
  doc.read
  if doc.respond_to?(:date) && !doc.site.future
    if doc.date.to_i > doc.site.time.to_i
      puts "#{doc.path} will not be published! Date #{doc.date} set after today/now!".yellow
    end
  end
end

Consider this a 👍 for a hook for after reading documents.

@envygeeks
Copy link
Contributor

I thought we had processing hooks?

@untra
Copy link
Contributor Author

untra commented Nov 24, 2015

I was looking here for whatever hooks were available.

@parkr parkr closed this as completed Nov 24, 2015
@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants