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

Breadcrumbs are problematic #174

Closed
franzinc opened this issue Apr 9, 2024 · 7 comments
Closed

Breadcrumbs are problematic #174

franzinc opened this issue Apr 9, 2024 · 7 comments

Comments

@franzinc
Copy link

franzinc commented Apr 9, 2024

I have an internal link checker (written in Common Lisp) and it's been a real challenge to get my internal documentation to pass with no bad links. There are many, many false positives. Why? Because of the breadcrumbs. They look like this:

<div class="main with-sidebar">
  <div class="breadcrumbs"><a href="/">Home</a> / <a href="/readme">readme</a> / <a href="/readme/agraph">agraph</a> / 
    <span>attributes-index-opt-performance</span>
  </div><h1 id="attributes-index-opt-performance">attributes-index-opt-performance</h1>

What's wrong is that /readme/agraph really should be /readme/agraph/, because when the base URI without the slash is merged with a document, say, foo.md, then it will produce /readme/foo.md instead of /readme/agraph/foo.md.

In all other places, the trailing slash is included.

It would be extremely helpful (I don't know how to workaround this in the link checker) if the trailing slash could be included. In this case, you know that the breadcrumbs are directories so including the trailing / is always the right thing.

I figured the fix would be pretty easy, but when I did git grep -i breadcrumbs it had no hits. So, maybe the real bug is in a dependent project?

Thank you.

@DannyBen
Copy link
Owner

The relevant code is here:

href: "#{config.base_uri}/#{partial_path}",

I will see if adding the trailing slash to all breadcrumbs hrefs works without breaking anything.

@DannyBen
Copy link
Owner

This is solved in the master branch and edge version.
Can you test it?

@DannyBen
Copy link
Owner

Version 1.2.0 is now released with this fix.
Thanks for the report.

@franzinc
Copy link
Author

@DannyBen thanks for the fix! However, we're having issues testing the new release:

2024-04-25 06:20:14 - NoMethodError - undefined method `last' for #<struct Madness::Breadcrumbs::Breadcrumb 
label="Home", href="/"> (
NoMethodError):
        /opt/dev/readme_theme/views/_breadcrumbs.slim:4:in `block in __tilt_3640'
        /opt/dev/readme_theme/views/_breadcrumbs.slim:3:in `each'
        /opt/dev/readme_theme/views/_breadcrumbs.slim:3:in `__tilt_3640'
        /usr/lib/ruby/gems/3.2.0/gems/tilt-2.3.0/lib/tilt/template.rb:207:in `bind_call'
        /usr/lib/ruby/gems/3.2.0/gems/tilt-2.3.0/lib/tilt/template.rb:207:in `evaluate'
        /usr/lib/ruby/gems/3.2.0/gems/tilt-2.3.0/lib/tilt/template.rb:102:in `render'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:871:in `render'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:806:in `slim'
        /opt/dev/readme_theme/views/document.slim:5:in `__tilt_3640'
        /usr/lib/ruby/gems/3.2.0/gems/tilt-2.3.0/lib/tilt/template.rb:207:in `bind_call'
        /usr/lib/ruby/gems/3.2.0/gems/tilt-2.3.0/lib/tilt/template.rb:207:in `evaluate'
        /usr/lib/ruby/gems/3.2.0/gems/tilt-2.3.0/lib/tilt/template.rb:102:in `render'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:871:in `render'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:806:in `slim'
        /usr/lib/ruby/gems/3.2.0/gems/madness-1.2.0/lib/madness/server.rb:60:in `block in <class:Server>'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1804:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1804:in `block in compile!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1071:in `block (3 levels) in route!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1089:in `route_eval'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1071:in `block (2 levels) in route!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1120:in `block in process_route'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1118:in `catch'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1118:in `process_route'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1069:in `block in route!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1066:in `each'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1066:in `route!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1190:in `block in dispatch!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `catch'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `invoke'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1185:in `dispatch!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1001:in `block in call!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `catch'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1161:in `invoke'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1001:in `call!'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:990:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-protection-4.0.0/lib/rack/protection/xss_header.rb:20:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-protection-4.0.0/lib/rack/protection/path_traversal.rb:18:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-protection-4.0.0/lib/rack/protection/json_csrf.rb:28:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-protection-4.0.0/lib/rack/protection/base.rb:53:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-protection-4.0.0/lib/rack/protection/base.rb:53:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-protection-4.0.0/lib/rack/protection/frame_options.rb:33:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-3.0.10/lib/rack/logger.rb:19:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-3.0.10/lib/rack/common_logger.rb:43:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:266:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:259:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-3.0.10/lib/rack/head.rb:15:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/rack-3.0.10/lib/rack/method_override.rb:28:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:224:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:2115:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `block in call'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1890:in `synchronize'
        /usr/lib/ruby/gems/3.2.0/gems/sinatra-4.0.0/lib/sinatra/base.rb:1674:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/configuration.rb:272:in `call'
        /usr/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/request.rb:100:in `block in handle_request'
        /usr/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:378:in `with_force_shutdown'
        /usr/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/request.rb:99:in `handle_request'
        /usr/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/server.rb:464:in `process_client'
        /usr/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/server.rb:245:in `block in run'
        /usr/lib/ruby/gems/3.2.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:155:in `block in spawn_thread'

@franzinc
Copy link
Author

@DannyBen
Copy link
Owner

You seem to be using a custom theme, am I right?

If so, use the original theme first or copy the breadcrumbs template, since it has changed.

@franzinc
Copy link
Author

@DannyBen That was it. Thank you so much!

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

No branches or pull requests

2 participants