Class: Intranet::Pandoc::Responder

Inherits:
AbstractResponder
  • Object
show all
Includes:
Core::HamlWrapper
Defined in:
lib/intranet/pandoc/responder.rb

Overview

The responder for the Pandoc module of the Intranet.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, title, rootdir, template = nil, in_menu = true) ⇒ Responder

Initializes a new Pandoc responder instance.



38
39
40
41
42
43
44
# File 'lib/intranet/pandoc/responder.rb', line 38

def initialize(logger, title, rootdir, template = nil, in_menu = true)
  @logger   = logger
  @title    = title
  @rootdir  = rootdir
  @template = template
  @in_menu  = in_menu
end

Instance Attribute Details

#titleString (readonly)

The title of the module instance, as displayed on the web page.



73
74
75
# File 'lib/intranet/pandoc/responder.rb', line 73

def title
  @title
end

Class Method Details

.module_homepageString

The homepage of the module.



29
30
31
# File 'lib/intranet/pandoc/responder.rb', line 29

def self.module_homepage
  HOMEPAGE_URL
end

.module_nameString

Returns the name of the module.



17
18
19
# File 'lib/intranet/pandoc/responder.rb', line 17

def self.module_name
  NAME
end

.module_versionString

The version of the module, according to semantic versionning.



23
24
25
# File 'lib/intranet/pandoc/responder.rb', line 23

def self.module_version
  VERSION
end

Instance Method Details

#generate_page(path, query) ⇒ Integer, String

Generates the HTML content associated to the given path and query.



63
64
65
66
67
68
69
# File 'lib/intranet/pandoc/responder.rb', line 63

def generate_page(path, query)
  case path
  when %r{^/.+\.html$} then serve_page(path.gsub(%r{^/(.+)\.html$}, '\\1'))
  when %r{^/.+\.(jpg|png|svg)$} then serve_media(path.gsub(%r{^/(.+)$}, '\\1'))
  else super(path, query)
  end
end

#in_menu?Boolean

Specifies if the responder instance should be displayed in the main navigation menu or not.



49
50
51
# File 'lib/intranet/pandoc/responder.rb', line 49

def in_menu?
  @in_menu
end

#resources_dirString

Specifies the absolute path to the resources directory for that module.



55
56
57
# File 'lib/intranet/pandoc/responder.rb', line 55

def resources_dir
  File.absolute_path(File.join('..', 'resources'), __dir__)
end