activeadmin_cms 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- M2QxNWQzOTJmMjc5NzhmZWU1YThkNDhiODYyYjUzNDBlZGIyYzViMA==
4
+ NmU5ODcxMmM0OGJjMTAyYTc2ODJiNDZmOGY3MDY3YzU1YTgxMDgxNw==
5
5
  data.tar.gz: !binary |-
6
- ZDQxZTRiNjRhNmQ4MGYwMzNjOGRjYTExMmFiMTdjYzAyMjdmOTE0Zg==
6
+ OGM2ODkxYmMwNmFmNTUwMWUxYTFmOTBkNmUwZWQ4N2U1NWJhMTc1OQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NzkzOWUwNTg0NmRlYWE2ZmU5ZjJiYzM5NTVlYWQ4MTdhMWU5YjNmYjkyYTZk
10
- MTI1MjQ2NjcwY2QzYWU3MjliNmE0MjMxN2ViNWFjYzdjNjIxNzU5N2U0YzBj
11
- NWQzNmI2OWNlYTkzZWRmYzZhODQxYTA3OGQwNGFmODBhMGUwNDU=
9
+ YTM2ZjVkZDAzZGZmOWM2OWMwMWE0NjA0NDM5ZGEzYzcyY2M2ZDgxYWU1Y2I5
10
+ YTA1ZWRjY2I1ZDhiNDNmODk1OTRkYmNjMDgxOThkYjg2NTRiOGQ2NGM2MmNj
11
+ MjI0MjdlZGI3Yzc2NTYxYjY5N2QwNDFkZGNjZjI5NjA1MDMxNzY=
12
12
  data.tar.gz: !binary |-
13
- YTNkM2JlM2E0YTIwYmRlZGRkMjljZDhmNDRjMDExMjVhNWYwODZmN2Q4MGFl
14
- MTM5Mjg2ZWM1MGQ3MGVlMjk3MTFlZGQxMGVkNTY3ZDM2NzdiMDk2MTExYmRj
15
- YTViNTU3MGNhYmRkYTc1ZDBhMTljMGZhNzZjOGE2Y2VlMWUwNTk=
13
+ OWQyMDQ0ZTc1NzEwMTU5ZWJiYTMxMDI3NjkzNTRlODQwYmYyNzg3NDg2MWE4
14
+ ZDFlOTE5ZjE4NzUwOTNiOWZkZGU2OTk4YmUxMzE2MDA3YTE1ZmNkZDNjMzMz
15
+ Yjg3MzQ3YmU5MmMwYjMwMmQ4N2E2ZDhhZmU2NTE5NDAxNzgxOWE=
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.0.7
2
+ * Added simple assets uploader
3
+
1
4
  == 0.0.6
2
5
  * Added liquid processor with menu builder
3
6
 
data/README.md CHANGED
@@ -12,6 +12,7 @@ NOTE: ActiveAdminCms is only compatible with Rails 4 and cares only about admin
12
12
  gem 'activeadmin', github: "gregbell/active_admin"
13
13
  gem 'activeadmin_cms'
14
14
  gem 'acts-as-taggable-on', github: 'mbleigh/acts-as-taggable-on' // if you are going to use tags
15
+ gem 'paperclip' // if you are going to use tags
15
16
  ```
16
17
 
17
18
  #### 2. Execute in console:
@@ -39,3 +40,10 @@ Append to active_admin.css (add it in `app/assets/stylesheets` if not exists)
39
40
  //= require "activeadmin_cms/base";
40
41
  ```
41
42
 
43
+ #### Add routes
44
+
45
+ Append following line to your `routes.rb` file
46
+
47
+ ```
48
+ mount ActiveadminCms::Engine => "/activeadmin_cms"
49
+ ```
@@ -1,7 +1,8 @@
1
1
  ActiveAdmin.register ActiveadminCms::Page, as: 'Page' do
2
2
  menu parent: "CMS"
3
3
  filter :title
4
-
4
+ filter :category
5
+
5
6
  action_item only: :show do
6
7
  if page.has_unpublished_changes? || !page.published?
7
8
  link_to "Publish", publish_admin_page_path, method: :put
@@ -12,6 +13,7 @@ ActiveAdmin.register ActiveadminCms::Page, as: 'Page' do
12
13
 
13
14
  index do
14
15
  column :id
16
+ column :category
15
17
  column :title do |page|
16
18
  if page.has_unpublished_changes?
17
19
  "* #{page.title}"
@@ -38,41 +40,38 @@ ActiveAdmin.register ActiveadminCms::Page, as: 'Page' do
38
40
  end
39
41
 
40
42
  controller do
43
+ def create
44
+ @page = ActiveadminCms::Page.new
45
+ save_page(@page)
46
+ end
47
+
41
48
  def update
42
49
  @page = ActiveadminCms::Page.find(params[:id])
50
+ save_page(@page)
51
+ end
43
52
 
44
- if @page.update_attributes(permitted_params)
53
+ def save_page(page)
54
+ page_params = permitted_params[:page]
55
+ asset_ids_str = page_params.delete(:asset_ids).to_s
56
+ puts asset_ids_str.gsub(/[\[\]]*/, '').split(',').map(&:strip).map(&:to_i)
57
+ page.asset_ids = asset_ids_str.gsub(/[\[\]]*/, '').split(',').map(&:strip).map(&:to_i)
58
+ page.attributes = page_params
59
+ if page.save
45
60
  if params[:commit].downcase != 'save'
46
- ActiveadminCms::PagesService.publish(@page)
61
+ ActiveadminCms::PagesService.publish(page)
47
62
  end
48
- redirect_to admin_page_path(@page)
63
+ redirect_to admin_page_path(page)
49
64
  else
50
- render :edit
65
+ render (page.new_record? ? :new : :edit)
51
66
  end
52
67
  end
53
68
  end
54
69
 
55
- form do |f|
56
- config = ActiveadminCms::Engine.config
57
- f.inputs "Details" do
58
- f.input :title
59
- if config.page_categories.any?
60
- f.input :category, collection: config.page_categories, include_blank: false
61
- end
62
- f.input :draft_content, label: false
63
- if config.page_editor_backend = 'ace_editor'
64
- f.form_buffers.last << content_tag(:div, page.draft_content, id: 'editor')
65
- end
66
- end
67
- f.buttons do
68
- f.submit('Save') +
69
- f.submit('Save & Publish')
70
- end
71
- end
70
+ form partial: "form"
72
71
 
73
72
  controller do
74
73
  def permitted_params
75
- params.require(:page).permit(:title, :draft_content, :category)
74
+ params.permit page: [:title, :draft_content, :category, :asset_ids, :slug]
76
75
  end
77
76
  end
78
77
 
@@ -42,7 +42,7 @@ ActiveAdmin.register ActiveadminCms::Post, as: 'Post' do
42
42
 
43
43
  controller do
44
44
  def permitted_params
45
- params.require(:post).permit(:title, :content, :tag_list)
45
+ params.permit post: [:title, :content, :tag_list]
46
46
  end
47
47
  end
48
48
 
@@ -1,2 +1,3 @@
1
1
  //= require jquery
2
- //= require ./editor/ace
2
+ //= require ./editor/ace
3
+ //= require ./helpers/assets_uploader
@@ -3,15 +3,25 @@
3
3
  //= require ace/mode-html.js
4
4
  //= require_self
5
5
 
6
+ if (!window.EditorWrapper) {
7
+ window.EditorWrapper = {}
8
+ }
9
+
6
10
  $(function (){
7
- $content = $('#page_draft_content')
8
- $content.hide()
9
- var editor = ace.edit("editor")
10
- editor.setTheme("ace/theme/tomorrow");
11
- editor.getSession().setMode("ace/mode/html");
12
- editor.getSession().setUseWrapMode(true);
13
- editor.setFontSize("16px");
14
- editor.on('change', function (e) {
15
- $content.val(editor.getValue())
16
- })
11
+ if ($('#editor').length) {
12
+ var $content = $('#page_draft_content')
13
+ $content.hide()
14
+ var editor = ace.edit("editor")
15
+ editor.setTheme("ace/theme/tomorrow");
16
+ editor.getSession().setMode("ace/mode/html");
17
+ editor.getSession().setUseWrapMode(true);
18
+ editor.setFontSize("16px");
19
+ editor.on('change', function (e) {
20
+ $content.val(editor.getValue())
21
+ })
22
+
23
+ window.EditorWrapper.insert = function (data) {
24
+ editor.insert(data);
25
+ }
26
+ }
17
27
  })
@@ -0,0 +1,47 @@
1
+ //= require jquery-fileupload/basic
2
+ //= require_self
3
+
4
+ var getAssetIds = function () {
5
+ return $('#page_asset_ids').val().replace(/[\[\]]*/g, '').split(',').filter(function(n) {return n});
6
+ }
7
+ var setAssetIds = function (assetIds) {
8
+ $('#page_asset_ids').val(assetIds.join(','))
9
+ }
10
+
11
+ $(function () {
12
+ var $uploader = $('#uploader')
13
+ $uploader.fileupload({
14
+ autoUpload: true,
15
+ dataType: 'json',
16
+ type: 'POST',
17
+ url: "/activeadmin_cms/assets.json",
18
+ fileInput: $('#uploader-file'),
19
+ paramName: 'asset[image]',
20
+ formData: {
21
+ _method: 'POST'
22
+ },
23
+ done: function(e, data) {
24
+ var assetIds = getAssetIds();
25
+ assetIds.push(data.result.id)
26
+ setAssetIds(assetIds)
27
+ var $el = $('<li />')
28
+ $el.addClass('asset')
29
+ $el.attr('data-id', data.result.id)
30
+ $el.attr('data-url', data.result.image_url)
31
+ $el.append($('<span class="delete">x</span>'))
32
+ $el.append($('<img src="' + data.result.image_thumb_url + '" />'))
33
+ $el.appendTo($('#uploader-images'))
34
+ }
35
+ })
36
+ $(document).on('click', '#uploader-images .asset .delete', function () {
37
+ var $el = $(this).closest('.asset')
38
+ $.post("/activeadmin_cms/assets/" + $el.data('id') + ".json", {_method: 'delete'});
39
+ $el.empty().remove()
40
+ var assetIds = getAssetIds()
41
+ assetIds.splice( assetIds.indexOf($el.data('id')), 1 );
42
+ setAssetIds(assetIds)
43
+ })
44
+ $(document).on('click', '#uploader-images .asset', function () {
45
+ EditorWrapper.insert($(this).data('url'))
46
+ })
47
+ })
@@ -1 +1,23 @@
1
- //= require activeadmin_cms/editor/ace
1
+ //= require activeadmin_cms/editor/ace
2
+
3
+ #active_admin_content #assets-container {
4
+ padding: 10px;
5
+ }
6
+
7
+ #active_admin_content #assets-container #uploader-images li {
8
+ display: inline-block;
9
+ width: 100px;
10
+ height: 100px;
11
+ position: relative;
12
+ cursor: pointer;
13
+ }
14
+
15
+ #active_admin_content #assets-container #uploader-images li .delete {
16
+ position: absolute;
17
+ top: 5px;
18
+ right: 5px;
19
+ cursor: pointer;
20
+ background: #fff;
21
+ font-size: 16px;
22
+ padding: 2px 6px;
23
+ }
@@ -1,7 +1,7 @@
1
- #active_admin_content form.page {
1
+ #active_admin_content form.activeadmin_cms_page {
2
2
  position: relative;
3
3
  }
4
- #active_admin_content form.page #editor {
4
+ #active_admin_content form.activeadmin_cms_page #editor {
5
5
  width: 100%;
6
6
  height: 500px;
7
7
  position: relative;
@@ -0,0 +1,23 @@
1
+ module ActiveadminCms
2
+ class AssetsController < ApplicationController
3
+ before_filter :authenticate_admin_user!
4
+ respond_to :json
5
+
6
+ def create
7
+ respond_with service.create(permited_params)
8
+ end
9
+
10
+ def destroy
11
+ respond_with service.destroy(params[:id])
12
+ end
13
+
14
+ private
15
+ def service
16
+ ActiveadminCms::AssetsService
17
+ end
18
+
19
+ def permited_params
20
+ params.require(:asset).permit(:image)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ module ActiveadminCms
2
+ class Asset < ActiveRecord::Base
3
+ if ActiveadminCms::Engine.config.assets_backend == 'paperclip'
4
+ has_attached_file :image, styles: { thumb: '100x100#' }
5
+ end
6
+
7
+ def image_url
8
+ image.url
9
+ end
10
+
11
+ def image_thumb_url
12
+ image.url(:thumb)
13
+ end
14
+
15
+ def as_json(options = {})
16
+ options[:methods] = [:image_url, :image_thumb_url]
17
+ super(options)
18
+ end
19
+ end
20
+ end
@@ -2,15 +2,10 @@ module ActiveadminCms
2
2
  class Page < ActiveRecord::Base
3
3
  validates :slug, presence: true, uniqueness: true
4
4
  validates :title, presence: true
5
+ has_many :assets, as: :content
5
6
 
6
7
  def has_unpublished_changes?
7
8
  content != draft_content
8
9
  end
9
-
10
- def publish!
11
- self.content = draft_content
12
- self.published = true
13
- self.save
14
- end
15
10
  end
16
11
  end
@@ -6,9 +6,6 @@ module ActiveadminCms
6
6
  acts_as_taggable
7
7
  end
8
8
 
9
- def publish!
10
- self.published = true
11
- self.save
12
- end
9
+
13
10
  end
14
11
  end
@@ -0,0 +1,17 @@
1
+ module ActiveadminCms
2
+ class AssetsService
3
+ class << self
4
+ def create(attributes)
5
+ asset = ActiveadminCms::Asset.new(attributes)
6
+ asset.save
7
+ asset
8
+ end
9
+
10
+ def destroy(asset_id)
11
+ asset = ActiveadminCms::Asset.find(asset_id)
12
+ asset.destroy
13
+ asset
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ - config = ActiveadminCms::Engine.config
2
+ = semantic_form_for [:admin, @page] do |f|
3
+ = f.inputs do
4
+ = f.input :title
5
+ = f.input :slug
6
+
7
+ - if config.page_categories.any?
8
+ = f.input :category, collection: config.page_categories, include_blank: false
9
+
10
+ = f.input :draft_content, label: false
11
+ li#editor-container
12
+ - if config.page_editor_backend = 'ace_editor'
13
+ #editor= @page.draft_content
14
+
15
+ = f.input :asset_ids, as: :hidden
16
+ li#assets-container
17
+ ul#uploader-images
18
+ - @page.assets.each do |asset|
19
+ li.asset data-id=(asset.id) data-url=(asset.image_url)
20
+ span.delete x
21
+ = image_tag asset.image_thumb_url, width: 100, height: 100
22
+ input#uploader-file type="file"
23
+ #uploader
24
+ = f.actions
25
+ = f.submit('Save')
26
+ = f.submit('Save & Publish')
data/config/routes.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  ActiveadminCms::Engine.routes.draw do
2
+ resources :assets, only: [:create, :destroy]
2
3
  end
@@ -0,0 +1,14 @@
1
+ class CreateActiveadminCmsAssets < ActiveRecord::Migration
2
+ def change
3
+ create_table :activeadmin_cms_assets do |t|
4
+ t.integer :content_id
5
+ t.string :content_type
6
+ t.string :image_file_name
7
+ t.string :image_content_type
8
+ t.integer :image_file_size
9
+ t.datetime :image_updated_at
10
+ t.timestamps
11
+ end
12
+ add_index :activeadmin_cms_assets, [:content_type, :content_id]
13
+ end
14
+ end
@@ -1,11 +1,18 @@
1
1
  require 'activeadmin'
2
2
  require 'ace-rails-ap'
3
3
  require 'jquery-rails'
4
+ require 'jquery-fileupload-rails'
4
5
  require 'liquid'
6
+
5
7
  begin
6
8
  require 'acts-as-taggable-on'
7
9
  rescue LoadError
8
10
  end
11
+ begin
12
+ require 'paperclip'
13
+ rescue LoadError
14
+ end
15
+
9
16
  module ActiveadminCms
10
17
  class Engine < ::Rails::Engine
11
18
  isolate_namespace ActiveadminCms
@@ -26,6 +33,11 @@ module ActiveadminCms
26
33
  else
27
34
  config.tags_backend = false
28
35
  end
36
+ if defined?(Paperclip)
37
+ config.assets_backend = 'paperclip'
38
+ else
39
+ config.assets_backend = false
40
+ end
29
41
  config.page_editor_backend = 'ace_editor'
30
42
  config.page_categories = ['main']
31
43
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveadminCms
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
Binary file
@@ -11,7 +11,20 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20131020181730) do
14
+ ActiveRecord::Schema.define(version: 20131020224503) do
15
+
16
+ create_table "activeadmin_cms_assets", force: true do |t|
17
+ t.integer "content_id"
18
+ t.string "content_type"
19
+ t.string "image_file_name"
20
+ t.string "image_content_type"
21
+ t.integer "image_file_size"
22
+ t.datetime "image_updated_at"
23
+ t.datetime "created_at"
24
+ t.datetime "updated_at"
25
+ end
26
+
27
+ add_index "activeadmin_cms_assets", ["content_type", "content_id"], name: "index_activeadmin_cms_assets_on_content_type_and_content_id"
15
28
 
16
29
  create_table "activeadmin_cms_pages", force: true do |t|
17
30
  t.string "title"
Binary file
@@ -33,3 +33,38 @@ Migrating to AddSlugToActiveadminCmsPages (20131020181730)
33
33
  SQL (1.7ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131020181730"]]
34
34
   (1.0ms) commit transaction
35
35
  ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
36
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37
+ Migrating to CreateActiveadminCmsAssets (20131020224503)
38
+  (0.1ms) begin transaction
39
+  (0.6ms) CREATE TABLE "activeadmin_cms_assets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "content_id" integer, "content_type" varchar(255), "image_file_name" varchar(255), "image_content_type" varchar(255), "image_file_size" integer, "image_updated_at" datetime, "created_at" datetime, "updated_at" datetime) 
40
+  (0.1ms) CREATE INDEX "index_activeadmin_cms_assets_on_content_type_and_content_id" ON "activeadmin_cms_assets" ("content_type", "content_id")
41
+ SQL (1.8ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131020224503"]]
42
+  (38.6ms) commit transaction
43
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
44
+  (1.4ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
45
+  (1.0ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
46
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
47
+ Migrating to CreateActiveadminCmsPosts (20131020140024)
48
+  (0.1ms) begin transaction
49
+  (0.5ms) CREATE TABLE "activeadmin_cms_posts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "content" text, "published" boolean DEFAULT 'f', "created_at" datetime, "updated_at" datetime) 
50
+ SQL (1.7ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131020140024"]]
51
+  (1.2ms) commit transaction
52
+ Migrating to CreateActiveadminCmsPages (20131020152912)
53
+  (0.1ms) begin transaction
54
+  (0.5ms) CREATE TABLE "activeadmin_cms_pages" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255), "category" varchar(255), "content" text, "draft_content" text, "published" boolean DEFAULT 'f', "created_at" datetime, "updated_at" datetime) 
55
+  (0.2ms) CREATE INDEX "index_activeadmin_cms_pages_on_category" ON "activeadmin_cms_pages" ("category")
56
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131020152912"]]
57
+  (1.0ms) commit transaction
58
+ Migrating to AddSlugToActiveadminCmsPages (20131020181730)
59
+  (0.1ms) begin transaction
60
+  (0.3ms) ALTER TABLE "activeadmin_cms_pages" ADD "slug" varchar(255)
61
+  (0.1ms) CREATE INDEX "index_activeadmin_cms_pages_on_slug" ON "activeadmin_cms_pages" ("slug")
62
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131020181730"]]
63
+  (1.2ms) commit transaction
64
+ Migrating to CreateActiveadminCmsAssets (20131020224503)
65
+  (0.1ms) begin transaction
66
+  (0.3ms) CREATE TABLE "activeadmin_cms_assets" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "content_id" integer, "content_type" varchar(255), "image_file_name" varchar(255), "image_content_type" varchar(255), "image_file_size" integer, "image_updated_at" datetime, "created_at" datetime, "updated_at" datetime) 
67
+  (0.1ms) CREATE INDEX "index_activeadmin_cms_assets_on_content_type_and_content_id" ON "activeadmin_cms_assets" ("content_type", "content_id")
68
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES (?) [["version", "20131020224503"]]
69
+  (1.0ms) commit transaction
70
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -803,3 +803,58 @@ ActiveadminCmsTest: test_truth
803
803
   (0.0ms) SAVEPOINT active_record_1
804
804
   (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
805
805
   (0.0ms) rollback transaction
806
+  (1.6ms) DELETE FROM "activeadmin_cms_posts";
807
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
808
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'activeadmin_cms_posts';
809
+  (1.0ms) DELETE FROM "activeadmin_cms_pages";
810
+  (0.1ms) SELECT name FROM sqlite_master WHERE type='table' AND name='sqlite_sequence';
811
+  (0.1ms) DELETE FROM sqlite_sequence where name = 'activeadmin_cms_pages';
812
+  (0.1ms) begin transaction
813
+ -----------------------------------------------------
814
+ #publish: test_0001_should change status to published
815
+ -----------------------------------------------------
816
+  (0.0ms) SAVEPOINT active_record_1
817
+  (0.0ms) RELEASE SAVEPOINT active_record_1
818
+  (0.0ms) SAVEPOINT active_record_1
819
+ SQL (13.2ms) INSERT INTO "activeadmin_cms_posts" ("content", "created_at", "title", "updated_at") VALUES (?, ?, ?, ?) [["content", "Foo content"], ["created_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00], ["title", "Foo post"], ["updated_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00]]
820
+ SQL (0.2ms) UPDATE "activeadmin_cms_posts" SET "published" = ?, "updated_at" = ? WHERE "activeadmin_cms_posts"."id" = 1 [["published", true], ["updated_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00]]
821
+ ActiveadminCms::Post Load (0.1ms) SELECT "activeadmin_cms_posts".* FROM "activeadmin_cms_posts" WHERE "activeadmin_cms_posts"."id" = ? LIMIT 1 [["id", 1]]
822
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
823
+  (0.4ms) rollback transaction
824
+  (0.1ms) begin transaction
825
+ -----------------------------------------------------
826
+ #publish: test_0001_should change status to published
827
+ -----------------------------------------------------
828
+  (0.0ms) SAVEPOINT active_record_1
829
+  (0.0ms) RELEASE SAVEPOINT active_record_1
830
+  (0.0ms) SAVEPOINT active_record_1
831
+ ActiveadminCms::Page Exists (0.1ms) SELECT 1 AS one FROM "activeadmin_cms_pages" WHERE "activeadmin_cms_pages"."slug" = 'slug-1' LIMIT 1
832
+ SQL (0.6ms) INSERT INTO "activeadmin_cms_pages" ("content", "created_at", "slug", "title", "updated_at") VALUES (?, ?, ?, ?, ?) [["content", "Foo content"], ["created_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00], ["slug", "slug-1"], ["title", "Foo page"], ["updated_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00]]
833
+ ActiveadminCms::Page Exists (0.1ms) SELECT 1 AS one FROM "activeadmin_cms_pages" WHERE ("activeadmin_cms_pages"."slug" = 'slug-1' AND "activeadmin_cms_pages"."id" != 1) LIMIT 1
834
+ SQL (0.2ms) UPDATE "activeadmin_cms_pages" SET "content" = ?, "published" = ?, "updated_at" = ? WHERE "activeadmin_cms_pages"."id" = 1 [["content", nil], ["published", true], ["updated_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00]]
835
+ ActiveadminCms::Page Load (0.1ms) SELECT "activeadmin_cms_pages".* FROM "activeadmin_cms_pages" WHERE "activeadmin_cms_pages"."id" = ? LIMIT 1 [["id", 1]]
836
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
837
+  (0.5ms) rollback transaction
838
+  (0.1ms) begin transaction
839
+ --------------------------------------------------
840
+ #publish: test_0002_should move content from draft
841
+ --------------------------------------------------
842
+  (0.0ms) SAVEPOINT active_record_1
843
+  (0.0ms) RELEASE SAVEPOINT active_record_1
844
+  (0.0ms) SAVEPOINT active_record_1
845
+ ActiveadminCms::Page Exists (0.1ms) SELECT 1 AS one FROM "activeadmin_cms_pages" WHERE "activeadmin_cms_pages"."slug" = 'slug-2' LIMIT 1
846
+ SQL (0.3ms) INSERT INTO "activeadmin_cms_pages" ("content", "created_at", "slug", "title", "updated_at") VALUES (?, ?, ?, ?, ?) [["content", "Foo content"], ["created_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00], ["slug", "slug-2"], ["title", "Foo page"], ["updated_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00]]
847
+ ActiveadminCms::Page Exists (0.1ms) SELECT 1 AS one FROM "activeadmin_cms_pages" WHERE ("activeadmin_cms_pages"."slug" = 'slug-2' AND "activeadmin_cms_pages"."id" != 1) LIMIT 1
848
+ SQL (0.1ms) UPDATE "activeadmin_cms_pages" SET "draft_content" = ?, "content" = ?, "published" = ?, "updated_at" = ? WHERE "activeadmin_cms_pages"."id" = 1 [["draft_content", "new content"], ["content", "new content"], ["published", true], ["updated_at", Mon, 21 Oct 2013 00:21:19 UTC +00:00]]
849
+ ActiveadminCms::Page Load (0.0ms) SELECT "activeadmin_cms_pages".* FROM "activeadmin_cms_pages" WHERE "activeadmin_cms_pages"."id" = ? LIMIT 1 [["id", 1]]
850
+  (0.1ms) ROLLBACK TO SAVEPOINT active_record_1
851
+  (0.5ms) rollback transaction
852
+  (0.0ms) begin transaction
853
+ ------------------------------
854
+ ActiveadminCmsTest: test_truth
855
+ ------------------------------
856
+  (0.1ms) SAVEPOINT active_record_1
857
+  (0.0ms) RELEASE SAVEPOINT active_record_1
858
+  (0.0ms) SAVEPOINT active_record_1
859
+  (0.0ms) ROLLBACK TO SAVEPOINT active_record_1
860
+  (0.1ms) rollback transaction
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module ActiveadminCms
4
+ class AssetTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Iskander Haziev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-20 00:00:00.000000000 Z
11
+ date: 2013-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: jquery-fileupload-rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: liquid
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,20 @@ dependencies:
80
94
  - - ! '>='
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: slim-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: sqlite3
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -189,11 +217,15 @@ files:
189
217
  - app/admin/manage_posts.rb
190
218
  - app/assets/javascripts/activeadmin_cms/base.js
191
219
  - app/assets/javascripts/activeadmin_cms/editor/ace.js
220
+ - app/assets/javascripts/activeadmin_cms/helpers/assets_uploader.js
192
221
  - app/assets/stylesheets/activeadmin_cms/base.css
193
222
  - app/assets/stylesheets/activeadmin_cms/editor/ace.css
194
223
  - app/controllers/activeadmin_cms/application_controller.rb
224
+ - app/controllers/activeadmin_cms/assets_controller.rb
225
+ - app/models/activeadmin_cms/asset.rb
195
226
  - app/models/activeadmin_cms/page.rb
196
227
  - app/models/activeadmin_cms/post.rb
228
+ - app/services/activeadmin_cms/assets_service.rb
197
229
  - app/services/activeadmin_cms/composer_service.rb
198
230
  - app/services/activeadmin_cms/menu_builder_service.rb
199
231
  - app/services/activeadmin_cms/pages_service.rb
@@ -201,11 +233,13 @@ files:
201
233
  - app/services/activeadmin_cms/processors/base.rb
202
234
  - app/services/activeadmin_cms/processors/parse_menu.rb
203
235
  - app/services/activeadmin_cms/processors/parse_template.rb
236
+ - app/views/admin/pages/_form.html.slim
204
237
  - app/views/layouts/activeadmin_cms/application.html.erb
205
238
  - config/routes.rb
206
239
  - db/migrate/20131020140024_create_activeadmin_cms_posts.rb
207
240
  - db/migrate/20131020152912_create_activeadmin_cms_pages.rb
208
241
  - db/migrate/20131020181730_add_slug_to_activeadmin_cms_pages.rb
242
+ - db/migrate/20131020224503_create_activeadmin_cms_assets.rb
209
243
  - lib/activeadmin_cms/engine.rb
210
244
  - lib/activeadmin_cms/version.rb
211
245
  - lib/activeadmin_cms.rb
@@ -254,6 +288,7 @@ files:
254
288
  - test/factories/pages.rb
255
289
  - test/factories/posts.rb
256
290
  - test/factories/sequences.rb
291
+ - test/models/activeadmin_cms/asset_test.rb
257
292
  - test/models/activeadmin_cms/page_test.rb
258
293
  - test/models/activeadmin_cms/post_test.rb
259
294
  - test/services/pages_service_test.rb
@@ -323,6 +358,7 @@ test_files:
323
358
  - test/factories/pages.rb
324
359
  - test/factories/posts.rb
325
360
  - test/factories/sequences.rb
361
+ - test/models/activeadmin_cms/asset_test.rb
326
362
  - test/models/activeadmin_cms/page_test.rb
327
363
  - test/models/activeadmin_cms/post_test.rb
328
364
  - test/services/pages_service_test.rb