Module: Scrivito::PresetRoutes

Defined in:
lib/fiona7/scrivito_patches/preset_routes.rb

Class Method Summary collapse

Class Method Details

.install_delayed(route_set = nil) ⇒ Object



8
9
10
11
12
# File 'lib/fiona7/scrivito_patches/preset_routes.rb', line 8

def self.install_delayed(route_set=nil)
  delayed.each do |route, delayed_lambda|
    delayed_lambda.call(route_set)
  end
end

.install_into(route_set, do_the_install = false) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fiona7/scrivito_patches/preset_routes.rb', line 14

def self.install_into(route_set, do_the_install=false)
  return unless do_the_install
  return if Scrivito::Configuration.scrivito_route_enabled?

  Scrivito::Configuration.with_scrivito_route_enabled do
    route_set.draw do
      scrivito_route '/', using: "homepage", via: :all

      if Scrivito::Configuration.legacy_routing
        scrivito_route ':id(/*slug)', using: "slug_id", via: :all
      else
        scrivito_route '(/)(*slug-):id', using: "slug_id", via: :all

        match ':id(/*slug)', to: 'scrivito/legacy_redirect#index', via: :all, constraints: {
          id: /[0-9]{4,}/
        }
      end

      scrivito_route '/*permalink', using: "permalink", format: false, via: :all
    end
  end
end

.install_slave_into(route_set, do_the_install = false) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fiona7/scrivito_patches/preset_routes.rb', line 37

def self.install_slave_into(route_set, do_the_install=false)
  return unless do_the_install
  return if Scrivito::Configuration.scrivito_route_enabled?

  Scrivito::Configuration.with_scrivito_route_enabled do
    route_set.draw do
      scrivito_route '/f7(/)', using: "homepage", via: :all

      if Scrivito::Configuration.legacy_routing
        scrivito_route '/f7/:id(/*slug)', using: "slug_id", via: :all
      else
        scrivito_route '/f7/(*slug-):id', using: "slug_id", via: :all

        match '/f7/:id(/*slug)', to: 'scrivito/legacy_redirect#index', via: :all, constraints: {
          id: /[0-9]{4,}/
        }
      end

      scrivito_route '/f7/*permalink', using: "permalink", format: false, via: :all
    end
  end
end