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

Include a separate directory to search for the "Links" check? #139

Closed
csu opened this issue Jan 7, 2015 · 7 comments
Closed

Include a separate directory to search for the "Links" check? #139

csu opened this issue Jan 7, 2015 · 7 comments

Comments

@csu
Copy link

csu commented Jan 7, 2015

I'm getting failures for links of the format /something/something/file.zip. I'm running checks on files in _site/, but Jekyll also includes the folders/files in the parent directory. Is there any way to include those in the "Link" check?

@gjtorikian
Copy link
Owner

Wow, I hadn't expected this, but you're absolutely right: https://travis-ci.org/gjtorikian/html-proofer/builds/46231488

I'll dig into fixing this as soon as I can.

@gjtorikian
Copy link
Owner

@csu Actually I goofed above, I had the file name wrong, and the zip file is correctly detected: https://travis-ci.org/gjtorikian/html-proofer/builds/46232517

Could you tell me more about your link setup? A repo or some CI output would be uber-helpful.

@csu
Copy link
Author

csu commented Jan 7, 2015

I'm in a Jekyll repository. An HTML file in _site has an src of the format /assets/2012/10/filename.zip (the file exists. relative to a file in _site, it's path would be ../assets/..../filename.zip). The output I'm getting from html-proofer is:

$ bundle exec rake
bundle exec jekyll build
Configuration file: /home/travis/build/csu/csu.github.io/_config.yml
            Source: /home/travis/build/csu/csu.github.io
       Destination: /home/travis/build/csu/csu.github.io/_site
      Generating... 
                    done.
 Auto-regeneration: disabled. Use --watch to enable.
Running ["Links", "Scripts"] checks on ./_site on *.html... 
Checking 100 external links...
Ran on 85 files!
- ./_site/index.html
  *  External link https://www.facebook.com/christophersu failed: 404 No error
- ./_site/wordpress/blog-stats-shortcodes/index.html
  *  internally linking to /assets/uploads/2012/10/blog-stats-shortcodes.zip, which does not exist
rake aborted!
HTML-Proofer found 2 failures!
/home/travis/.rvm/gems/ruby-2.1.0/gems/html-proofer-1.6.0/lib/html/proofer.rb:144:in `run'
/home/travis/build/csu/csu.github.io/Rakefile:51:in `block in <top (required)>'
/home/travis/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
/home/travis/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => default => test
(See full trace by running task with --trace)
The command "bundle exec rake" exited with 1.
cache.2
store build cache
0.23snothing changed, not updating cache
Done. Your build exited with 1.

My rake test:

require 'html/proofer'

module HTML
  class Proofer
    def get_checks
      %w{Links Scripts}
    end
  end
end 

task :test do
  sh "bundle exec jekyll build"
  HTML::Proofer.new("./_site", {:href_ignore => ['www.facebook.com']}).run
end

@gjtorikian
Copy link
Owner

Couple of things:

  • You wrote:

    An HTML file in _site has an src of the format /assets/2012/10/filename.zip

    But the output shows /assets/uploads/... as the link. Just want to make sure those two are right.

  • relative to a file in _site, it's path would be ../assets/

    Am I correct in reading that the link to the zip is outside the _src dir? Pretty sure Jekyll won't serve that file, either, since it expects everything within that dir. It doesn't matter if it exists on disk. If you really want to include it, you could probably try passing the dir itself: HTML::Proofer.new(".", ....

@csu
Copy link
Author

csu commented Jan 7, 2015

Yeah, that link is correct. I was writing it from memory.

I just checked and the file doesn't appear in the assets folder within _site. Oddly enough, Jekyll still serves it on the live site. Quite peculiar, but I guess the problem isn't with html-proofer, but rather somewhere in Jekyll or with my environment.

@gjtorikian
Copy link
Owner

I think that may be so. I think it's entirely possible to "jail" html-proofer, though--that is, if you refer to a link outside of your served directory, I think that should count as a failure (with a configurable option).

For example, let's say you're checking _site. You can absolutely have a link that's valid, locally, to /Users/csy/Documents/awebpage.html. But of course, once you push that file online, it's broken.

Given that, I'll keep this issue open as something to work on.

@gjtorikian
Copy link
Owner

HTMLProofer 3.0 was just released, and this might be fixed with the new check_directories method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants