File: source.rb

package info (click to toggle)
webgen 0.3.8-3
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 1,912 kB
  • ctags: 586
  • sloc: ruby: 4,789; makefile: 9
file content (21 lines) | stat: -rw-r--r-- 564 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
module WebgenDocuPlugins

  class ShowSourceTag < Tags::DefaultTag

    summary "Copy the page source and link to it"

    tag 'source'

    def process_tag( tag, node, refNode )
      outpath = node.recursive_value( 'src' ).sub( /^#{Webgen::Plugin['Configuration']['srcDirectory']}/, Webgen::Plugin['Configuration']['outDirectory'] )
      if File.exists?( node.recursive_value('src') )
        FileUtils.cp( node.recursive_value( 'src' ), outpath )
        "Source: <a href=\"#{node['src']}\">page source</a>"
      else
        ""
      end
    end

  end

end