Permalink
Browse files

first version

  • Loading branch information...
1 parent 7bfc831 commit 92e30d713241e811f92269110f432cdb0831898f @Fivell Fivell committed Nov 5, 2012
View
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+# Specify your gem's dependencies in active_admin_sidebar.gemspec
+
+gemspec
View
@@ -1,4 +1,30 @@
active_admin_sidebar
====================
-easy change sidebar position with activeadmin
+easy change sidebar position with activeadmin
+
+
+1) change sidebar position dynamically with before_filter
+
+ # app/admin/posts.rb
+ ActiveAdmin.register Post do
+ before_filter :sidebar_left!
+ end
+
+ # app/admin/comments.rb
+ ActiveAdmin.register Comment do
+ before_filter :sidebar_right!
+ end
+
+
+
+2) move sidebar to left within all resource
+
+
+ # == Controller Filters
+ #
+ # You can add before, after and around filters to all of your
+ # Active Admin resources from here.
+ #
+ config.before_filter :sidebar_left!
+
View
@@ -0,0 +1 @@
+require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "active_admin_sidebar/version"
+
+Gem::Specification.new do |s|
+ s.name = "active_admin_sidebar"
+ s.version = ActiveAdminSidebar::VERSION
+ s.authors = ["Igor"]
+ s.email = ["fedoronchuk@gmail.com"]
+ s.homepage = ""
+ s.summary = %q{TODO: Write a gem summary}
+ s.description = %q{TODO: Write a gem description}
+
+ s.add_dependency "activeadmin"
+
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+end
@@ -0,0 +1,17 @@
+body.active_admin #active_admin_content.left_sidebar #sidebar{
+ float: left;
+ margin-left: 0;
+
+}
+body.active_admin #active_admin_content.left_sidebar #main_content_wrapper{
+ float:left;
+ width:70%;
+ margin-right:0;
+ margin-left:5px;
+ margin-left:5px;
+ float:left;
+}
+
+body.active_admin #active_admin_content.left_sidebar #main_content_wrapper #main_content{
+ margin:0;
+}
@@ -0,0 +1,15 @@
+require 'active_admin'
+require "active_admin_sidebar/version"
+require 'active_admin_sidebar/activeadmin_views_pages_base'
+require 'active_admin_sidebar/positions'
+
+module ActiveAdminSidebar
+ class Engine < Rails::Engine
+ config.after_initialize do
+ ActiveAdmin::ResourceController.send :include, ActiveAdminSidebar::Positions
+ end
+ end
+end
+
+
+
@@ -0,0 +1,31 @@
+class ActiveAdmin::Views::Pages::Base < Arbre::HTML::Document
+
+ def build_page_content
+ build_flash_messages
+ classes = Arbre::HTML::ClassList.new
+
+ classes << 'without_sidebar' if skip_sidebar?
+ classes << 'with_sidebar' unless skip_sidebar?
+ classes << 'left_sidebar' if left_sidebar?
+
+ div :id => "active_admin_content", :class => classes do
+
+ build_sidebar unless skip_sidebar? || right_sidebar?
+ build_main_content_wrapper
+ build_sidebar unless skip_sidebar? || left_sidebar?
+
+ end
+ end
+
+
+ def left_sidebar?
+ assigns[:sidebar_position] == :left
+ end
+
+ def right_sidebar?
+ !left_sidebar?
+ end
+
+
+
+end
@@ -0,0 +1,11 @@
+module ActiveAdminSidebar
+ module Positions
+ def left_sidebar!
+ @sidebar_position = :left
+ end
+ def right_sidebar!
+ @sidebar_position = :right
+ end
+
+ end
+end
@@ -0,0 +1,3 @@
+module ActiveAdminSidebar
+ VERSION = "0.0.1"
+end

0 comments on commit 92e30d7

Please sign in to comment.