caboose-cms 0.2.8 → 0.2.11

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.
@@ -1,4 +1,4 @@
1
- Copyright 2013 YOURNAME
1
+ Copyright 2013 William Barry
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -94,9 +94,9 @@ module Caboose
94
94
  # GET /pages/new
95
95
  def new
96
96
  return if !user_is_allowed('pages', 'add')
97
- @pages = Page.new
98
- @parent_id = params[:parent_id].nil? ? params[:parent_id] : -1
99
- render :layout => 'caboose/admin'
97
+ @parent_id = params[:parent_id].nil? ? params[:parent_id] : 1
98
+ @parent = Page.find(@parent_id)
99
+ render :layout => 'caboose/modal'
100
100
  end
101
101
 
102
102
  # GET /pages/1/redirect
@@ -21,7 +21,7 @@ class Caboose::PagePlugin < Caboose::CaboosePlugin
21
21
  #item['children'] << { 'id' => 'use_redirect_urls', 'href' => '#', 'text' => '' + (uru ? 'Disable' : 'Enable') + ' Redirect Urls' }
22
22
  end
23
23
  if (user.is_allowed('pages', 'add') || is_admin)
24
- item['children'] << { 'href' => "/pages/new?parent_id=#{page.id}" , 'text' => 'New Page' }
24
+ item['children'] << { 'href' => "/pages/new?parent_id=#{page.id}" , 'text' => 'New Page', 'modal' => true }
25
25
  end
26
26
  nav << item
27
27
  return nav
@@ -1,23 +1,37 @@
1
1
 
2
2
  <h1>New Page</h1>
3
- <div id='page_new_container'></div>
3
+ <p>Parent: <%= @parent ? @parent.title : "Home" %></p>
4
+ <input type='hidden' id='parent_id' name='parent_id' value='<%= @parent_id %>' />
5
+ <p><input type='text' id='title' name='title' placeholder='Title' style="width: 400px;" /></p>
6
+ <p><input type='submit' value='Add Page' onclick='add_page();' /></p>
4
7
 
5
8
  <% content_for :caboose_js do %>
9
+ <%= javascript_include_tag "caboose/model/all" %>
6
10
  <script type='text/javascript'>
7
11
 
8
- var page = false;
12
+ var modal = false;
9
13
  $(document).ready(function() {
14
+ modal = new CabooseModal(420);
15
+ });
10
16
 
11
- page = new Model({
12
- name: 'Page',
13
- id: 'new',
14
- attributes: [
15
- { name: 'parent_id' , type: 'select' , value: <%= @parent_id %>, options_url: '/pages/sitemap-options' },
16
- { name: 'title' , type: 'text' , value: '' }
17
- ]
17
+ function add_page()
18
+ {
19
+ modal.autosize("<p class='loading'>Adding page...</p>");
20
+ $.ajax({
21
+ url: '/pages',
22
+ type: 'post',
23
+ data: {
24
+ parent_id: $('#parent_id').val(),
25
+ title: $('#title').val()
26
+ },
27
+ success: function(resp) {
28
+ if (resp.error)
29
+ modal.autosize("<p class='note error'>" + resp.error + "</p>");
30
+ if (resp.redirect)
31
+ parent.window.location = resp.redirect
32
+ }
18
33
  });
19
-
20
- });
34
+ }
21
35
 
22
36
  </script>
23
37
  <% end %>
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.2.8'
2
+ VERSION = '0.2.11'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.2.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-11 00:00:00.000000000 Z
12
+ date: 2013-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails