Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add showoff generator

  • Loading branch information...
commit adb99654e4fdf331b0e5e6954c77f1e7d6f5ea52 1 parent 42b82e5
@adamlogic authored
View
9 app/controllers/mockups_controller.rb
@@ -5,21 +5,20 @@ def frameset
end
def index
- @entries = ActiveSupport::OrderedHash.new
+ @entries = []
+ @directories = ActiveSupport::OrderedHash.new
Dir.glob File.join(Rails.root, 'app', 'views', 'mockups', '**', '[^_]*.html.*') do |template|
parent_dir = File.dirname(template).split(/[\/]/).last
template_name = File.basename(template).split('.').first
if parent_dir == 'mockups'
- @entries[template_name] = nil
+ @entries << template_name
else
- (@entries[parent_dir] ||= []) << template_name
+ (@directories[parent_dir] ||= []) << template_name
end
end
- # @pages = template_files.map { |f| f.scan(/mockups\/([^.]+)/).flatten.first }
-
render :layout => false
end
View
25 app/views/mockups/index.html.erb
@@ -2,25 +2,24 @@
<html>
<head>
- <%= stylesheet_link_tag 'mockups.css' %>
+ <%= stylesheet_link_tag 'showoff.css' %>
</head>
<body>
- <ul id="mockups_tree">
- <% @entries.each do |name, mockups| %>
+ <ul id="showoff_tree">
+ <% @directories.each do |name, mockups| %>
<li>
- <% if mockups.nil? %>
- <%= link_to name.humanize, mockup_path(name), :target => 'content' %>
- <% else %>
- <h2><%= name.humanize.titleize %></h2>
- <ul>
- <% mockups.each do |mockup| %>
- <li><%= link_to mockup.humanize, mockup_path(mockup, :parent_dir => name), :target => 'content' %></li>
- <% end %>
- </ul>
- <% end %>
+ <h2><%= name.humanize.titleize %></h2>
+ <ul>
+ <% mockups.each do |mockup| %>
+ <li><%= link_to mockup.humanize.titleize, mockup_path(mockup, :parent_dir => name), :target => 'content' %></li>
+ <% end %>
+ </ul>
</li>
<% end %>
+ <% @entries.each do |name| %>
+ <li><%= link_to name.humanize.titleize, mockup_path(name), :target => 'content' %></li>
+ <% end %>
</ul>
</body>
View
12 generators/showoff/USAGE
@@ -1,8 +1,12 @@
Description:
- Explain the generator
+ The showoff generator creates the mockups directory along with
+ a few samples to demonstrate how to use the plugin. It also
+ creates a stylesheet that is used in the sidebar when viewing
+ mockups.
Example:
- ./script/generate mockups Thing
+ script/generate showoff
- This will create:
- what/will/it/create
+ This will create:
+ app/views/mockups (and some samples therein)
+ public/stylesheets/showoff.css
View
9 generators/showoff/showoff_generator.rb
@@ -1,8 +1,11 @@
-class ShowoffGenerator < Rails::Generator::NamedBase
+class ShowoffGenerator < Rails::Generator::Base
def manifest
record do |m|
- # m.directory "lib"
- # m.template 'README', "README"
+ m.directory 'app/views/mockups/sample_section'
+ m.file 'sample_mockup.html.erb', 'app/views/mockups/sample_mockup.html.erb'
+ m.file 'alternate_layout.alternate.html.erb', 'app/views/mockups/alternate_layout.alternate.html.erb'
+ m.file 'sample_nested.html.erb', 'app/views/mockups/sample_section/sample_nested.html.erb'
+ m.file 'showoff.css', 'public/stylesheets/showoff.css'
end
end
end
View
1  generators/showoff/templates/alternate_layout.alternate.html.erb
@@ -0,0 +1 @@
+<h1>Alternate Layout Example</h1>
View
1  generators/showoff/templates/sample_mockup.html.erb
@@ -0,0 +1 @@
+<h1>Sample Mockup</h1>
View
1  generators/showoff/templates/sample_nested.html.erb
@@ -0,0 +1 @@
+<h1>Sample Nested Mockup<h1>
View
9 generators/showoff/templates/showoff.css
@@ -0,0 +1,9 @@
+html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; }
+html, body { height: 100%; }
+ol, ul { list-style: none; }
+
+body { background-color: #eee; font: 13px/1.5 Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif; }
+
+#showoff_tree { padding: 10px; }
+#showoff_tree ul { padding: 0 10px 20px; }
+#showoff_tree h2 { padding-bottom: 3px; font-weight: bold; }
Please sign in to comment.
Something went wrong with that request. Please try again.