locomotive_cms 0.0.2.9 → 0.0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/app/controllers/admin/accounts_controller.rb +5 -11
- data/app/controllers/admin/asset_collections_controller.rb +5 -46
- data/app/controllers/admin/assets_controller.rb +12 -30
- data/app/controllers/admin/base_controller.rb +15 -19
- data/app/controllers/admin/content_types_controller.rb +1 -46
- data/app/controllers/admin/contents_controller.rb +15 -42
- data/app/controllers/admin/current_sites_controller.rb +10 -11
- data/app/controllers/admin/custom_fields_controller.rb +1 -1
- data/app/controllers/admin/layouts_controller.rb +2 -46
- data/app/controllers/admin/memberships_controller.rb +5 -18
- data/app/controllers/admin/my_accounts_controller.rb +11 -9
- data/app/controllers/admin/pages_controller.rb +6 -45
- data/app/controllers/admin/sitemaps_controller.rb +16 -0
- data/app/controllers/admin/sites_controller.rb +12 -19
- data/app/controllers/admin/snippets_controller.rb +2 -45
- data/app/controllers/admin/theme_assets_controller.rb +13 -54
- data/app/helpers/admin/assets_helper.rb +1 -1
- data/app/helpers/admin/base_helper.rb +2 -2
- data/app/helpers/admin/pages_helper.rb +13 -0
- data/app/models/membership.rb +4 -1
- data/app/models/page.rb +8 -1
- data/app/models/page_part.rb +1 -4
- data/app/views/admin/asset_collections/_asset.html.haml +1 -1
- data/app/views/admin/asset_collections/edit.html.haml +7 -7
- data/app/views/admin/asset_collections/new.html.haml +1 -1
- data/app/views/admin/assets/_form.html.haml +1 -1
- data/app/views/admin/assets/edit.html.haml +3 -3
- data/app/views/admin/assets/new.html.haml +2 -2
- data/app/views/admin/content_types/edit.html.haml +1 -1
- data/app/views/admin/contents/edit.html.haml +1 -1
- data/app/views/admin/contents/index.html.haml +1 -1
- data/app/views/admin/contents/new.html.haml +1 -1
- data/app/views/admin/current_sites/edit.html.haml +3 -3
- data/app/views/admin/layouts/edit.html.haml +2 -2
- data/app/views/admin/layouts/index.html.haml +1 -1
- data/app/views/admin/my_accounts/edit.html.haml +3 -3
- data/app/views/admin/pages/edit.html.haml +1 -1
- data/app/views/admin/pages/index.html.haml +1 -1
- data/app/views/admin/shared/_head.html.haml +1 -1
- data/app/views/admin/shared/menu/_assets.html.haml +2 -2
- data/app/views/admin/sitemaps/show.xml.builder +18 -0
- data/app/views/admin/snippets/edit.html.haml +2 -2
- data/app/views/admin/snippets/index.html.haml +1 -1
- data/app/views/admin/theme_assets/_form.html.haml +9 -9
- data/app/views/admin/theme_assets/edit.html.haml +4 -4
- data/app/views/admin/theme_assets/index.html.haml +1 -1
- data/app/views/admin/theme_assets/new.html.haml +1 -1
- data/app/views/layouts/admin/application.html.haml +1 -0
- data/config/initializers/locomotive.rb +21 -0
- data/config/locales/admin_ui_en.yml +2 -66
- data/config/locales/admin_ui_fr.yml +0 -64
- data/config/locales/flash.en.yml +116 -0
- data/config/locales/flash.fr.yml +116 -0
- data/config/routes.rb +3 -0
- data/lib/generators/locomotive/copy_assets/copy_assets_generator.rb +14 -0
- data/lib/generators/locomotive/install/install_generator.rb +15 -2
- data/lib/generators/locomotive/install/templates/README +17 -0
- data/lib/locomotive.rb +3 -0
- data/lib/locomotive/admin_responder.rb +28 -0
- data/lib/locomotive/inherited_resources.rb +46 -0
- data/lib/locomotive/liquid/drops/page.rb +1 -1
- data/lib/locomotive/liquid/filters/text.rb +1 -1
- data/lib/locomotive/liquid/tags/nav.rb +7 -4
- data/public/images/admin/icons/actions.png +0 -0
- data/public/images/admin/menu/icons/assets.png +0 -0
- data/public/javascripts/admin/application.js +3 -0
- data/public/javascripts/admin/pages.js +1 -1
- data/public/javascripts/admin/plugins/shortcut.js +55 -0
- data/public/stylesheets/admin/application.css +1 -1
- data/public/stylesheets/admin/buttons.css +8 -13
- data/public/stylesheets/admin/formtastic_changes.css +1 -2
- data/public/stylesheets/admin/layout.css +24 -12
- data/public/stylesheets/admin/menu.css +3 -3
- data/spec/factories.rb +1 -1
- data/spec/lib/locomotive/liquid/tags/nav_spec.rb +11 -2
- data/spec/models/membership_spec.rb +5 -4
- data/spec/models/page_spec.rb +10 -8
- metadata +30 -6
- data/lib/generators/locomotive/assets/assets_generator.rb +0 -16
@@ -3,36 +3,23 @@ module Admin
|
|
3
3
|
|
4
4
|
sections 'settings'
|
5
5
|
|
6
|
-
def new
|
7
|
-
@membership = current_site.memberships.build
|
8
|
-
end
|
9
|
-
|
10
6
|
def create
|
11
7
|
@membership = current_site.memberships.build(params[:membership])
|
12
8
|
|
13
|
-
case @membership.
|
9
|
+
case @membership.process!
|
14
10
|
when :create_account
|
15
11
|
redirect_to new_admin_account_url(:email => @membership.email)
|
16
12
|
when :save_it
|
17
|
-
|
18
|
-
flash_success!
|
19
|
-
redirect_to edit_admin_site_url
|
13
|
+
respond_with @membership, :location => edit_admin_current_site_url
|
20
14
|
when :error
|
21
|
-
|
22
|
-
render :action => 'new'
|
15
|
+
respond_with @membership, :flash => true
|
23
16
|
when :nothing
|
24
|
-
|
25
|
-
redirect_to edit_admin_site_url
|
17
|
+
respond_with @membership, :alert => t('flash.admin.memberships.create.already_created'), :location => edit_admin_current_site_url
|
26
18
|
end
|
27
19
|
end
|
28
20
|
|
29
21
|
def destroy
|
30
|
-
|
31
|
-
current_site.save
|
32
|
-
|
33
|
-
flash_success!
|
34
|
-
|
35
|
-
redirect_to edit_admin_site_url
|
22
|
+
destroy! { edit_admin_current_site_url }
|
36
23
|
end
|
37
24
|
|
38
25
|
end
|
@@ -3,19 +3,21 @@ module Admin
|
|
3
3
|
|
4
4
|
sections 'settings', 'account'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
actions :edit, :update
|
7
|
+
|
8
|
+
respond_to :json, :only => :update
|
9
9
|
|
10
10
|
def update
|
11
|
+
update! { edit_admin_my_account_url }
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def resource
|
11
17
|
@account = current_admin
|
12
|
-
if @account.update_attributes(params[:account])
|
13
|
-
flash_success!
|
14
|
-
redirect_to edit_admin_my_account_url
|
15
|
-
else
|
16
|
-
render :action => :edit
|
17
|
-
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def begin_of_association_chain; nil; end # not related directly to current_site
|
21
|
+
|
20
22
|
end
|
21
23
|
end
|
@@ -2,6 +2,8 @@ module Admin
|
|
2
2
|
class PagesController < BaseController
|
3
3
|
|
4
4
|
sections 'contents'
|
5
|
+
|
6
|
+
respond_to :json, :only => [:update, :sort]
|
5
7
|
|
6
8
|
def index
|
7
9
|
@pages = current_site.pages.roots
|
@@ -11,60 +13,19 @@ module Admin
|
|
11
13
|
@page = current_site.pages.build
|
12
14
|
@page.parts << PagePart.build_body_part
|
13
15
|
end
|
14
|
-
|
15
|
-
def edit
|
16
|
-
@page = current_site.pages.find(params[:id])
|
17
|
-
end
|
18
|
-
|
19
|
-
def create
|
20
|
-
@page = current_site.pages.build(params[:page])
|
21
|
-
|
22
|
-
if @page.save
|
23
|
-
flash_success!
|
24
|
-
redirect_to edit_admin_page_url(@page)
|
25
|
-
else
|
26
|
-
flash_error!
|
27
|
-
render :action => 'new'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def update
|
32
|
-
@page = current_site.pages.find(params[:id])
|
33
|
-
|
34
|
-
if @page.update_attributes(params[:page])
|
35
|
-
flash_success!
|
36
|
-
redirect_to edit_admin_page_url(@page)
|
37
|
-
else
|
38
|
-
flash_error!
|
39
|
-
render :action => "edit"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
16
|
+
|
43
17
|
def sort
|
44
18
|
@page = current_site.pages.find(params[:id])
|
45
19
|
@page.sort_children!(params[:children])
|
46
20
|
|
47
|
-
|
21
|
+
respond_with @page
|
48
22
|
end
|
49
|
-
|
23
|
+
|
50
24
|
def get_path
|
51
25
|
page = current_site.pages.build(:parent => current_site.pages.find(params[:parent_id]), :slug => params[:slug].slugify)
|
52
26
|
|
53
27
|
render :json => { :url => page.url, :slug => page.slug }
|
54
28
|
end
|
55
|
-
|
56
|
-
def destroy
|
57
|
-
@page = current_site.pages.find(params[:id])
|
58
|
-
|
59
|
-
begin
|
60
|
-
@page.destroy
|
61
|
-
flash_success!
|
62
|
-
rescue Exception => e
|
63
|
-
flash[:error] = e.to_s
|
64
|
-
end
|
65
|
-
|
66
|
-
redirect_to admin_pages_url
|
67
|
-
end
|
68
|
-
|
29
|
+
|
69
30
|
end
|
70
31
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Admin
|
2
|
+
class SitemapsController < ActionController::Base
|
3
|
+
|
4
|
+
include Locomotive::Routing::SiteDispatcher
|
5
|
+
|
6
|
+
before_filter :require_site
|
7
|
+
|
8
|
+
respond_to :xml
|
9
|
+
|
10
|
+
def show
|
11
|
+
@pages = current_site.pages.published
|
12
|
+
@host = request.host
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -3,35 +3,28 @@ module Admin
|
|
3
3
|
|
4
4
|
sections 'settings'
|
5
5
|
|
6
|
-
def new
|
7
|
-
@site = Site.new
|
8
|
-
end
|
9
|
-
|
10
6
|
def create
|
11
7
|
@site = Site.new(params[:site])
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
flash_success!
|
16
|
-
redirect_to edit_admin_my_account_url
|
17
|
-
else
|
18
|
-
flash_error!
|
19
|
-
render :action => 'new'
|
20
|
-
end
|
8
|
+
@site.memberships.build :account => @current_admin, :admin => true
|
9
|
+
|
10
|
+
create! { edit_admin_my_account_url }
|
21
11
|
end
|
22
|
-
|
12
|
+
|
23
13
|
def destroy
|
24
14
|
@site = current_admin.sites.detect { |s| s._id == params[:id] }
|
25
|
-
|
15
|
+
|
26
16
|
if @site != current_site
|
27
17
|
@site.destroy
|
28
|
-
flash_success!
|
29
18
|
else
|
30
|
-
|
19
|
+
@site.errors.add(:base, 'Can not destroy the site you are logging in now')
|
31
20
|
end
|
32
21
|
|
33
|
-
|
22
|
+
respond_with @site, :location => edit_admin_my_account_url
|
34
23
|
end
|
35
|
-
|
24
|
+
|
25
|
+
protected
|
26
|
+
|
27
|
+
def begin_of_association_chain; nil; end # not related directly to current_site
|
28
|
+
|
36
29
|
end
|
37
30
|
end
|
@@ -2,55 +2,12 @@ module Admin
|
|
2
2
|
class SnippetsController < BaseController
|
3
3
|
|
4
4
|
sections 'settings'
|
5
|
+
|
6
|
+
respond_to :json, :only => :update
|
5
7
|
|
6
8
|
def index
|
7
9
|
@snippets = current_site.snippets.order_by([[:name, :asc]])
|
8
10
|
end
|
9
11
|
|
10
|
-
def new
|
11
|
-
@snippet = current_site.snippets.build
|
12
|
-
end
|
13
|
-
|
14
|
-
def edit
|
15
|
-
@snippet = current_site.snippets.find(params[:id])
|
16
|
-
end
|
17
|
-
|
18
|
-
def create
|
19
|
-
@snippet = current_site.snippets.build(params[:snippet])
|
20
|
-
|
21
|
-
if @snippet.save
|
22
|
-
flash_success!
|
23
|
-
redirect_to edit_admin_snippet_url(@snippet)
|
24
|
-
else
|
25
|
-
flash_error!
|
26
|
-
render :action => 'new'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def update
|
31
|
-
@snippet = current_site.snippets.find(params[:id])
|
32
|
-
|
33
|
-
if @snippet.update_attributes(params[:snippet])
|
34
|
-
flash_success!
|
35
|
-
redirect_to edit_admin_snippet_url(@snippet)
|
36
|
-
else
|
37
|
-
flash_error!
|
38
|
-
render :action => "edit"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def destroy
|
43
|
-
@snippet = current_site.snippets.find(params[:id])
|
44
|
-
|
45
|
-
begin
|
46
|
-
@snippet.destroy
|
47
|
-
flash_success!
|
48
|
-
rescue Exception => e
|
49
|
-
flash[:error] = e.to_s
|
50
|
-
end
|
51
|
-
|
52
|
-
redirect_to admin_snippets_url
|
53
|
-
end
|
54
|
-
|
55
12
|
end
|
56
13
|
end
|
@@ -5,6 +5,8 @@ module Admin
|
|
5
5
|
|
6
6
|
sections 'settings', 'theme_assets'
|
7
7
|
|
8
|
+
respond_to :json, :only => [:create, :update]
|
9
|
+
|
8
10
|
def index
|
9
11
|
assets = current_site.theme_assets.all
|
10
12
|
@non_image_assets = assets.find_all { |a| a.stylesheet? || a.javascript? }
|
@@ -12,69 +14,26 @@ module Admin
|
|
12
14
|
@flash_assets = assets.find_all { |a| a.movie? }
|
13
15
|
|
14
16
|
if request.xhr?
|
15
|
-
render :action => 'images', :layout => false
|
17
|
+
render :action => 'images', :layout => false and return
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
19
|
-
def new
|
20
|
-
@asset = current_site.theme_assets.build
|
21
|
-
end
|
22
|
-
|
23
|
-
def edit
|
24
|
-
@asset = current_site.theme_assets.find(params[:id])
|
25
|
-
end
|
26
|
-
|
27
21
|
def create
|
28
22
|
params[:theme_asset] = { :source => params[:file] } if params[:file]
|
29
23
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
format.json do
|
39
|
-
render :json => {
|
40
|
-
:status => 'success',
|
41
|
-
:name => truncate(@asset.slug, :length => 22),
|
42
|
-
:url => @asset.source.url,
|
43
|
-
:vignette_url => @asset.vignette_url
|
44
|
-
}
|
45
|
-
end
|
46
|
-
else
|
47
|
-
format.html do
|
48
|
-
flash_error!
|
49
|
-
render :action => 'new'
|
50
|
-
end
|
51
|
-
format.json do
|
52
|
-
render :json => { :status => 'error' }
|
53
|
-
end
|
24
|
+
create! do |success, failure|
|
25
|
+
success.json do
|
26
|
+
render :json => {
|
27
|
+
:status => 'success',
|
28
|
+
:name => truncate(@theme_asset.slug, :length => 22),
|
29
|
+
:url => @theme_asset.source.url,
|
30
|
+
:vignette_url => @theme_asset.vignette_url
|
31
|
+
}
|
54
32
|
end
|
33
|
+
failure.json { render :json => { :status => 'error' } }
|
55
34
|
end
|
56
35
|
end
|
57
|
-
|
58
|
-
def update
|
59
|
-
@asset = current_site.theme_assets.find(params[:id])
|
60
|
-
|
61
|
-
if @asset.update_attributes(params[:theme_asset])
|
62
|
-
flash_success!
|
63
|
-
redirect_to edit_admin_theme_asset_url(@asset)
|
64
|
-
else
|
65
|
-
flash_error!
|
66
|
-
render :action => 'edit'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def destroy
|
71
|
-
@asset = current_site.theme_assets.find(params[:id])
|
72
|
-
@asset.destroy
|
73
|
-
|
74
|
-
flash_success!
|
75
|
-
redirect_to admin_theme_assets_url
|
76
|
-
end
|
77
|
-
|
36
|
+
|
78
37
|
end
|
79
38
|
|
80
39
|
end
|
@@ -5,7 +5,7 @@ module Admin::AssetsHelper
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def image_dimensions_and_size(asset)
|
8
|
-
content_tag(:small, "#{asset.width}px x #{
|
8
|
+
content_tag(:small, "#{asset.width}px x #{asset.height}px | #{number_to_human_size(asset.size)}")
|
9
9
|
end
|
10
10
|
|
11
11
|
def allow_plain_text_editing?(asset)
|
@@ -17,7 +17,7 @@ module Admin::BaseHelper
|
|
17
17
|
def admin_button_tag(text, url, options = {})
|
18
18
|
text = text.is_a?(Symbol) ? t(".#{text}") : text
|
19
19
|
link_to(url, options) do
|
20
|
-
content_tag(:
|
20
|
+
content_tag(:em, escape_once(' ')) + text
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -50,5 +50,5 @@ module Admin::BaseHelper
|
|
50
50
|
def nocoffee_tag
|
51
51
|
link_to 'noCoffee', 'http://www.nocoffee.fr', :id => 'nocoffee'
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
end
|
@@ -1,5 +1,18 @@
|
|
1
1
|
module Admin::PagesHelper
|
2
2
|
|
3
|
+
def page_main_url(page)
|
4
|
+
url = ''
|
5
|
+
|
6
|
+
if page.site.domains.empty?
|
7
|
+
url = main_site_url(page.site)
|
8
|
+
else
|
9
|
+
url = "http://#{current_site.domains.first}"
|
10
|
+
url += ":#{request.port}" if request.port != 80
|
11
|
+
end
|
12
|
+
|
13
|
+
File.join(url, page.fullpath)
|
14
|
+
end
|
15
|
+
|
3
16
|
def parent_pages_options
|
4
17
|
roots = current_site.pages.roots.where(:slug.ne => '404').and(:_id.ne => @page.id)
|
5
18
|
|
data/app/models/membership.rb
CHANGED
@@ -21,14 +21,17 @@ class Membership
|
|
21
21
|
self.account = Account.where(:email => email).first
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
24
|
+
def process!
|
25
25
|
if @email.blank?
|
26
|
+
self.errors.add_on_blank(:email)
|
26
27
|
:error
|
27
28
|
elsif self.account.nil?
|
28
29
|
:create_account
|
29
30
|
elsif self.site.memberships.find_all { |m| m.account_id == self.account_id }.size > 1
|
31
|
+
self.errors.add(:base, 'Already created')
|
30
32
|
:nothing
|
31
33
|
else
|
34
|
+
self.save
|
32
35
|
:save_it
|
33
36
|
end
|
34
37
|
end
|
data/app/models/page.rb
CHANGED
@@ -33,6 +33,7 @@ class Page
|
|
33
33
|
named_scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb
|
34
34
|
named_scope :index, :where => { :slug => 'index', :depth => 0, :published => true }
|
35
35
|
named_scope :not_found, :where => { :slug => '404', :depth => 0, :published => true }
|
36
|
+
named_scope :published, :where => { :published => true }
|
36
37
|
|
37
38
|
## behaviours ##
|
38
39
|
liquify_template :joined_parts
|
@@ -47,6 +48,10 @@ class Page
|
|
47
48
|
self.slug == '404' && self.depth.to_i == 0
|
48
49
|
end
|
49
50
|
|
51
|
+
def index_or_not_found?
|
52
|
+
self.index? || self.not_found?
|
53
|
+
end
|
54
|
+
|
50
55
|
def fullpath(force = false)
|
51
56
|
if read_attribute(:fullpath).present? && !force
|
52
57
|
return read_attribute(:fullpath)
|
@@ -79,8 +84,10 @@ class Page
|
|
79
84
|
return if (self.site rescue nil).nil?
|
80
85
|
|
81
86
|
if self.index? || self.not_found?
|
82
|
-
|
87
|
+
self.errors[:base] << I18n.t('errors.messages.protected_page')
|
83
88
|
end
|
89
|
+
|
90
|
+
self.errors.empty?
|
84
91
|
end
|
85
92
|
|
86
93
|
def normalize_slug
|