locomotivecms 3.0.0.pre.alpha → 3.0.0.pre.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/api/locomotive/api/entities/site_entity.rb +4 -0
- data/app/api/locomotive/api/forms/site_form.rb +1 -1
- data/app/api/locomotive/api/resources/site_resource.rb +2 -0
- data/app/assets/javascripts/locomotive/utils/notify.js.coffee +13 -0
- data/app/assets/javascripts/locomotive/views/application_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_assets/dropzone_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_assets/edit_image_view.js.coffee +4 -2
- data/app/assets/javascripts/locomotive/views/pages/_form_view.js.coffee +14 -4
- data/app/assets/javascripts/locomotive/views/pages/edit_view.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/pages/list_view.js.coffee +2 -4
- data/app/assets/stylesheets/locomotive/components/_misc.scss +2 -1
- data/app/assets/stylesheets/locomotive/components/misc/_notify.scss +27 -0
- data/app/assets/stylesheets/locomotive/components/sidebar/_pages_tree.scss +1 -1
- data/app/controllers/locomotive/pages_controller.rb +6 -8
- data/app/helpers/locomotive/base_helper.rb +2 -3
- data/app/helpers/locomotive/custom_fields_helper.rb +2 -2
- data/app/helpers/locomotive/pages_helper.rb +17 -16
- data/app/helpers/locomotive/shared/pages_helper.rb +2 -2
- data/app/models/locomotive/concerns/page/layout.rb +4 -0
- data/app/models/locomotive/page.rb +2 -3
- data/app/models/locomotive/site.rb +0 -4
- data/app/services/locomotive/content_entry_service.rb +1 -0
- data/app/services/locomotive/page_service.rb +23 -51
- data/app/services/locomotive/page_tree_service.rb +64 -0
- data/app/views/locomotive/accounts/new.html.haml +2 -1
- data/app/views/locomotive/current_site/form/_main.html.haml +1 -1
- data/app/views/locomotive/custom_fields/select_options/edit.html.haml +1 -1
- data/app/views/locomotive/memberships/new.html.haml +1 -1
- data/app/views/locomotive/my_account/form/_actions.html.haml +1 -6
- data/app/views/locomotive/my_account/form/_main.html.haml +1 -1
- data/app/views/locomotive/pages/form/_main.html.haml +17 -3
- data/app/views/locomotive/pages/form/_tabs.html.haml +3 -5
- data/app/views/locomotive/pages/new.html.haml +8 -11
- data/app/views/locomotive/shared/_sidebar.html.haml +3 -0
- data/app/views/locomotive/shared/_sidebar_without_site.html.haml +2 -0
- data/app/views/locomotive/shared/header/_account_menu.html.haml +1 -1
- data/app/views/locomotive/shared/sidebar/_link.html.haml +1 -1
- data/app/views/locomotive/shared/sidebar/_my_account.html.haml +1 -1
- data/app/views/locomotive/shared/sidebar/_page.html.haml +6 -1
- data/app/views/locomotive/shared/sidebar/_pages.html.haml +1 -1
- data/app/views/locomotive/sites/new.html.haml +1 -1
- data/config/locales/admin_ui.en.yml +6 -16
- data/lib/locomotive/simple_form.rb +2 -2
- data/lib/locomotive/version.rb +4 -1
- data/spec/models/locomotive/concerns/page/layout_spec.rb +26 -0
- data/vendor/assets/javascripts/locomotive/bootstrap-notify.js +2 -0
- data/vendor/assets/javascripts/locomotive/resizeImage.js +0 -2
- metadata +10 -9
- data/app/views/locomotive/pages/_form.html.haml +0 -66
- data/app/views/locomotive/pages/_page.html.haml +0 -44
- data/vendor/assets/javascripts/locomotive/bootstrap-growl.js +0 -312
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10adf1633c36bc535a1fee5de2d222f04b412144
|
4
|
+
data.tar.gz: 941c8279d7f786e77f16a659745c9d3c74166172
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1023a316c88d96e7eb64e5b77c88027e1071f9b536fdd59d8db139a85f86160c44b8245f70829bd1fa8a91241dcc9bf4b6d87d10d9ad17298a99b11277367e3
|
7
|
+
data.tar.gz: bfd4756b7844f6013e639960b21a4ce8461a32b2c9af5cb6332d8a40abdf93eb294435975523a5d78173c491a7b9d120948e21f58b74fec81261235e7d58ec4d
|
@@ -4,7 +4,7 @@ module Locomotive
|
|
4
4
|
|
5
5
|
class SiteForm < BaseForm
|
6
6
|
|
7
|
-
attrs :name, :handle, :robots_txt, :locales, :domains, :timezone
|
7
|
+
attrs :name, :handle, :robots_txt, :locales, :domains, :timezone, :picture
|
8
8
|
|
9
9
|
attrs :seo_title, :meta_keywords, :meta_description, localized: true
|
10
10
|
|
@@ -64,6 +64,7 @@ module Locomotive
|
|
64
64
|
optional :locales, type: Array
|
65
65
|
optional :domains, type: Array
|
66
66
|
optional :timezone
|
67
|
+
optional :picture
|
67
68
|
end
|
68
69
|
end
|
69
70
|
post do
|
@@ -88,6 +89,7 @@ module Locomotive
|
|
88
89
|
optional :locales, type: Array
|
89
90
|
optional :domains, type: Array
|
90
91
|
optional :timezone
|
92
|
+
optional :picture
|
91
93
|
end
|
92
94
|
end
|
93
95
|
put ':id' do
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Locomotive.notify = (message, type) ->
|
2
|
+
icon = if type == 'danger'
|
3
|
+
'exclamation-triangle'
|
4
|
+
else if type == 'success'
|
5
|
+
'check'
|
6
|
+
else
|
7
|
+
'exclamation-circle'
|
8
|
+
|
9
|
+
$.notify { message: message, icon: "fa fa-#{icon}" },
|
10
|
+
type: type
|
11
|
+
placement:
|
12
|
+
from: 'bottom'
|
13
|
+
align: 'right'
|
@@ -32,7 +32,7 @@ class Locomotive.Views.ApplicationView extends Backbone.View
|
|
32
32
|
|
33
33
|
render_flash_messages: (messages) ->
|
34
34
|
_.each messages, (couple) ->
|
35
|
-
|
35
|
+
Locomotive.notify couple[1], couple[0]
|
36
36
|
|
37
37
|
automatic_max_height: ->
|
38
38
|
$(window).on 'resize', => @set_max_height()
|
@@ -38,7 +38,7 @@ class Locomotive.Views.ContentAssets.DropzoneView extends Backbone.View
|
|
38
38
|
form_data = new FormData()
|
39
39
|
|
40
40
|
_.each event.target.files || event.originalEvent.dataTransfer.files, (file, i) ->
|
41
|
-
form_data.append("content_assets[
|
41
|
+
form_data.append("content_assets[][source]", file)
|
42
42
|
|
43
43
|
@upload_files(form_data)
|
44
44
|
|
@@ -21,7 +21,8 @@ class Locomotive.Views.ContentAssets.EditImageView extends Backbone.View
|
|
21
21
|
@create_resize_popover()
|
22
22
|
|
23
23
|
create_cropper: ->
|
24
|
-
@$cropper
|
24
|
+
@$cropper = @$('.image-container > img')
|
25
|
+
@cropper_enabled = false
|
25
26
|
|
26
27
|
@set_cropper_height()
|
27
28
|
@$cropper.cropper
|
@@ -84,6 +85,7 @@ class Locomotive.Views.ContentAssets.EditImageView extends Backbone.View
|
|
84
85
|
.then (image) =>
|
85
86
|
@width = width
|
86
87
|
@height = height
|
88
|
+
@cropper_enabled = true
|
87
89
|
@$cropper.cropper('replace', image.src)
|
88
90
|
@set_cropper_height()
|
89
91
|
$btn.button('reset')
|
@@ -99,7 +101,7 @@ class Locomotive.Views.ContentAssets.EditImageView extends Backbone.View
|
|
99
101
|
return unless @cropper_enabled
|
100
102
|
|
101
103
|
$link = $(event.target).closest('.apply-btn')
|
102
|
-
image_url = @$cropper.cropper('getDataURL')
|
104
|
+
image_url = @$cropper.cropper('getDataURL') || @$cropper.attr('src')
|
103
105
|
blob = window.dataURLtoBlob(image_url)
|
104
106
|
|
105
107
|
form_data = new FormData()
|
@@ -1,10 +1,20 @@
|
|
1
|
-
|
1
|
+
#= require ../shared/form_view
|
2
2
|
|
3
|
-
|
3
|
+
Locomotive.Views.Pages ||= {}
|
4
|
+
|
5
|
+
class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
|
6
|
+
|
7
|
+
el: '#content'
|
8
|
+
|
9
|
+
initialize: ->
|
10
|
+
@attach_events_on_redirect_attribute()
|
11
|
+
|
12
|
+
attach_events_on_redirect_attribute: ->
|
13
|
+
@$('#page_redirect').on 'switchChange.bootstrapSwitch', (event, state) ->
|
14
|
+
$inputs = $('.locomotive_page_redirect_url, .locomotive_page_redirect_type')
|
15
|
+
$inputs.toggleClass('hide')
|
4
16
|
|
5
|
-
# class Locomotive.Views.Pages.FormView extends Locomotive.Views.Shared.FormView
|
6
17
|
|
7
|
-
# el: '#content'
|
8
18
|
|
9
19
|
# events:
|
10
20
|
# 'change #page_parent_id': 'change_page_url'
|
@@ -70,10 +70,8 @@ class Locomotive.Views.Pages.ListView extends Backbone.View
|
|
70
70
|
error: @.on_failed_sort
|
71
71
|
|
72
72
|
on_successful_sort: (data, status, xhr) ->
|
73
|
-
|
74
|
-
type: 'success'
|
73
|
+
Locomotive.notify decodeURIComponent($.parseJSON(xhr.getResponseHeader('X-Message'))), 'success'
|
75
74
|
|
76
75
|
on_failed_sort: (data, status, xhr) ->
|
77
|
-
|
78
|
-
type: 'error'
|
76
|
+
Locomotive.notify decodeURIComponent($.parseJSON(xhr.getResponseHeader('X-Message'))), 'error'
|
79
77
|
|
@@ -1 +1,2 @@
|
|
1
|
-
@import "misc/nav";
|
1
|
+
@import "misc/nav";
|
2
|
+
@import "misc/notify";
|
@@ -0,0 +1,27 @@
|
|
1
|
+
[data-notify="container"] {
|
2
|
+
border: none;
|
3
|
+
|
4
|
+
[data-notify="icon"] {
|
5
|
+
font-size: 18px;
|
6
|
+
margin-right: 9px;
|
7
|
+
color: #fff;
|
8
|
+
}
|
9
|
+
|
10
|
+
[data-notify="message"] {
|
11
|
+
color: #fff;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
[data-notify="container"].alert-success {
|
16
|
+
background-color: $brand-success;
|
17
|
+
}
|
18
|
+
|
19
|
+
[data-notify="container"].alert-danger {
|
20
|
+
background-color: $brand-danger;
|
21
|
+
}
|
22
|
+
|
23
|
+
[data-notify="container"].alert-info {
|
24
|
+
[data-notify="icon"], [data-notify="message"] {
|
25
|
+
color: $state-info-text;
|
26
|
+
}
|
27
|
+
}
|
@@ -11,12 +11,6 @@ module Locomotive
|
|
11
11
|
|
12
12
|
respond_to :json, only: [:sort]
|
13
13
|
|
14
|
-
def index
|
15
|
-
authorize Page
|
16
|
-
@pages = current_site.all_pages_in_once
|
17
|
-
respond_with(@pages)
|
18
|
-
end
|
19
|
-
|
20
14
|
def new
|
21
15
|
authorize Page
|
22
16
|
@page = current_site.pages.build
|
@@ -25,7 +19,7 @@ module Locomotive
|
|
25
19
|
|
26
20
|
def create
|
27
21
|
authorize Page
|
28
|
-
@page =
|
22
|
+
@page = service.create(page_params)
|
29
23
|
respond_with @page, location: -> { edit_page_path(current_site, @page) }
|
30
24
|
end
|
31
25
|
|
@@ -36,7 +30,7 @@ module Locomotive
|
|
36
30
|
|
37
31
|
def update
|
38
32
|
authorize @page
|
39
|
-
@page
|
33
|
+
service.update(@page, page_params)
|
40
34
|
respond_with @page, location: edit_page_path(current_site, @page)
|
41
35
|
end
|
42
36
|
|
@@ -62,5 +56,9 @@ module Locomotive
|
|
62
56
|
params.require(:page).permit(:title, :parent_id, :listed, :published)
|
63
57
|
end
|
64
58
|
|
59
|
+
def service
|
60
|
+
@service ||= Locomotive::PageService.new(current_site)
|
61
|
+
end
|
62
|
+
|
65
63
|
end
|
66
64
|
end
|
@@ -125,9 +125,8 @@ module Locomotive
|
|
125
125
|
|
126
126
|
def flash_key_to_bootstrap_alert(key)
|
127
127
|
case key.to_sym
|
128
|
-
when :notice
|
129
|
-
when :alert then :
|
130
|
-
when :error then :warning
|
128
|
+
when :notice then :success
|
129
|
+
when :alert, :error then :danger
|
131
130
|
else
|
132
131
|
:info
|
133
132
|
end
|
@@ -25,17 +25,17 @@ module Locomotive
|
|
25
25
|
list
|
26
26
|
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
def display_page_layouts?
|
29
|
+
((@page.persisted? && @page.allow_layout?) || !@page.persisted?) &&
|
30
|
+
!current_site.pages.layouts.empty?
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
def options_for_page_layouts
|
34
|
+
layouts = current_site.pages.layouts.map do |_layout|
|
35
|
+
[_layout.title, _layout._id]
|
36
|
+
end
|
37
|
+
[[t(:no_layout, scope: 'locomotive.pages.form'), nil]] + layouts
|
38
|
+
end
|
39
39
|
|
40
40
|
# def options_for_page_response_type
|
41
41
|
# [
|
@@ -46,12 +46,13 @@ module Locomotive
|
|
46
46
|
# ]
|
47
47
|
# end
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
49
|
+
def options_for_page_redirect_type
|
50
|
+
puts t('.redirect_type.permanent').inspect
|
51
|
+
[
|
52
|
+
[t('.redirect_type.permanent'), 301],
|
53
|
+
[t('.redirect_type.temporary'), 302]
|
54
|
+
]
|
55
|
+
end
|
55
56
|
|
56
57
|
# def page_response_type_to_string(page)
|
57
58
|
# options_for_page_response_type.detect { |t| t.last == page.response_type }.try(:first) || '—'
|
@@ -10,7 +10,7 @@ module Locomotive
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def build_page_tree
|
13
|
-
@page_tree ||= Locomotive::
|
13
|
+
@page_tree ||= Locomotive::PageTreeService.new(current_site).build_tree
|
14
14
|
end
|
15
15
|
|
16
16
|
class Node < Struct.new(:page, :children, :controller)
|
@@ -20,7 +20,7 @@ module Locomotive
|
|
20
20
|
def_delegators :page, :_id, :title, :index_or_not_found?, :published?, :templatized?, :translated?, :redirect?, :response_type
|
21
21
|
|
22
22
|
def fold_state
|
23
|
-
controller.send(:cookies)["node-#{_id}"] != '
|
23
|
+
controller.send(:cookies)["node-#{_id}"] != 'unfolded' ? 'folded' : 'unfolded'
|
24
24
|
end
|
25
25
|
|
26
26
|
def nodes
|
@@ -3,19 +3,18 @@ module Locomotive
|
|
3
3
|
|
4
4
|
include Locomotive::Mongoid::Document
|
5
5
|
|
6
|
-
MINIMAL_ATTRIBUTES = %w(_id title slug fullpath position depth published templatized target_klass_name redirect listed response_type parent_id parent_ids site_id created_at updated_at raw_template)
|
6
|
+
MINIMAL_ATTRIBUTES = %w(_id title slug fullpath position depth published templatized target_klass_name redirect listed response_type parent_id parent_ids site_id created_at updated_at raw_template is_layout)
|
7
7
|
|
8
8
|
## concerns ##
|
9
9
|
include Concerns::Page::Tree
|
10
10
|
include Concerns::Page::EditableElements
|
11
11
|
include Concerns::Page::Layout
|
12
|
-
# include Concerns::Page::Parse
|
13
|
-
# include Concerns::Page::Render
|
14
12
|
include Concerns::Page::Templatized
|
15
13
|
include Concerns::Page::Redirect
|
16
14
|
include Concerns::Page::Listed
|
17
15
|
include Concerns::Shared::Slug
|
18
16
|
include Concerns::Shared::Seo
|
17
|
+
include Concerns::Shared::Userstamp
|
19
18
|
|
20
19
|
## fields ##
|
21
20
|
field :title, localize: true
|
@@ -43,10 +43,6 @@ module Locomotive
|
|
43
43
|
|
44
44
|
## methods ##
|
45
45
|
|
46
|
-
def all_pages_in_once
|
47
|
-
PageService.new(self).build_tree
|
48
|
-
end
|
49
|
-
|
50
46
|
# Get all the pages in the right order: depth and position, both ASC.
|
51
47
|
#
|
52
48
|
# @param [ Hash ] conditions Extra conditions passed to the Mongoid criteria
|
@@ -1,63 +1,35 @@
|
|
1
1
|
module Locomotive
|
2
2
|
|
3
|
-
class PageService < Struct.new(:site)
|
3
|
+
class PageService < Struct.new(:site, :account)
|
4
4
|
|
5
|
-
#
|
6
|
-
#
|
7
|
-
# the mongodb returns the minimal set of required attributes to build
|
8
|
-
# the tree.
|
5
|
+
# Create a page from the attributes passed in parameter.
|
6
|
+
# It sets the created_by column with the current account.
|
9
7
|
#
|
10
|
-
# @
|
8
|
+
# @param [ Hash ] attributes The attributes of new page.
|
11
9
|
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
# move the "page not found" (404) at the end of the array
|
19
|
-
page_not_found = page
|
20
|
-
elsif page.index?
|
21
|
-
# make the index page without children
|
22
|
-
tree << [page, nil]
|
23
|
-
else
|
24
|
-
tree << _build_tree(page, pages)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
tree << [page_not_found, nil]
|
10
|
+
# @return [ Object ] An instance of the page.
|
11
|
+
#
|
12
|
+
def create(attributes)
|
13
|
+
site.pages.build(attributes).tap do |page|
|
14
|
+
page.created_by = account if account
|
15
|
+
page.save
|
29
16
|
end
|
30
17
|
end
|
31
18
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
while !pages.empty?
|
47
|
-
page = pages[i]
|
48
|
-
|
49
|
-
break if page.nil? # end of the array
|
50
|
-
|
51
|
-
if page.parent_id == current_page.id
|
52
|
-
page = pages.delete_at(i)
|
53
|
-
|
54
|
-
children << _build_tree(page, pages)
|
55
|
-
else
|
56
|
-
i += 1
|
57
|
-
end
|
19
|
+
# Update a page from the attributes passed in parameter.
|
20
|
+
# It sets the updated_by column with the current account.
|
21
|
+
#
|
22
|
+
# @param [ Object ] entry The page to update.
|
23
|
+
# @param [ Hash ] attributes The attributes of new page.
|
24
|
+
#
|
25
|
+
# @return [ Object ] The instance of the page.
|
26
|
+
#
|
27
|
+
def update(page, attributes)
|
28
|
+
page.tap do
|
29
|
+
page.attributes = attributes
|
30
|
+
page.updated_by = account
|
31
|
+
page.save
|
58
32
|
end
|
59
|
-
|
60
|
-
[current_page, children]
|
61
33
|
end
|
62
34
|
|
63
35
|
end
|