qbrick 2.6.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/qbrick/pages_controller.rb +1 -2
- data/app/helpers/qbrick/admin_helper.rb +6 -2
- data/app/models/qbrick/page.rb +24 -0
- data/db/migrate/24_localize_publish_column.rb +1 -1
- data/lib/qbrick/engine.rb +7 -1
- data/lib/qbrick/version.rb +1 -1
- data/spec/controllers/qbrick/pages_controller_spec.rb +1 -1
- data/spec/models/page_spec.rb +40 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f3ceb72b5a03c06f602281f41bcc750f8d49ce
|
4
|
+
data.tar.gz: 4618b777f6e1a6151b95a1e17d6894aa158ac42c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c779195400c460314f4d37a8a6796637e043427dd6643c9d4aea53be22fa0c35914926e8177e10093cab10e9b28f3924e4746ce8147790196d04c3d51aad0383
|
7
|
+
data.tar.gz: bd0e378f688977977cb1dde7512f59ad11c6111a238fd56c1767343692be81f07d2fb6d7fb9332b9352b3321b77a948c38c4cafbbbf9aed4d8cd27a01dc0ad31
|
@@ -13,9 +13,8 @@ module Qbrick
|
|
13
13
|
|
14
14
|
def show
|
15
15
|
if redirect_page?
|
16
|
-
redirect_url = @page.redirect_url.sub(%r{\A\/+}, '') # remove all preceding slashes
|
17
16
|
session[:qbrick_referrer] = @page.id
|
18
|
-
redirect_to
|
17
|
+
redirect_to @page.redirect_url
|
19
18
|
elsif @page.present?
|
20
19
|
respond_with @page
|
21
20
|
elsif @page.blank? && respond_to?(:handle_404)
|
@@ -8,8 +8,12 @@ module Qbrick
|
|
8
8
|
#
|
9
9
|
def method_missing(method, *args, &block)
|
10
10
|
main_app.send(method, *args, &block)
|
11
|
-
rescue NoMethodError
|
12
|
-
|
11
|
+
rescue NoMethodError => exception
|
12
|
+
bc = ::ActiveSupport::BacktraceCleaner.new
|
13
|
+
bc.add_silencer { |l| l =~ /^#{__FILE__}.+#{__method__}'?$/ }
|
14
|
+
exception.set_backtrace bc.clean(exception.backtrace)
|
15
|
+
|
16
|
+
raise exception
|
13
17
|
end
|
14
18
|
|
15
19
|
def sublime_video_include_tag
|
data/app/models/qbrick/page.rb
CHANGED
@@ -27,6 +27,7 @@ module Qbrick
|
|
27
27
|
|
28
28
|
before_validation :create_slug, :create_path
|
29
29
|
after_save :update_child_paths
|
30
|
+
validate :remove_preceding_slashes, if: :redirect?
|
30
31
|
|
31
32
|
validates :title, presence: true
|
32
33
|
validates :slug, presence: true
|
@@ -81,6 +82,29 @@ module Qbrick
|
|
81
82
|
page_type == Qbrick::PageType::REDIRECT || page_type == Qbrick::PageType::CUSTOM
|
82
83
|
end
|
83
84
|
|
85
|
+
def internal_redirect?
|
86
|
+
return false unless redirect?
|
87
|
+
|
88
|
+
scheme = URI.parse(redirect_url).scheme
|
89
|
+
return true if scheme.nil?
|
90
|
+
|
91
|
+
internal_redirect = Qbrick::Engine.hosts.find do |h|
|
92
|
+
URI.parse("#{scheme}://#{h}").route_to(redirect_url).host.nil?
|
93
|
+
end
|
94
|
+
|
95
|
+
internal_redirect.present?
|
96
|
+
end
|
97
|
+
|
98
|
+
def external_redirect?
|
99
|
+
redirect? && !internal_redirect?
|
100
|
+
end
|
101
|
+
|
102
|
+
def remove_preceding_slashes
|
103
|
+
return if redirect_url.blank?
|
104
|
+
|
105
|
+
redirect_url.sub!(%r{^/+}, '/')
|
106
|
+
end
|
107
|
+
|
84
108
|
def navigation?
|
85
109
|
page_type == Qbrick::PageType::NAVIGATION
|
86
110
|
end
|
@@ -10,7 +10,7 @@ class LocalizePublishColumn < ActiveRecord::Migration
|
|
10
10
|
|
11
11
|
new_translations = Qbrick::Page.translated_columns_for(:published) - %w(published_en)
|
12
12
|
Qbrick::Page.all.each do |page|
|
13
|
-
page.
|
13
|
+
page.update_columns Hash[new_translations.zip([page.published_en] * new_translations.count)]
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
data/lib/qbrick/engine.rb
CHANGED
@@ -11,7 +11,7 @@ module Qbrick
|
|
11
11
|
isolate_namespace Qbrick
|
12
12
|
|
13
13
|
config.i18n.fallbacks = [:de]
|
14
|
-
config.i18n.load_path += Dir[Qbrick::Engine.root.join('config
|
14
|
+
config.i18n.load_path += Dir[Qbrick::Engine.root.join('config/locales/**/*.{yml}').to_s]
|
15
15
|
|
16
16
|
# defaults to nil
|
17
17
|
config.sublime_video_token = nil
|
@@ -23,5 +23,11 @@ module Qbrick
|
|
23
23
|
require 'action_view/dependency_tracker'
|
24
24
|
ActionView::DependencyTracker.register_tracker :haml, ActionView::DependencyTracker::ERBTracker
|
25
25
|
end
|
26
|
+
|
27
|
+
def hosts
|
28
|
+
[Socket.gethostname].tap do |result|
|
29
|
+
result.concat [Rails.application.config.hosts].flatten if Rails.application.config.respond_to? :hosts
|
30
|
+
end
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
data/lib/qbrick/version.rb
CHANGED
@@ -60,7 +60,7 @@ describe Qbrick::PagesController, type: :controller do
|
|
60
60
|
|
61
61
|
context 'when page is a redirect page' do
|
62
62
|
it 'redirects to the redirected url' do
|
63
|
-
page = FactoryGirl.create :page, page_type: 'redirect', slug: 'dumdidum', redirect_url: 'de/redirect_page'
|
63
|
+
page = FactoryGirl.create :page, page_type: 'redirect', slug: 'dumdidum', redirect_url: '/de/redirect_page'
|
64
64
|
get :show, url: page.slug
|
65
65
|
expect(response).to redirect_to('/de/redirect_page')
|
66
66
|
end
|
data/spec/models/page_spec.rb
CHANGED
@@ -537,4 +537,44 @@ describe Qbrick::Page, type: :model do
|
|
537
537
|
expect(child_page.create_path).to eq '/le_parent/le_child'
|
538
538
|
end
|
539
539
|
end
|
540
|
+
|
541
|
+
context 'when it is a redirect page' do
|
542
|
+
let(:page) { build :page, page_type: Qbrick::PageType::REDIRECT }
|
543
|
+
|
544
|
+
describe '#internal_redirect?' do
|
545
|
+
it 'returns false for non redirect pages' do
|
546
|
+
expect(build(:page).internal_redirect?).to be_falsey
|
547
|
+
end
|
548
|
+
|
549
|
+
it 'returns false for external redirects' do
|
550
|
+
page.redirect_url = 'http://google.de'
|
551
|
+
expect(page.internal_redirect?).to be_falsey
|
552
|
+
end
|
553
|
+
|
554
|
+
it 'returns true for internal redirects' do
|
555
|
+
page.redirect_url = '/huhu'
|
556
|
+
expect(page.internal_redirect?).to be_truthy
|
557
|
+
page.redirect_url = "http://#{Socket.gethostname}/huhu"
|
558
|
+
expect(page.internal_redirect?).to be_truthy
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
describe '#external_redirect?' do
|
563
|
+
it 'returns false for non redirect pages' do
|
564
|
+
expect(build(:page).external_redirect?).to be_falsey
|
565
|
+
end
|
566
|
+
|
567
|
+
it 'returns true for external redirects' do
|
568
|
+
page.redirect_url = 'http://google.de'
|
569
|
+
expect(page.external_redirect?).to be_truthy
|
570
|
+
end
|
571
|
+
|
572
|
+
it 'returns false for internal redirects' do
|
573
|
+
page.redirect_url = '/huhu'
|
574
|
+
expect(page.external_redirect?).to be_falsey
|
575
|
+
page.redirect_url = "http://#{Socket.gethostname}/huhu"
|
576
|
+
expect(page.external_redirect?).to be_falsey
|
577
|
+
end
|
578
|
+
end
|
579
|
+
end
|
540
580
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qbrick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Immanuel Häussermann
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2015-06-
|
15
|
+
date: 2015-06-10 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec-rails
|