cardboard_cms 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75333a699fb1dccadb5e0e997b8c7a500ba5b9dd
4
- data.tar.gz: 055466fb6267926f0b78c134a82598d7aa5b6364
3
+ metadata.gz: e0c9ba046a708dba52e5848d89dd284ee9bcec1e
4
+ data.tar.gz: 5171f5d82832e70ff0ed47c8200a2539837561bd
5
5
  SHA512:
6
- metadata.gz: 1e4f0901db574ea6abdfc3a8c3390690741a06e0c4d4aedb3d2c29594267f3e3c031b2942b649d9103bd8ce62f3d91e09fb48040047680bc6345329214ad7bc1
7
- data.tar.gz: 6fe7a9005e459619530949535a6bdaf23c021299e4c97b654e83192e5529198db8ba2ad61f93468019702562a730619c4cafb920ec5a141ad47bf708890b5855
6
+ metadata.gz: 7e37d4374060af4c6cddc1ac86988f8bd6822b57213ae7cdbf46e7911ad2fe445fc0842f57c6a1e4f316ba42aaaacaba226fbdc2c2c646a32508151304a44e07
7
+ data.tar.gz: f368b5dbcc53f777e18498b3c792336bb259b1447c98b4229290a018355cbd693211cacb68c9cbea421b8c1cedf1124550cba3bfd4b6db801fc9927c9c4e67ec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cardboard_cms (0.2.1)
4
+ cardboard_cms (0.2.2)
5
5
  bootstrap-datepicker-rails
6
6
  bootstrap-sass (~> 2.2)
7
7
  bootstrap-wysihtml5-rails
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", github: "smashingboxes/cardboard"
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
- position: 0
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
- $('select[data-search-select]').select2({allowClear: true, width: "resolve"});
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){
@@ -30,6 +30,7 @@
30
30
  }
31
31
 
32
32
  #main_content{
33
+ min-width: $site_min_width;
33
34
  background: $content_background;
34
35
  }
35
36
 
@@ -17,7 +17,7 @@ $main_topbar_zindex: 100;
17
17
  @include border-radius(0px);
18
18
  border: none;
19
19
  padding: 0px 10px;
20
- min-width: 760px;
20
+ min-width: $site_min_width;
21
21
  a{color: $main_topbar_color;}
22
22
  text-shadow: $main_topbar_color_text_shadow;
23
23
 
@@ -8,6 +8,7 @@ $content_sidebar_width: 280px !default;
8
8
  $content_background: #f4f7f9 !default;
9
9
  $brand_color: #f9334a !default;
10
10
  $table_head: #E1E1E1 !default;
11
+ $site_min_width: 780px !default;
11
12
 
12
13
  // Overwrite as needed
13
14
  // //
@@ -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 ||= Cardboard::Page.find_by_url(params[:id]) || Cardboard::Page.root
27
- # || raise(ActionController::RoutingError.new("No root page, make sure to run `rake cardboard:seed`"))
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, :value => "Cardboard::Field::#{field[:type].camelize}"
13
- = w.hidden_field :identifier, :value => 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
- => link_to pages_new_path, class:"btn btn-primary" do
3
- i.icon-plus
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
- li
10
- a href="#link_pane_1" data-toggle="pill" Pages
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
- div.tab-pane class="link_pages" id="link_pane_1"
18
- ul
19
- = nested_pages do |page, subpages|
20
- li
21
- = link_to page.title, "#", "data-url" => page.url
22
- = content_tag(:ul, subpages) if subpages
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 "http://fonts.googleapis.com/css?family=Roboto:300,400,500,700,900"
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="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"
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="http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(cardboard_user.email.downcase)}" width="23" height="23" style="width:23px !important;"
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.map{|x|x.controller_name}.each do |controller|
25
- if controller.singularize == controller && controller.pluralize != controller
26
- resource controller #singular controller
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
@@ -74,7 +74,6 @@ module Cardboard
74
74
  db_settings.update_attributes!(template: settings)
75
75
  self.populate_fields(settings, db_settings)
76
76
  end
77
- Cardboard::Setting.add("company_name", type: "string", default: Cardboard.application.site_title, seeding: true)
78
77
  end
79
78
 
80
79
  end
@@ -1,3 +1,3 @@
1
1
  module Cardboard
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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
- # # Page and Settings admin forms
2
- # # Example
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: true
16
+ # repeatable: Slide
17
17
  # fields:
18
- # image1:
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
- # position: 1
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
@@ -48,6 +48,6 @@ Cardboard.setup do |config|
48
48
  # link. For example :get, :delete, :put, etc..
49
49
  #
50
50
  # Default:
51
- # config.logout_link_method = :get
51
+ # config.logout_link_method = :delete
52
52
 
53
53
  end
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.1
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-02-18 00:00:00.000000000 Z
12
+ date: 2014-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails