Sha256: afb15e07866dca2a70ea3573d34a6b10fb43b0a302ec927f273bd4265c3cd7fe

Contents?: true

Size: 887 Bytes

Versions: 14

Compression:

Stored size: 887 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=\"#{CGI::escapeHTML(prepath + "/" + page.escaped_url_path)}\">#{CGI::escapeHTML(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

14 entries across 14 versions & 1 rubygems

Version Path
gollum-lib-6.0-java lib/gollum-lib/macro/navigation.rb
gollum-lib-6.0 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.4-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.4 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.3-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.3 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.2-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.2 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.1-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2.1 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.2 lib/gollum-lib/macro/navigation.rb
gollum-lib-5.1.3-java lib/gollum-lib/macro/navigation.rb
gollum-lib-5.1.3 lib/gollum-lib/macro/navigation.rb