-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Conversation
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.
I like this idea. |
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 |
I understand.. but it'll be easier once GitHub Pages switches onto a release with this patch.
A log message would be great. But, its better if its implemented by the concerned plugin itself..
|
@benbalter I'd like your thoughts on this.. Thanks. |
lib/jekyll/page.rb
Outdated
@@ -184,4 +184,14 @@ def write? | |||
true | |||
end | |||
end | |||
|
|||
class PageWithoutAFile < Page |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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..
lib/jekyll/page.rb
Outdated
@@ -184,4 +184,14 @@ def write? | |||
true | |||
end | |||
end | |||
|
|||
class PageWithoutAFile < Page | |||
# --------------------------------------------------------------- |
There was a problem hiding this comment.
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?
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. |
Sorry, no. just an assumption.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm alive
There was a problem hiding this 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 😄
There was a problem hiding this 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 👍
test/test_page_without_a_file.rb
Outdated
})) | ||
end | ||
|
||
context "on intialized" do |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
test/test_page_without_a_file.rb
Outdated
require "helper" | ||
|
||
class TestPageWithoutAFile < JekyllUnitTest | ||
def setup_page(*args) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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. 👍
props to @Crunch09 for the suggestion
4880329
to
02d8e9c
Compare
test/test_page_without_a_file.rb
Outdated
@@ -3,13 +3,13 @@ | |||
require "helper" | |||
|
|||
class TestPageWithoutAFile < JekyllUnitTest | |||
def setup_page(*args) | |||
def setup_page(*args, base: source_dir, klass: PageWithoutAFile) |
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
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 😉
There was a problem hiding this comment.
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..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough 👍
@jekyllbot: merge +dev |
Official plugins
jekyll-sitemap
,jekyll-feed
and a couple more add aPage
subclass to generate a file (usually from Liquid templates not present in the user's source directory).Advantages
Plugins known to implement this subclass or similar:
jekyll-sitemap
jekyll-feed
jekyll-admin
jekyll-redirect-from