activeadmin_cms 0.0.2 → 0.0.3

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTliNzk3OGFiYWViODEyN2EzYTA2ZjEwODBjOGU1NzkyNmEwOWVlNg==
4
+ NDM5MzNiZTExZjA4MjA1ZWMzNGVlZjlmMTlhY2VmMDA0ZjQwNjgzNA==
5
5
  data.tar.gz: !binary |-
6
- YjNlMGJjOTZmYWVkZDM1OWI5MmNkOWJiYWU1NTMwOWYwNzdhYzAxNA==
6
+ MGU2YTVlMDljZTM2MWVlN2YxMTk3YmJjODVkNTcxZjk4MGVlZWEyMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZGU0NzNiMDZhMWQ1MGQ1ZTkyNzM0Y2NjNGZhZWZjZDUwMjkxZmIxNzQzNDdi
10
- ZjIwYTFjODZjMWIzYzI2NWE5N2JiZDE3ZTkxZWU3NTg5ZTRiMzQyZjYxZDgz
11
- NzY5NTA5MjdjNzBmMWM4NGI2NGIzNDA1YzFmZDNjNTk4MDdlMDU=
9
+ YTQyYzI5ODM5NzYxNGU0NTEyMGQ5NGZhNTk5MjBhYjk4MzcyMmIxYzNmZjQw
10
+ YTgyMTY3ZTAyY2ZkMzNkMDE0YjZiMjE4MjY3NDkyMmRhM2Q3YzVkZDc1YjUx
11
+ ZGQzMDQyY2UxODMyZDY3ODk0ODNkNzEyMzBmZDQ4NTkxNmNlMTE=
12
12
  data.tar.gz: !binary |-
13
- MjI1NTg1OWYwMDExZTI2MzczMTg0MDM0MTEwYWI2ZTdjZDgwYmY5NDRlY2My
14
- OTBkNTI4NzE5MTZhZGExY2M5ZDM0NmRkMTIyN2Y0NzJiYmY4MDE3NmMzZDc2
15
- YjIyMWNkZmZlMzBhMjMwM2IzYTQ2ZmQzODY1Y2U1ZGZhZGYyMDY=
13
+ ZTI2MGYxZDNiN2MxNTYzMmU4OTgyNjRhNjgwNmM1ZTFmYTg4ZTY1YTZmZDQy
14
+ MjExNGY2MjQwMGZkYjcxMTliNWJkN2EyOWY2MDUyYjczZWE3NzJjNzJlNmQ4
15
+ OGRkMmNmM2ZmMjJkMWNmYTliOTVkZjFiODMzM2Y1N2Q2NDU4NzQ=
data/CHANGELOG ADDED
@@ -0,0 +1,9 @@
1
+ == 0.0.3
2
+ * Published & Draft pages
3
+ * Make compatible only with rails 4
4
+
5
+ == 0.0.2
6
+ * Added simple content editor
7
+
8
+ == 0.0.1
9
+ * Initial release
data/README.md CHANGED
@@ -2,20 +2,12 @@
2
2
 
3
3
  ActiveAdminCms adds CMS functionality to your ActiveAdmin backend.
4
4
 
5
+ NOTE: ActiveAdminCms is only compatible with Rails 4 and cares only about admin part.
6
+
5
7
  ## Installation
6
8
 
7
9
  #### 1. Add this line(s) to your application's Gemfile:
8
10
 
9
- Rails 3
10
-
11
- ```
12
- gem 'activeadmin'
13
- gem 'activeadmin_cms'
14
- gem 'acts-as-taggable-on' // if you are going to use tags
15
- ```
16
-
17
- Rails 4
18
-
19
11
  ```
20
12
  gem 'activeadmin', github: "gregbell/active_admin"
21
13
  gem 'activeadmin_cms'
@@ -30,7 +22,7 @@ $ rails generate acts_as_taggable_on:migration // if you are going to use tags
30
22
  $ rake db:migrate
31
23
  ```
32
24
 
33
- #### 3. Add javascript bindings
25
+ #### 3. Add javascript bindings & stylesheets
34
26
 
35
27
  Append to active_admin.js (add it in `app/assets/javascripts` if not exists)
36
28
 
@@ -39,3 +31,11 @@ Append to active_admin.js (add it in `app/assets/javascripts` if not exists)
39
31
  //= require activeadmin_cms/base
40
32
  ```
41
33
 
34
+ Append to active_admin.css (add it in `app/assets/stylesheets` if not exists)
35
+
36
+ ```
37
+ //= require "active_admin/mixins";
38
+ //= require "active_admin/base";
39
+ //= require "activeadmin_cms/base";
40
+ ```
41
+
@@ -0,0 +1,98 @@
1
+ ActiveAdmin.register ActiveadminCms::Page, as: 'Page' do
2
+ menu parent: "CMS"
3
+ filter :title
4
+
5
+ action_item only: :show do
6
+ if page.has_changed_content? || !page.published?
7
+ link_to "Publish", publish_admin_page_path, method: :put
8
+ elsif page.published?
9
+ link_to "Move draft", draft_admin_page_path, method: :put
10
+ end
11
+ end
12
+
13
+ index do
14
+ column :id
15
+ column :title do |page|
16
+ if page.has_changed_content?
17
+ "* #{page.title}"
18
+ else
19
+ page.title
20
+ end
21
+ end
22
+ column :created_at
23
+ default_actions
24
+ end
25
+
26
+ show do
27
+ panel "Post Details" do
28
+ attributes_table_for page do
29
+ row(:title) do |page|
30
+ if page.has_changed_content?
31
+ "* #{page.title}"
32
+ else
33
+ page.title
34
+ end
35
+ end
36
+ if page.has_changed_content?
37
+ row(:draft_content) { page.draft_content.html_safe }
38
+ end
39
+ row(:content) { page.content.html_safe }
40
+ row(:published?)
41
+ row(:created_at)
42
+ end
43
+ end
44
+ active_admin_comments
45
+ end
46
+
47
+ controller do
48
+ def update
49
+ @page = ActiveadminCms::Page.find(params[:id])
50
+
51
+ if @page.update_attributes(permitted_params)
52
+ if params[:commit].downcase != 'save'
53
+ @page.publish!
54
+ end
55
+ redirect_to admin_page_path(@page)
56
+ else
57
+ render :edit
58
+ end
59
+ end
60
+ end
61
+
62
+ form do |f|
63
+ config = ActiveadminCms::Engine.config
64
+ f.inputs "Details" do
65
+ f.input :title
66
+ if config.page_categories.any?
67
+ f.input :category, collection: config.page_categories, include_blank: false
68
+ end
69
+ f.input :draft_content, label: 'Content'
70
+ if config.page_editor_backend = 'ace_editor'
71
+ f.form_buffers.last << content_tag(:div, page.draft_content, id: 'editor')
72
+ end
73
+ end
74
+ f.buttons do
75
+ f.submit('Save') +
76
+ f.submit('Save & Publish')
77
+ end
78
+ end
79
+
80
+ controller do
81
+ def permitted_params
82
+ params.require(:page).permit(:title, :draft_content, :category)
83
+ end
84
+ end
85
+
86
+ member_action :publish, method: :put do
87
+ page = ActiveadminCms::Page.find(params[:id])
88
+ page.publish!
89
+ redirect_to admin_page_path(page), notice: "The page has been published!"
90
+ end
91
+
92
+ member_action :draft, method: :put do
93
+ page = ActiveadminCms::Page.find(params[:id])
94
+ page.published = false
95
+ page.save
96
+ redirect_to admin_page_path(page), notice: "The page has been moved to draft!"
97
+ end
98
+ end
@@ -0,0 +1,61 @@
1
+ ActiveAdmin.register ActiveadminCms::Post, as: 'Post' do
2
+ menu parent: "CMS"
3
+ filter :title
4
+
5
+ action_item only: :show do
6
+ if !post.published?
7
+ link_to "Publish", publish_admin_post_path, method: :put
8
+ elsif post.published?
9
+ link_to "Move draft", draft_admin_post_path, method: :put
10
+ end
11
+ end
12
+
13
+ index do
14
+ column :id
15
+ column :title
16
+ column :created_at
17
+ default_actions
18
+ end
19
+
20
+ show do
21
+ panel "Post Details" do
22
+ attributes_table_for post do
23
+ row(:title)
24
+ row(:content)
25
+ row(:published)
26
+ row(:created_at)
27
+ end
28
+ end
29
+ active_admin_comments
30
+ end
31
+
32
+ form do |f|
33
+ f.inputs "Details" do
34
+ f.input :title
35
+ f.input :content
36
+ if ActiveadminCms::Engine.config.tags_backend = 'acts_as_taggable_on'
37
+ f.input :tag_list
38
+ end
39
+ end
40
+ f.actions
41
+ end
42
+
43
+ controller do
44
+ def permitted_params
45
+ params.require(:post).permit(:title, :content, :tag_list)
46
+ end
47
+ end
48
+
49
+ member_action :publish, method: :put do
50
+ post = ActiveadminCms::Post.find(params[:id])
51
+ post.publish!
52
+ redirect_to admin_post_path(post), notice: "The post has been published!"
53
+ end
54
+
55
+ member_action :draft, method: :put do
56
+ post = ActiveadminCms::Post.find(params[:id])
57
+ post.published = false
58
+ post.save
59
+ redirect_to admin_post_path(post), notice: "The post has been moved to draft!"
60
+ end
61
+ end
@@ -4,7 +4,7 @@
4
4
  //= require_self
5
5
 
6
6
  $(function (){
7
- $content = $('#page_content')
7
+ $content = $('#page_draft_content')
8
8
  $content.hide()
9
9
  var editor = ace.edit("editor")
10
10
  editor.setTheme("ace/theme/twilight");
@@ -1,4 +1,13 @@
1
1
  module ActiveadminCms
2
2
  class Page < ActiveRecord::Base
3
+ def has_changed_content?
4
+ content != draft_content
5
+ end
6
+
7
+ def publish!
8
+ self.content = draft_content
9
+ self.published = true
10
+ self.save
11
+ end
3
12
  end
4
13
  end
@@ -3,5 +3,10 @@ module ActiveadminCms
3
3
  if ActiveadminCms::Engine.config.tags_backend = 'acts_as_taggable_on'
4
4
  acts_as_taggable
5
5
  end
6
+
7
+ def publish!
8
+ self.published = true
9
+ self.save
10
+ end
6
11
  end
7
12
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveadminCms
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Haziev
@@ -171,8 +171,8 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
- - app/admin/pages.rb
175
- - app/admin/posts.rb
174
+ - app/admin/manage_pages.rb
175
+ - app/admin/manage_posts.rb
176
176
  - app/assets/javascripts/activeadmin_cms/base.js
177
177
  - app/assets/javascripts/activeadmin_cms/editor/ace.js
178
178
  - app/assets/stylesheets/activeadmin_cms/base.css
@@ -192,6 +192,7 @@ files:
192
192
  - MIT-LICENSE
193
193
  - Rakefile
194
194
  - README.md
195
+ - CHANGELOG
195
196
  - test/activeadmin_cms_test.rb
196
197
  - test/dummy/app/assets/javascripts/application.js
197
198
  - test/dummy/app/assets/stylesheets/application.css
data/app/admin/pages.rb DELETED
@@ -1,44 +0,0 @@
1
- ActiveAdmin.register ActiveadminCms::Page, as: 'Page' do
2
- menu parent: "CMS"
3
- filter :title
4
-
5
- index do
6
- column :id
7
- column :title
8
- column :created_at
9
- default_actions
10
- end
11
-
12
- show do
13
- panel "Post Details" do
14
- attributes_table_for page do
15
- row(:title)
16
- row(:content)
17
- row(:published)
18
- row(:created_at)
19
- end
20
- end
21
- active_admin_comments
22
- end
23
-
24
- form do |f|
25
- config = ActiveadminCms::Engine.config
26
- f.inputs "Details" do
27
- f.input :title
28
- if config.page_categories.any?
29
- f.input :category, collection: config.page_categories, include_blank: false
30
- end
31
- f.input :content
32
- if config.page_editor_backend = 'ace_editor'
33
- f.form_buffers.last << content_tag(:div, nil, id: 'editor')
34
- end
35
- end
36
- f.buttons
37
- end
38
-
39
- controller do
40
- def permitted_params
41
- params.permit page: [:title, :content, :category]
42
- end
43
- end
44
- end
data/app/admin/posts.rb DELETED
@@ -1,40 +0,0 @@
1
- ActiveAdmin.register ActiveadminCms::Post, as: 'Post' do
2
- menu parent: "CMS"
3
- filter :title
4
-
5
- index do
6
- column :id
7
- column :title
8
- column :created_at
9
- default_actions
10
- end
11
-
12
- show do
13
- panel "Post Details" do
14
- attributes_table_for post do
15
- row(:title)
16
- row(:content)
17
- row(:published)
18
- row(:created_at)
19
- end
20
- end
21
- active_admin_comments
22
- end
23
-
24
- form do |f|
25
- f.inputs "Details" do
26
- f.input :title
27
- f.input :content
28
- if ActiveadminCms::Engine.config.tags_backend = 'acts_as_taggable_on'
29
- f.input :tag_list
30
- end
31
- end
32
- f.buttons
33
- end
34
-
35
- controller do
36
- def permitted_params
37
- params.permit post: [:title, :content, :tag_list]
38
- end
39
- end
40
- end