-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
administrate:views:sidebar
generator
Problem: Users often want to customize the sidebar markup. Although the sidbar can be generated through the layout generator, the sidebar is customized often enough to warrant its own command. Solution: Add a sidebar generator.
- Loading branch information
1 parent
c132777
commit 04ee51c
Showing
5 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "administrate/view_generator" | ||
|
||
module Administrate | ||
module Generators | ||
module Views | ||
class SidebarGenerator < Administrate::ViewGenerator | ||
source_root template_source_path | ||
|
||
def copy_sidebar | ||
copy_resource_template("_sidebar") | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require "spec_helper" | ||
require "generators/administrate/views/sidebar_generator" | ||
require "support/generator_spec_helpers" | ||
|
||
describe Administrate::Generators::Views::SidebarGenerator, :generator do | ||
describe "administrate:views:sidebar" do | ||
it "copies the sidebar partial into the `admin/application` namespace" do | ||
expected_contents = contents_for_application_template("_sidebar") | ||
generated_file = file("app/views/admin/application/_sidebar.html.erb") | ||
|
||
run_generator [] | ||
|
||
contents = File.read(generated_file) | ||
expect(contents).to eq(expected_contents) | ||
end | ||
end | ||
end |