cardboard_cms 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +8 -2
- data/app/assets/javascripts/cardboard/admin.js +5 -1
- data/app/assets/javascripts/cardboard/rich_text.js +5 -4
- data/app/assets/stylesheets/cardboard/_content.css.scss +1 -0
- data/app/assets/stylesheets/cardboard/_main_topbar.css.scss +1 -1
- data/app/assets/stylesheets/cardboard/_variables.scss +1 -0
- data/app/controllers/cardboard/resource_controller.rb +5 -0
- data/app/controllers/pages_controller.rb +7 -2
- data/app/models/cardboard/field/rich_text.rb +4 -0
- data/app/views/cardboard/pages/_part_fields.html.slim +5 -4
- data/app/views/cardboard/pages/_sidebar.html.slim +4 -3
- data/app/views/cardboard/rich_editor/_links_modal.html.slim +10 -8
- data/app/views/layouts/cardboard/_head.html.slim +2 -2
- data/app/views/layouts/cardboard/_main_sidebar.html.slim +1 -5
- data/app/views/layouts/cardboard/_main_topbar.html.slim +4 -3
- data/config/routes.rb +8 -5
- data/lib/cardboard/helpers/seed.rb +0 -1
- data/lib/cardboard/version.rb +1 -1
- data/lib/cardboard_cms.rb +15 -0
- data/lib/generators/cardboard/install/templates/cardboard.yml +13 -6
- data/test/dummy/config/initializers/cardboard.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0c9ba046a708dba52e5848d89dd284ee9bcec1e
|
4
|
+
data.tar.gz: 5171f5d82832e70ff0ed47c8200a2539837561bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e37d4374060af4c6cddc1ac86988f8bd6822b57213ae7cdbf46e7911ad2fe445fc0842f57c6a1e4f316ba42aaaacaba226fbdc2c2c646a32508151304a44e07
|
7
|
+
data.tar.gz: f368b5dbcc53f777e18498b3c792336bb259b1447c98b4229290a018355cbd693211cacb68c9cbea421b8c1cedf1124550cba3bfd4b6db801fc9927c9c4e67ec
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ Cardboard is a simple CMS Engine for your Rails 4 applications.
|
|
25
25
|
Add the gem to the `Gemfile`
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
gem "cardboard_cms"
|
28
|
+
gem "cardboard_cms"
|
29
29
|
```
|
30
30
|
|
31
31
|
And run `bundle install`.
|
@@ -104,7 +104,13 @@ pages:
|
|
104
104
|
type: image
|
105
105
|
required: true
|
106
106
|
default: CrashTest.jpg
|
107
|
-
|
107
|
+
pages:
|
108
|
+
two_column:
|
109
|
+
parts:
|
110
|
+
main:
|
111
|
+
fields:
|
112
|
+
body:
|
113
|
+
type: rich_text
|
108
114
|
```
|
109
115
|
|
110
116
|
pages, parts and fields take identifiers (home_page, slideshow and image1) used to reference the data form the views. Choose these names carefully!
|
@@ -31,8 +31,12 @@ $(document).on('click', '.nav-tabs a', function(e){
|
|
31
31
|
|
32
32
|
$(document).on("page:load ready cocoon:after-insert", function(e){
|
33
33
|
|
34
|
+
$('select[data-search-select]').each(function() {
|
35
|
+
var options = $(this).data("select2-options")
|
36
|
+
$(this).select2($.extend({allowClear: true, width: "resolve"}, options));
|
37
|
+
});
|
34
38
|
$('select:not([data-search-select])').selectpicker();
|
35
|
-
|
39
|
+
|
36
40
|
|
37
41
|
$('.nav-tabs a:first').tab('show');
|
38
42
|
|
@@ -49,10 +49,11 @@ var page_links_template = {
|
|
49
49
|
}
|
50
50
|
|
51
51
|
var rich_text_editor_defaults = {
|
52
|
-
image: false,
|
53
|
-
customTemplates: page_links_template,
|
54
|
-
parserRules: wysihtml5ParserRules,
|
55
|
-
useLineBreaks: false
|
52
|
+
"image": false,
|
53
|
+
"customTemplates": page_links_template,
|
54
|
+
"parserRules": wysihtml5ParserRules,
|
55
|
+
"useLineBreaks": false,
|
56
|
+
"font-styles": false
|
56
57
|
}
|
57
58
|
|
58
59
|
$(document).on("ready page:load", function(e){
|
@@ -7,6 +7,11 @@ class Cardboard::ResourceController < Cardboard::ApplicationController
|
|
7
7
|
|
8
8
|
before_filter :check_ability
|
9
9
|
|
10
|
+
def self.singular?
|
11
|
+
name = controller_name
|
12
|
+
name == name.singularize and name != name.pluralize
|
13
|
+
end
|
14
|
+
|
10
15
|
def collection
|
11
16
|
@q ||= end_of_association_chain.search(params[:q])
|
12
17
|
|
@@ -23,8 +23,13 @@ private
|
|
23
23
|
# helper_method :edit_link
|
24
24
|
|
25
25
|
def current_page
|
26
|
-
@page
|
27
|
-
|
26
|
+
return @page unless @page.nil?
|
27
|
+
@page = if params[:id].nil?
|
28
|
+
Cardboard::Page.root
|
29
|
+
else
|
30
|
+
Cardboard::Page.find_by_url(params[:id])
|
31
|
+
end
|
32
|
+
@page || raise(ActionController::RoutingError.new("Page not found"))
|
28
33
|
end
|
29
34
|
|
30
35
|
end
|
@@ -17,5 +17,9 @@ module Cardboard
|
|
17
17
|
return nil unless value_changed?
|
18
18
|
self.value = ActionController::Base.helpers.sanitize(self.value, :tags => %w(strong b i u em br p div span ul ol li a pre code blockquote h1 h2 h3), :attributes => %w(class style href src width height alt))
|
19
19
|
end
|
20
|
+
|
21
|
+
def is_required
|
22
|
+
errors.add(:value, "is required") if required_field? && ActionController::Base.helpers.strip_tags(value_uid).blank?
|
23
|
+
end
|
20
24
|
end
|
21
25
|
end
|
@@ -7,11 +7,12 @@
|
|
7
7
|
- part_hash[:fields].each do |field_identifier, field|
|
8
8
|
|
9
9
|
- fields = part.fields.find{|ob| ob.identifier == field_identifier}
|
10
|
-
|
10
|
+
- fields = part.fields.build(type: "Cardboard::Field::#{field[:type].camelize}", identifier: field_identifier, default: field[:default] ) if fields.blank?
|
11
|
+
|
11
12
|
= f.simple_fields_for :fields, fields do |w|
|
12
|
-
= w.hidden_field :type
|
13
|
-
= w.hidden_field :identifier
|
14
|
-
|
13
|
+
= w.hidden_field :type
|
14
|
+
= w.hidden_field :identifier
|
15
|
+
|
15
16
|
- begin
|
16
17
|
= render "cardboard/fields/#{field[:type]}", f: w, field: field, identifier: field_identifier
|
17
18
|
- rescue ActionView::MissingTemplate => e
|
@@ -1,8 +1,9 @@
|
|
1
1
|
form class="form-inline"
|
2
|
-
|
3
|
-
|
2
|
+
- if Cardboard.used_with_templates?
|
3
|
+
=> link_to pages_new_path, class:"btn btn-primary" do
|
4
|
+
i.icon-plus
|
4
5
|
|
5
|
-
.input-append style="width: 160px"
|
6
|
+
.input-append style=(Cardboard.used_with_templates?? "width: 160px" : nil)
|
6
7
|
input id="sidebar_page_search" type="text" placeholder="Search Pages"
|
7
8
|
button type="submit" class="btn"
|
8
9
|
i.icon-search
|
@@ -6,20 +6,22 @@ li
|
|
6
6
|
|
7
7
|
.modal-body
|
8
8
|
ul class="nav nav-pills"
|
9
|
-
|
10
|
-
|
9
|
+
- if Cardboard.used_with_pages?
|
10
|
+
li
|
11
|
+
a href="#link_pane_1" data-toggle="pill" Pages
|
11
12
|
li
|
12
13
|
a href="#link_pane_2" data-toggle="pill" URL
|
13
14
|
li
|
14
15
|
a href="#link_pane_3" data-toggle="pill" Email
|
15
16
|
|
16
17
|
div class="tab-content"
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
- if Cardboard.used_with_pages?
|
19
|
+
div.tab-pane class="link_pages" id="link_pane_1"
|
20
|
+
ul
|
21
|
+
= nested_pages do |page, subpages|
|
22
|
+
li
|
23
|
+
= link_to page.title, "#", "data-url" => page.url
|
24
|
+
= content_tag(:ul, subpages) if subpages
|
23
25
|
|
24
26
|
div.tab-pane id="link_pane_2"
|
25
27
|
input placeholder='http://website.com' class='input-xlarge' value='http://'
|
@@ -4,13 +4,13 @@ title
|
|
4
4
|
| Cardboard CMS
|
5
5
|
|
6
6
|
= stylesheet_link_tag "cardboard"
|
7
|
-
= stylesheet_link_tag "
|
7
|
+
= stylesheet_link_tag "https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900"
|
8
8
|
/ = stylesheet_link_tag "http://fonts.googleapis.com/css?family=Montserrat:400,700"
|
9
9
|
|
10
10
|
= csrf_meta_tags
|
11
11
|
|
12
12
|
/[if lt IE 9]
|
13
|
-
script src="
|
13
|
+
script src="https://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"
|
14
14
|
|
15
15
|
= javascript_include_tag 'cardboard'
|
16
16
|
= include_gon
|
@@ -5,8 +5,4 @@
|
|
5
5
|
|
6
6
|
- Cardboard.resource_controllers.reject{|x|x.menu == false}.sort! { |a,b| a.menu[:priority] <=> b.menu[:priority] }.each do |controller|
|
7
7
|
- if cardboard_user_can_manage?(controller.controller_name.to_sym)
|
8
|
-
= main_sidebar_nav_link controller.menu[:label], {controller: controller.controller_name, action: :index}, class: "nav_resource_link"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
= main_sidebar_nav_link controller.menu[:label], {controller: controller.controller_name, action: controller.singular? ? :show : :index}, class: "nav_resource_link"
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#cardboard_logo CB
|
4
4
|
|
5
5
|
= link_to main_app.root_path, id: "brand" do
|
6
|
-
= Cardboard::Setting.company_name
|
6
|
+
= Cardboard::Setting.company_name || Cardboard.application.site_title
|
7
7
|
|
8
8
|
ul.nav.pull-right
|
9
9
|
|
@@ -11,17 +11,18 @@
|
|
11
11
|
= link_to dashboard_path do
|
12
12
|
i.icon-dashboard
|
13
13
|
' Dashboard
|
14
|
-
- if cardboard_user_can_manage?(:settings)
|
14
|
+
- if cardboard_user_can_manage?(:settings) && Cardboard.used_with_settings?
|
15
15
|
li
|
16
16
|
= link_to settings_path do
|
17
17
|
i.icon-cogs
|
18
18
|
| Settings
|
19
|
+
|
19
20
|
|
20
21
|
li.divider
|
21
22
|
|
22
23
|
li.dropdown.third
|
23
24
|
a.dropdown-toggle data-toggle="dropdown" href="#"
|
24
|
-
img alt="Avatar" src="
|
25
|
+
img alt="Avatar" src="https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(cardboard_user.email.downcase)}" width="23" height="23" style="width:23px !important;"
|
25
26
|
span.user-name.hidden-phone
|
26
27
|
= cardboard_user.email
|
27
28
|
b class="caret"
|
data/config/routes.rb
CHANGED
@@ -21,11 +21,14 @@ Cardboard::Engine.routes.draw do
|
|
21
21
|
|
22
22
|
scope as: 'cardboard' do
|
23
23
|
#generate routes for custom cardboard resources controllers
|
24
|
-
Cardboard.resource_controllers.
|
25
|
-
if controller.
|
26
|
-
|
24
|
+
Cardboard.resource_controllers.each do |controller|
|
25
|
+
if controller.singular?
|
26
|
+
# Singular controller names are non-standard in rails. We must specify the
|
27
|
+
# controller explicitly here to keep the name from
|
28
|
+
# being pluralized in the route.
|
29
|
+
resource controller.controller_name, controller: controller.controller_name
|
27
30
|
else
|
28
|
-
resources controller
|
31
|
+
resources controller.controller_name
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -52,4 +55,4 @@ Rails.application.routes.named_routes.module.module_eval do
|
|
52
55
|
return nil unless url = page_path(identifier, options)
|
53
56
|
root_url + url[1..-1]
|
54
57
|
end
|
55
|
-
end
|
58
|
+
end
|
data/lib/cardboard/version.rb
CHANGED
data/lib/cardboard_cms.rb
CHANGED
@@ -25,6 +25,21 @@ module Cardboard
|
|
25
25
|
@used_as_cms
|
26
26
|
end
|
27
27
|
|
28
|
+
def used_with_pages?
|
29
|
+
@used_with_pages = Cardboard::Template.where("is_page = ?", true).count > 0 if @used_with_pages.nil? #handle false
|
30
|
+
@used_with_pages
|
31
|
+
end
|
32
|
+
|
33
|
+
def used_with_templates?
|
34
|
+
@used_with_templates = Cardboard::Template.where("is_page = ? OR is_page IS NULL", false).count > 0 if @used_with_templates.nil? #handle false
|
35
|
+
@used_with_templates
|
36
|
+
end
|
37
|
+
|
38
|
+
def used_with_settings?
|
39
|
+
@used_with_settings = Cardboard::Setting.count > 0 if @used_with_settings.nil? #handle false
|
40
|
+
@used_with_settings
|
41
|
+
end
|
42
|
+
|
28
43
|
def set_resource_controllers
|
29
44
|
# might not be needed in production
|
30
45
|
Dir[Rails.root.join('app/controllers/cardboard/*_controller.rb')].map.each do |controller|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# #
|
2
|
-
|
1
|
+
# # Pages, Templates and Settings
|
2
|
+
|
3
3
|
# pages:
|
4
4
|
# home:
|
5
5
|
# title: Welcome
|
@@ -13,16 +13,23 @@
|
|
13
13
|
# show_slideshow:
|
14
14
|
# type: boolean
|
15
15
|
# slideshow:
|
16
|
-
# repeatable:
|
16
|
+
# repeatable: Slide
|
17
17
|
# fields:
|
18
|
-
#
|
18
|
+
# image:
|
19
19
|
# type: image
|
20
|
-
# position: 0
|
21
20
|
# description:
|
22
21
|
# hint: This will be visible on mouse over
|
23
22
|
# type: string
|
24
23
|
# required: false
|
25
|
-
#
|
24
|
+
# templates:
|
25
|
+
# two_column:
|
26
|
+
# parts:
|
27
|
+
# main:
|
28
|
+
# fields:
|
29
|
+
# body:
|
30
|
+
# type: rich_text
|
31
|
+
# sidebar:
|
32
|
+
# type: rich_text
|
26
33
|
# settings:
|
27
34
|
# more_fun:
|
28
35
|
# type: boolean
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cardboard_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Elfassy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|