Skip to content

Commit 92e30d7

Browse files
committed
first version
1 parent 7bfc831 commit 92e30d7

File tree

9 files changed

+130
-1
lines changed

9 files changed

+130
-1
lines changed

Gemfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source "http://rubygems.org"
2+
# Specify your gem's dependencies in active_admin_sidebar.gemspec
3+
4+
gemspec

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,30 @@
11
active_admin_sidebar
22
====================
33

4-
easy change sidebar position with activeadmin
4+
easy change sidebar position with activeadmin
5+
6+
7+
1) change sidebar position dynamically with before_filter
8+
9+
# app/admin/posts.rb
10+
ActiveAdmin.register Post do
11+
before_filter :sidebar_left!
12+
end
13+
14+
# app/admin/comments.rb
15+
ActiveAdmin.register Comment do
16+
before_filter :sidebar_right!
17+
end
18+
19+
20+
21+
2) move sidebar to left within all resource
22+
23+
24+
# == Controller Filters
25+
#
26+
# You can add before, after and around filters to all of your
27+
# Active Admin resources from here.
28+
#
29+
config.before_filter :sidebar_left!
30+

Rakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require "bundler/gem_tasks"

active_admin_sidebar.gemspec

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# -*- encoding: utf-8 -*-
2+
$:.push File.expand_path("../lib", __FILE__)
3+
require "active_admin_sidebar/version"
4+
5+
Gem::Specification.new do |s|
6+
s.name = "active_admin_sidebar"
7+
s.version = ActiveAdminSidebar::VERSION
8+
s.authors = ["Igor"]
9+
s.email = ["[email protected]"]
10+
s.homepage = ""
11+
s.summary = %q{TODO: Write a gem summary}
12+
s.description = %q{TODO: Write a gem description}
13+
14+
s.add_dependency "activeadmin"
15+
16+
s.files = `git ls-files`.split("\n")
17+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19+
s.require_paths = ["lib"]
20+
21+
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
body.active_admin #active_admin_content.left_sidebar #sidebar{
2+
float: left;
3+
margin-left: 0;
4+
5+
}
6+
body.active_admin #active_admin_content.left_sidebar #main_content_wrapper{
7+
float:left;
8+
width:70%;
9+
margin-right:0;
10+
margin-left:5px;
11+
margin-left:5px;
12+
float:left;
13+
}
14+
15+
body.active_admin #active_admin_content.left_sidebar #main_content_wrapper #main_content{
16+
margin:0;
17+
}

lib/active_admin_sidebar.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
require 'active_admin'
2+
require "active_admin_sidebar/version"
3+
require 'active_admin_sidebar/activeadmin_views_pages_base'
4+
require 'active_admin_sidebar/positions'
5+
6+
module ActiveAdminSidebar
7+
class Engine < Rails::Engine
8+
config.after_initialize do
9+
ActiveAdmin::ResourceController.send :include, ActiveAdminSidebar::Positions
10+
end
11+
end
12+
end
13+
14+
15+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document
2+
3+
def build_page_content
4+
build_flash_messages
5+
classes = Arbre::HTML::ClassList.new
6+
7+
classes << 'without_sidebar' if skip_sidebar?
8+
classes << 'with_sidebar' unless skip_sidebar?
9+
classes << 'left_sidebar' if left_sidebar?
10+
11+
div :id => "active_admin_content", :class => classes do
12+
13+
build_sidebar unless skip_sidebar? || right_sidebar?
14+
build_main_content_wrapper
15+
build_sidebar unless skip_sidebar? || left_sidebar?
16+
17+
end
18+
end
19+
20+
21+
def left_sidebar?
22+
assigns[:sidebar_position] == :left
23+
end
24+
25+
def right_sidebar?
26+
!left_sidebar?
27+
end
28+
29+
30+
31+
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module ActiveAdminSidebar
2+
module Positions
3+
def left_sidebar!
4+
@sidebar_position = :left
5+
end
6+
def right_sidebar!
7+
@sidebar_position = :right
8+
end
9+
10+
end
11+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module ActiveAdminSidebar
2+
VERSION = "0.0.1"
3+
end

0 commit comments

Comments
 (0)