-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Allow static files to be symlinked in unsafe mode or non-prod environments #4640 8000
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
Conversation
@@ -80,7 +80,7 @@ def write(dest) | |||
|
|||
FileUtils.mkdir_p(File.dirname(dest_path)) | |||
FileUtils.rm(dest_path) if File.exist?(dest_path) | |||
FileUtils.cp(path, dest_path) | |||
FileUtils.copy_entry(path, dest_path) |
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.
Could you please wrap this around a @site.safe
call? We cannot use copy_entry
in safe mode.
if @site.safe || Jekyll.env.start_with?("prod")
FileUtils.cp(path, dest_path)
else
FileUtils.copy_entry(path, dest_path)
end
The Jekyll.env.start_with? "prod"
ensures production builds (where the destination and source may not be on the same host) work as expected.
I just updated the code and tested it, works fine here. Thanks for your assistance. |
@@ -80,7 +80,11 @@ def write(dest) | |||
|
|||
FileUtils.mkdir_p(File.dirname(dest_path)) | |||
FileUtils.rm(dest_path) if File.exist?(dest_path) | |||
FileUtils.cp(path, dest_path) | |||
if @site.safe |
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 am happy to accept this if you add Jekyll.env == "production"
here.
Production builds should produce an artifact (the compiled site) that is standalone and does not have any external dependencies on other files. A symlink cannot be guaranteed to validate that requirement.
I added the condition again. |
@surrim Sounds good! |
@jekyllbot: merge +minor |
* origin/master: (65 commits) Update history to reflect merge of #4703 [ci skip] Update history to reflect merge of #4712 [ci skip] Highlight the test code Update history to reflect merge of #4640 [ci skip] readded "env=prod"-condition Update history to reflect merge of #3849 [ci skip] Update history to reflect merge of #4624 [ci skip] Update history to reflect merge of #4704 [ci skip] Update history to reflect merge of #4706 [ci skip] Checks for link file extension in tests Updating assets documentation Fix test teardown for cleaner. Update history to reflect merge of #4542 [ci skip] Add explanation of site variables in the example _config.yml Use double quotes in the gemfile Add test for creation of Gemfile by 'jekyll new' Add comment about github-pages Update history to reflect merge of #4533 [ci skip] Ensure Rouge closes its div/figure properly after highlighting ends. Add Site#config= which can be used to set the config ...
This patch enables symlinks for static files. Now you can do something like this:
The generated page could be something like that:
grep
for invalid URLs (e.g. DSC0001.jpg becomes dsc0001.jpg), written things can stay untouched when filenames or folders changels -l
, etc.)