activeadmin-mongoid 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in activeadmin-mongoid.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Elia Schito
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # ActiveAdmin::Mongoid
2
+
3
+ ActiveAdmin hacks to support Mongoid.
4
+ Some ActiveAdmin features are disabled:
5
+
6
+ - comments
7
+ - sidebar filters
8
+
9
+ For more on Mongoid support in ActiveAdmin see [this issue](https://github.com/gregbell/active_admin/issues/26).
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'activeadmin-mongoid'
17
+ ```
18
+
19
+ You can safely remove the following lines, since are already activeadmin-mongoid dependencies:
20
+
21
+ ```ruby
22
+ gem 'activeadmin'
23
+ gem 'meta_search', '>= 1.1.0.pre'
24
+ gem 'sass-rails', ['~> 3.1', '>= 3.1.4']
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle
30
+
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create new Pull Request
39
+
40
+ ## Copyright
41
+
42
+ Copyright © 2012 Elia Schito. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/active_admin/mongoid/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ['Elia Schito']
6
+ gem.email = ['elia@schito.me']
7
+ gem.description = %q{ActiveAdmin hacks to support Mongoid (some ActiveAdmin features are disabled)}
8
+ gem.summary = %q{ActiveAdmin hacks to support Mongoid}
9
+ gem.homepage = ''
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = 'activeadmin-mongoid'
15
+ gem.require_paths = ['lib']
16
+ gem.version = ActiveAdmin::Mongoid::VERSION
17
+ gem.license = 'MIT'
18
+
19
+ gem.add_runtime_dependency 'mongoid', '~> 2.0'
20
+ gem.add_runtime_dependency 'activeadmin', '~> 0.4'
21
+ gem.add_runtime_dependency 'meta_search', '>= 1.1.0.pre'
22
+ gem.add_runtime_dependency 'sass-rails', ['~> 3.1', '>= 3.1.4']
23
+ end
@@ -0,0 +1 @@
1
+ require 'active_admin/mongoid'
@@ -0,0 +1,20 @@
1
+ require 'active_admin'
2
+
3
+ module ActiveAdmin
4
+ module Mongoid
5
+ end
6
+
7
+ class << self
8
+ alias setup_without_mongoid setup
9
+
10
+ # Load monkey patches *after* the setup process
11
+ def setup *args, &block
12
+ setup_without_mongoid *args, &block
13
+
14
+ require 'active_admin/mongoid/comments'
15
+ require 'active_admin/mongoid/form_builder'
16
+ require 'active_admin/mongoid/resource'
17
+ require 'active_admin/mongoid/document'
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,7 @@
1
+ ActiveAdmin::Namespace # autoload
2
+ class ActiveAdmin::Namespace
3
+ # Disable comments
4
+ def comments?
5
+ false
6
+ end
7
+ end
@@ -0,0 +1,21 @@
1
+ require 'mongoid'
2
+
3
+ module ActiveAdmin::Mongoid::Document
4
+ extend ActiveSupport::Concern
5
+
6
+ module ClassMethods
7
+ def content_columns
8
+ @content_columns ||= fields.map(&:second).select {|f| f.name !~ /(^_|^(created|updated)_at)/}
9
+ end
10
+
11
+ def columns
12
+ @columns ||= fields.map(&:second)
13
+ end
14
+
15
+ def reorder *args
16
+ scoped
17
+ end
18
+ end
19
+ end
20
+
21
+ Mongoid::Document.send :include, ActiveAdmin::Mongoid::Document
@@ -0,0 +1,13 @@
1
+ require 'active_admin/form_builder'
2
+
3
+ class ActiveAdmin::FormBuilder
4
+ def inputs(*args, &block)
5
+ # Store that we are creating inputs without a block
6
+ @inputs_with_block = block_given? ? true : false
7
+ content = with_new_form_buffer do
8
+ super
9
+ # form_buffers.last
10
+ end
11
+ form_buffers.last << content.html_safe
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ require 'active_admin'
2
+ require 'inherited_resources'
3
+
4
+ ActiveAdmin::Resource # autoload
5
+ class ActiveAdmin::Resource
6
+ def resource_table_name
7
+ resource.collection_name
8
+ end
9
+
10
+ # Disable filters
11
+ def add_default_sidebar_sections
12
+ end
13
+ end
14
+
15
+ ActiveAdmin::ResourceController # autoload
16
+ class ActiveAdmin::ResourceController
17
+ # Use #desc and #asc for sorting.
18
+ def sort_order(chain)
19
+ params[:order] ||= active_admin_config.sort_order
20
+ table_name = active_admin_config.resource_table_name
21
+ if params[:order] && params[:order] =~ /^([\w\_\.]+)_(desc|asc)$/
22
+ chain.send($2, $1)
23
+ else
24
+ chain # just return the chain
25
+ end
26
+ end
27
+
28
+ # Disable filters
29
+ def search(chain)
30
+ chain
31
+ end
32
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveAdmin
2
+ module Mongoid
3
+ VERSION = '0.0.1'
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require 'active_admin/mongoid'
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activeadmin-mongoid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Elia Schito
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mongoid
16
+ requirement: &70117976268100 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70117976268100
25
+ - !ruby/object:Gem::Dependency
26
+ name: activeadmin
27
+ requirement: &70117976267460 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '0.4'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70117976267460
36
+ - !ruby/object:Gem::Dependency
37
+ name: meta_search
38
+ requirement: &70117976266920 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.0.pre
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70117976266920
47
+ - !ruby/object:Gem::Dependency
48
+ name: sass-rails
49
+ requirement: &70117976266280 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: 3.1.4
58
+ type: :runtime
59
+ prerelease: false
60
+ version_requirements: *70117976266280
61
+ description: ActiveAdmin hacks to support Mongoid (some ActiveAdmin features are disabled)
62
+ email:
63
+ - elia@schito.me
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - .gitignore
69
+ - Gemfile
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - activeadmin-mongoid.gemspec
74
+ - lib/active_admin-mongoid.rb
75
+ - lib/active_admin/mongoid.rb
76
+ - lib/active_admin/mongoid/comments.rb
77
+ - lib/active_admin/mongoid/document.rb
78
+ - lib/active_admin/mongoid/form_builder.rb
79
+ - lib/active_admin/mongoid/resource.rb
80
+ - lib/active_admin/mongoid/version.rb
81
+ - lib/activeadmin-mongoid.rb
82
+ homepage: ''
83
+ licenses:
84
+ - MIT
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.17
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: ActiveAdmin hacks to support Mongoid
107
+ test_files: []