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

Refactor and add sitemap to site.pages #137

Merged
merged 2 commits into from Oct 15, 2016
Merged

Refactor and add sitemap to site.pages #137

merged 2 commits into from Oct 15, 2016

Conversation

pathawks
Copy link
Member

This PR takes advantage of some of the newer features in Jekyll to reduce some of the code necessary. Now that we require Jekyll 3.3, we do not need to keep all the old workarounds.

@pathawks pathawks force-pushed the pr/refactor branch 4 times, most recently from 509e22f to 8ff1599 Compare October 15, 2016 17:03
INCLUDED_EXTENSIONS = %W(
.htm
.html
.xhtml
.pdf
).freeze

MINIFY_REGEX = %r!(>\n|})\s+!.freeze
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we see a > followed by a single linebreak, or a }, we will strip all the whitespace that follows.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add that explanation as a code comment?

benbalter
benbalter previously approved these changes Oct 15, 2016
INCLUDED_EXTENSIONS = %W(
.htm
.html
.xhtml
.pdf
).freeze

MINIFY_REGEX = %r!(>\n|})\s+!.freeze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add that explanation as a code comment?

end

private
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, technically, this would be a breaking change to the Ruby API. I'm all for it, but we'd have to make it a major bump then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, but since we have not yet reached 1.0.0, a minor bump will suffice.

From semver.org:

Version 1.0.0 defines the public API. The way in which the version number is incremented after this release is dependent on this public API and how it changes.

So, technically, we have not yet defined a public API.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TIL'd.

def write
FileUtils.mkdir_p File.dirname(destination_path)
File.open(destination_path, "w") { |f| f.write(sitemap_content) }
@site.in_dest_dir("sitemap.xml")
end

def sitemap_content
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this return the content, or a Page, if so, perhaps just sitemap?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pathawks
Copy link
Member Author

I don't know if it's worth documenting, but this change adds the sitemap to site.pages instead of just writing it as a static file.

@pathawks pathawks force-pushed the pr/refactor branch 2 times, most recently from a84e934 to 5a0e199 Compare October 15, 2016 18:23
@pathawks pathawks dismissed benbalter’s stale review October 15, 2016 18:26

I am nervous and want to have one more review with the changes I made, please

@pathawks
Copy link
Member Author

@benbalter Could you look over once more please?

@site.keep_files ||= []
@site.keep_files << "sitemap.xml"
end
@site.pages << sitemap unless sitemap_exists?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may cause a problem for sites that iterate through pages, but if we call it out in the changelog, we should be fine.

@@ -22,6 +22,10 @@ those other gems if you *want* the sitemap to include the generated
content, or *before* those other gems if you *don't want* the sitemap to
include the generated content from the gems. (Programming is *hard*.)

Because the sitemap is added to `site.pages`, you may have to modify any
templates that iterate through all pages (for example, to build a menu of
all of the site's content).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benbalter Is this enough of an explanation?

@pathawks pathawks changed the title Refactor Refactor and add sitemap to site.pages Oct 15, 2016
@pathawks
Copy link
Member Author

@jekyllbot: merge

@jekyllbot jekyllbot merged commit 696e123 into master Oct 15, 2016
@jekyllbot jekyllbot deleted the pr/refactor branch October 15, 2016 19:07
jekyllbot added a commit that referenced this pull request Oct 15, 2016
@jekyll jekyll locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants