Class: Journeybook::Site

Inherits:
ApplicationRecord show all
Defined in:
app/models/journeybook/site.rb

Instance Method Summary collapse

Instance Method Details

#layout_nameObject



16
17
18
# File 'app/models/journeybook/site.rb', line 16

def layout_name
  layout.presence || Journeybook.configuration.default_layout
end

#matches_path?(request_path) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/journeybook/site.rb', line 31

def matches_path?(request_path)
  relative_path_for(request_path).present?
end

#public_path_for(page) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'app/models/journeybook/site.rb', line 35

def public_path_for(page)
  return unless page

  prefix = normalize_path(path_prefix)
  path = normalize_path(page.path)
  return path if prefix == "/"
  return prefix if path == "/"

  "#{prefix}#{path}"
end

#relative_path_for(request_path) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'app/models/journeybook/site.rb', line 20

def relative_path_for(request_path)
  path = normalize_path(request_path)
  prefix = normalize_path(path_prefix)

  return path if prefix == "/"
  return unless path == prefix || path.start_with?("#{prefix}/")

  relative = path.delete_prefix(prefix)
  relative.presence || "/"
end