locomotive_cms 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/locomotive/api/base_controller.rb +7 -2
- data/app/controllers/locomotive/api/tokens_controller.rb +1 -1
- data/app/models/locomotive/ability.rb +9 -3
- data/app/models/locomotive/account.rb +1 -2
- data/app/presenters/locomotive/account_presenter.rb +1 -1
- data/features/api/authorization/sites.feature +0 -1
- data/lib/locomotive/dragonfly.rb +11 -1
- data/lib/locomotive/render.rb +2 -5
- data/lib/locomotive/version.rb +1 -1
- data/spec/lib/locomotive/liquid/filters/resize_spec.rb +19 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d79c21569c5137978e3d1c2bcb0fc979ae1ceb5c
|
4
|
+
data.tar.gz: 79fe09d1318424c387abb7b545a16f30598885b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bf645dc0029bafcbb19028434be2653522efd1e95c0261e95eaa69b39dc905a9a7f577ab8bb081cebbb746945facf4272abb894d6afa979a1e300c3a4f68fc7
|
7
|
+
data.tar.gz: 7eae460e4ca873b5d60e5f4e7950a5f7e5e071a9ebafe677faa4468a7f544feb56bfb1cd2354c06a8b5ea4d540aaf730a904a0fad1c1ce0c0d5cb60c24a7f468
|
@@ -40,10 +40,15 @@ module Locomotive
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def set_locale
|
43
|
-
|
43
|
+
locale = params[:locale] ||
|
44
|
+
current_site.try(:default_locale) ||
|
45
|
+
current_locomotive_account.try(:locale) ||
|
46
|
+
Locomotive.config.default_locale
|
47
|
+
|
48
|
+
::Mongoid::Fields::I18n.locale = locale
|
44
49
|
::I18n.locale = ::Mongoid::Fields::I18n.locale
|
45
50
|
|
46
|
-
self.setup_i18n_fallbacks
|
51
|
+
self.setup_i18n_fallbacks if current_site
|
47
52
|
end
|
48
53
|
|
49
54
|
def render_access_denied(exception)
|
@@ -6,7 +6,7 @@ module Locomotive
|
|
6
6
|
|
7
7
|
def create
|
8
8
|
begin
|
9
|
-
token = Account.create_api_token(
|
9
|
+
token = Account.create_api_token(params[:email], params[:password], params[:api_key])
|
10
10
|
respond_with({ token: token }, location: root_url)
|
11
11
|
rescue Exception => e
|
12
12
|
respond_with({ message: e.message }, status: 401, location: root_url)
|
@@ -15,9 +15,9 @@ module Locomotive
|
|
15
15
|
@membership = Membership.new(account: @account, role: 'admin')
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
if @membership.nil?
|
19
|
+
setup_account_without_a_site
|
20
|
+
elsif @membership.admin?
|
21
21
|
setup_admin_permissions!
|
22
22
|
else
|
23
23
|
setup_default_permissions!
|
@@ -28,6 +28,12 @@ module Locomotive
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
+
def setup_account_without_a_site
|
32
|
+
cannot :manage, :all
|
33
|
+
|
34
|
+
can :create, Site
|
35
|
+
end
|
36
|
+
|
31
37
|
def setup_default_permissions!
|
32
38
|
cannot :manage, :all
|
33
39
|
end
|
@@ -78,14 +78,13 @@ module Locomotive
|
|
78
78
|
# If an error occurs (invalid account, ...etc), this method raises an exception that has
|
79
79
|
# to be caught somewhere.
|
80
80
|
#
|
81
|
-
# @param [ Site ] site The site where the authentication request is made
|
82
81
|
# @param [ String ] email The email of the account
|
83
82
|
# @param [ String ] password The password of the account
|
84
83
|
# @param [ String ] api_key The API key of the site.
|
85
84
|
#
|
86
85
|
# @return [ String ] The API token
|
87
86
|
#
|
88
|
-
def self.create_api_token(
|
87
|
+
def self.create_api_token(email, password, api_key)
|
89
88
|
if api_key.present?
|
90
89
|
account = self.where(api_key: api_key).first
|
91
90
|
|
@@ -2,7 +2,7 @@ module Locomotive
|
|
2
2
|
class AccountPresenter < BasePresenter
|
3
3
|
|
4
4
|
## properties ##
|
5
|
-
properties :name, :email, :locale, :encrypted_password, :password_salt
|
5
|
+
properties :name, :email, :locale, :encrypted_password, :password_salt, :api_key
|
6
6
|
property :admin, only_getter: true
|
7
7
|
|
8
8
|
with_options only_setter: true do |presenter|
|
@@ -84,7 +84,6 @@ Feature: Sites
|
|
84
84
|
And the JSON response at "1/memberships" should not have 0 entries
|
85
85
|
And the JSON response at "2/memberships" should not have 0 entries
|
86
86
|
|
87
|
-
|
88
87
|
Scenario: Creating new site as a Designer
|
89
88
|
Given I have a "designer" API token
|
90
89
|
When I do an API POST to sites.json with:
|
data/lib/locomotive/dragonfly.rb
CHANGED
@@ -25,7 +25,7 @@ module Locomotive
|
|
25
25
|
if source.is_a?(String) || source.is_a?(Hash) # simple string or theme asset
|
26
26
|
source = source['url'] if source.is_a?(Hash)
|
27
27
|
|
28
|
-
source
|
28
|
+
clean_source!(source)
|
29
29
|
|
30
30
|
if source =~ /^http/
|
31
31
|
file = self.app.fetch_url(source)
|
@@ -49,5 +49,15 @@ module Locomotive
|
|
49
49
|
::Dragonfly.app
|
50
50
|
end
|
51
51
|
|
52
|
+
protected
|
53
|
+
|
54
|
+
def self.clean_source!(source)
|
55
|
+
# remove the leading / trailing whitespaces
|
56
|
+
source.strip!
|
57
|
+
|
58
|
+
# remove the query part (usually, timestamp) if local file
|
59
|
+
source.sub!(/(\?.*)$/, '') unless source =~ /^http/
|
60
|
+
end
|
61
|
+
|
52
62
|
end
|
53
63
|
end
|
data/lib/locomotive/render.rb
CHANGED
@@ -67,11 +67,8 @@ module Locomotive
|
|
67
67
|
|
68
68
|
# Inputs which define the ETag for this response
|
69
69
|
etag_inputs = {
|
70
|
-
'page'
|
71
|
-
'
|
72
|
-
'page_path' => params[:page_path],
|
73
|
-
'locale' => params[:locale]
|
74
|
-
}
|
70
|
+
'page' => @page.cache_key,
|
71
|
+
'locale' => params[:locale]
|
75
72
|
}
|
76
73
|
|
77
74
|
if @page.with_cache?
|
data/lib/locomotive/version.rb
CHANGED
@@ -2,13 +2,14 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Locomotive::Liquid::Filters::Resize do
|
4
4
|
before :each do
|
5
|
-
@site
|
6
|
-
@theme_asset
|
7
|
-
@theme_asset_path
|
8
|
-
@asset
|
9
|
-
@asset_url
|
10
|
-
@
|
11
|
-
@
|
5
|
+
@site = FactoryGirl.create(:site)
|
6
|
+
@theme_asset = FactoryGirl.create(:theme_asset, source: FixturedAsset.open('5k.png'), site: @site)
|
7
|
+
@theme_asset_path = "/sites/#{@theme_asset.site_id}/theme/images/5k.png"
|
8
|
+
@asset = FactoryGirl.create(:asset, source: FixturedAsset.open('5k.png'), site: @site)
|
9
|
+
@asset_url = @asset.source.url
|
10
|
+
@asset_url_with_ts = "#{@asset.source.url}?24e29997bcb00e97d8252cdd29d14e2d"
|
11
|
+
@asset_path = "/sites/#{@asset.site_id}/assets/#{@asset.id}/5k.png"
|
12
|
+
@context = Liquid::Context.new( { }, { 'asset_url' => @asset_url, 'asset_url_with_ts' => @asset_url_with_ts, 'theme_asset' => @theme_asset.to_liquid }, { site: @site })
|
12
13
|
end
|
13
14
|
|
14
15
|
describe '#resize' do
|
@@ -32,6 +33,16 @@ describe Locomotive::Liquid::Filters::Resize do
|
|
32
33
|
|
33
34
|
end
|
34
35
|
|
36
|
+
context 'when an asset url with a timestamp is given' do
|
37
|
+
|
38
|
+
subject { Liquid::Template.parse('{{ asset_url_with_ts | resize: "40x30" }}').render(@context) }
|
39
|
+
|
40
|
+
it 'returns the location of the resized image' do
|
41
|
+
subject.should =~ /images\/dynamic\/.*\/5k.png/
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
35
46
|
context 'when a theme asset is given' do
|
36
47
|
before :each do
|
37
48
|
@template = Liquid::Template.parse("{{ theme_asset | resize: '300x400' }}")
|
@@ -57,5 +68,6 @@ describe Locomotive::Liquid::Filters::Resize do
|
|
57
68
|
end
|
58
69
|
|
59
70
|
end
|
71
|
+
|
60
72
|
end
|
61
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: locomotive_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Didier Lafforgue
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04
|
11
|
+
date: 2014-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -436,14 +436,14 @@ dependencies:
|
|
436
436
|
requirements:
|
437
437
|
- - "~>"
|
438
438
|
- !ruby/object:Gem::Version
|
439
|
-
version: 1.0.
|
439
|
+
version: 1.0.4
|
440
440
|
type: :runtime
|
441
441
|
prerelease: false
|
442
442
|
version_requirements: !ruby/object:Gem::Requirement
|
443
443
|
requirements:
|
444
444
|
- - "~>"
|
445
445
|
- !ruby/object:Gem::Version
|
446
|
-
version: 1.0.
|
446
|
+
version: 1.0.4
|
447
447
|
- !ruby/object:Gem::Dependency
|
448
448
|
name: rack-cache
|
449
449
|
requirement: !ruby/object:Gem::Requirement
|