Sha256: 2fc28a4afb4905e3c4c5b8c385e309c6c607127d92a0e305ae4fa2edc2f018e1

Contents?: true

Size: 1.05 KB

Versions: 55

Compression:

Stored size: 1.05 KB

Contents

require 'webgen/tag'
class PrevNextTag
    include Webgen::Tag::Base

    def call(tag, body, context)
        node = context.content_node
        while !node.is_file?
            node = node.parent
        end

        siblings = node.parent.children.sort
        siblings.delete_if { |n| !n.meta_info['in_menu'] }
        prev, _ = siblings.
            enum_for(:each_cons, 2).
            find { |prev, this| this == node }
        _, nxt = siblings.
            enum_for(:each_cons, 2).
            find { |this, nxt| this == node }

        content = if tag == "next" && nxt
                      node.link_to(nxt)
                  elsif tag == "previous" && prev
                      node.link_to(prev)
                  end

        if content
            if !body.empty?
                body.gsub '%', content
            else
                content
            end
        end
    end
end

config = Webgen::WebsiteAccess.website.config
config['contentprocessor.tags.map']['previous'] = 'PrevNextTag'
config['contentprocessor.tags.map']['next'] = 'PrevNextTag'


Version data entries

55 entries across 55 versions & 2 rubygems

Version Path
roby-3.0.0 doc/guide/ext/previous_next.rb
autoproj-1.7.0.rc2 doc/guide/ext/previous_next.rb
autoproj-1.7.0.rc1 doc/guide/ext/previous_next.rb
autoproj-1.7.0.b3 doc/guide/ext/previous_next.rb
autoproj-1.7.0.b2 doc/guide/ext/previous_next.rb
autoproj-1.7.0.b1 doc/guide/ext/previous_next.rb
autoproj-1.6.2 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc9 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc8 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc7 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc6 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc5 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc4 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc3 doc/guide/ext/previous_next.rb
autoproj-1.6.2.rc2 doc/guide/ext/previous_next.rb
autoproj-1.6.1 doc/guide/ext/previous_next.rb
autoproj-1.6.1.b1 doc/guide/ext/previous_next.rb
autoproj-1.6.0 doc/guide/ext/previous_next.rb
autoproj-1.6.0.rc6 doc/guide/ext/previous_next.rb
autoproj-1.6.0.rc5 doc/guide/ext/previous_next.rb