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

Allow Jekyll Source Directory #42

Merged
merged 8 commits into from
Sep 10, 2016
Merged

Allow Jekyll Source Directory #42

merged 8 commits into from
Sep 10, 2016

Conversation

mloberg
Copy link
Contributor

@mloberg mloberg commented Sep 1, 2016

Jekyll Compose assumes that the Jekyll code lives in the root directory, so if you have custom source set in your config, it won't respect that.

I've updated compose to load in configuration (adding both --config and --source options).

mloberg and others added 7 commits September 1, 2016 08:27
In some Jekyll setups, the site assets are in a sub-directory. The drafts command, does not process any configuration files or allow to set the site source. Add these options to the draft command and update the FileCreator class to take an optional root that will be prepended to the file.path.
Load in Jekyll configuration when parsing args.

Add source method to return Jekyll source directory and update the drafts command to use this new method.
Update the page command to use the correct Jekyll source from config or command line option.
Update post command to respect any custom Jekyll source.
Update Publish command to allow custom Jekyll source.

Update MovementArgParser to generate Jekyll config like was done with ArgParser.

Update FileMover to automatically use a root directory if given.
Update Unpublish command to allow custom Jekyll source.
Both Publish and Unpublish take in the relative path as the argument, so
prepending the root directory won't give you the correct path to the
file. Just prepend the root directory to the target path.
@parkr
Copy link
Member

parkr commented Sep 1, 2016

Seems logical to me. LGTM.

@jekyll/compose?

@@ -24,4 +25,8 @@ def title
def force?
!!options["force"]
end

def source
source = config['source'].gsub(/^#{Regexp.quote(Dir.pwd)}/, '')
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this variable assign necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Other methods had an assign, so I thought I would follow that pattern. I can remove this if it isn't doing anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I hadn't noticed that. I'm pretty confident those do nothing, would you remove all three?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. I'll update that tonight.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this and removed all unnecessary variable assignments in that class.

@courajs
Copy link
Contributor

courajs commented Sep 9, 2016

Great work! My only feedback would be that the specs are becoming hard to read, because of the overriding of lets. For example in draft_spec.rb, the body of it 'should use source directory set by config' is exactly the same as the simple case it 'creates a new draft', but it's different because drafts_dir is overridden down here, which causes path to evaluate differently at the top.

If you have the time to refactor that to make it clearer, that would be amazing! If not, this is mergable as-is.

LGTM

@mloberg
Copy link
Contributor Author

mloberg commented Sep 9, 2016

@courajs I haven't done much Ruby and almost no spec testing in Ruby. Are there any guides or best practices that might help me out?

@courajs
Copy link
Contributor

courajs commented Sep 9, 2016

I'm not sure there's a guide that would help you with this specific issue. But I think it will make things clearer to explicitly re-define path, rather than re-defining drafts_path and relying on changes to cascade. Then make it similarly explicit for post_path and draft_path in publish_spec.rb and unpublish_spec.rb.
If necessary we can always merge as-is, and I'll open a refactoring issue for someone interested to pick up.

The variable assignments in ArgParser do nothing, so remove them.
@mloberg
Copy link
Contributor Author

mloberg commented Sep 10, 2016

@courajs Is something like this what you're looking for?

it 'creates draft in specified source directory' do
  site_dir = 'site'
  path = Pathname.new source_dir(site_dir, '_drafts', 'a-test-post.md')
  expect(path).not_to exist
  capture_stdout { described_class.process(args, 'source' => site_dir) }
  expect(path).to exist
end

@courajs
Copy link
Contributor

courajs commented Sep 10, 2016

Ah, I didn't realize the after(:each) hook was using draft_dir to clean up. It's seeming like a lot of effort for not too much gain, I'll just merge this. The CI failure is an intermittent problem that I opened an issue for (#44), but they pass locally for me.

@courajs courajs merged commit 8100f7e into jekyll:master Sep 10, 2016
@jekyll jekyll locked and limited conversation to collaborators Apr 23, 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.

5 participants