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

Add PageWithoutAFile class from jekyll plugins #6556

Merged
merged 7 commits into from
Nov 30, 2017

Conversation

ashmaroli
Copy link
Member

@ashmaroli ashmaroli commented Nov 14, 2017

Official plugins jekyll-sitemap, jekyll-feed and a couple more add a Page subclass to generate a file (usually from Liquid templates not present in the user's source directory).

Advantages

  • Users adding both plugins need not allocate memory for the twin subclasses.
  • Also allows other third-party plugins that follows the above implementation.

Plugins known to implement this subclass or similar:

jekyll-feed and jekyll-sitemap add a Page subclass to generate a file
from liquid templates not present in the user's source directory.

Advantages
  - Users adding both plugins need not allocate memory for the twin
    subclasses.
  - Also allows other third-party plugins that follows the above
    implementation.
@pathawks
Copy link
Member

I like this idea.
I’m not sure if this is the best place to put this subclass, but it is so small that I’m ok with it.

@pathawks
Copy link
Member

Plugins wouldn’t be able to take advantage of this right away, as we tend to support older versions of Jekyll.

I wonder if, as long as we’re consolidating this, we could provide a mechanism to let the user know where a PageWithoutAFile originated, since the path is useless.

@ashmaroli
Copy link
Member Author

take advantage of this right away, as we tend to support older versions of Jekyll.

I understand.. but it'll be easier once GitHub Pages switches onto a release with this patch.

I wonder if, as long as we’re consolidating this, we could provide a mechanism to let the user know where a PageWithoutAFile originated, since the path is useless.

A log message would be great. But, its better if its implemented by the concerned plugin itself..

           JekyllFeed: feed.xml generated
        JekyllSitemap: sitemap.xml generated

@ashmaroli ashmaroli requested a review from benbalter November 14, 2017 06:23
@ashmaroli
Copy link
Member Author

@benbalter I'd like your thoughts on this.. Thanks.

@@ -184,4 +184,14 @@ def write?
true
end
end

class PageWithoutAFile < Page
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer a different name such as BasePage or BasicPage here. The fact that it doesn't have a file is irrelevant, IMHO

Copy link
Member Author

Choose a reason for hiding this comment

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

Naming has been a rough sea here at Jekyll AFAIR.. so I'll change it to whatever the majority zeros in..

@@ -184,4 +184,14 @@ def write?
true
end
end

class PageWithoutAFile < Page
# ---------------------------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

This documentation here isn't enough for justifying and explaining the existence of this class. Could we get some proper class level documentation?

@mattr-
Copy link
Member

mattr- commented Nov 14, 2017

Users adding both plugins need not allocate memory for the twin subclasses.

Do you have hard numbers for this?

I do like this idea. Something that multiple plugins are using should be in the core. With just a few small tweaks, I think this will be ready.

@ashmaroli
Copy link
Member Author

Do you have hard numbers for this?

Sorry, no. just an assumption..

Copy link
Contributor

@jekyllbot jekyllbot left a comment

Choose a reason for hiding this comment

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

I'm alive

Copy link
Member

@parkr parkr left a comment

Choose a reason for hiding this comment

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

I'm 👍 on this! Can we put it in its own file instead of putting it in page.rb? We'll also want a few tests to help define the API boundaries for adding content and verify that it doesn't access any files 😄

@ashmaroli ashmaroli changed the title Add PageWithoutAFile class from jekyll plugins Add PageWithoutAFile class from jekyll plugins [WIP] Nov 28, 2017
@ashmaroli ashmaroli changed the title Add PageWithoutAFile class from jekyll plugins [WIP] Add PageWithoutAFile class from jekyll plugins Nov 28, 2017
@ashmaroli ashmaroli added this to the v3.7.0 milestone Nov 29, 2017
Copy link
Member

@Crunch09 Crunch09 left a comment

Choose a reason for hiding this comment

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

LGTM, just two small comments 👍

}))
end

context "on intialized" do
Copy link
Member

Choose a reason for hiding this comment

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

on intialize ? Or maybe even with default config ? What do you think?

Copy link
Member Author

@ashmaroli ashmaroli Nov 30, 2017

Choose a reason for hiding this comment

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

I disagree with with default config.. PageWithoutAFile instances do not change on passing different parameters. For a given site, its always nil content and empty data hash.

require "helper"

class TestPageWithoutAFile < JekyllUnitTest
def setup_page(*args)
Copy link
Member

Choose a reason for hiding this comment

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

tiny thing: Instead of overriding this entire method to have the only difference in having PageWithoutAFile.new instead of Page.new ,what do you think of changing the method signature to something like:

def setup_page(*args, klass: Page)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for the suggestion. I had considered using a similar signature (klass=Page, *args), but opted out since I'm creating a Jekyll::Page instance only once in this new unit-test-class.

That said, I like your syntax with Keyword Arguments. Improves future tests-scalability. 👍

@@ -3,13 +3,13 @@
require "helper"

class TestPageWithoutAFile < JekyllUnitTest
def setup_page(*args)
def setup_page(*args, base: source_dir, klass: PageWithoutAFile)
Copy link
Member

Choose a reason for hiding this comment

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

@ashmaroli Hey, sorry my first suggestion was unclear: I tought about moving setup_page, which is also defined in TestPage, to JekyllUnitTest and give it then a klass option because that's the only difference between those two methods and then we would only define it once :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I see.. I should've understood your obvious intention.. my bad..

Copy link
Member

Choose a reason for hiding this comment

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

No worries at all! It's already better 😉

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't want to change test_page.rb in this PR (since its an addition-only patch, right now..). Perhaps, a separate future PR would be best..

Copy link
Member

Choose a reason for hiding this comment

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

Fair enough 👍

@DirtyF
Copy link
Member

DirtyF commented Nov 30, 2017

@jekyllbot: merge +dev

@jekyllbot jekyllbot merged commit 3834200 into jekyll:master Nov 30, 2017
jekyllbot added a commit that referenced this pull request Nov 30, 2017
@DirtyF DirtyF removed the request for review from benbalter November 30, 2017 18:17
@ashmaroli ashmaroli deleted the page-without-file branch December 1, 2017 07:30
DirtyF pushed a commit that referenced this pull request Dec 7, 2017
DirtyF pushed a commit that referenced this pull request Dec 7, 2017
@jekyll jekyll locked and limited conversation to collaborators Jul 12, 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

7 participants