implement the mechanism to pick a different locale for content types + implement multi-language for content types + rename scss files to css.scss
This commit is contained in:
commit
0489bbe4c2
11
Gemfile
11
Gemfile
@ -6,25 +6,24 @@ gem 'rake', '0.9.2'
|
|||||||
|
|
||||||
gem 'rails', '~> 3.1.3'
|
gem 'rails', '~> 3.1.3'
|
||||||
|
|
||||||
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'# FIXME: waiting for the new devise gem coming soon
|
gem 'devise', '~> 1.5.3'
|
||||||
gem 'cancan', '~> 1.6.7'
|
gem 'cancan', '~> 1.6.7'
|
||||||
|
|
||||||
gem 'bson_ext', '~> 1.4.0'
|
gem 'mongo', '~> 1.5.2'
|
||||||
gem 'mongoid', '~> 2.3.3'
|
gem 'bson_ext', '~> 1.5.2'
|
||||||
|
gem 'mongoid', '~> 2.4.0'
|
||||||
gem 'locomotive_mongoid_acts_as_tree', :git => 'git@github.com:locomotivecms/mongoid_acts_as_tree.git'
|
gem 'locomotive_mongoid_acts_as_tree', :git => 'git@github.com:locomotivecms/mongoid_acts_as_tree.git'
|
||||||
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git'
|
|
||||||
gem 'custom_fields', :path => '../gems/custom_fields' # DEV
|
gem 'custom_fields', :path => '../gems/custom_fields' # DEV
|
||||||
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => 'experimental'
|
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => 'experimental'
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
|
|
||||||
gem 'haml', '~> 3.1.3'
|
gem 'haml', '~> 3.1.3'
|
||||||
gem 'sass-rails', '~> 3.1.4'
|
gem 'sass-rails', '~> 3.1.4'
|
||||||
gem "compass", :git => 'git://github.com/chriseppstein/compass.git'
|
|
||||||
gem 'coffee-script', '~> 2.2.0'
|
gem 'coffee-script', '~> 2.2.0'
|
||||||
gem 'uglifier', '~> 1.0.4'
|
gem 'uglifier', '~> 1.0.4'
|
||||||
|
gem 'compass', '~> 0.12.alpha.4'
|
||||||
gem 'jquery-rails', '~> 1.0.16'
|
gem 'jquery-rails', '~> 1.0.16'
|
||||||
gem 'rails-backbone', '0.5.4'
|
gem 'rails-backbone', '0.5.4'
|
||||||
gem 'handlebars-rails', :git => 'git://github.com/yabawock/handlebars-rails.git'
|
|
||||||
gem 'codemirror-rails'
|
gem 'codemirror-rails'
|
||||||
gem 'tinymce-rails'
|
gem 'tinymce-rails'
|
||||||
gem 'flash_cookie_session', '~> 1.1.1'
|
gem 'flash_cookie_session', '~> 1.1.1'
|
||||||
|
121
Gemfile.lock
121
Gemfile.lock
@ -1,27 +1,3 @@
|
|||||||
GIT
|
|
||||||
remote: git://github.com/chriseppstein/compass.git
|
|
||||||
revision: 79d94647f9a00b06c4a83db02e86f5d404569baf
|
|
||||||
specs:
|
|
||||||
compass (0.12.alpha.1.79d9464)
|
|
||||||
chunky_png (~> 1.2)
|
|
||||||
fssm (>= 0.2.7)
|
|
||||||
sass (~> 3.1)
|
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: git://github.com/plataformatec/devise.git
|
|
||||||
revision: ede004169c6af7416f8c4e3fc29a653bee133f60
|
|
||||||
specs:
|
|
||||||
devise (1.5.1)
|
|
||||||
bcrypt-ruby (~> 3.0)
|
|
||||||
orm_adapter (~> 0.0.3)
|
|
||||||
warden (~> 1.1)
|
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: git://github.com/yabawock/handlebars-rails.git
|
|
||||||
revision: a09077aa91f10e08403af84586b2f2f0b38d9e2f
|
|
||||||
specs:
|
|
||||||
handlebars-rails (0.9.1)
|
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git@github.com:locomotivecms/mongoid_acts_as_tree.git
|
remote: git@github.com:locomotivecms/mongoid_acts_as_tree.git
|
||||||
revision: ca494d22c3d7946385aba1153c017d9c30e9f9d3
|
revision: ca494d22c3d7946385aba1153c017d9c30e9f9d3
|
||||||
@ -34,12 +10,12 @@ PATH
|
|||||||
custom_fields (2.0.0.rc1)
|
custom_fields (2.0.0.rc1)
|
||||||
activesupport (~> 3.1.3)
|
activesupport (~> 3.1.3)
|
||||||
carrierwave-mongoid (~> 0.1.3)
|
carrierwave-mongoid (~> 0.1.3)
|
||||||
mongoid (~> 2.3.4)
|
mongoid (~> 2.4.0)
|
||||||
|
|
||||||
GEM
|
GEM
|
||||||
remote: http://rubygems.org/
|
remote: http://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
RedCloth (4.2.8)
|
RedCloth (4.2.9)
|
||||||
SystemTimer (1.2.3)
|
SystemTimer (1.2.3)
|
||||||
ZenTest (4.6.2)
|
ZenTest (4.6.2)
|
||||||
actionmailer (3.1.3)
|
actionmailer (3.1.3)
|
||||||
@ -77,8 +53,9 @@ GEM
|
|||||||
autotest (4.4.6)
|
autotest (4.4.6)
|
||||||
ZenTest (>= 4.4.1)
|
ZenTest (>= 4.4.1)
|
||||||
bcrypt-ruby (3.0.1)
|
bcrypt-ruby (3.0.1)
|
||||||
bson (1.4.0)
|
bson (1.5.2)
|
||||||
bson_ext (1.4.0)
|
bson_ext (1.5.2)
|
||||||
|
bson (= 1.5.2)
|
||||||
builder (3.0.0)
|
builder (3.0.0)
|
||||||
bushido (0.0.35)
|
bushido (0.0.35)
|
||||||
highline (>= 1.6.1)
|
highline (>= 1.6.1)
|
||||||
@ -101,23 +78,28 @@ GEM
|
|||||||
cells (3.7.1)
|
cells (3.7.1)
|
||||||
actionpack (~> 3.0)
|
actionpack (~> 3.0)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
childprocess (0.2.2)
|
childprocess (0.2.8)
|
||||||
ffi (~> 1.0.6)
|
ffi (~> 1.0.6)
|
||||||
chunky_png (1.2.5)
|
chunky_png (1.2.5)
|
||||||
codemirror-rails (0.3.1)
|
codemirror-rails (0.3.2)
|
||||||
|
railties (~> 3.0)
|
||||||
coffee-script (2.2.0)
|
coffee-script (2.2.0)
|
||||||
coffee-script-source
|
coffee-script-source
|
||||||
execjs
|
execjs
|
||||||
coffee-script-source (1.1.3)
|
coffee-script-source (1.2.0)
|
||||||
cucumber (1.1.3)
|
compass (0.12.alpha.4)
|
||||||
|
chunky_png (~> 1.2)
|
||||||
|
fssm (>= 0.2.7)
|
||||||
|
sass (~> 3.1)
|
||||||
|
cucumber (1.1.4)
|
||||||
builder (>= 2.1.2)
|
builder (>= 2.1.2)
|
||||||
diff-lcs (>= 1.1.2)
|
diff-lcs (>= 1.1.2)
|
||||||
gherkin (~> 2.6.7)
|
gherkin (~> 2.7.1)
|
||||||
json (>= 1.4.6)
|
json (>= 1.4.6)
|
||||||
term-ansicolor (>= 1.0.6)
|
term-ansicolor (>= 1.0.6)
|
||||||
cucumber-rails (1.2.0)
|
cucumber-rails (1.2.1)
|
||||||
capybara (>= 1.1.1)
|
capybara (>= 1.1.2)
|
||||||
cucumber (>= 1.1.1)
|
cucumber (>= 1.1.3)
|
||||||
nokogiri (>= 1.5.0)
|
nokogiri (>= 1.5.0)
|
||||||
database_cleaner (0.7.0)
|
database_cleaner (0.7.0)
|
||||||
delayed_job (3.0.0)
|
delayed_job (3.0.0)
|
||||||
@ -125,15 +107,19 @@ GEM
|
|||||||
delayed_job_mongoid (1.0.8)
|
delayed_job_mongoid (1.0.8)
|
||||||
delayed_job (~> 3.0.0)
|
delayed_job (~> 3.0.0)
|
||||||
mongoid (>= 2.0)
|
mongoid (>= 2.0)
|
||||||
|
devise (1.5.3)
|
||||||
|
bcrypt-ruby (~> 3.0)
|
||||||
|
orm_adapter (~> 0.0.3)
|
||||||
|
warden (~> 1.1)
|
||||||
diff-lcs (1.1.3)
|
diff-lcs (1.1.3)
|
||||||
dragonfly (0.9.8)
|
dragonfly (0.9.9)
|
||||||
rack
|
rack
|
||||||
ejs (1.0.0)
|
ejs (1.0.0)
|
||||||
erubis (2.7.0)
|
erubis (2.7.0)
|
||||||
excon (0.7.8)
|
excon (0.7.12)
|
||||||
execjs (1.2.9)
|
execjs (1.2.13)
|
||||||
multi_json (~> 1.0)
|
multi_json (~> 1.0)
|
||||||
factory_girl (2.3.1)
|
factory_girl (2.3.2)
|
||||||
activesupport
|
activesupport
|
||||||
factory_girl_rails (1.4.0)
|
factory_girl_rails (1.4.0)
|
||||||
factory_girl (~> 2.3.0)
|
factory_girl (~> 2.3.0)
|
||||||
@ -154,25 +140,26 @@ GEM
|
|||||||
formatador (0.2.1)
|
formatador (0.2.1)
|
||||||
formtastic (2.0.2)
|
formtastic (2.0.2)
|
||||||
rails (~> 3.0)
|
rails (~> 3.0)
|
||||||
fssm (0.2.7)
|
fssm (0.2.8.1)
|
||||||
gherkin (2.6.8)
|
gherkin (2.7.2)
|
||||||
json (>= 1.4.6)
|
json (>= 1.4.6)
|
||||||
growl-glue (1.0.7)
|
growl-glue (1.0.7)
|
||||||
haml (3.1.3)
|
haml (3.1.4)
|
||||||
highline (1.6.8)
|
highline (1.6.9)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
httparty (0.8.1)
|
httparty (0.8.1)
|
||||||
multi_json
|
multi_json
|
||||||
multi_xml
|
multi_xml
|
||||||
i18n (0.6.0)
|
i18n (0.6.0)
|
||||||
jquery-rails (1.0.18)
|
jquery-rails (1.0.19)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
json (1.6.1)
|
json (1.6.4)
|
||||||
json_pure (1.6.1)
|
kaminari (0.13.0)
|
||||||
kaminari (0.12.4)
|
actionpack (>= 3.0.0)
|
||||||
rails (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
kgio (2.6.0)
|
railties (>= 3.0.0)
|
||||||
|
kgio (2.7.2)
|
||||||
launchy (2.0.5)
|
launchy (2.0.5)
|
||||||
addressable (~> 2.2.6)
|
addressable (~> 2.2.6)
|
||||||
locomotive_liquid (2.2.2)
|
locomotive_liquid (2.2.2)
|
||||||
@ -183,13 +170,13 @@ GEM
|
|||||||
mime-types (1.17.2)
|
mime-types (1.17.2)
|
||||||
mimetype-fu (0.1.2)
|
mimetype-fu (0.1.2)
|
||||||
mocha (0.9.12)
|
mocha (0.9.12)
|
||||||
mongo (1.4.0)
|
mongo (1.5.2)
|
||||||
bson (= 1.4.0)
|
bson (= 1.5.2)
|
||||||
mongoid (2.3.4)
|
mongoid (2.4.0)
|
||||||
activemodel (~> 3.1)
|
activemodel (~> 3.1)
|
||||||
mongo (~> 1.3)
|
mongo (~> 1.3)
|
||||||
tzinfo (~> 0.3.22)
|
tzinfo (~> 0.3.22)
|
||||||
multi_json (1.0.3)
|
multi_json (1.0.4)
|
||||||
multi_xml (0.4.1)
|
multi_xml (0.4.1)
|
||||||
net-scp (1.0.4)
|
net-scp (1.0.4)
|
||||||
net-ssh (>= 1.99.1)
|
net-ssh (>= 1.99.1)
|
||||||
@ -200,7 +187,7 @@ GEM
|
|||||||
cucumber (>= 0.8)
|
cucumber (>= 0.8)
|
||||||
rake
|
rake
|
||||||
polyglot (0.3.3)
|
polyglot (0.3.3)
|
||||||
rack (1.3.5)
|
rack (1.3.6)
|
||||||
rack-cache (1.1)
|
rack-cache (1.1)
|
||||||
rack (>= 0.4)
|
rack (>= 0.4)
|
||||||
rack-mount (0.8.3)
|
rack-mount (0.8.3)
|
||||||
@ -230,7 +217,7 @@ GEM
|
|||||||
thor (~> 0.14.6)
|
thor (~> 0.14.6)
|
||||||
raindrops (0.8.0)
|
raindrops (0.8.0)
|
||||||
rake (0.9.2)
|
rake (0.9.2)
|
||||||
rdoc (3.11)
|
rdoc (3.12)
|
||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
responders (0.6.4)
|
responders (0.6.4)
|
||||||
rest-client (1.6.7)
|
rest-client (1.6.7)
|
||||||
@ -240,7 +227,7 @@ GEM
|
|||||||
rspec-core (~> 2.6.0)
|
rspec-core (~> 2.6.0)
|
||||||
rspec-expectations (~> 2.6.0)
|
rspec-expectations (~> 2.6.0)
|
||||||
rspec-mocks (~> 2.6.0)
|
rspec-mocks (~> 2.6.0)
|
||||||
rspec-cells (0.1.0)
|
rspec-cells (0.1.1)
|
||||||
rails (~> 3.0)
|
rails (~> 3.0)
|
||||||
rspec-rails (~> 2.2)
|
rspec-rails (~> 2.2)
|
||||||
rspec-core (2.6.4)
|
rspec-core (2.6.4)
|
||||||
@ -253,19 +240,19 @@ GEM
|
|||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
rspec (~> 2.6.0)
|
rspec (~> 2.6.0)
|
||||||
ruby-hmac (0.4.0)
|
ruby-hmac (0.4.0)
|
||||||
rubyzip (0.9.4)
|
rubyzip (0.9.5)
|
||||||
sanitize (2.0.3)
|
sanitize (2.0.3)
|
||||||
nokogiri (>= 1.4.4, < 1.6)
|
nokogiri (>= 1.4.4, < 1.6)
|
||||||
sass (3.1.10)
|
sass (3.1.12)
|
||||||
sass-rails (3.1.5)
|
sass-rails (3.1.5)
|
||||||
actionpack (~> 3.1.0)
|
actionpack (~> 3.1.0)
|
||||||
railties (~> 3.1.0)
|
railties (~> 3.1.0)
|
||||||
sass (~> 3.1.10)
|
sass (~> 3.1.10)
|
||||||
tilt (~> 1.3.2)
|
tilt (~> 1.3.2)
|
||||||
selenium-webdriver (2.13.0)
|
selenium-webdriver (2.16.0)
|
||||||
childprocess (>= 0.2.1)
|
childprocess (>= 0.2.5)
|
||||||
ffi (~> 1.0.9)
|
ffi (~> 1.0.9)
|
||||||
json_pure
|
multi_json (~> 1.0.4)
|
||||||
rubyzip
|
rubyzip
|
||||||
sprockets (2.0.3)
|
sprockets (2.0.3)
|
||||||
hike (~> 1.2)
|
hike (~> 1.2)
|
||||||
@ -301,7 +288,7 @@ DEPENDENCIES
|
|||||||
ZenTest
|
ZenTest
|
||||||
actionmailer-with-request (~> 0.3.0)
|
actionmailer-with-request (~> 0.3.0)
|
||||||
autotest
|
autotest
|
||||||
bson_ext (~> 1.4.0)
|
bson_ext (~> 1.5.2)
|
||||||
bushido (= 0.0.35)
|
bushido (= 0.0.35)
|
||||||
cancan (~> 1.6.7)
|
cancan (~> 1.6.7)
|
||||||
capybara
|
capybara
|
||||||
@ -309,12 +296,12 @@ DEPENDENCIES
|
|||||||
cells (~> 3.7.1)
|
cells (~> 3.7.1)
|
||||||
codemirror-rails
|
codemirror-rails
|
||||||
coffee-script (~> 2.2.0)
|
coffee-script (~> 2.2.0)
|
||||||
compass!
|
compass (~> 0.12.alpha.4)
|
||||||
cucumber-rails
|
cucumber-rails
|
||||||
custom_fields!
|
custom_fields!
|
||||||
database_cleaner
|
database_cleaner
|
||||||
delayed_job_mongoid (~> 1.0.8)
|
delayed_job_mongoid (~> 1.0.8)
|
||||||
devise!
|
devise (~> 1.5.3)
|
||||||
dragonfly (~> 0.9.8)
|
dragonfly (~> 0.9.8)
|
||||||
factory_girl_rails (~> 1.1)
|
factory_girl_rails (~> 1.1)
|
||||||
flash_cookie_session (~> 1.1.1)
|
flash_cookie_session (~> 1.1.1)
|
||||||
@ -322,7 +309,6 @@ DEPENDENCIES
|
|||||||
formtastic (~> 2.0.2)
|
formtastic (~> 2.0.2)
|
||||||
growl-glue
|
growl-glue
|
||||||
haml (~> 3.1.3)
|
haml (~> 3.1.3)
|
||||||
handlebars-rails!
|
|
||||||
highline (~> 1.6.2)
|
highline (~> 1.6.2)
|
||||||
httparty (~> 0.8.1)
|
httparty (~> 0.8.1)
|
||||||
jquery-rails (~> 1.0.16)
|
jquery-rails (~> 1.0.16)
|
||||||
@ -332,7 +318,8 @@ DEPENDENCIES
|
|||||||
locomotive_mongoid_acts_as_tree!
|
locomotive_mongoid_acts_as_tree!
|
||||||
mimetype-fu (~> 0.1.2)
|
mimetype-fu (~> 0.1.2)
|
||||||
mocha (= 0.9.12)
|
mocha (= 0.9.12)
|
||||||
mongoid (~> 2.3.3)
|
mongo (~> 1.5.2)
|
||||||
|
mongoid (~> 2.4.0)
|
||||||
pickle
|
pickle
|
||||||
rack-cache (~> 1.1)
|
rack-cache (~> 1.1)
|
||||||
rails (~> 3.1.3)
|
rails (~> 3.1.3)
|
||||||
|
@ -48,7 +48,7 @@ h2. Community
|
|||||||
h2. Team
|
h2. Team
|
||||||
|
|
||||||
* Developers: "Didier Lafforgue":http://www.nocoffee.fr, "Jacques Crocker":http://www.railsjedi.com, "Mario Visic":http://www.mariovisic.com
|
* Developers: "Didier Lafforgue":http://www.nocoffee.fr, "Jacques Crocker":http://www.railsjedi.com, "Mario Visic":http://www.mariovisic.com
|
||||||
* Contributors: "Dirk Kelly":http://www.dirkkelly.com, "Raphael Costa":http://raphaelcosta.net (Brazilian Portuguese translation), "Bernd Hauser":http://www.designhunger.de (German translation), "Andrea Frigido":http://www.frisoft.it (Italian translation), "Enrique García":https://github.com/kikito (Spanish translation), "Lars Smit":https://github.com/larssmit (Dutch translation), "PitOn":https://github.com/GarPit (Russian translation)
|
* Contributors: "Dirk Kelly":http://www.dirkkelly.com, "Raphael Costa":http://raphaelcosta.net (Brazilian Portuguese translation), "Bernd Hauser":http://www.designhunger.de (German translation), "Andrea Frigido":http://www.frisoft.it (Italian translation), "Enrique García":https://github.com/kikito (Spanish translation), "Lars Smit":https://github.com/larssmit (Dutch translation), "PitOn":https://github.com/GarPit (Russian translation), "paulsponagl":https://github.com/paulsponagl
|
||||||
* UI Designer: "Sacha Greif":http://www.sachagreif.com
|
* UI Designer: "Sacha Greif":http://www.sachagreif.com
|
||||||
* IE maintainer: "Alex Sanford":https://github.com/alexsanford
|
* IE maintainer: "Alex Sanford":https://github.com/alexsanford
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
//= require jquery-ui
|
//= require jquery-ui
|
||||||
//= require jquery_ujs
|
//= require jquery_ujs
|
||||||
//= require underscore
|
//= require underscore
|
||||||
//= require handlebars
|
|
||||||
//= require backbone
|
//= require backbone
|
||||||
//= require codemirror
|
//= require codemirror
|
||||||
//= require tinymce-jquery
|
//= require tinymce-jquery
|
||||||
|
@ -3,13 +3,11 @@
|
|||||||
#= require_tree ./utils
|
#= require_tree ./utils
|
||||||
#= require_tree ./models
|
#= require_tree ./models
|
||||||
#= require_tree ./views
|
#= require_tree ./views
|
||||||
#= require_tree ./routers
|
|
||||||
|
|
||||||
window.Locomotive =
|
window.Locomotive =
|
||||||
mount_on: '/locomotive'
|
mount_on: '/locomotive'
|
||||||
Models: {}
|
Models: {}
|
||||||
Collections: {}
|
Collections: {}
|
||||||
Routers: {}
|
|
||||||
Views: {}
|
Views: {}
|
||||||
|
|
||||||
window.Locomotive.Views.Memberships = {}
|
window.Locomotive.Views.Memberships = {}
|
@ -13,8 +13,8 @@ class Locomotive.Models.CustomField extends Backbone.Model
|
|||||||
toJSONForSave: ->
|
toJSONForSave: ->
|
||||||
_.tap {}, (hash) =>
|
_.tap {}, (hash) =>
|
||||||
for key, value of @.toJSON()
|
for key, value of @.toJSON()
|
||||||
hash[key] = value unless _.include(['select_options', 'type_text', 'created_at', 'updated_at'], key)
|
hash[key] = value unless _.include(['select_options', 'type_text', 'text_formatting_text', 'undefined_text', 'undefined', 'created_at', 'updated_at'], key)
|
||||||
hash.select_options_attributes = @get('select_options').toJSONForSave() if @get('select_options')
|
hash.select_options_attributes = @get('select_options').toJSONForSave() if @get('select_options')? && @get('select_options').length > 0
|
||||||
|
|
||||||
class Locomotive.Models.CustomFieldsCollection extends Backbone.Collection
|
class Locomotive.Models.CustomFieldsCollection extends Backbone.Collection
|
||||||
|
|
||||||
|
@ -22,5 +22,26 @@
|
|||||||
var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', 'g');
|
var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', 'g');
|
||||||
return this.replace(/\s/g, sep).replace(alphaNumRegexp, '').replace(avoidDuplicateRegexp, sep).toLowerCase()
|
return this.replace(/\s/g, sep).replace(alphaNumRegexp, '').replace(avoidDuplicateRegexp, sep).toLowerCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addParameterToURL = function(key, value) { // code from http://stackoverflow.com/questions/486896/adding-a-parameter-to-the-url-with-javascript
|
||||||
|
key = encodeURIComponent(key); value = encodeURIComponent(value);
|
||||||
|
|
||||||
|
var kvp = document.location.search.substr(1).split('&');
|
||||||
|
|
||||||
|
var i = kvp.length; var x; while(i--) {
|
||||||
|
x = kvp[i].split('=');
|
||||||
|
|
||||||
|
if (x[0] == key) {
|
||||||
|
x[1] = value;
|
||||||
|
kvp[i] = x.join('=');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i < 0) { kvp[kvp.length] = [key,value].join('='); }
|
||||||
|
|
||||||
|
//this will reload the page, it's likely better to store this until finished
|
||||||
|
document.location.search = kvp.join('&');
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ class Locomotive.Views.ApplicationView extends Backbone.View
|
|||||||
|
|
||||||
@enable_sites_picker()
|
@enable_sites_picker()
|
||||||
|
|
||||||
|
@enable_content_locale_picker()
|
||||||
|
|
||||||
# render page view
|
# render page view
|
||||||
if @options.view?
|
if @options.view?
|
||||||
@view = new @options.view(@options.view_data || {})
|
@view = new @options.view(@options.view_data || {})
|
||||||
@ -66,3 +68,17 @@ class Locomotive.Views.ApplicationView extends Backbone.View
|
|||||||
event.stopPropagation() & event.preventDefault()
|
event.stopPropagation() & event.preventDefault()
|
||||||
picker.toggle()
|
picker.toggle()
|
||||||
|
|
||||||
|
enable_content_locale_picker: ->
|
||||||
|
link = @$('#content-locale-picker-link')
|
||||||
|
picker = @$('#content-locale-picker')
|
||||||
|
|
||||||
|
return if picker.size() == 0
|
||||||
|
|
||||||
|
link.bind 'click', (event) ->
|
||||||
|
event.stopPropagation() & event.preventDefault()
|
||||||
|
picker.toggle()
|
||||||
|
|
||||||
|
picker.find('li span.text').bind 'click', (event) ->
|
||||||
|
locale = $(event.target).html()
|
||||||
|
window.addParameterToURL 'content_locale', locale
|
||||||
|
|
||||||
|
@ -14,8 +14,6 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|||||||
initialize: ->
|
initialize: ->
|
||||||
@model = new Locomotive.Models.ContentEntry(@options.content_entry)
|
@model = new Locomotive.Models.ContentEntry(@options.content_entry)
|
||||||
|
|
||||||
console.log(@model.urlRoot)
|
|
||||||
|
|
||||||
window.foo = @model
|
window.foo = @model
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
Backbone.ModelBinding.bind @
|
||||||
@ -61,7 +59,6 @@ class Locomotive.Views.ContentEntries.FormView extends Locomotive.Views.Shared.F
|
|||||||
@$('li.input.highlighted > input[type=text]').slugify(target: @$('#content_entry__slug'))
|
@$('li.input.highlighted > input[type=text]').slugify(target: @$('#content_entry__slug'))
|
||||||
|
|
||||||
refresh_file_fields: ->
|
refresh_file_fields: ->
|
||||||
console.log('refresh_file_fields')
|
|
||||||
_.each @_file_field_views, (view) => view.refresh()
|
_.each @_file_field_views, (view) => view.refresh()
|
||||||
|
|
||||||
remove: ->
|
remove: ->
|
||||||
|
@ -23,7 +23,7 @@ class Locomotive.Views.ContentTypes.FormView extends Locomotive.Views.Shared.For
|
|||||||
|
|
||||||
@enable_liquid_editing() # turn textarea into editable liquid code zone
|
@enable_liquid_editing() # turn textarea into editable liquid code zone
|
||||||
|
|
||||||
@enable_public_form_checkbox()
|
@enable_public_submission_checkbox()
|
||||||
|
|
||||||
@enable_order_by_toggler()
|
@enable_order_by_toggler()
|
||||||
|
|
||||||
@ -48,10 +48,10 @@ class Locomotive.Views.ContentTypes.FormView extends Locomotive.Views.Shared.For
|
|||||||
theme: 'default medium'
|
theme: 'default medium'
|
||||||
onChange: (editor) => @model.set(raw_item_template: editor.getValue())
|
onChange: (editor) => @model.set(raw_item_template: editor.getValue())
|
||||||
|
|
||||||
enable_public_form_checkbox: ->
|
enable_public_submission_checkbox: ->
|
||||||
@_enable_checkbox 'public_form_enabled',
|
@_enable_checkbox 'public_submission_enabled',
|
||||||
on_callback: => @$('#content_type_public_form_accounts_input').show()
|
on_callback: => @$('#content_type_public_submission_accounts_input').show()
|
||||||
off_callback: => @$('#content_type_public_form_accounts_input').hide()
|
off_callback: => @$('#content_type_public_submission_accounts_input').hide()
|
||||||
|
|
||||||
enable_order_by_toggler: ->
|
enable_order_by_toggler: ->
|
||||||
@$('#content_type_order_by_input').bind 'change', (event) =>
|
@$('#content_type_order_by_input').bind 'change', (event) =>
|
||||||
|
@ -28,6 +28,7 @@ class Locomotive.Views.ContentTypes.CustomFieldEntryView extends Backbone.View
|
|||||||
return @
|
return @
|
||||||
|
|
||||||
enable_behaviours: ->
|
enable_behaviours: ->
|
||||||
|
@$('li.input.toggle input[type=checkbox]').checkToggle()
|
||||||
@render_select_options_view()
|
@render_select_options_view()
|
||||||
|
|
||||||
switch_to_type: ->
|
switch_to_type: ->
|
||||||
|
@ -13,19 +13,39 @@ class Locomotive.Views.CurrentSite.EditView extends Locomotive.Views.Shared.Form
|
|||||||
initialize: ->
|
initialize: ->
|
||||||
@model = new Locomotive.Models.CurrentSite(@options.site)
|
@model = new Locomotive.Models.CurrentSite(@options.site)
|
||||||
|
|
||||||
Backbone.ModelBinding.bind @
|
Backbone.ModelBinding.bind @, checkbox: 'class'
|
||||||
|
|
||||||
window.foo = @model
|
window.foo = @model
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@add_toggle_mode_for_locales()
|
||||||
|
|
||||||
|
@make_locales_sortable()
|
||||||
|
|
||||||
@render_domains()
|
@render_domains()
|
||||||
|
|
||||||
@render_memberships()
|
@render_memberships()
|
||||||
|
|
||||||
@enable_liquid_editing()
|
@enable_liquid_editing()
|
||||||
|
|
||||||
|
add_toggle_mode_for_locales: ->
|
||||||
|
@$('#site_locales_input .list input[type=checkbox]').bind 'change', (event) ->
|
||||||
|
el = $(event.target)
|
||||||
|
if el.is(':checked')
|
||||||
|
el.closest('.entry').addClass('selected')
|
||||||
|
else
|
||||||
|
el.closest('.entry').removeClass('selected')
|
||||||
|
|
||||||
|
make_locales_sortable: ->
|
||||||
|
@sortable_locales_list = @$('#site_locales_input .list').sortable
|
||||||
|
items: '.entry'
|
||||||
|
tolerance: 'pointer'
|
||||||
|
update: =>
|
||||||
|
list = _.map @$('#site_locales_input .list input:checked'), (el) => $(el).val()
|
||||||
|
@model.set locales: list
|
||||||
|
|
||||||
render_domains: ->
|
render_domains: ->
|
||||||
@domains_view = new Locomotive.Views.Sites.DomainsView model: @model, errors: @options.errors
|
@domains_view = new Locomotive.Views.Sites.DomainsView model: @model, errors: @options.errors
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ class Locomotive.Views.Import.ShowView extends Backbone.View
|
|||||||
@refresh_steps
|
@refresh_steps
|
||||||
|
|
||||||
refresh_steps: (data) =>
|
refresh_steps: (data) =>
|
||||||
console.log 'refresh_steps: ....'
|
|
||||||
window.foo = data
|
window.foo = data
|
||||||
window.bar = @
|
window.bar = @
|
||||||
|
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
@import "compass/css3/border-radius";
|
@import "compass/css3/border-radius";
|
||||||
@import "helpers";
|
@import "helpers";
|
||||||
|
|
||||||
#sites-picker {
|
@mixin picker {
|
||||||
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 97px;
|
// top: 97px;
|
||||||
|
|
||||||
margin: 5px 0 0 0;
|
// margin: 5px 0 0 0;
|
||||||
padding: 0 0 0 0;
|
padding: 0 0 0 0;
|
||||||
min-width: 160px;
|
// min-width: 160px;
|
||||||
z-index: 999;
|
// z-index: 999;
|
||||||
|
|
||||||
@include border-radius(4px);
|
@include border-radius(4px);
|
||||||
border: 1px solid #000;
|
border: 1px solid #000;
|
@ -0,0 +1,85 @@
|
|||||||
|
@import "picker";
|
||||||
|
|
||||||
|
#content-locale-picker-link {
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
padding-left: 10px !important;
|
||||||
|
padding-right: 25px !important;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
.hand {
|
||||||
|
position: absolute;
|
||||||
|
top: 7px;
|
||||||
|
right: 7px;
|
||||||
|
|
||||||
|
height: 7px;
|
||||||
|
width: 12px;
|
||||||
|
|
||||||
|
background: transparent image-url("locomotive/menu/icons.png") no-repeat 0px -16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img.flag {
|
||||||
|
float: left;
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.text {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
// position: relative;
|
||||||
|
// top: -6px;
|
||||||
|
|
||||||
|
color: #fff;
|
||||||
|
font-size: 11px;
|
||||||
|
text-shadow: 1px 1px 1px #000;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
.others {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#content-locale-picker {
|
||||||
|
@include picker;
|
||||||
|
|
||||||
|
display: none;
|
||||||
|
|
||||||
|
top: 152px;
|
||||||
|
right: 22px;
|
||||||
|
|
||||||
|
min-width: 63px;
|
||||||
|
z-index: 999;
|
||||||
|
|
||||||
|
li {
|
||||||
|
height: 26px;
|
||||||
|
padding: 2px 8px !important;
|
||||||
|
|
||||||
|
img.flag {
|
||||||
|
position: relative;
|
||||||
|
top: 1px;
|
||||||
|
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.text {
|
||||||
|
position: relative;
|
||||||
|
top: -6px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-bottom: 0px;
|
||||||
|
@include box-shadow(transparent 0 0 0 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -279,6 +279,63 @@ form.formtastic {
|
|||||||
}
|
}
|
||||||
} // li.string, li.password
|
} // li.string, li.password
|
||||||
|
|
||||||
|
&.locale, &.locales {
|
||||||
|
.list {
|
||||||
|
margin-left: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.locales {
|
||||||
|
label {
|
||||||
|
color: #8B8D9A;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry {
|
||||||
|
float: left;
|
||||||
|
width: 212px;
|
||||||
|
|
||||||
|
margin-left: 10px;
|
||||||
|
|
||||||
|
&:first-child {
|
||||||
|
margin-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
float: none;
|
||||||
|
display: inline-block;
|
||||||
|
width: auto;
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
padding-left: 31px;
|
||||||
|
margin-left: 8px;
|
||||||
|
|
||||||
|
font-weight: normal;
|
||||||
|
|
||||||
|
img {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.selected {
|
||||||
|
label {
|
||||||
|
color: #585A69;
|
||||||
|
}
|
||||||
|
&:first-child {
|
||||||
|
label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // .entry.selected
|
||||||
|
|
||||||
|
} // .entry
|
||||||
|
|
||||||
|
.inline-hints {
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
} // > li.locale, li.locales
|
||||||
|
|
||||||
&.code {
|
&.code {
|
||||||
|
|
||||||
textarea, .CodeMirror-scroll {
|
textarea, .CodeMirror-scroll {
|
||||||
@ -521,35 +578,6 @@ form.formtastic {
|
|||||||
}
|
}
|
||||||
} // > li#site_memberships_input
|
} // > li#site_memberships_input
|
||||||
|
|
||||||
&#account_locale_input {
|
|
||||||
.entry {
|
|
||||||
float: left;
|
|
||||||
width: 212px;
|
|
||||||
|
|
||||||
margin-right: 10px;
|
|
||||||
|
|
||||||
&:nth-child(3n) {
|
|
||||||
margin-right: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
label {
|
|
||||||
float: none;
|
|
||||||
display: inline-block;
|
|
||||||
width: auto;
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
padding-left: 31px;
|
|
||||||
margin-left: 8px;
|
|
||||||
|
|
||||||
img {
|
|
||||||
position: absolute;
|
|
||||||
top: 2px;
|
|
||||||
left: 0px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // > li#account_locale_input
|
|
||||||
|
|
||||||
&#account_sites_input {
|
&#account_sites_input {
|
||||||
.entry {
|
.entry {
|
||||||
strong {
|
strong {
|
@ -56,7 +56,7 @@
|
|||||||
@include box-shadow(rgba(0, 0, 0, 0.3) 0px -1px 10px 0px, rgba(0, 0, 0, 0.2) 0px 4px 6px 4px, rgba(255, 255, 255, 0.2) 0 1px 0 0 inset);
|
@include box-shadow(rgba(0, 0, 0, 0.3) 0px -1px 10px 0px, rgba(0, 0, 0, 0.2) 0px 4px 6px 4px, rgba(255, 255, 255, 0.2) 0 1px 0 0 inset);
|
||||||
@include background-image(linear-gradient(#3f3f45, #23242b));
|
@include background-image(linear-gradient(#3f3f45, #23242b));
|
||||||
|
|
||||||
& > ul > li > a, & > .action a {
|
& > ul > li > a, & > .actions .button {
|
||||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.6);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.6);
|
||||||
@ -72,8 +72,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& > .action {
|
& > .actions {
|
||||||
a:hover {
|
.button:hover {
|
||||||
border: 1px solid rgba(255, 255, 255, 0.5);
|
border: 1px solid rgba(255, 255, 255, 0.5);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -108,22 +108,29 @@
|
|||||||
} // > li
|
} // > li
|
||||||
} // > ul
|
} // > ul
|
||||||
|
|
||||||
& > .action {
|
& > .actions {
|
||||||
@include absolute-position(top, 0px, right, 12px);
|
@include absolute-position(top, 0px, right, 12px);
|
||||||
height: 58px;
|
height: 58px;
|
||||||
padding-left: 20px;
|
padding-top: 17px;
|
||||||
|
padding-left: 10px;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
|
|
||||||
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
border-left: 1px solid rgba(0, 0, 0, 0.3);
|
||||||
@include box-shadow(rgba(255, 255, 255, 0.1) 1px 0 0 0 inset);
|
@include box-shadow(rgba(255, 255, 255, 0.1) 1px 0 0 0 inset);
|
||||||
|
|
||||||
a {
|
.action {
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
height: 20px;
|
height: 22px;
|
||||||
line-height: 20px;
|
line-height: 22px;
|
||||||
|
|
||||||
margin: 17px 0 0 0;
|
margin: 0 0 0 0;
|
||||||
padding: 0px 10px 0 15px;
|
padding: 0px 10px 0 15px;
|
||||||
|
|
||||||
@include border-radius(10px);
|
@include border-radius(10px);
|
12
app/assets/stylesheets/locomotive/sites_picker.css.scss
Normal file
12
app/assets/stylesheets/locomotive/sites_picker.css.scss
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
@import "picker";
|
||||||
|
|
||||||
|
#sites-picker {
|
||||||
|
|
||||||
|
@include picker;
|
||||||
|
|
||||||
|
top: 97px;
|
||||||
|
|
||||||
|
margin: 5px 0 0 0;
|
||||||
|
min-width: 160px;
|
||||||
|
z-index: 999;
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
#content-locale-picker
|
||||||
|
%ul
|
||||||
|
- @locales.each do |locale|
|
||||||
|
%li
|
||||||
|
= image_tag "locomotive/icons/flags/#{locale}.png", :class => 'flag'
|
||||||
|
|
||||||
|
%span.text= locale
|
17
app/cells/locomotive/content_locale_picker_cell.rb
Normal file
17
app/cells/locomotive/content_locale_picker_cell.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
class Locomotive::ContentLocalePickerCell < Cell::Base
|
||||||
|
|
||||||
|
def show(args)
|
||||||
|
site = args[:site]
|
||||||
|
locale = args[:locale].to_s
|
||||||
|
|
||||||
|
logger.debug "site.locales = #{site.locales.inspect}"
|
||||||
|
|
||||||
|
if site.locales.empty? || site.locales.size < 2
|
||||||
|
''
|
||||||
|
else
|
||||||
|
@locales = site.locales - [locale]
|
||||||
|
render
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -1,61 +0,0 @@
|
|||||||
module Locomotive
|
|
||||||
class ApiContentsController < ActionController::Base
|
|
||||||
|
|
||||||
# FIXME: NEED REFACTORING
|
|
||||||
|
|
||||||
include Locomotive::Routing::SiteDispatcher
|
|
||||||
|
|
||||||
before_filter :require_site
|
|
||||||
|
|
||||||
before_filter :set_content_type
|
|
||||||
|
|
||||||
before_filter :block_content_type_with_disabled_api
|
|
||||||
|
|
||||||
before_filter :sanitize_content_params, :only => :create
|
|
||||||
|
|
||||||
def create
|
|
||||||
@entry = @content_type.entries.build(params[:entry])
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
if @entry.save
|
|
||||||
format.json { render :json => { :entry => @entry } }
|
|
||||||
format.html do
|
|
||||||
flash[@content_type.slug.singularize] = @entry.aliased_attributes
|
|
||||||
redirect_to params[:success_callback]
|
|
||||||
end
|
|
||||||
else
|
|
||||||
format.json { render :json => { :entry => @content, :errors => @content.errors } }
|
|
||||||
format.html do
|
|
||||||
flash[@content_type.slug.singularize] = @content.aliased_attributes
|
|
||||||
flash['errors'] = @content.errors_to_hash
|
|
||||||
redirect_to params[:error_callback]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def set_content_type
|
|
||||||
@content_type = current_site.content_types.where(:slug => params[:slug]).first
|
|
||||||
end
|
|
||||||
|
|
||||||
def block_content_type_with_disabled_api
|
|
||||||
unless @content_type.api_enabled?
|
|
||||||
respond_to do |format|
|
|
||||||
format.json { render :json => { :error => 'Api not enabled' }, :status => :forbidden }
|
|
||||||
format.html { render :text => 'Api not enabled', :status => :forbidden }
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def sanitize_content_params
|
|
||||||
(params[:content] || {}).each do |key, value|
|
|
||||||
next unless value.is_a?(String)
|
|
||||||
params[:content][key] = Sanitize.clean(value, Sanitize::Config::BASIC)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
@ -3,6 +3,8 @@ module Locomotive
|
|||||||
|
|
||||||
include Locomotive::Routing::SiteDispatcher
|
include Locomotive::Routing::SiteDispatcher
|
||||||
|
|
||||||
|
include Locomotive::ActionController::Helpers
|
||||||
|
|
||||||
layout '/locomotive/layouts/application'
|
layout '/locomotive/layouts/application'
|
||||||
|
|
||||||
before_filter :require_account
|
before_filter :require_account
|
||||||
@ -13,19 +15,17 @@ module Locomotive
|
|||||||
|
|
||||||
load_and_authorize_resource
|
load_and_authorize_resource
|
||||||
|
|
||||||
before_filter :set_locale
|
before_filter :set_back_office_locale
|
||||||
|
|
||||||
|
before_filter :set_current_content_locale
|
||||||
|
|
||||||
before_filter :set_current_thread_variables
|
before_filter :set_current_thread_variables
|
||||||
|
|
||||||
helper_method :sections, :current_site_public_url, :switch_to_site_url, :public_page_url, :current_ability
|
helper_method :sections, :current_ability
|
||||||
|
|
||||||
# https://rails.lighthouseapp.com/projects/8994/tickets/1905-apphelpers-within-plugin-not-being-mixed-in
|
helper Locomotive::BaseHelper, Locomotive::ContentTypesHelper
|
||||||
helper Locomotive::BaseHelper, Locomotive::ContentTypesHelper #, Locomotive::BoxHelper
|
|
||||||
# Dir[File.dirname(__FILE__) + "/../../helpers/**/*_helper.rb"].each do |file|
|
|
||||||
# helper "locomotive/#{File.basename(file, '.rb').gsub(/_helper$/, '')}"
|
|
||||||
# end
|
|
||||||
|
|
||||||
self.responder = Locomotive::Responder # custom responder
|
self.responder = Locomotive::ActionController::Responder # custom responder
|
||||||
|
|
||||||
respond_to :html
|
respond_to :html
|
||||||
|
|
||||||
@ -56,51 +56,5 @@ module Locomotive
|
|||||||
authenticate_locomotive_account!
|
authenticate_locomotive_account!
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.sections(main, sub = nil)
|
|
||||||
before_filter do |c|
|
|
||||||
sub = sub.call(c) if sub.respond_to?(:call)
|
|
||||||
sections = { :main => main, :sub => sub }
|
|
||||||
c.instance_variable_set(:@locomotive_sections, sections)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def sections(key = nil)
|
|
||||||
if !key.nil? && key.to_sym == :sub
|
|
||||||
@locomotive_sections[:sub] || self.controller_name.dasherize
|
|
||||||
else
|
|
||||||
@locomotive_sections[:main]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_locale
|
|
||||||
I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale
|
|
||||||
end
|
|
||||||
|
|
||||||
# ___ site/page urls builder ___
|
|
||||||
|
|
||||||
def current_site_public_url
|
|
||||||
request.protocol + request.host_with_port
|
|
||||||
end
|
|
||||||
|
|
||||||
def switch_to_site_url(site, options = {})
|
|
||||||
options = { :fullpath => true, :protocol => true }.merge(options)
|
|
||||||
|
|
||||||
url = "#{site.subdomain}.#{Locomotive.config.domain}"
|
|
||||||
url += ":#{request.port}" if request.port != 80
|
|
||||||
|
|
||||||
url = File.join(url, request.fullpath) if options[:fullpath]
|
|
||||||
url = "http://#{url}" if options[:protocol]
|
|
||||||
url
|
|
||||||
end
|
|
||||||
|
|
||||||
def public_page_url(page, options = {})
|
|
||||||
if content = options.delete(:content)
|
|
||||||
File.join(current_site_public_url, page.fullpath.gsub('content_type_template', ''), content._slug)
|
|
||||||
else
|
|
||||||
File.join(current_site_public_url, page.fullpath)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -7,6 +7,8 @@ module Locomotive
|
|||||||
|
|
||||||
load_and_authorize_resource :class => 'Site'
|
load_and_authorize_resource :class => 'Site'
|
||||||
|
|
||||||
|
helper 'Locomotive::Sites'
|
||||||
|
|
||||||
before_filter :filter_attributes
|
before_filter :filter_attributes
|
||||||
|
|
||||||
respond_to :json, :only => :update
|
respond_to :json, :only => :update
|
||||||
|
19
app/controllers/locomotive/public/base_controller.rb
Normal file
19
app/controllers/locomotive/public/base_controller.rb
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Public
|
||||||
|
class BaseController < ApplicationController
|
||||||
|
|
||||||
|
include Locomotive::Routing::SiteDispatcher
|
||||||
|
|
||||||
|
include Locomotive::ActionController::Helpers
|
||||||
|
|
||||||
|
before_filter :require_site
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def set_locale
|
||||||
|
logger.info "[public/set_locale] TODO"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,50 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Public
|
||||||
|
class ContentEntriesController < BaseController
|
||||||
|
|
||||||
|
before_filter :set_content_type
|
||||||
|
|
||||||
|
before_filter :sanitize_entry_params, :only => :create
|
||||||
|
|
||||||
|
skip_before_filter :verify_authenticity_token
|
||||||
|
|
||||||
|
self.responder = Locomotive::ActionController::PublicResponder # custom responder
|
||||||
|
|
||||||
|
respond_to :html, :json
|
||||||
|
|
||||||
|
def create
|
||||||
|
@entry = @content_type.entries.create(params[:entry])
|
||||||
|
flash[@content_type.slug.singularize] = @entry.to_presenter(:include_errors => true).as_json
|
||||||
|
respond_with @entry, :location => self.callback_url
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def set_content_type
|
||||||
|
@content_type = current_site.content_types.where(:slug => params[:slug]).first
|
||||||
|
|
||||||
|
# check if ability to receive public submissions
|
||||||
|
unless @content_type.public_submission_enabled?
|
||||||
|
respond_to do |format|
|
||||||
|
format.json { render :json => { :error => 'Public submissions not accepted' }, :status => :forbidden }
|
||||||
|
format.html { render :text => 'Public submissions not accepted', :status => :forbidden }
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def callback_url
|
||||||
|
@entry.errors.empty? ? params[:success_callback] : params[:error_callback]
|
||||||
|
end
|
||||||
|
|
||||||
|
def sanitize_entry_params
|
||||||
|
entry_params = params[:entry] || params[:content] || {}
|
||||||
|
entry_params.each do |key, value|
|
||||||
|
next unless value.is_a?(String)
|
||||||
|
entry_params[key] = Sanitize.clean(value, Sanitize::Config::BASIC)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
26
app/controllers/locomotive/public/rendering_controller.rb
Normal file
26
app/controllers/locomotive/public/rendering_controller.rb
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Public
|
||||||
|
class RenderingController < ApplicationController
|
||||||
|
|
||||||
|
include Locomotive::Routing::SiteDispatcher
|
||||||
|
|
||||||
|
include Locomotive::Render
|
||||||
|
|
||||||
|
before_filter :require_site
|
||||||
|
|
||||||
|
before_filter :authenticate_admin!, :only => [:edit]
|
||||||
|
|
||||||
|
before_filter :validate_site_membership, :only => [:edit]
|
||||||
|
|
||||||
|
def show
|
||||||
|
render_locomotive_page
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@editing = true
|
||||||
|
render_locomotive_page
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
16
app/controllers/locomotive/public/robots_controller.rb
Normal file
16
app/controllers/locomotive/public/robots_controller.rb
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Public
|
||||||
|
class RobotsController < BaseController
|
||||||
|
|
||||||
|
include Locomotive::Render
|
||||||
|
|
||||||
|
respond_to :txt
|
||||||
|
|
||||||
|
def show
|
||||||
|
template = ::Liquid::Template.parse(current_site.robots_txt)
|
||||||
|
render :text => template.render('request_host' => self.request.host.downcase)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
14
app/controllers/locomotive/public/sitemaps_controller.rb
Normal file
14
app/controllers/locomotive/public/sitemaps_controller.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Public
|
||||||
|
class SitemapsController < BaseController
|
||||||
|
|
||||||
|
respond_to :xml
|
||||||
|
|
||||||
|
def show
|
||||||
|
@pages = current_site.pages.published
|
||||||
|
respond_with @pages
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,22 +0,0 @@
|
|||||||
module Locomotive
|
|
||||||
class RenderingController < ActionController::Base
|
|
||||||
|
|
||||||
include Locomotive::Routing::SiteDispatcher
|
|
||||||
|
|
||||||
include Locomotive::Render
|
|
||||||
|
|
||||||
before_filter :require_site
|
|
||||||
before_filter :authenticate_admin!, :only => [:edit]
|
|
||||||
before_filter :validate_site_membership, :only => [:edit]
|
|
||||||
|
|
||||||
def show
|
|
||||||
render_locomotive_page
|
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
|
||||||
@editing = true
|
|
||||||
render_locomotive_page
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
module Locomotive
|
|
||||||
class RobotsController < ActionController::Base
|
|
||||||
|
|
||||||
include Locomotive::Routing::SiteDispatcher
|
|
||||||
|
|
||||||
include Locomotive::Render
|
|
||||||
|
|
||||||
before_filter :require_site
|
|
||||||
|
|
||||||
respond_to :txt
|
|
||||||
|
|
||||||
def show
|
|
||||||
template = ::Liquid::Template.parse(current_site.robots_txt)
|
|
||||||
render :text => template.render('request_host' => self.request.host.downcase)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,18 +0,0 @@
|
|||||||
module Locomotive
|
|
||||||
class SitemapsController < BaseController
|
|
||||||
|
|
||||||
skip_before_filter :require_account, :validate_site_membership, :set_locale
|
|
||||||
|
|
||||||
before_filter :require_site
|
|
||||||
|
|
||||||
respond_to :xml
|
|
||||||
|
|
||||||
skip_load_and_authorize_resource
|
|
||||||
|
|
||||||
def show
|
|
||||||
@pages = current_site.pages.published
|
|
||||||
respond_with @pages
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
@ -36,14 +36,6 @@ module Locomotive::BaseHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# def collection_to_js(collection, options = {}) # FIXME: DEPRECATED
|
|
||||||
# js = collection.collect { |object| object.to_json }
|
|
||||||
#
|
|
||||||
# options_to_js = ActiveSupport::JSON.encode(options).gsub(/^\{/, '').gsub(/\}$/, '')
|
|
||||||
#
|
|
||||||
# "new Object({ \"collection\": [#{js.join(', ')}], #{options_to_js} })"
|
|
||||||
# end
|
|
||||||
|
|
||||||
def flash_message
|
def flash_message
|
||||||
if not flash.empty?
|
if not flash.empty?
|
||||||
first_key = flash.keys.first
|
first_key = flash.keys.first
|
||||||
|
@ -1,23 +1,50 @@
|
|||||||
module Locomotive::ContentTypesHelper
|
module Locomotive::ContentTypesHelper
|
||||||
|
|
||||||
def each_content_type_menu_item(&block)
|
# Iterates over the content types with the following rules
|
||||||
current_site.content_types.ordered.only(:site_id, :name, :slug, :label_field_name).each do |content_type|
|
# - content types are ordered by the updated_at date (DESC)
|
||||||
next unless content_type.persisted?
|
# - each content type has its own submenu if saved recently
|
||||||
|
# - if there are more than ui.max_content_types content types, the extra ones go under "..."
|
||||||
|
# - if a content type is selected and it is part of the extra content types, then
|
||||||
|
# it will be moved to the first position in the displayed list (with its own submenu)
|
||||||
|
#
|
||||||
|
# @param [ Block ] block The statements responsible to display the menu item from a content type or a list of content types
|
||||||
|
#
|
||||||
|
def each_content_type(&block)
|
||||||
|
visible, others = [], []
|
||||||
|
|
||||||
item_on = (content_type.slug == @content_type.slug) rescue nil
|
current_site.content_types.ordered.only(:site_id, :name, :slug, :label_field_name).each_with_index do |content_type, index|
|
||||||
|
next if !content_type.persisted?
|
||||||
|
|
||||||
label = truncate(content_type.name, :length => 15)
|
if index >= Locomotive.config.ui.max_content_types
|
||||||
url = content_entries_url(content_type.slug)
|
if self.is_content_type_selected(content_type)
|
||||||
css = @content_type && content_type.slug == @content_type.slug ? 'on' : ''
|
others << visible.delete_at(Locomotive.config.ui.max_content_types - 1) # swap content types
|
||||||
|
visible.insert(0, content_type)
|
||||||
html = submenu_entry(label, url, :i18n => false, :css => css) do
|
else
|
||||||
yield(content_type)
|
others << content_type # fills the "..." menu
|
||||||
|
end
|
||||||
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
haml_concat(html)
|
visible << content_type
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
visible.map { |c| yield(c) }
|
||||||
|
yield(others)
|
||||||
|
end
|
||||||
|
|
||||||
|
def is_content_type_selected(content_type)
|
||||||
|
@content_type && content_type.slug == @content_type.slug
|
||||||
|
end
|
||||||
|
|
||||||
|
# Renders the label of a content type entry. If no raw_item_template filled in the content type,
|
||||||
|
# it just calls the _label method of the entry (based on the label_field_id). Otherwise, it
|
||||||
|
# parses and renders the liquid template.
|
||||||
|
#
|
||||||
|
# @param [ ContentType ] content_type The content type for better performance
|
||||||
|
# @param [ ContentEntry] entry The entry we want to display the label
|
||||||
|
#
|
||||||
|
# @return [ String ] The label of the content type entry
|
||||||
|
#
|
||||||
def entry_label(content_type, entry)
|
def entry_label(content_type, entry)
|
||||||
if content_type.raw_item_template.blank?
|
if content_type.raw_item_template.blank?
|
||||||
entry._label # default one
|
entry._label # default one
|
||||||
@ -34,90 +61,4 @@ module Locomotive::ContentTypesHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# MAX_DISPLAYED_CONTENTS = 4
|
|
||||||
#
|
|
||||||
# def fetch_content_types
|
|
||||||
# return @content_types if @content_types
|
|
||||||
#
|
|
||||||
# @content_types = current_site.content_types.ordered.
|
|
||||||
# limit(:contents => Locomotive.config.lastest_items_nb).
|
|
||||||
# only(:site_id, :name, :slug, :highlighted_field_name, :contents_custom_fields_version, :order_by, :serialized_item_template, :raw_item_template).to_a
|
|
||||||
#
|
|
||||||
# if @content_type && @content_type.persisted? && @content_types.index(@content_type) >= MAX_DISPLAYED_CONTENTS
|
|
||||||
# @content_types.delete(@content_type)
|
|
||||||
# @content_types.insert(0, @content_type)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# # be sure, we've got the custom klass up-to-date, otherwise it will fail miserably
|
|
||||||
# @content_types.each do |content_type|
|
|
||||||
# if content_type.content_klass_out_of_date?
|
|
||||||
# content_type.reload
|
|
||||||
# content_type.invalidate_content_klass
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# @content_types
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def each_content_type_menu_item(which = :first, &block)
|
|
||||||
# types = fetch_content_types
|
|
||||||
# sliced = []
|
|
||||||
#
|
|
||||||
# if which == :first
|
|
||||||
# sliced = types[0..MAX_DISPLAYED_CONTENTS - 1]
|
|
||||||
# elsif types.size > MAX_DISPLAYED_CONTENTS
|
|
||||||
# sliced = types[MAX_DISPLAYED_CONTENTS, types.size - MAX_DISPLAYED_CONTENTS]
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# return [] if sliced.empty?
|
|
||||||
#
|
|
||||||
# sliced.each do |content_type|
|
|
||||||
# next if content_type.new_record?
|
|
||||||
# item_on = (content_type.slug == @content_type.slug) rescue nil
|
|
||||||
#
|
|
||||||
# label = truncate(content_type.name, :length => 15)
|
|
||||||
# url = contents_url(content_type.slug)
|
|
||||||
# css = @content_type && content_type.slug == @content_type.slug ? 'on' : ''
|
|
||||||
#
|
|
||||||
# html = submenu_entry(label, url, :i18n => false, :css => css) do
|
|
||||||
# yield(content_type)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# haml_concat(html)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def other_content_types(&block)
|
|
||||||
# types = fetch_content_types
|
|
||||||
#
|
|
||||||
# if types.size > MAX_DISPLAYED_CONTENTS
|
|
||||||
# sliced = types[MAX_DISPLAYED_CONTENTS, types.size - MAX_DISPLAYED_CONTENTS]
|
|
||||||
#
|
|
||||||
# html = submenu_entry('...', '#', :i18n => false) do
|
|
||||||
# yield(sliced)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# haml_concat(html)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def content_label_for(content)
|
|
||||||
# if content._parent.raw_item_template.blank?
|
|
||||||
# content._label # default one
|
|
||||||
# else
|
|
||||||
# assigns = {
|
|
||||||
# 'site' => current_site,
|
|
||||||
# 'content' => content.to_liquid
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# registers = {
|
|
||||||
# :controller => self,
|
|
||||||
# :site => current_site,
|
|
||||||
# :current_locomotive_account => current_locomotive_account
|
|
||||||
# }
|
|
||||||
#
|
|
||||||
# preserve(content._parent.item_template.render(::Liquid::Context.new({}, assigns, registers)))
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
module Locomotive::SitesHelper
|
module Locomotive::SitesHelper
|
||||||
|
|
||||||
# def error_on_domain(site, name)
|
def ordered_current_site_locales
|
||||||
# if (error = (site.errors[:domains] || []).detect { |n| n.include?(name) })
|
current_site.locales + (Locomotive.config.site_locales - current_site.locales)
|
||||||
# content_tag(:span, error, :class => 'inline-errors')
|
end
|
||||||
# else
|
|
||||||
# ''
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
59
app/inputs/locomotive/locales_input.rb
Normal file
59
app/inputs/locomotive/locales_input.rb
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
module Locomotive
|
||||||
|
class LocalesInput < ::Formtastic::Inputs::CheckBoxesInput
|
||||||
|
|
||||||
|
def to_html
|
||||||
|
input_wrapping do
|
||||||
|
label_html <<
|
||||||
|
choices_group_wrapping do
|
||||||
|
collection.map { |choice|
|
||||||
|
choice_wrapping(choice_wrapping_html_options(choice)) do
|
||||||
|
choice_html(choice)
|
||||||
|
end
|
||||||
|
}.join("\n").html_safe
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def choices_group_wrapping(&block)
|
||||||
|
template.content_tag(:div,
|
||||||
|
template.capture(&block),
|
||||||
|
choices_group_wrapping_html_options
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def choice_wrapping(html_options, &block)
|
||||||
|
template.content_tag(:div,
|
||||||
|
template.capture(&block),
|
||||||
|
html_options
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def choice_html(choice)
|
||||||
|
check_box_without_hidden_input(choice) <<
|
||||||
|
template.content_tag(:label,
|
||||||
|
choice_label(choice),
|
||||||
|
label_html_options.merge(:for => choice_input_dom_id(choice), :class => nil)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def choice_label(choice)
|
||||||
|
text = I18n.t("locomotive.my_account.edit.#{choice}")
|
||||||
|
template.image_tag("locomotive/icons/flags/#{choice}.png", :alt => text) << text
|
||||||
|
end
|
||||||
|
|
||||||
|
def choices_group_wrapping_html_options
|
||||||
|
{ :class => 'list' }
|
||||||
|
end
|
||||||
|
|
||||||
|
def choice_wrapping_html_options(choice)
|
||||||
|
super.tap do |options|
|
||||||
|
options[:class] = "entry #{checked?(choice) ? 'selected' : ''}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def hidden_fields?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -4,9 +4,9 @@ module Locomotive
|
|||||||
default :from => Locomotive.config.mailer_sender
|
default :from => Locomotive.config.mailer_sender
|
||||||
|
|
||||||
def new_content_entry(account, entry)
|
def new_content_entry(account, entry)
|
||||||
@account, @entry = account, entry
|
@account, @entry, @type = account, entry.to_presenter, entry.content_type
|
||||||
|
|
||||||
subject = t('locomotive.notifications.new_content_entry.subject', :type => entry.content_type.name, :locale => account.locale)
|
subject = t('locomotive.notifications.new_content_entry.subject', :type => @type.name, :locale => account.locale)
|
||||||
|
|
||||||
mail :subject => subject, :to => account.email
|
mail :subject => subject, :to => account.email
|
||||||
end
|
end
|
||||||
|
@ -27,7 +27,7 @@ module Locomotive
|
|||||||
|
|
||||||
## named scopes ##
|
## named scopes ##
|
||||||
scope :visible, :where => { :_visible => true }
|
scope :visible, :where => { :_visible => true }
|
||||||
scope :latest_updated, :order_by => :updated_at.desc, :limit => Locomotive.config.lastest_entries_nb
|
scope :latest_updated, :order_by => :updated_at.desc, :limit => Locomotive.config.ui.lastest_entries_nb
|
||||||
|
|
||||||
## methods ##
|
## methods ##
|
||||||
|
|
||||||
@ -64,8 +64,8 @@ module Locomotive
|
|||||||
Locomotive::Liquid::Drops::ContentEntry.new(self)
|
Locomotive::Liquid::Drops::ContentEntry.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_presenter
|
def to_presenter(options = {})
|
||||||
Locomotive::ContentEntryPresenter.new(self)
|
Locomotive::ContentEntryPresenter.new(self, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def as_json(options = {})
|
def as_json(options = {})
|
||||||
@ -119,10 +119,10 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def send_notifications
|
def send_notifications
|
||||||
return if !self.content_type.public_form_enabled? || self.content_type.public_form_accounts.blank?
|
return if !self.content_type.public_submission_enabled? || self.content_type.public_submission_accounts.blank?
|
||||||
|
|
||||||
self.content_type.site.accounts.each do |account|
|
self.content_type.site.accounts.each do |account|
|
||||||
next unless self.content_type.public_form_accounts.include?(account._id.to_s)
|
next unless self.content_type.public_submission_accounts.include?(account._id.to_s)
|
||||||
|
|
||||||
Locomotive::Notifications.new_content_entry(account, self).deliver
|
Locomotive::Notifications.new_content_entry(account, self).deliver
|
||||||
end
|
end
|
||||||
|
@ -16,8 +16,8 @@ module Locomotive
|
|||||||
field :group_by_field_id, :type => BSON::ObjectId
|
field :group_by_field_id, :type => BSON::ObjectId
|
||||||
field :order_by
|
field :order_by
|
||||||
field :order_direction, :default => 'asc'
|
field :order_direction, :default => 'asc'
|
||||||
field :public_form_enabled, :type => Boolean, :default => false
|
field :public_submission_enabled, :type => Boolean, :default => false
|
||||||
field :public_form_accounts, :type => Array
|
field :public_submission_accounts, :type => Array
|
||||||
|
|
||||||
## associations ##
|
## associations ##
|
||||||
belongs_to :site, :class_name => 'Locomotive::Site'
|
belongs_to :site, :class_name => 'Locomotive::Site'
|
||||||
@ -53,8 +53,8 @@ module Locomotive
|
|||||||
[order_by_attribute, direction]
|
[order_by_attribute, direction]
|
||||||
end
|
end
|
||||||
|
|
||||||
def ordered_entries
|
def ordered_entries(conditions = {})
|
||||||
self.entries.order_by([order_by_definition])
|
self.entries.order_by([order_by_definition]).where(conditions)
|
||||||
end
|
end
|
||||||
|
|
||||||
def groupable?
|
def groupable?
|
||||||
@ -81,6 +81,39 @@ module Locomotive
|
|||||||
self.to_presenter.as_json
|
self.to_presenter.as_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def order_by_attribute
|
||||||
|
return self.order_by if %w(created_at updated_at _position).include?(self.order_by)
|
||||||
|
self.entries_custom_fields.find(self.order_by).name rescue 'created_at'
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_default_values
|
||||||
|
self.order_by ||= 'created_at'
|
||||||
|
self.label_field_id = self.entries_custom_fields.first._id if self.label_field_id.blank?
|
||||||
|
field = self.entries_custom_fields.find(self.label_field_id)
|
||||||
|
self.label_field_name = field.name
|
||||||
|
end
|
||||||
|
|
||||||
|
def normalize_slug
|
||||||
|
self.slug = self.name.clone if self.slug.blank? && self.name.present?
|
||||||
|
self.slug.permalink! if self.slug.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def bubble_fields_errors_up
|
||||||
|
return if self.errors[:entries_custom_fields].empty?
|
||||||
|
|
||||||
|
self.errors.set(:entries_custom_fields, [])
|
||||||
|
|
||||||
|
self.entries_custom_fields.each do |field|
|
||||||
|
next if field.valid?
|
||||||
|
self.errors.add(:entries_custom_fields, field.errors.to_a)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# def list_or_group_contents
|
# def list_or_group_contents
|
||||||
# if self.groupable?
|
# if self.groupable?
|
||||||
# groups = self.contents.klass.send(:"group_by_#{self.group_by_field._alias}", :ordered_contents)
|
# groups = self.contents.klass.send(:"group_by_#{self.group_by_field._alias}", :ordered_contents)
|
||||||
@ -138,42 +171,6 @@ module Locomotive
|
|||||||
# self.save
|
# self.save
|
||||||
# end
|
# end
|
||||||
#
|
#
|
||||||
# def highlighted_field
|
|
||||||
# self.entries_custom_fields.detect { |f| f._name == self.highlighted_field_name }
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def group_by_field
|
# def group_by_field
|
||||||
# @group_by_field ||= self.entries_custom_fields.detect { |f| f._name == self.group_by_field_name }
|
# @group_by_field ||= self.entries_custom_fields.detect { |f| f._name == self.group_by_field_name }
|
||||||
# end
|
# end
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def order_by_attribute
|
|
||||||
return self.order_by if %w(created_at updated_at _position).include?(self.order_by)
|
|
||||||
self.entries_custom_fields.find(self.order_by).name rescue 'created_at'
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_default_values
|
|
||||||
self.order_by ||= 'created_at'
|
|
||||||
field = self.entries_custom_fields.find(self.label_field_id) rescue self.entries_custom_fields.first
|
|
||||||
self.label_field_name = field.name
|
|
||||||
end
|
|
||||||
|
|
||||||
def normalize_slug
|
|
||||||
self.slug = self.name.clone if self.slug.blank? && self.name.present?
|
|
||||||
self.slug.permalink! if self.slug.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def bubble_fields_errors_up
|
|
||||||
return if self.errors[:entries_custom_fields].empty?
|
|
||||||
|
|
||||||
self.errors.set(:entries_custom_fields, [])
|
|
||||||
|
|
||||||
self.entries_custom_fields.each do |field|
|
|
||||||
next if field.valid?
|
|
||||||
self.errors.add(:entries_custom_fields, field.errors.to_a)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
57
app/models/locomotive/extensions/site/i18n.rb
Normal file
57
app/models/locomotive/extensions/site/i18n.rb
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Extensions
|
||||||
|
module Site
|
||||||
|
module I18n
|
||||||
|
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
|
||||||
|
## fields ##
|
||||||
|
field :locales, :type => 'RawArray', :default => []
|
||||||
|
|
||||||
|
## callbacks ##
|
||||||
|
# after_validation :add_missing_locales_for_all_pages
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
module InstanceMethods
|
||||||
|
|
||||||
|
def locales=(array)
|
||||||
|
array = [] if array.blank?; super(array)
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_locale
|
||||||
|
self.locales.first || Locomotive.config.site_locales.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def locale_fallbacks(locale)
|
||||||
|
[locale.to_s] + (locales - [locale.to_s])
|
||||||
|
end
|
||||||
|
|
||||||
|
# protected
|
||||||
|
#
|
||||||
|
# def add_missing_locales_for_all_pages
|
||||||
|
# if self.locales_changed?
|
||||||
|
# list = self.pages.to_a
|
||||||
|
#
|
||||||
|
# while !list.empty? do
|
||||||
|
# page = list.pop
|
||||||
|
# begin
|
||||||
|
# page.send(:set_slug_and_fullpath_for_all_locales, self.locales)
|
||||||
|
#
|
||||||
|
# page.save
|
||||||
|
#
|
||||||
|
# rescue TypeError => e
|
||||||
|
# list.insert(0, page)
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -41,7 +41,7 @@ module Locomotive
|
|||||||
validates_exclusion_of :slug, :in => Locomotive.config.reserved_slugs, :if => Proc.new { |p| p.depth == 0 }
|
validates_exclusion_of :slug, :in => Locomotive.config.reserved_slugs, :if => Proc.new { |p| p.depth == 0 }
|
||||||
|
|
||||||
## named scopes ##
|
## named scopes ##
|
||||||
scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_entries_nb
|
scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.ui.lastest_entries_nb
|
||||||
scope :root, :where => { :slug => 'index', :depth => 0 }
|
scope :root, :where => { :slug => 'index', :depth => 0 }
|
||||||
scope :not_found, :where => { :slug => '404', :depth => 0 }
|
scope :not_found, :where => { :slug => '404', :depth => 0 }
|
||||||
scope :published, :where => { :published => true }
|
scope :published, :where => { :published => true }
|
||||||
@ -98,7 +98,7 @@ module Locomotive
|
|||||||
return if self.site.nil? || self.site.destroyed?
|
return if self.site.nil? || self.site.destroyed?
|
||||||
|
|
||||||
if self.index? || self.not_found?
|
if self.index? || self.not_found?
|
||||||
self.errors[:base] << I18n.t('errors.messages.protected_page')
|
self.errors[:base] << ::I18n.t('errors.messages.protected_page')
|
||||||
end
|
end
|
||||||
|
|
||||||
self.errors.empty?
|
self.errors.empty?
|
||||||
@ -110,7 +110,7 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def set_default_raw_template
|
def set_default_raw_template
|
||||||
self.raw_template ||= I18n.t('attributes.defaults.pages.other.body')
|
self.raw_template ||= ::I18n.t('attributes.defaults.pages.other.body')
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -7,6 +7,7 @@ module Locomotive
|
|||||||
extend Extensions::Site::SubdomainDomains
|
extend Extensions::Site::SubdomainDomains
|
||||||
extend Extensions::Site::FirstInstallation
|
extend Extensions::Site::FirstInstallation
|
||||||
include Extensions::Shared::Seo
|
include Extensions::Shared::Seo
|
||||||
|
include Extensions::Site::I18n
|
||||||
|
|
||||||
## fields ##
|
## fields ##
|
||||||
field :name
|
field :name
|
||||||
|
@ -20,8 +20,6 @@ class Locomotive::BasePresenter
|
|||||||
|
|
||||||
def id
|
def id
|
||||||
self.source.persisted? || self.source.embedded? ? self.source._id.to_s : nil
|
self.source.persisted? || self.source.embedded? ? self.source._id.to_s : nil
|
||||||
# self.persisted? ? self.source._id.to_s : nil
|
|
||||||
# self.source._id.to_s
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def ability?
|
def ability?
|
||||||
@ -35,8 +33,8 @@ class Locomotive::BasePresenter
|
|||||||
def as_json(methods = nil)
|
def as_json(methods = nil)
|
||||||
methods ||= self.included_methods
|
methods ||= self.included_methods
|
||||||
{}.tap do |hash|
|
{}.tap do |hash|
|
||||||
methods.map(&:to_sym).each do |meth|
|
methods.each do |meth|
|
||||||
hash[meth] = self.send(meth) rescue nil
|
hash[meth] = self.send(meth.to_sym) rescue nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,20 +3,33 @@ module Locomotive
|
|||||||
|
|
||||||
delegate :_slug, :_position, :seo_title, :meta_keywords, :meta_description, :to => :source
|
delegate :_slug, :_position, :seo_title, :meta_keywords, :meta_description, :to => :source
|
||||||
|
|
||||||
def custom_fields_methods
|
# Returns the value of a field in the context of the current entry.
|
||||||
source.custom_fields_recipe['rules'].map do |rule|
|
#
|
||||||
case rule['type']
|
# @params [ CustomFields::Field ] field The field
|
||||||
when 'select' then [rule['name'], "#{rule['name']}_id"]
|
#
|
||||||
when 'date' then "formatted_#{rule['name']}"
|
# @returns [ Object ] The value of the field for the entry
|
||||||
when 'file' then "#{rule['name']}_url"
|
#
|
||||||
else
|
def value_for(field)
|
||||||
rule['name']
|
getter = [*self.getters_for(field.name, field.type)].first.to_sym
|
||||||
|
self.source.send(getter)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Returns the list of getters for an entry
|
||||||
|
#
|
||||||
|
# @returns [ List ] a list of method names (string)
|
||||||
|
#
|
||||||
|
def custom_fields_methods
|
||||||
|
self.source.custom_fields_recipe['rules'].map do |rule|
|
||||||
|
self.getters_for rule['name'], rule['type']
|
||||||
end.flatten
|
end.flatten
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Lists of all the attributes editable by a html form
|
||||||
|
#
|
||||||
|
# @returns [ List ] a list of attributes (string)
|
||||||
|
#
|
||||||
def safe_attributes
|
def safe_attributes
|
||||||
source.custom_fields_recipe['rules'].map do |rule|
|
self.source.custom_fields_recipe['rules'].map do |rule|
|
||||||
case rule['type']
|
case rule['type']
|
||||||
when 'select' then "#{rule['name']}_id"
|
when 'select' then "#{rule['name']}_id"
|
||||||
when 'date' then "formatted_#{rule['name']}"
|
when 'date' then "formatted_#{rule['name']}"
|
||||||
@ -27,6 +40,10 @@ module Locomotive
|
|||||||
end.flatten + %w(_slug seo_title meta_keywords meta_description)
|
end.flatten + %w(_slug seo_title meta_keywords meta_description)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def errors
|
||||||
|
self.source.errors.to_hash.stringify_keys
|
||||||
|
end
|
||||||
|
|
||||||
def content_type_slug
|
def content_type_slug
|
||||||
self.source.content_type.slug
|
self.source.content_type.slug
|
||||||
end
|
end
|
||||||
@ -36,7 +53,9 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def included_methods
|
def included_methods
|
||||||
super + self.custom_fields_methods + %w(_slug _position content_type_slug _file_fields safe_attributes persisted)
|
default_list = %w(_slug _position content_type_slug _file_fields safe_attributes)
|
||||||
|
default_list << 'errors' if !!self.options[:include_errors]
|
||||||
|
super + self.custom_fields_methods + default_list
|
||||||
end
|
end
|
||||||
|
|
||||||
def method_missing(meth, *arguments, &block)
|
def method_missing(meth, *arguments, &block)
|
||||||
@ -47,5 +66,24 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
# Gets the names of the getter methods for a field.
|
||||||
|
# The names depend on the field type.
|
||||||
|
#
|
||||||
|
# @params [ String ] name Name of the field
|
||||||
|
# @params [ String ] type Type of the field
|
||||||
|
#
|
||||||
|
# @returns [ Object ] A string or an array of names
|
||||||
|
def getters_for(name, type)
|
||||||
|
case type
|
||||||
|
when 'select' then [name, "#{name}_id"]
|
||||||
|
when 'date' then "formatted_#{name}"
|
||||||
|
when 'file' then "#{name}_url"
|
||||||
|
else
|
||||||
|
name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -1,7 +1,7 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
class SitePresenter < BasePresenter
|
class SitePresenter < BasePresenter
|
||||||
|
|
||||||
delegate :name, :subdomain, :domains, :robots_txt, :seo_title, :meta_keywords, :meta_description, :domains_without_subdomain, :to => :source
|
delegate :name, :locales, :subdomain, :domains, :robots_txt, :seo_title, :meta_keywords, :meta_description, :domains_without_subdomain, :to => :source
|
||||||
|
|
||||||
def domain_name
|
def domain_name
|
||||||
Locomotive.config.domain
|
Locomotive.config.domain
|
||||||
@ -12,7 +12,7 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def included_methods
|
def included_methods
|
||||||
super + %w(name domain_name subdomain domains robots_txt seo_title meta_keywords meta_description domains_without_subdomain memberships)
|
super + %w(name locales domain_name subdomain domains robots_txt seo_title meta_keywords meta_description domains_without_subdomain memberships)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -33,6 +33,6 @@
|
|||||||
|
|
||||||
= f.input :order_direction, :as => :select, :collection => options_for_order_direction, :include_blank => false, :wrapper_html => { :style => "#{'display: none' if @content_type.order_manually?}" }
|
= f.input :order_direction, :as => :select, :collection => options_for_order_direction, :include_blank => false, :wrapper_html => { :style => "#{'display: none' if @content_type.order_manually?}" }
|
||||||
|
|
||||||
= f.input :public_form_enabled, :as => :'Locomotive::Toggle'
|
= f.input :public_submission_enabled, :as => :'Locomotive::Toggle'
|
||||||
|
|
||||||
= f.input :public_form_accounts, :as => :select, :collection => options_for_account, :include_blank => false, :multiple => true, :wrapper_html => { :class => 'multiple', :style => (@content_type.public_form_enabled? ? '' : 'display: none') }
|
= f.input :public_submission_accounts, :as => :select, :collection => options_for_account, :include_blank => false, :multiple => true, :wrapper_html => { :class => 'multiple', :style => (@content_type.public_submission_enabled? ? '' : 'display: none') }
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
= render 'locomotive/shared/actions/contents'
|
= render 'locomotive/shared/actions/contents'
|
||||||
|
|
||||||
- content_for :buttons do
|
- content_for :buttons do
|
||||||
= local_action_button :show_items, content_entries_url(@content_type.slug_was), :class => 'show'
|
= local_action_button :show_entries, content_entries_url(@content_type.slug_was), :class => 'show'
|
||||||
= local_action_button :new_item, new_content_entry_url(@content_type.slug_was), :class => 'new'
|
= local_action_button :new_entry, new_content_entry_url(@content_type.slug_was), :class => 'new'
|
||||||
|
|
||||||
%p!= t('.help')
|
%p!= t('.help')
|
||||||
|
|
||||||
|
@ -6,13 +6,9 @@
|
|||||||
:plain
|
:plain
|
||||||
{ site: #{@site.to_json(:current_account => current_locomotive_account, :current_site => current_site)}, errors: #{@site.errors.to_json} }
|
{ site: #{@site.to_json(:current_account => current_locomotive_account, :current_site => current_site)}, errors: #{@site.errors.to_json} }
|
||||||
|
|
||||||
= f.inputs :name => :information, :style => 'display: none' do
|
= f.inputs :name => :information do
|
||||||
= f.input :name
|
= f.input :name, :wrapper_html => { :style => 'display: none' }
|
||||||
|
= f.input :locales, :as => '::Locomotive::Locales', :collection => ordered_current_site_locales, :input_html => { :class => 'locales' }
|
||||||
= f.inputs :name => :seo, :class => "inputs foldable #{'folded' if inputs_folded?(@site)}" do
|
|
||||||
= f.input :seo_title
|
|
||||||
= f.input :meta_keywords
|
|
||||||
= f.input :meta_description
|
|
||||||
|
|
||||||
- if can?(:point, Locomotive::Site)
|
- if can?(:point, Locomotive::Site)
|
||||||
- if manage_subdomain_or_domains?
|
- if manage_subdomain_or_domains?
|
||||||
@ -22,6 +18,12 @@
|
|||||||
- if manage_domains?
|
- if manage_domains?
|
||||||
= f.input :domains, :as => :'Locomotive::Empty'
|
= f.input :domains, :as => :'Locomotive::Empty'
|
||||||
|
|
||||||
|
|
||||||
|
= f.inputs :name => :seo, :class => "inputs foldable #{'folded' if inputs_folded?(@site)}" do
|
||||||
|
= f.input :seo_title
|
||||||
|
= f.input :meta_keywords
|
||||||
|
= f.input :meta_description
|
||||||
|
|
||||||
- if can?(:index, Locomotive::Membership)
|
- if can?(:index, Locomotive::Membership)
|
||||||
|
|
||||||
= f.inputs :name => :memberships do
|
= f.inputs :name => :memberships do
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
- highlighted_field_name = parent.highlighted_field_name rescue ''
|
|
||||||
|
|
||||||
= form.inputs :name => title || :attributes do
|
|
||||||
- form.object.custom_fields.each do |field|
|
|
||||||
- highlighted = highlighted_field_name == field._name
|
|
||||||
- required = highlighted || field.required
|
|
||||||
|
|
||||||
= render "/admin/custom_fields/types/#{field.kind}", :form => form, :parent => parent, :field => field, :required => required, :highlighted => highlighted
|
|
||||||
|
|
||||||
= render '/admin/custom_fields/category_tmpl'
|
|
@ -40,9 +40,11 @@
|
|||||||
|
|
||||||
= g.input :hint, :input_html => { :class => 'hint' }
|
= g.input :hint, :input_html => { :class => 'hint' }
|
||||||
|
|
||||||
|
= g.input :localized, :as => :'Locomotive::Toggle', :input_html => { :class => 'localized' }
|
||||||
|
|
||||||
= g.input :select_options, :as => :'Locomotive::Empty', :wrapper_html => { :class => 'extra select-options', :style => 'display: none' }
|
= g.input :select_options, :as => :'Locomotive::Empty', :wrapper_html => { :class => 'extra select-options', :style => 'display: none' }
|
||||||
|
|
||||||
= g.input :text_formatting, :as => :select, :collection => options_for_text_formatting, :include_blank => false, :wrapper_html => { :class => 'extra text-formatting', :style => 'display: none' }
|
= g.input :text_formatting, :as => :select, :collection => options_for_text_formatting, :include_blank => false, :wrapper_html => { :class => 'extra text-formatting' }, :input_html => { :class => 'text_formatting' }
|
||||||
|
|
||||||
%span.actions
|
%span.actions
|
||||||
= link_to 'toggle', '#', :class => 'toggle'
|
= link_to 'toggle', '#', :class => 'toggle'
|
||||||
|
@ -1 +1,4 @@
|
|||||||
= f.input name, :label => field.label, :as => :'Locomotive::Toggle', :hint => field.hint
|
= f.input name,
|
||||||
|
:label => field.label,
|
||||||
|
:hint => field.hint,
|
||||||
|
:as => :'Locomotive::Toggle'
|
@ -1,4 +0,0 @@
|
|||||||
= form.custom_input field._alias.to_sym, :label => field.label, :hint => field.hint, :css => 'toggle', :required => required do
|
|
||||||
= form.select field._name.to_sym, field.ordered_category_items.collect { |item| [item.name, item.id] }
|
|
||||||
%button.button.light.edit-categories-link{ :type => 'button', :'data-url' => edit_admin_custom_field_path(parent.class.model_name.underscore, parent.slug, field) }
|
|
||||||
%span!= t('.edit_categories')
|
|
@ -1 +1,5 @@
|
|||||||
= f.input :"formatted_#{name}", :label => field.label, :hint => field.hint, :input_html => { :maxlength => 10 }, :wrapper_html => { :class => 'date' }
|
= f.input :"formatted_#{name}",
|
||||||
|
:label => field.label,
|
||||||
|
:hint => field.hint,
|
||||||
|
:wrapper_html => { :class => 'date' },
|
||||||
|
:input_html => { :maxlength => 10 }
|
||||||
|
@ -1 +1,4 @@
|
|||||||
= f.input name, :label => field.label, :hint => field.hint, :as => :'Locomotive::File'
|
= f.input name,
|
||||||
|
:label => field.label,
|
||||||
|
:hint => field.hint,
|
||||||
|
:as => :'Locomotive::File'
|
@ -1 +1,5 @@
|
|||||||
= f.input :"#{name}_id", :as => 'select', :collection => field.ordered_select_options.map { |option| [option.name, option.id] }, :label => field.label, :hint => field.hint
|
= f.input :"#{name}_id",
|
||||||
|
:label => field.label,
|
||||||
|
:hint => field.hint,
|
||||||
|
:as => 'select',
|
||||||
|
:collection => field.ordered_select_options.map { |option| [option.name, option.id] }
|
@ -1 +1,4 @@
|
|||||||
= f.input name, :label => field.label, :hint => field.hint, :wrapper_html => { :class => "#{'highlighted' if highlighted}" }
|
= f.input name,
|
||||||
|
:label => field.label,
|
||||||
|
:hint => field.hint,
|
||||||
|
:wrapper_html => { :class => "#{'highlighted' if highlighted}" }
|
@ -1 +1,5 @@
|
|||||||
= f.input field.name.to_sym, :label => field.label, :hint => field.hint, :as => :'Locomotive::Rte', :input_html => { :class => field.text_formatting }
|
= f.input field.name.to_sym,
|
||||||
|
:label => field.label,
|
||||||
|
:hint => field.hint,
|
||||||
|
:as => field.text_formatting == 'html' ? :'Locomotive::Rte' : 'text',
|
||||||
|
:input_html => { :class => field.text_formatting }
|
@ -15,7 +15,7 @@
|
|||||||
= yield :submenu
|
= yield :submenu
|
||||||
|
|
||||||
- if content_for? :actions
|
- if content_for? :actions
|
||||||
.action
|
.actions
|
||||||
= yield :actions
|
= yield :actions
|
||||||
|
|
||||||
#content
|
#content
|
||||||
|
@ -3,19 +3,20 @@
|
|||||||
%hr
|
%hr
|
||||||
|
|
||||||
%p
|
%p
|
||||||
%b= t('.type', :type => @content_entry.content_type.name, :locale => @account.locale)
|
%b= t('.type', :type => @type.name, :locale => @account.locale)
|
||||||
%br
|
%br
|
||||||
%i= @content_entry.content_type.description
|
%i= @type.description
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
|
|
||||||
%ul
|
%ul
|
||||||
- @content_entry.custom_fields.each do |field|
|
- @type.entries_custom_fields.each do |field|
|
||||||
|
- value = @entry.value_for(field)
|
||||||
%li
|
%li
|
||||||
%strong= field.label
|
%strong= field.label
|
||||||
-
|
-
|
||||||
%i
|
%i
|
||||||
- if field.file?
|
- if field.type == 'file'
|
||||||
= link_to File.basename(@content_entry.send(field.name).url), @content_entry.send(field.name).url
|
= link_to File.basename(value), value
|
||||||
- else
|
- else
|
||||||
= @content_entry.send(field.name)
|
= value
|
||||||
|
@ -10,9 +10,6 @@
|
|||||||
= stylesheet_link_tag 'locomotive', :media => 'screen'
|
= stylesheet_link_tag 'locomotive', :media => 'screen'
|
||||||
= javascript_include_tag 'locomotive'
|
= javascript_include_tag 'locomotive'
|
||||||
|
|
||||||
/ [if IE]
|
|
||||||
= stylesheet_link_tag 'locomotive/ie', :media => 'screen'
|
|
||||||
|
|
||||||
%script{ :type => 'text/javascript' }
|
%script{ :type => 'text/javascript' }
|
||||||
:plain
|
:plain
|
||||||
window.locale = '#{I18n.locale}';
|
window.locale = '#{I18n.locale}';
|
||||||
|
@ -14,3 +14,5 @@
|
|||||||
- if can?(:manage, Locomotive::Site)
|
- if can?(:manage, Locomotive::Site)
|
||||||
%p.action
|
%p.action
|
||||||
= link_to t('locomotive.sites_picker.new'), new_site_url
|
= link_to t('locomotive.sites_picker.new'), new_site_url
|
||||||
|
|
||||||
|
= render_cell 'locomotive/content_locale_picker', :show, :site => current_site, :locale => current_content_locale
|
@ -1,2 +1,12 @@
|
|||||||
- if can? :manage, Locomotive::ContentType
|
- if can? :manage, Locomotive::ContentType
|
||||||
= link_to content_tag(:em) + content_tag(:span, t('locomotive.content_types.index.new')), new_content_type_url
|
.action
|
||||||
|
= link_to content_tag(:em) + content_tag(:span, t('locomotive.content_types.index.new')), new_content_type_url, :class => 'button'
|
||||||
|
|
||||||
|
.action
|
||||||
|
= link_to '#', :id => 'content-locale-picker-link', :class => 'button' do
|
||||||
|
%span.hand
|
||||||
|
|
||||||
|
|
||||||
|
= image_tag "locomotive/icons/flags/#{current_content_locale}.png", :class => 'flag'
|
||||||
|
|
||||||
|
%span.text= current_content_locale
|
@ -11,13 +11,25 @@
|
|||||||
= link_to truncate(page.title, :length => 25), edit_page_url(page)
|
= link_to truncate(page.title, :length => 25), edit_page_url(page)
|
||||||
%span= time_ago_in_words(page.updated_at)
|
%span= time_ago_in_words(page.updated_at)
|
||||||
|
|
||||||
- each_content_type_menu_item do |content_type|
|
- each_content_type do |menu_item|
|
||||||
|
-if menu_item.is_a?(Array)
|
||||||
|
- content_types = menu_item
|
||||||
|
= submenu_entry '...', '#', :i18n => false do
|
||||||
|
.wrapper
|
||||||
|
.inner
|
||||||
|
%ul.big-links
|
||||||
|
- content_types.each do |content_type|
|
||||||
|
%li
|
||||||
|
= link_to truncate(content_type.name, :length => 20), content_entries_url(content_type.slug)
|
||||||
|
- else
|
||||||
|
- content_type = menu_item
|
||||||
|
= submenu_entry truncate(content_type.name, :length => 15), content_entries_url(content_type.slug), :i18n => false, :css => "#{'on' if is_content_type_selected(content_type)}" do
|
||||||
.wrapper
|
.wrapper
|
||||||
.header
|
.header
|
||||||
%p= link_to t('locomotive.content_entries.index.new'), new_content_entry_url(content_type.slug)
|
%p= link_to t('locomotive.content_entries.index.new'), new_content_entry_url(content_type.slug)
|
||||||
|
|
||||||
- if can? :manage, content_type
|
- if can? :manage, content_type
|
||||||
%p.edit= link_to t('locomotive.content_entries.index.edit'), edit_content_type_url(content_type)
|
%p.edit= link_to t('locomotive.content_types.index.edit'), edit_content_type_url(content_type)
|
||||||
|
|
||||||
.inner
|
.inner
|
||||||
%h2!= t('locomotive.content_entries.index.lastest_entries')
|
%h2!= t('locomotive.content_entries.index.lastest_entries')
|
||||||
@ -26,10 +38,3 @@
|
|||||||
%li
|
%li
|
||||||
= link_to truncate(entry._label(content_type), :length => 20), edit_content_entry_url(content_type.slug, entry)
|
= link_to truncate(entry._label(content_type), :length => 20), edit_content_entry_url(content_type.slug, entry)
|
||||||
%span= time_ago_in_words(entry.updated_at)
|
%span= time_ago_in_words(entry.updated_at)
|
||||||
|
|
||||||
/ - other_content_types do |content_types|
|
|
||||||
/ .inner
|
|
||||||
/ %ul.big-links
|
|
||||||
/ - content_types.each do |content_type|
|
|
||||||
/ %li
|
|
||||||
/ = link_to truncate(content_type.name, :length => 20), contents_url(content_type.slug)
|
|
@ -222,14 +222,15 @@ en:
|
|||||||
content_types:
|
content_types:
|
||||||
index:
|
index:
|
||||||
new: new model
|
new: new model
|
||||||
|
edit: edit model
|
||||||
new:
|
new:
|
||||||
title: New model
|
title: New model
|
||||||
help: "Create your own data model (Projects, People, ...etc). Your model should have one field at least. The items created from this content type would have their first field mandatory."
|
help: "Create your own data model (Projects, People, ...etc). Your model should have one field at least. The items created from this content type would have their first field mandatory."
|
||||||
edit:
|
edit:
|
||||||
title: Editing model
|
title: Editing model
|
||||||
help: "Your model should have one field at least. The items created from this content type would have their first field mandatory."
|
help: "Your model should have one field at least. The items created from this content type would have their first field mandatory."
|
||||||
show_items: show items
|
show_entries: show entries
|
||||||
new_item: new item
|
new_entry: new entry
|
||||||
form:
|
form:
|
||||||
order_by:
|
order_by:
|
||||||
created_at: 'By creation date'
|
created_at: 'By creation date'
|
||||||
|
@ -41,7 +41,8 @@ en:
|
|||||||
default_site_template: "Use the default site template. Click <a href='#'>here</a> to upload a site template as a zip file instead."
|
default_site_template: "Use the default site template. Click <a href='#'>here</a> to upload a site template as a zip file instead."
|
||||||
content_type:
|
content_type:
|
||||||
raw_item_template: Item template
|
raw_item_template: Item template
|
||||||
public_form_accounts: Notified Accounts
|
public_submission_enabled: Public submission
|
||||||
|
public_submission_accounts: Notified Accounts
|
||||||
"custom_fields/field":
|
"custom_fields/field":
|
||||||
select_options: "Options"
|
select_options: "Options"
|
||||||
content_entry:
|
content_entry:
|
||||||
@ -53,6 +54,8 @@ en:
|
|||||||
password_confirmation: New password confirmation
|
password_confirmation: New password confirmation
|
||||||
page:
|
page:
|
||||||
seo_title: Title
|
seo_title: Title
|
||||||
|
site:
|
||||||
|
locales: Languages
|
||||||
|
|
||||||
hints:
|
hints:
|
||||||
page:
|
page:
|
||||||
@ -67,6 +70,7 @@ en:
|
|||||||
snippet:
|
snippet:
|
||||||
slug: "You need to know it in order to insert the snippet inside a page"
|
slug: "You need to know it in order to insert the snippet inside a page"
|
||||||
site:
|
site:
|
||||||
|
locales: "Drag&drop a flag to the first position to make it the default one."
|
||||||
seo_title: "Define a global value here which should be used as the value for the title tag in the head section."
|
seo_title: "Define a global value here which should be used as the value for the title tag in the head section."
|
||||||
meta_keywords: "Meta keywords used within the head tag of the page. They are separated by a comma. Required for SEO."
|
meta_keywords: "Meta keywords used within the head tag of the page. They are separated by a comma. Required for SEO."
|
||||||
meta_description: "Meta description used within the head tag of the page. Required for SEO."
|
meta_description: "Meta description used within the head tag of the page. Required for SEO."
|
||||||
@ -95,8 +99,8 @@ en:
|
|||||||
name: "We suggest you to type the plural form of the model. Ex: Projects, Recipes, Posts, Articles, ...etc"
|
name: "We suggest you to type the plural form of the model. Ex: Projects, Recipes, Posts, Articles, ...etc"
|
||||||
slug: "It will be used as the name of the collection in the liquid templates. Ex: <span class='code'>{{ contents.my_projects }}</span>"
|
slug: "It will be used as the name of the collection in the liquid templates. Ex: <span class='code'>{{ contents.my_projects }}</span>"
|
||||||
raw_item_template: "You can customize the text displayed for each item in the list. Simply use Liquid. Ex: <span class='code'>{{ entry.name }})</span>"
|
raw_item_template: "You can customize the text displayed for each item in the list. Simply use Liquid. Ex: <span class='code'>{{ entry.name }})</span>"
|
||||||
public_form_enabled: "It is used to let people from outside to create new instances (example: messages in a contact form)"
|
public_submission_enabled: "It is used to let people from outside to create new entries (example: messages in a contact form)"
|
||||||
public_form_accounts: "A notification email will be sent to each of the accounts listed above when a new instance is created"
|
public_submission_accounts: "If the public submission option is enabled and for each entry created, sends a notification email tothe accounts listed above."
|
||||||
"custom_fields/field":
|
"custom_fields/field":
|
||||||
name: "Name of the property for liquid templates. Ex: <span class='code'>{{ your_object.<name_of_your_field> }}</span>"
|
name: "Name of the property for liquid templates. Ex: <span class='code'>{{ your_object.<name_of_your_field> }}</span>"
|
||||||
hint: "Text displayed in the model form just below the field"
|
hint: "Text displayed in the model form just below the field"
|
||||||
|
@ -41,8 +41,6 @@ Locomotive::Engine.routes.draw do
|
|||||||
put :sort, :on => :collection
|
put :sort, :on => :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
resources :api_contents, :path => 'api/:slug/contents', :controller => 'api_contents', :only => [:create]
|
|
||||||
|
|
||||||
resources :custom_fields, :path => 'custom/:parent/:slug/fields'
|
resources :custom_fields, :path => 'custom/:parent/:slug/fields'
|
||||||
|
|
||||||
resources :cross_domain_sessions, :only => [:new, :create]
|
resources :cross_domain_sessions, :only => [:new, :create]
|
||||||
@ -58,13 +56,16 @@ end
|
|||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
# sitemap
|
# sitemap
|
||||||
match '/sitemap.xml' => 'locomotive/sitemaps#show', :format => 'xml'
|
match '/sitemap.xml' => 'locomotive/public/sitemaps#show', :format => 'xml'
|
||||||
|
|
||||||
# robots.txt
|
# robots.txt
|
||||||
match '/robots.txt' => 'locomotive/robots#show', :format => 'txt'
|
match '/robots.txt' => 'locomotive/public/robots#show', :format => 'txt'
|
||||||
|
|
||||||
|
# public content entry submissions
|
||||||
|
resources :locomotive_entry_submissions, :controller => 'locomotive/public/content_entries', :path => 'entry_submissions/:slug'
|
||||||
|
|
||||||
# magic urls
|
# magic urls
|
||||||
match '/' => 'locomotive/rendering#show'
|
match '/' => 'locomotive/public/rendering#show'
|
||||||
match '*path/edit' => 'locomotive/rendering#edit'
|
match '*path/edit' => 'locomotive/public/rendering#edit'
|
||||||
match '*path' => 'locomotive/rendering#show'
|
match '*path' => 'locomotive/public/rendering#show'
|
||||||
end
|
end
|
16
doc/TODO
16
doc/TODO
@ -8,9 +8,9 @@ x bugs:
|
|||||||
x undefined method `_selector' for #<Locomotive::Page:0x00000107434768>
|
x undefined method `_selector' for #<Locomotive::Page:0x00000107434768>
|
||||||
x editable_elements => view + handlebar template
|
x editable_elements => view + handlebar template
|
||||||
x editable_short_text => tinymce
|
x editable_short_text => tinymce
|
||||||
- editable_file =>
|
x editable_file =>
|
||||||
x backbone / handlebar
|
x backbone / handlebar
|
||||||
- new formtastic inputs
|
x new formtastic inputs
|
||||||
x menu / submenu in full css3 (no images)
|
x menu / submenu in full css3 (no images)
|
||||||
x fix css in firefox
|
x fix css in firefox
|
||||||
x update page in ajax
|
x update page in ajax
|
||||||
@ -49,7 +49,7 @@ x edit my site
|
|||||||
x show / hide options of a field based on its type
|
x show / hide options of a field based on its type
|
||||||
x select: add/edit/remove options
|
x select: add/edit/remove options
|
||||||
x text: formatting
|
x text: formatting
|
||||||
- change in main menu
|
x change in main menu
|
||||||
x manage contents
|
x manage contents
|
||||||
x list (highlighted field)
|
x list (highlighted field)
|
||||||
x slugify
|
x slugify
|
||||||
@ -61,7 +61,15 @@ x edit my site
|
|||||||
x file
|
x file
|
||||||
x edit
|
x edit
|
||||||
x destroy
|
x destroy
|
||||||
- public_form (previously api something)
|
x public_form (previously api something)
|
||||||
|
x bug text formatting
|
||||||
|
- use list_or_group_entries instead of ordered_entries
|
||||||
|
- bug ui with contents popup
|
||||||
|
- custom_fields: use the appropriate icon to drag select options
|
||||||
|
- i18n
|
||||||
|
x add locales a site responds to
|
||||||
|
- locale switcher
|
||||||
|
- inline editor
|
||||||
|
|
||||||
- disallow to click twice on the submit form button (spinner ?)
|
- disallow to click twice on the submit form button (spinner ?)
|
||||||
- message to notify people if their browser is too old
|
- message to notify people if their browser is too old
|
||||||
|
@ -8,10 +8,13 @@
|
|||||||
- content_types:
|
- content_types:
|
||||||
- category => select
|
- category => select
|
||||||
- highlighted_field_name => highlighted_field_id (label_field_id)
|
- highlighted_field_name => highlighted_field_id (label_field_id)
|
||||||
- api_enabled => public_form_enabled
|
- api_enabled => public_submission_enabled
|
||||||
- api_accounts => public_form_accounts
|
- api_accounts => public_submission_accounts
|
||||||
- contents (content_entries now)
|
- contents (content_entries now)
|
||||||
- _position_in_list => _position
|
- _position_in_list => _position
|
||||||
|
- api_contents:
|
||||||
|
- url => entry_submissions
|
||||||
|
- params[:content] => params[:entries]
|
||||||
|
|
||||||
|
|
||||||
collection, selector = Locomotive::ContentType.collection, Locomotive::ContentType.criteria.selector
|
collection, selector = Locomotive::ContentType.collection, Locomotive::ContentType.criteria.selector
|
||||||
|
@ -44,11 +44,17 @@ Locomotive.configure do |config|
|
|||||||
config.delayed_job = false
|
config.delayed_job = false
|
||||||
|
|
||||||
# configure how many items we display in sub menu in the "Contents" section.
|
# configure how many items we display in sub menu in the "Contents" section.
|
||||||
# config.lastest_entries_nb = 5
|
# config.ui = {
|
||||||
|
# :lastest_entries_nb => 5,
|
||||||
|
# :max_content_types => 4
|
||||||
|
# }
|
||||||
|
|
||||||
# default locale (for now, only en, de, fr, pt-BR and it are supported)
|
# default locale (for now, only en, de, fr, pt-BR and it are supported)
|
||||||
config.default_locale = :en
|
config.default_locale = :en
|
||||||
|
|
||||||
|
# available locales suggested to "localize" a site. You will have to pick up at least one among that list.
|
||||||
|
# config.site_locales = %w{en de fr pt-BR it nl no es ru}
|
||||||
|
|
||||||
# tell if logs are enabled. Useful for debug purpose.
|
# tell if logs are enabled. Useful for debug purpose.
|
||||||
config.enable_logs = true
|
config.enable_logs = true
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ require 'locomotive/version'
|
|||||||
require 'locomotive/core_ext'
|
require 'locomotive/core_ext'
|
||||||
require 'locomotive/configuration'
|
require 'locomotive/configuration'
|
||||||
require 'locomotive/logger'
|
require 'locomotive/logger'
|
||||||
|
|
||||||
require 'locomotive/formtastic'
|
require 'locomotive/formtastic'
|
||||||
require 'locomotive/dragonfly'
|
require 'locomotive/dragonfly'
|
||||||
require 'locomotive/kaminari'
|
require 'locomotive/kaminari'
|
||||||
@ -15,7 +14,7 @@ require 'locomotive/mongoid'
|
|||||||
require 'locomotive/carrierwave'
|
require 'locomotive/carrierwave'
|
||||||
require 'locomotive/custom_fields'
|
require 'locomotive/custom_fields'
|
||||||
require 'locomotive/httparty'
|
require 'locomotive/httparty'
|
||||||
require 'locomotive/responder'
|
require 'locomotive/action_controller'
|
||||||
require 'locomotive/routing'
|
require 'locomotive/routing'
|
||||||
require 'locomotive/regexps'
|
require 'locomotive/regexps'
|
||||||
require 'locomotive/render'
|
require 'locomotive/render'
|
||||||
@ -76,11 +75,11 @@ module Locomotive
|
|||||||
self.add_middlewares
|
self.add_middlewares
|
||||||
|
|
||||||
# Load all the dynamic classes (custom fields)
|
# Load all the dynamic classes (custom fields)
|
||||||
# begin
|
begin
|
||||||
# ContentType.all.collect(&:fetch_content_klass)
|
ContentType.all.collect { |content_type| content_type.klass_with_custom_fields(:entries) }
|
||||||
# rescue ::Mongoid::Errors::InvalidDatabase => e
|
rescue ::Mongoid::Errors::InvalidDatabase => e
|
||||||
# # let assume it's because of the first install (meaning no config.yml file)
|
# let assume it's because of the first install (meaning no config.yml file)
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.add_middlewares
|
def self.add_middlewares
|
||||||
|
3
lib/locomotive/action_controller.rb
Normal file
3
lib/locomotive/action_controller.rb
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
require 'locomotive/action_controller/helpers'
|
||||||
|
require 'locomotive/action_controller/responder'
|
||||||
|
require 'locomotive/action_controller/public_responder'
|
91
lib/locomotive/action_controller/helpers.rb
Normal file
91
lib/locomotive/action_controller/helpers.rb
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
module Locomotive
|
||||||
|
module ActionController
|
||||||
|
module Helpers
|
||||||
|
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
helper_method :current_site_public_url, :switch_to_site_url, :public_page_url, :current_content_locale
|
||||||
|
end
|
||||||
|
|
||||||
|
module InstanceMethods
|
||||||
|
|
||||||
|
# ___ locales ___
|
||||||
|
|
||||||
|
def current_content_locale
|
||||||
|
::Mongoid::Fields::I18n.locale
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_current_content_locale
|
||||||
|
# I18n.default_site_locale = current_site.default_locale
|
||||||
|
|
||||||
|
if params[:content_locale].present?
|
||||||
|
session[:content_locale] = params[:content_locale]
|
||||||
|
end
|
||||||
|
|
||||||
|
unless current_site.locales.include?(session[:content_locale])
|
||||||
|
session[:content_locale] = current_site.default_locale
|
||||||
|
end
|
||||||
|
|
||||||
|
::Mongoid::Fields::I18n.locale = session[:content_locale]
|
||||||
|
(current_site.locales || []).each do |locale|
|
||||||
|
::Mongoid::Fields::I18n.fallbacks_for(locale, current_site.locale_fallbacks(locale))
|
||||||
|
end
|
||||||
|
|
||||||
|
logger.debug "*** content locale = #{session[:content_locale]} / #{::Mongoid::Fields::I18n.locale}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def set_back_office_locale
|
||||||
|
::I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale
|
||||||
|
end
|
||||||
|
|
||||||
|
def sections(key = nil)
|
||||||
|
if !key.nil? && key.to_sym == :sub
|
||||||
|
@locomotive_sections[:sub] || self.controller_name.dasherize
|
||||||
|
else
|
||||||
|
@locomotive_sections[:main]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# ___ site/page urls builder ___
|
||||||
|
|
||||||
|
def current_site_public_url
|
||||||
|
request.protocol + request.host_with_port
|
||||||
|
end
|
||||||
|
|
||||||
|
def switch_to_site_url(site, options = {})
|
||||||
|
options = { :fullpath => true, :protocol => true }.merge(options)
|
||||||
|
|
||||||
|
url = "#{site.subdomain}.#{Locomotive.config.domain}"
|
||||||
|
url += ":#{request.port}" if request.port != 80
|
||||||
|
|
||||||
|
url = File.join(url, request.fullpath) if options[:fullpath]
|
||||||
|
url = "http://#{url}" if options[:protocol]
|
||||||
|
url
|
||||||
|
end
|
||||||
|
|
||||||
|
def public_page_url(page, options = {})
|
||||||
|
if content = options.delete(:content)
|
||||||
|
File.join(current_site_public_url, page.fullpath.gsub('content_type_template', ''), content._slug)
|
||||||
|
else
|
||||||
|
File.join(current_site_public_url, page.fullpath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
module ClassMethods
|
||||||
|
|
||||||
|
def sections(main, sub = nil)
|
||||||
|
before_filter do |c|
|
||||||
|
sub = sub.call(c) if sub.respond_to?(:call)
|
||||||
|
sections = { :main => main, :sub => sub }
|
||||||
|
c.instance_variable_set(:@locomotive_sections, sections)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
17
lib/locomotive/action_controller/public_responder.rb
Normal file
17
lib/locomotive/action_controller/public_responder.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
module Locomotive
|
||||||
|
module ActionController
|
||||||
|
class PublicResponder < ::ActionController::Responder
|
||||||
|
|
||||||
|
def navigation_behavior(error)
|
||||||
|
if get?
|
||||||
|
raise error
|
||||||
|
elsif has_errors? && default_action
|
||||||
|
redirect_to navigation_location
|
||||||
|
else
|
||||||
|
redirect_to navigation_location
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
63
lib/locomotive/action_controller/responder.rb
Normal file
63
lib/locomotive/action_controller/responder.rb
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
module Locomotive
|
||||||
|
module ActionController
|
||||||
|
class Responder < ::ActionController::Responder
|
||||||
|
|
||||||
|
include ::Responders::FlashResponder
|
||||||
|
|
||||||
|
# by default flash_now messages if the resource has errors
|
||||||
|
def set_flash_now?
|
||||||
|
super || has_errors?
|
||||||
|
end
|
||||||
|
|
||||||
|
def to_json
|
||||||
|
if get?
|
||||||
|
display resource
|
||||||
|
elsif has_errors?
|
||||||
|
with_flash_message(:alert) do
|
||||||
|
display resource.errors, :status => :unprocessable_entity
|
||||||
|
end
|
||||||
|
elsif post?
|
||||||
|
in_header = controller.request.headers['X-Flash'] == 'true'
|
||||||
|
with_flash_message(:notice, in_header) do
|
||||||
|
display resource, :location => api_location
|
||||||
|
end
|
||||||
|
elsif put?
|
||||||
|
with_flash_message do |message|
|
||||||
|
display resource, :status => :ok, :location => api_location
|
||||||
|
end
|
||||||
|
elsif delete?
|
||||||
|
with_flash_message do |message|
|
||||||
|
display resource, :status => :ok, :location => api_location
|
||||||
|
end
|
||||||
|
elsif has_empty_resource_definition?
|
||||||
|
display empty_resource, :status => :ok
|
||||||
|
else
|
||||||
|
with_flash_message do
|
||||||
|
head :ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def with_flash_message(type = :notice, in_header = true)
|
||||||
|
if in_header
|
||||||
|
set_flash_message!
|
||||||
|
message = controller.flash[type]
|
||||||
|
|
||||||
|
controller.headers['X-Message'] = message
|
||||||
|
controller.headers['X-Message-Type'] = type
|
||||||
|
|
||||||
|
yield if block_given?
|
||||||
|
|
||||||
|
controller.flash.discard # reset flash messages !
|
||||||
|
else
|
||||||
|
set_flash_message!
|
||||||
|
|
||||||
|
yield if block_given?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -8,6 +8,7 @@ module Locomotive
|
|||||||
# :forbidden_paths => %w{layouts snippets stylesheets javascripts assets admin system api},
|
# :forbidden_paths => %w{layouts snippets stylesheets javascripts assets admin system api},
|
||||||
:reserved_slugs => %w{stylesheets javascripts assets admin images api pages edit},
|
:reserved_slugs => %w{stylesheets javascripts assets admin images api pages edit},
|
||||||
:locales => %w{en de fr pt-BR it nl no es ru},
|
:locales => %w{en de fr pt-BR it nl no es ru},
|
||||||
|
:site_locales => %w{en de fr pt-BR it nl no es ru},
|
||||||
:cookie_key => '_locomotive_session',
|
:cookie_key => '_locomotive_session',
|
||||||
:enable_logs => false,
|
:enable_logs => false,
|
||||||
:hosting => :auto,
|
:hosting => :auto,
|
||||||
@ -16,7 +17,10 @@ module Locomotive
|
|||||||
:mailer_sender => 'support@example.com',
|
:mailer_sender => 'support@example.com',
|
||||||
:manage_subdomain => false,
|
:manage_subdomain => false,
|
||||||
:manage_manage_domains => false,
|
:manage_manage_domains => false,
|
||||||
|
:ui => {
|
||||||
:lastest_entries_nb => 5,
|
:lastest_entries_nb => 5,
|
||||||
|
:max_content_types => 2
|
||||||
|
},
|
||||||
:rack_cache => {
|
:rack_cache => {
|
||||||
:verbose => true,
|
:verbose => true,
|
||||||
:metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
|
:metastore => URI.encode("file:#{Rails.root}/tmp/dragonfly/cache/meta"), # URI encoded in case of spaces
|
||||||
|
@ -24,7 +24,7 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
initializer 'locomotive.action_controller' do |app|
|
initializer 'locomotive.action_controller' do |app|
|
||||||
ActionController::Base.wrap_parameters :format => [:json]
|
::ActionController::Base.wrap_parameters :format => [:json]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
79
lib/locomotive/liquid/drops/content_types.rb
Normal file
79
lib/locomotive/liquid/drops/content_types.rb
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Liquid
|
||||||
|
module Drops
|
||||||
|
class ContentTypes < ::Liquid::Drop
|
||||||
|
|
||||||
|
def before_method(meth)
|
||||||
|
type = @context.registers[:site].content_types.where(:slug => meth.to_s).first
|
||||||
|
ProxyCollection.new(type)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
class ProxyCollection < ::Liquid::Drop
|
||||||
|
|
||||||
|
def initialize(content_type)
|
||||||
|
@content_type = content_type
|
||||||
|
@collection = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
def first
|
||||||
|
self.collection.first
|
||||||
|
end
|
||||||
|
|
||||||
|
def last
|
||||||
|
self.collection.last
|
||||||
|
end
|
||||||
|
|
||||||
|
def each(&block)
|
||||||
|
self.collection.each(&block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def each_with_index(&block)
|
||||||
|
self.collection.each_with_index(&block)
|
||||||
|
end
|
||||||
|
|
||||||
|
def count
|
||||||
|
@count ||= self.collection.count
|
||||||
|
end
|
||||||
|
|
||||||
|
alias :size :count
|
||||||
|
alias :length :count
|
||||||
|
|
||||||
|
def empty?
|
||||||
|
self.collection.empty?
|
||||||
|
end
|
||||||
|
|
||||||
|
def any?
|
||||||
|
self.collection.any?
|
||||||
|
end
|
||||||
|
|
||||||
|
def public_submission_url
|
||||||
|
@context.registers[:controller].main_app.locomotive_entry_submissions_url(@content_type.slug)
|
||||||
|
end
|
||||||
|
|
||||||
|
def before_method(meth)
|
||||||
|
klass = @content_type.entries.klass # delegate to the proxy class
|
||||||
|
|
||||||
|
if (meth.to_s =~ /^group_by_.+$/) == 0
|
||||||
|
klass.send(meth, :ordered_entries)
|
||||||
|
else
|
||||||
|
Rails.logger.warn "[Liquid template] trying to call #{meth} on a content_type object"
|
||||||
|
# klass.send(meth)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
|
|
||||||
|
def paginate(options = {})
|
||||||
|
@collection.page(options[:page]).per(options[:per_page])
|
||||||
|
end
|
||||||
|
|
||||||
|
def collection
|
||||||
|
@collection ||= @content_type.ordered_entries(@context['with_scope'])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,79 +1,81 @@
|
|||||||
module Locomotive
|
# DEPRECATED
|
||||||
module Liquid
|
|
||||||
module Drops
|
|
||||||
class Contents < ::Liquid::Drop
|
|
||||||
|
|
||||||
# TODO: refactoring
|
# module Locomotive
|
||||||
|
# module Liquid
|
||||||
def before_method(meth)
|
# module Drops
|
||||||
type = @context.registers[:site].content_types.where(:slug => meth.to_s).first
|
# class Contents < ::Liquid::Drop
|
||||||
ProxyCollection.new(type)
|
#
|
||||||
end
|
# # TODO: refactoring
|
||||||
|
#
|
||||||
end
|
# def before_method(meth)
|
||||||
|
# type = @context.registers[:site].content_types.where(:slug => meth.to_s).first
|
||||||
class ProxyCollection < ::Liquid::Drop
|
# ProxyCollection.new(type)
|
||||||
|
# end
|
||||||
def initialize(content_type)
|
#
|
||||||
@content_type = content_type
|
# end
|
||||||
@collection = nil
|
#
|
||||||
end
|
# class ProxyCollection < ::Liquid::Drop
|
||||||
|
#
|
||||||
def first
|
# def initialize(content_type)
|
||||||
self.collection.first
|
# @content_type = content_type
|
||||||
end
|
# @collection = nil
|
||||||
|
# end
|
||||||
def last
|
#
|
||||||
self.collection.last
|
# def first
|
||||||
end
|
# self.collection.first
|
||||||
|
# end
|
||||||
def each(&block)
|
#
|
||||||
self.collection.each(&block)
|
# def last
|
||||||
end
|
# self.collection.last
|
||||||
|
# end
|
||||||
def each_with_index(&block)
|
#
|
||||||
self.collection.each_with_index(&block)
|
# def each(&block)
|
||||||
end
|
# self.collection.each(&block)
|
||||||
|
# end
|
||||||
def size
|
#
|
||||||
self.collection.size
|
# def each_with_index(&block)
|
||||||
end
|
# self.collection.each_with_index(&block)
|
||||||
|
# end
|
||||||
alias :length :size
|
#
|
||||||
|
# def size
|
||||||
def empty?
|
# self.collection.size
|
||||||
self.collection.empty?
|
# end
|
||||||
end
|
#
|
||||||
|
# alias :length :size
|
||||||
def any?
|
#
|
||||||
self.collection.any?
|
# def empty?
|
||||||
end
|
# self.collection.empty?
|
||||||
|
# end
|
||||||
def api
|
#
|
||||||
{ 'create' => @context.registers[:controller].send('api_contents_url', @content_type.slug) }
|
# def any?
|
||||||
end
|
# self.collection.any?
|
||||||
|
# end
|
||||||
def before_method(meth)
|
#
|
||||||
klass = @content_type.entries.klass # delegate to the proxy class
|
# def api
|
||||||
|
# { 'create' => @context.registers[:controller].send('api_contents_url', @content_type.slug) }
|
||||||
if (meth.to_s =~ /^group_by_.+$/) == 0
|
# end
|
||||||
klass.send(meth, :ordered_contents)
|
#
|
||||||
else
|
# def before_method(meth)
|
||||||
klass.send(meth)
|
# klass = @content_type.entries.klass # delegate to the proxy class
|
||||||
end
|
#
|
||||||
end
|
# if (meth.to_s =~ /^group_by_.+$/) == 0
|
||||||
|
# klass.send(meth, :ordered_contents)
|
||||||
protected
|
# else
|
||||||
|
# klass.send(meth)
|
||||||
def paginate(options = {})
|
# end
|
||||||
@collection = Kaminari.paginate_array(self.collection).page(options[:page]).per(options[:per_page])
|
# end
|
||||||
end
|
#
|
||||||
|
# protected
|
||||||
def collection
|
#
|
||||||
@collection ||= @content_type.ordered_contents(@context['with_scope'])
|
# def paginate(options = {})
|
||||||
end
|
# @collection = Kaminari.paginate_array(self.collection).page(options[:page]).per(options[:per_page])
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
end
|
# def collection
|
||||||
end
|
# @collection ||= @content_type.ordered_contents(@context['with_scope'])
|
||||||
end
|
# end
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
@ -2,32 +2,33 @@
|
|||||||
|
|
||||||
require 'mongoid'
|
require 'mongoid'
|
||||||
|
|
||||||
module Mongoid
|
module Mongoid#:nodoc:
|
||||||
module Document
|
module Document #:nodoc:
|
||||||
def as_json(options = {})
|
def as_json(options = {})
|
||||||
attrs = super(options)
|
attrs = super(options)
|
||||||
attrs["id"] = attrs["_id"]
|
attrs["id"] = attrs["_id"]
|
||||||
attrs
|
attrs
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
module Fields #:nodoc:
|
||||||
|
module Internal #:nodoc:
|
||||||
|
class RawArray < Mongoid::Fields::Internal::Array
|
||||||
|
def resizable?; false; end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Limit feature for embedded documents
|
class RawArray < ::Array; end
|
||||||
|
end
|
||||||
module Mongoid #:nodoc:
|
|
||||||
|
|
||||||
# without callback feature
|
# without callback feature
|
||||||
module Callbacks
|
module Callbacks #:nodoc:
|
||||||
|
module ClassMethods #:nodoc:
|
||||||
module ClassMethods
|
|
||||||
|
|
||||||
def without_callback(*args, &block)
|
def without_callback(*args, &block)
|
||||||
skip_callback(*args)
|
skip_callback(*args)
|
||||||
yield
|
yield
|
||||||
set_callback(*args)
|
set_callback(*args)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -61,7 +61,8 @@ module Locomotive
|
|||||||
assigns = {
|
assigns = {
|
||||||
'site' => current_site,
|
'site' => current_site,
|
||||||
'page' => @page,
|
'page' => @page,
|
||||||
'contents' => Locomotive::Liquid::Drops::Contents.new,
|
'models' => Locomotive::Liquid::Drops::ContentTypes.new,
|
||||||
|
'contents' => Locomotive::Liquid::Drops::ContentTypes.new, # DEPRECATED
|
||||||
'current_page' => self.params[:page],
|
'current_page' => self.params[:page],
|
||||||
'params' => self.params,
|
'params' => self.params,
|
||||||
'path' => request.path,
|
'path' => request.path,
|
||||||
@ -72,10 +73,12 @@ module Locomotive
|
|||||||
|
|
||||||
assigns.merge!(Locomotive.config.context_assign_extensions)
|
assigns.merge!(Locomotive.config.context_assign_extensions)
|
||||||
|
|
||||||
assigns.merge!(flash.to_hash.stringify_keys) # data from api
|
Rails.logger.debug flash.to_hash.stringify_keys.inspect
|
||||||
|
|
||||||
|
assigns.merge!(flash.to_hash.stringify_keys) # data from public submissions
|
||||||
|
|
||||||
if @page.templatized? # add instance from content type
|
if @page.templatized? # add instance from content type
|
||||||
assigns['content_entry'] = @content_entry
|
assigns['entry'] = @content_entry
|
||||||
assigns[@page.content_type.slug.singularize] = @content_entry # just here to help to write readable liquid code
|
assigns[@page.content_type.slug.singularize] = @content_entry # just here to help to write readable liquid code
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -111,7 +114,7 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
def editing_page?
|
def editing_page?
|
||||||
@editing
|
!!@editing
|
||||||
end
|
end
|
||||||
|
|
||||||
def page_status
|
def page_status
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
module Locomotive
|
|
||||||
class Responder < ::ActionController::Responder
|
|
||||||
|
|
||||||
include ::Responders::FlashResponder
|
|
||||||
|
|
||||||
# by default flash_now messages if the resource has errors
|
|
||||||
def set_flash_now?
|
|
||||||
super || has_errors?
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_json
|
|
||||||
if get?
|
|
||||||
display resource
|
|
||||||
elsif has_errors?
|
|
||||||
with_flash_message(:alert) do
|
|
||||||
display resource.errors, :status => :unprocessable_entity
|
|
||||||
end
|
|
||||||
elsif post?
|
|
||||||
in_header = controller.request.headers['X-Flash'] == 'true'
|
|
||||||
with_flash_message(:notice, in_header) do
|
|
||||||
display resource, :location => api_location
|
|
||||||
end
|
|
||||||
elsif put?
|
|
||||||
with_flash_message do |message|
|
|
||||||
display resource, :status => :ok, :location => api_location
|
|
||||||
end
|
|
||||||
elsif delete?
|
|
||||||
with_flash_message do |message|
|
|
||||||
display resource, :status => :ok, :location => api_location
|
|
||||||
end
|
|
||||||
elsif has_empty_resource_definition?
|
|
||||||
display empty_resource, :status => :ok
|
|
||||||
else
|
|
||||||
with_flash_message do
|
|
||||||
head :ok
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def with_flash_message(type = :notice, in_header = true)
|
|
||||||
if in_header
|
|
||||||
set_flash_message!
|
|
||||||
message = controller.flash[type]
|
|
||||||
|
|
||||||
controller.headers['X-Message'] = message
|
|
||||||
controller.headers['X-Message-Type'] = type
|
|
||||||
|
|
||||||
yield if block_given?
|
|
||||||
|
|
||||||
controller.flash.discard # reset flash messages !
|
|
||||||
else
|
|
||||||
set_flash_message!
|
|
||||||
|
|
||||||
yield if block_given?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|||||||
s.required_rubygems_version = '>= 1.3.6'
|
s.required_rubygems_version = '>= 1.3.6'
|
||||||
s.rubyforge_project = 'nowarning'
|
s.rubyforge_project = 'nowarning'
|
||||||
|
|
||||||
s.add_dependency 'rails', '~> 3.0.10'
|
s.add_dependency 'rails', '~> 3.1.3'
|
||||||
s.add_dependency 'warden'
|
s.add_dependency 'warden'
|
||||||
s.add_dependency 'devise', '1.3.4'
|
s.add_dependency 'devise', '1.3.4'
|
||||||
s.add_dependency 'devise_bushido_authenticatable', '1.0.0.alpha10'
|
s.add_dependency 'devise_bushido_authenticatable', '1.0.0.alpha10'
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user