Sha256: 177d57c4441c6b8412a5e999a53918a57758adc51472098e3a2096d67da2494c

Contents?: true

Size: 848 Bytes

Versions: 17

Compression:

Stored size: 848 Bytes

Contents

module Gollum
  class Macro
    class Navigation < Gollum::Macro

      def render(title = "Navigate this directory", toc_root_path = ::File.dirname(@page.url_path), full_path = false)
        pages = @wiki.pages
        if pages.size > 0
          prepath=@wiki.base_path.sub(/\/$/, '')
          list_items = pages.map do |page|
            if toc_root_path == '.' || page.url_path =~ /^#{toc_root_path}\//
              path_display = (full_path || toc_root_path == '.') ? page.url_path  : page.url_path.sub(/^#{toc_root_path}\//,"").sub(/^\//,'')
              "<li><a href=\"#{prepath}/#{page.escaped_url_path}\">#{path_display}</a></li>"
            end
          end
          result = "<ul>#{list_items.join}</ul>"
        end
        "<div class=\"toc\"><div class=\"toc-title\">#{title}</div>#{result}</div>"
      end

    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
gollum-lib-5.1.1-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.1.1 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.1-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.1 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.6-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.6 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.5-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.5 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.4-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.4 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.3-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.3 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.2-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.2 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.1-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0.1 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.0 lib/gollum-lib/macro/navigation.rb