cmor_cms 0.0.58.pre → 0.0.59.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e62b58cc0f32abc8a8e6cac3b17b5350a7ba6350033c2cb56daee44999c18d7
4
- data.tar.gz: 868f1976844967465b2d1927eb3663451a2765d1f4af6dad2b46a5aeb023fe48
3
+ metadata.gz: e185b056371db7d645ccb896b3a87ca63aa61427fa0bf4d27f4f8b3ae2c9cee4
4
+ data.tar.gz: b7942385f07c0dbbce28f8b129229635ab4c00af1e8ed6d92d8c29322409ffaa
5
5
  SHA512:
6
- metadata.gz: e5d90528cdf4eca40def1bed25061495afecd6c4e262f422745e299d8d93bfd6f326283d4bb66f525255e508d62031301127318b20cb759cb275845bb2720f9c
7
- data.tar.gz: 6aa4f799ca502629eec72427a7463cc62ee57b0ae0a3718478f7d73d1234e14c66b8257afdd3f474fecd7aaf19930c6f58ed66b8b12166d98264cd5c03f43a91
6
+ metadata.gz: 8d976aee1a3eab730e130b8a842123d80c44342b265cdf989ac6752847a6615fa8a117393abf47db4e954f9bf64a1ce86ed6a2572957ee3846f646c0ad128979
7
+ data.tar.gz: cf09c9a732f6fdd53213e84fa1d220e2056985ba11fb682bb5e996fb0f5ce616db7359db10f1cf1612d9c2a55b8ad2c9d6bbfd268a081093cbfde22d25bfe4a2
@@ -0,0 +1,34 @@
1
+ module Cmor
2
+ module Cms
3
+ class RedirectMiddleware
4
+ def initialize(app)
5
+ @app = app
6
+ end
7
+
8
+ def redirect_to(location)
9
+ [301, {'Location' => location, 'Content-Type' => 'text/html'}, ['Moved Permanently']]
10
+ end
11
+
12
+ def call(env)
13
+ req = Rack::Request.new(env)
14
+ if redirect = find_redirect_for(req.path)
15
+ return redirect_to(redirect.target)
16
+ end
17
+ @app.call(env)
18
+ end
19
+
20
+ def find_redirect_for(request_path)
21
+ Cmor::Cms::Redirect.published.where(source: request_path).first
22
+ end
23
+ # def call(env)
24
+ # req = Rack::Request.new(env)
25
+ # return redirect(redirects[req.path]) if redirects.include?(req.path)
26
+ # @app.call(env)
27
+ # end
28
+
29
+ # def redirects
30
+ # { '/source' => '/target' }
31
+ # end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,13 @@
1
+ module Cmor
2
+ module Cms
3
+ class Redirect < ApplicationRecord
4
+ include ActsAsPublished::ActiveRecord
5
+ acts_as_published
6
+
7
+ acts_as_list
8
+
9
+ validates :source, presence: true
10
+ validates :target, presence: true
11
+ end
12
+ end
13
+ end
@@ -22,6 +22,9 @@ de:
22
22
  cmor/cms/partial:
23
23
  one: Fragment
24
24
  other: Fragmente
25
+ cmor/cms/redirect:
26
+ one: Umleitung
27
+ other: Umleitungen
25
28
  cmor/cms/template:
26
29
  one: Vorlage
27
30
  other: Vorlagen
@@ -113,6 +116,11 @@ de:
113
116
  locale: Sprache
114
117
  path_and_filename: Dateipfad
115
118
  pathname: Pfad
119
+ cmor/cms/redirect:
120
+ <<: *defaults
121
+ source: Quelle
122
+ target: Ziel
123
+ position: Position
116
124
  cmor/cms/template:
117
125
  <<: *defaults
118
126
  basename: Name
@@ -22,6 +22,9 @@ en:
22
22
  cmor/cms/partial:
23
23
  one: Partial
24
24
  other: Partials
25
+ cmor/cms/redirect:
26
+ one: Umleitung
27
+ other: Umleitungen
25
28
  cmor/cms/template:
26
29
  one: Template
27
30
  other: Templates
@@ -111,6 +114,11 @@ en:
111
114
  locale: Language
112
115
  path_and_filename: Filepath
113
116
  pathname: Path
117
+ cmor/cms/redirect:
118
+ <<: *defaults
119
+ source: Source
120
+ target: Target
121
+ position: Position
114
122
  cmor/cms/template:
115
123
  <<: *defaults
116
124
  basename: Name
@@ -0,0 +1,12 @@
1
+ class CreateCmorCmsRedirects < ActiveRecord::Migration[5.2]
2
+ def change
3
+ create_table :cmor_cms_redirects do |t|
4
+ t.text :source
5
+ t.text :target
6
+ t.integer :position
7
+ t.timestamp :published_at
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -15,6 +15,10 @@ module Cmor
15
15
  initializer "cmor_cms_engine.register_template_handlers" do |app|
16
16
  ::ActionView::Template.register_template_handler :textile, ::ActionView::Template::Handlers::Textile.new
17
17
  end
18
+
19
+ initializer "cmor_cms_engine.add_redirect_middleware" do |app|
20
+ app.middleware.use Cmor::Cms::RedirectMiddleware
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -1,3 +1,4 @@
1
+ require 'acts_as_list'
1
2
  require 'acts_as_published'
2
3
  require 'awesome_nested_set'
3
4
  require 'cmor_core_frontend'
@@ -0,0 +1,6 @@
1
+ FactoryBot.define do
2
+ factory :cmor_cms_redirect, class: 'Cmor::Cms::Redirect' do
3
+ source { "/source" }
4
+ target { "/target" }
5
+ end
6
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmor_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.58.pre
4
+ version: 0.0.59.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-17 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.58.pre
33
+ version: 0.0.59.pre
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.58.pre
40
+ version: 0.0.59.pre
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cmor_core_frontend
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.0.58.pre
47
+ version: 0.0.59.pre
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.58.pre
54
+ version: 0.0.59.pre
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -318,6 +318,20 @@ dependencies:
318
318
  - - ">="
319
319
  - !ruby/object:Gem::Version
320
320
  version: '0'
321
+ - !ruby/object:Gem::Dependency
322
+ name: acts_as_list
323
+ requirement: !ruby/object:Gem::Requirement
324
+ requirements:
325
+ - - ">="
326
+ - !ruby/object:Gem::Version
327
+ version: '0'
328
+ type: :runtime
329
+ prerelease: false
330
+ version_requirements: !ruby/object:Gem::Requirement
331
+ requirements:
332
+ - - ">="
333
+ - !ruby/object:Gem::Version
334
+ version: '0'
321
335
  - !ruby/object:Gem::Dependency
322
336
  name: awesome_nested_set
323
337
  requirement: !ruby/object:Gem::Requirement
@@ -424,6 +438,7 @@ files:
424
438
  - app/importers/cmor/cms/importers/navigation.rb
425
439
  - app/importers/cmor/cms/importers/navigation_item.rb
426
440
  - app/importers/cmor/cms/importers/page.rb
441
+ - app/middlewares/cmor/cms/redirect_middleware.rb
427
442
  - app/models/cmor/cms/content_block.rb
428
443
  - app/models/cmor/cms/content_box.rb
429
444
  - app/models/cmor/cms/layout.rb
@@ -431,6 +446,7 @@ files:
431
446
  - app/models/cmor/cms/navigation_item.rb
432
447
  - app/models/cmor/cms/page.rb
433
448
  - app/models/cmor/cms/partial.rb
449
+ - app/models/cmor/cms/redirect.rb
434
450
  - app/models/cmor/cms/template.rb
435
451
  - app/resolvers/cmor/cms/database_resolver.rb
436
452
  - app/resolvers/cmor/cms/layout_resolver.rb
@@ -467,6 +483,7 @@ files:
467
483
  - db/migrate/20200120134422_add_published_at_to_cmor_cms_navigation_items.rb
468
484
  - db/migrate/20200120141440_set_all_publishable_to_published.rb
469
485
  - db/migrate/20200514115526_create_cmor_cms_layouts.rb
486
+ - db/migrate/20200813085847_create_cmor_cms_redirects.rb
470
487
  - lib/cmor/cms.rb
471
488
  - lib/cmor/cms/action_view/template_patch.rb
472
489
  - lib/cmor/cms/action_view/template_renderer_patch.rb
@@ -490,6 +507,7 @@ files:
490
507
  - spec/factories/cmor/cms/navigations.rb
491
508
  - spec/factories/cmor/cms/pages.rb
492
509
  - spec/factories/cmor/cms/partials.rb
510
+ - spec/factories/cmor/cms/redirects.rb
493
511
  - spec/factories/cmor/cms/templates.rb
494
512
  homepage: https://github.com/content-management-on-rails
495
513
  licenses: