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 option to exclude specific directories #50

Merged
merged 9 commits into from
Feb 11, 2019
Merged

Add option to exclude specific directories #50

merged 9 commits into from
Feb 11, 2019

Conversation

jeff-matthews
Copy link
Contributor

@jeff-matthews jeff-matthews commented Feb 8, 2019

Fixes #49

I added some logic to the generator.rb file to exclude directories specified in a project's _config.yml file like so:

jekyll_relative_links:
  exclude:
    - directory

The plugin still seems to be processing all directories though because I don't see confirmation in the console that the specified directories have been excluded when it gets to the jekyll-relative-links stage:

bundle exec jekyll build --trace --verbose
  Logging at level: debug
Configuration file: /Users/jeffmatthews/git/devdocs/_config.yml
         Requiring: /Users/jeffmatthews/git/devdocs/_plugins/page-canonical-url.rb
         Requiring: /Users/jeffmatthews/git/devdocs/_plugins/last-modified-at.rb
         Requiring: /Users/jeffmatthews/git/devdocs/_plugins/page-baseurl-generator.rb
         Requiring: /Users/jeffmatthews/git/devdocs/_plugins/collapsible-content.rb
         Requiring: /Users/jeffmatthews/git/devdocs/_plugins/glossary-tooltip.rb
         Requiring: /Users/jeffmatthews/git/devdocs/_plugins/remote_markdown.rb
         Requiring: jekyll-sitemap
         Requiring: jekyll-redirect-from
         Requiring: jekyll-titles-from-headings
         Requiring: jekyll-optional-front-matter
         Requiring: jekyll-relative-links
            Source: /Users/jeffmatthews/git/devdocs
       Destination: /Users/jeffmatthews/git/devdocs/_site
 Incremental build: disabled. Enable with --incremental
      Generating...
       EntryFilter: excluded /bin
       EntryFilter: excluded /scss
       EntryFilter: excluded /rakelib
       EntryFilter: excluded /README.md
       EntryFilter: excluded /Rakefile
       EntryFilter: excluded /package-lock.json
       EntryFilter: excluded /package.json
       EntryFilter: excluded /Gemfile
       EntryFilter: excluded /Gemfile.lock
           Reading: _videos/fundamentals/create-a-new-module.md
           Reading: _videos/fundamentals/add-new-product-attribute.md
           Reading: _videos/fundamentals/index.md
           Reading: _videos/fundamentals/create-a-new-page.md
           Reading: _videos/fundamentals/add-a-new-table-to-database.md
           Reading: _videos/fundamentals/add-a-javascript-module.md
           Reading: _videos/index.html
        Generating: JekyllRedirectFrom::Generator finished in 9.121496 seconds.
        Generating: JekyllOptionalFrontMatter::Generator finished in 2.861665 seconds.
        Generating: Jekyll::JekyllSitemap finished in 0.002033 seconds.
        Generating: JekyllTitlesFromHeadings::Generator finished in 0.109857 seconds.
        Generating: JekyllRelativeLinks::Generator finished in 670.421584 seconds.
...

@benbalter
Copy link
Owner

@jeff-matthews Thanks for this. I moved things around a bit to better conform to Ruby style, and added tests. I believe things should now be working as expected. Mind giving it another try?

If things look good, if you wouldn't mind documenting the new behavior in the README, I believe this PR can be merged and I can cut a new release.

@jeff-matthews
Copy link
Contributor Author

Thanks @benbalter! I pulled your changes, but I'm getting an error:

bundler: failed to load command: jekyll (/Users/jeffmatthews/.rvm/gems/ruby-2.5.3/bin/jekyll)
NoMethodError: undefined method `config' for #<Jekyll::Configuration:0x00007fda99e0fe18>
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/filters/url_filters.rb:55:in `sanitized_baseurl'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/filters/url_filters.rb:35:in `relative_url'
  /Users/jeffmatthews/git/forks/jekyll-relative-links/lib/jekyll-relative-links/generator.rb:91:in `url_for_path'
  /Users/jeffmatthews/git/forks/jekyll-relative-links/lib/jekyll-relative-links/generator.rb:55:in `block in replace_relative_links!'
  /Users/jeffmatthews/git/forks/jekyll-relative-links/lib/jekyll-relative-links/generator.rb:50:in `gsub'
  /Users/jeffmatthews/git/forks/jekyll-relative-links/lib/jekyll-relative-links/generator.rb:50:in `replace_relative_links!'
  /Users/jeffmatthews/git/forks/jekyll-relative-links/lib/jekyll-relative-links/generator.rb:42:in `block in generate'
  /Users/jeffmatthews/git/forks/jekyll-relative-links/lib/jekyll-relative-links/generator.rb:37:in `each'
  /Users/jeffmatthews/git/forks/jekyll-relative-links/lib/jekyll-relative-links/generator.rb:37:in `generate'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/site.rb:174:in `block in generate'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/site.rb:172:in `each'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/site.rb:172:in `generate'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/site.rb:72:in `process'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/command.rb:28:in `process_site'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/commands/build.rb:65:in `build'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/commands/build.rb:36:in `process'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/gems/jekyll-3.7.4/exe/jekyll:15:in `<top (required)>'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/bin/jekyll:23:in `load'
  /Users/jeffmatthews/.rvm/gems/ruby-2.5.3/bin/jekyll:23:in `<top (required)>'```

@benbalter
Copy link
Owner

@jeff-matthews sorry about that. You actually found a long-standing bug, and I think a long-standing mistake in the Jekyll documentation. I'll open an issue upstream, but things should be fixed here and I can build locally outside of tests. Mind giving it another try?

@jeff-matthews
Copy link
Contributor Author

jeff-matthews commented Feb 11, 2019

@benbalter, works like a charm! Generation time in my particular project went from ~670 seconds to ~4 seconds, which is a huge improvement. I'll update the README with the new behavior and push those changes to this PR.

@benbalter benbalter merged commit 1978852 into benbalter:master Feb 11, 2019
@welcome
Copy link

welcome bot commented Feb 11, 2019

Congrats on getting your first pull request to Jekyll Relative Links merged! Without amazing humans like you submitting pull requests, we couldn’t run this project. You rock! 🎉

If you're interested in tackling another bug or feature, take a look at the open issues, especially those labeled help wanted.

@benbalter
Copy link
Owner

Thanks @jeff-matthews!

@jeff-matthews
Copy link
Contributor Author

Thank you @benbalter!!!

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

Successfully merging this pull request may close these issues.

3 participants