startups 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. data/CHANGELOG +12 -0
  2. data/LICENSE +20 -0
  3. data/Manifest +29 -0
  4. data/README +29 -0
  5. data/Rakefile +16 -0
  6. data/TODO +5 -0
  7. data/lib/startups.rb +3 -0
  8. data/rails_generators/startup_content/USAGE +11 -0
  9. data/rails_generators/startup_content/startup_content_generator.rb +94 -0
  10. data/rails_generators/startup_content/templates/content_controller.rb +7 -0
  11. data/rails_generators/startup_content/templates/content_controller_test.rb +14 -0
  12. data/rails_generators/startup_content/templates/content_helper.rb +3 -0
  13. data/rails_generators/startup_content/templates/example.html.erb +3 -0
  14. data/rails_generators/startup_content/templates/help.html.erb +3 -0
  15. data/rails_generators/startup_content/templates/home.html.erb +4 -0
  16. data/rails_generators/startup_layout/USAGE +11 -0
  17. data/rails_generators/startup_layout/startup_layout_generator.rb +42 -0
  18. data/rails_generators/startup_layout/templates/app/helpers/layout_helper.rb +71 -0
  19. data/rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_footer.html.erb +6 -0
  20. data/rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_header.html.erb +4 -0
  21. data/rails_generators/startup_layout/templates/app/views/layouts/startup_layout.html.erb +40 -0
  22. data/rails_generators/startup_layout/templates/app/views/layouts/startup_layout_shway.html.erb +39 -0
  23. data/rails_generators/startup_layout/templates/public/stylesheets/startup_layout.css +33 -0
  24. data/rails_generators/startup_layout/templates/public/stylesheets/startup_layout_reset.css +47 -0
  25. data/rails_generators/startup_nav/USAGE +12 -0
  26. data/rails_generators/startup_nav/startup_nav_generator.rb +65 -0
  27. data/rails_generators/startup_nav/templates/_nav.html.erb +8 -0
  28. data/rails_generators/startup_nav/templates/nav.css +34 -0
  29. data/rails_generators/startup_nav/templates/nav_helper.rb +39 -0
  30. data/startups.gemspec +30 -0
  31. metadata +93 -0
data/CHANGELOG ADDED
@@ -0,0 +1,12 @@
1
+ 0.0.0 (Aug 13th, 2009)
2
+
3
+ * just getting started. Added the nav startup.
4
+
5
+ 0.0.1 (Oct 16th, 2009)
6
+
7
+ * Added the content and layout startups.
8
+ * Tweaked all the startups to play nice.
9
+ * Added better wireframe styles
10
+ * Added examples.
11
+ * Generating all 3 startups will get you a working example with 3 pages.
12
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Ryan Owens
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest ADDED
@@ -0,0 +1,29 @@
1
+ CHANGELOG
2
+ lib/startups.rb
3
+ LICENSE
4
+ Manifest
5
+ rails_generators/startup_content/startup_content_generator.rb
6
+ rails_generators/startup_content/templates/content_controller.rb
7
+ rails_generators/startup_content/templates/content_controller_test.rb
8
+ rails_generators/startup_content/templates/content_helper.rb
9
+ rails_generators/startup_content/templates/example.html.erb
10
+ rails_generators/startup_content/templates/help.html.erb
11
+ rails_generators/startup_content/templates/home.html.erb
12
+ rails_generators/startup_content/USAGE
13
+ rails_generators/startup_layout/startup_layout_generator.rb
14
+ rails_generators/startup_layout/templates/app/helpers/layout_helper.rb
15
+ rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_footer.html.erb
16
+ rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_header.html.erb
17
+ rails_generators/startup_layout/templates/app/views/layouts/startup_layout.html.erb
18
+ rails_generators/startup_layout/templates/app/views/layouts/startup_layout_shway.html.erb
19
+ rails_generators/startup_layout/templates/public/stylesheets/startup_layout.css
20
+ rails_generators/startup_layout/templates/public/stylesheets/startup_layout_reset.css
21
+ rails_generators/startup_layout/USAGE
22
+ rails_generators/startup_nav/startup_nav_generator.rb
23
+ rails_generators/startup_nav/templates/_nav.html.erb
24
+ rails_generators/startup_nav/templates/nav.css
25
+ rails_generators/startup_nav/templates/nav_helper.rb
26
+ rails_generators/startup_nav/USAGE
27
+ Rakefile
28
+ README
29
+ TODO
data/README ADDED
@@ -0,0 +1,29 @@
1
+ = search_scope
2
+
3
+ Rails gem with collection of Rails "startups" for features such as navigation and forms with customizable error handling.
4
+
5
+ == Install
6
+
7
+ gem install startups
8
+
9
+ == Usage
10
+
11
+ After installing the gem, you can use the startup generators in your Rails app.
12
+
13
+ From your rails app's root directory, type:
14
+ script/generate startup_nav
15
+
16
+ #TODO script/destroy should also work?
17
+
18
+ == Included Generators
19
+
20
+ * startup_nav: generates the files needed for a simple, easily styled navigation.
21
+ * startup_content: generated a content controller for home and other non-rest pages. A basic layout and stylesheet is also provided.
22
+
23
+ * COMING SOON: startup_form: generates the files needed for generic forms with customizable error handling.
24
+ ** updating this to use formatastic
25
+
26
+ For more information, run:
27
+ script/generate startup_nav --help
28
+
29
+
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('startups', '0.0.1') do |p|
6
+ p.project = "startups"
7
+ p.description = "A collection of Rails \"startups\" for features such as a standard layout, navigation and forms with customizable error handling."
8
+ p.url = "http://rubyforge.org/projects/startups"
9
+ p.author = 'Ryan Owens'
10
+ p.email = "ryan (at) infoether (dot) com"
11
+ p.ignore_pattern = ["tmp/*", "script/*", "startups_notes.txt", "*.tmproj"]
12
+ p.development_dependencies = []
13
+ end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
16
+
data/TODO ADDED
@@ -0,0 +1,5 @@
1
+
2
+ #TODO make script/destroy work
3
+
4
+ #TODO add form generator
5
+
data/lib/startups.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Startups
2
+ # look under rails_generators for the meat
3
+ end
@@ -0,0 +1,11 @@
1
+ Description:
2
+ The startup_content generator creates a content controller for home and other non-rest pages.
3
+
4
+ Examples:
5
+ script/generate startup_content
6
+
7
+
8
+ #TODO UPDATE THIS OUTPUT
9
+ Template: app/views/layouts/application.html.erb
10
+ Stylesheet: public/stylesheets/startup.css
11
+ Helper: app/helpers/startup_helper.rb
@@ -0,0 +1,94 @@
1
+ class StartupContentGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ m.directory 'app/helpers'
6
+ m.directory 'app/controllers'
7
+ m.directory 'app/views/content'
8
+ m.directory 'test/functional'
9
+
10
+ m.file "content_controller.rb", "app/controllers/content_controller.rb"
11
+ m.file "home.html.erb", "app/views/content/home.html.erb"
12
+ m.file "help.html.erb", "app/views/content/help.html.erb"
13
+ m.file "example.html.erb", "app/views/content/example.html.erb"
14
+ m.file "content_helper.rb", "app/helpers/content_helper.rb"
15
+ m.file "content_controller_test.rb", "test/functional/content_controller_test.rb"
16
+
17
+ m.route %{
18
+ map.with_options(:controller => "content") do |content_map|
19
+ content_map.help 'help', :action => 'help'
20
+ content_map.placeholder 'placeholder/:name', :action => 'placeholder'
21
+ end }
22
+ m.route 'map.root :controller => "content", :action => "home"'
23
+
24
+ # example
25
+ # m.route :name => 'version', :controller => 'version', :action => 'display_version'
26
+ end
27
+ end
28
+
29
+ protected
30
+
31
+ def banner
32
+ <<-EOS
33
+ Creates content controller for home and other non-rest pages.
34
+
35
+ USAGE: #{$0} #{spec.name}
36
+ EOS
37
+ end
38
+
39
+ end
40
+
41
+
42
+ #TODO put this somewhere else, or figure out a better way to do it so I don't have to copy it for other generators.
43
+ #modified from: http://patshaughnessy.net/2009/9/2/rails-generator-tutorial-part-2-writing-a-custom-manifest-action
44
+ module Rails
45
+ module Generator
46
+ module Commands
47
+
48
+ class Base
49
+ def route_code(route_options)
50
+ if route_options.is_a? Hash
51
+ "map.#{route_options[:name]} '#{route_options[:name]}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
52
+ else
53
+ route_options.to_s.gsub("\n ","\n").strip
54
+ end
55
+ end
56
+ def route_code_log_message(route_options)
57
+ code = route_code(route_options)
58
+ if code.index "\n"
59
+ code = code[0,code.index("\n")]
60
+ code = "#{code} ... end" if code.index ' do '
61
+ end
62
+ code
63
+ end
64
+ end
65
+
66
+ # Here's a readable version of the long string used above in route_code;
67
+ # but it should be kept on one line to avoid inserting extra whitespace
68
+ # into routes.rb when the generator is run:
69
+ # "map.#{route_options[:name]} '#{route_options[:name]}',
70
+ # :controller => '#{route_options[:controller]}',
71
+ # :action => '#{route_options[:action]}'"
72
+
73
+ class Create
74
+ def route(route_options)
75
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
76
+ logger.route route_code_log_message(route_options)
77
+ #TODO add something here to prevent duplicating the route. Like file_contains? or something.
78
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |m|
79
+ "#{m}\n #{route_code(route_options)}\n"
80
+ end
81
+ end
82
+ end
83
+
84
+ class Destroy
85
+ def route(route_options)
86
+ logger.remove_route route_code_log_message(route_options)
87
+ to_remove = "\n #{route_code(route_options)}"
88
+ gsub_file 'config/routes.rb', /(#{to_remove})/mi, ''
89
+ end
90
+ end
91
+
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,7 @@
1
+ class ContentController < ApplicationController
2
+
3
+ def placeholder
4
+ render :action => params[:name]
5
+ end
6
+
7
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class ContentControllerTest < ActionController::TestCase
4
+
5
+ # def setup
6
+ # setup_test_data
7
+ # login_user
8
+ # end
9
+
10
+ # Replace this with your real tests.
11
+ test "the truth" do
12
+ assert true
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ module ContentHelper
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ <% layout_options :nav => :example, :heading => "Example Page Heading", :title => "Example Page Window Title", :crumbs => [link_to('Home',root_url),'example crumb'] %>
2
+
3
+ Blah Blah Blah
@@ -0,0 +1,3 @@
1
+ <% layout_options :nav => :help, :heading => "Help" %>
2
+
3
+ Blah Blah Blah
@@ -0,0 +1,4 @@
1
+ <% layout_options :nav => :home, :heading => "Home Page" %>
2
+
3
+ Blah Blah Blah
4
+
@@ -0,0 +1,11 @@
1
+ Description:
2
+ The startup_layout generator creates a basic layout with the necessary helpers, stylesheet etc.
3
+ For now, the startup_nav startup is a prerequisite.
4
+
5
+ Examples:
6
+ script/generate startup_layout
7
+
8
+ #TODO UPDATE THIS OUTPUT
9
+ Template: app/views/layouts/application.html.erb
10
+ Stylesheet: public/stylesheets/startup.css
11
+ Helper: app/helpers/startup_helper.rb
@@ -0,0 +1,42 @@
1
+ class StartupLayoutGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ m.directory 'public/stylesheets'
6
+ m.directory 'app/helpers'
7
+ m.directory 'app/views/layouts'
8
+
9
+ m.file "app/helpers/layout_helper.rb", "app/helpers/layout_helper.rb"
10
+
11
+ #TODO add checks here for other startups so the layout can include eg. the nav stuff, etc.
12
+ #TODO possibly add shway versions of things as well.
13
+ m.template "app/views/layouts/startup_layout.html.erb", "app/views/layouts/application.html.erb"#, :assigns => { :foo => 'foo' }
14
+ m.file "app/views/layouts/_startup_layout_footer.html.erb", "app/views/layouts/_footer.html.erb"
15
+ m.file "app/views/layouts/_startup_layout_header.html.erb", "app/views/layouts/_header.html.erb"
16
+
17
+ m.file "public/stylesheets/startup_layout_reset.css", "public/stylesheets/reset.css"
18
+ m.file "public/stylesheets/startup_layout.css", "public/stylesheets/application.css"
19
+
20
+ remove_file 'public/index.html'
21
+ end
22
+ end
23
+
24
+ protected
25
+
26
+ def remove_file(relative_destination)
27
+ destination = destination_path('public/index.html')
28
+ if File.exist?(destination)
29
+ logger.rm relative_destination
30
+ FileUtils.rm(destination)
31
+ end
32
+ end
33
+
34
+ def banner
35
+ <<-EOS
36
+ Creates a basic layout with the necessary helpers, stylesheet etc.
37
+
38
+ USAGE: #{$0} #{spec.name}
39
+ EOS
40
+ end
41
+
42
+ end
@@ -0,0 +1,71 @@
1
+ module LayoutHelper
2
+
3
+ attr_accessor :title, :heading, :heading_image, :body_class, :crumbs
4
+
5
+ #for any options that match setter methods, set them. Raise errors for the rest.
6
+ def layout_options(options={})
7
+ return if options.blank?
8
+ options = options.clone
9
+ options.keys.each do |key|
10
+ #if there is a layout_ version of the setter, call it
11
+ layout_setter = "layout_#{key}=".intern
12
+ if self.respond_to? layout_setter
13
+ self.send layout_setter, options.delete(key)
14
+ next
15
+ end
16
+ setter = "#{key}=".intern
17
+ #if there is a setter, call it
18
+ if self.respond_to? setter
19
+ self.send setter, options.delete(key)
20
+ next
21
+ end
22
+ #if there is a no setter, but there is a method, call it with *args
23
+ #TODO write some tests for varying method signatures
24
+ if self.respond_to?(key) && (method(key).arity == 1 || method(key).arity <= -2)
25
+ self.send key, *options.delete(key)
26
+ next
27
+ end
28
+ #if there was no setter and no method available, raise
29
+ raise "No setter or method was found for the layout_option: #{key}"
30
+ end
31
+ nil
32
+ end
33
+
34
+ def layout_title
35
+ #NOTE: @selected_nav_title may get set by the nav startup if it's installed. Using the instance var makes it easier to mix and match the startups.
36
+ @title || @selected_nav_title || @heading || 'Default Title (CHANGEME)'
37
+ end
38
+
39
+ def layout_heading(text=@heading,options={})
40
+ options[:img] = @heading_image unless options.has_key? :img
41
+ if options[:img].blank?
42
+ text.blank? ? nil : %{<h1>#{text}</h1>}
43
+ #TODO make sifrd an option
44
+ # text.blank? ? nil : %{<h1 class="sifrd">#{text}</h1>}
45
+ else
46
+ %{<h1>#{image_tag(options[:img], :alt => text)}</h1>} unless text.blank?
47
+ end
48
+ end
49
+
50
+ def layout_crumbs
51
+ return if @crumbs.blank?
52
+ html = []
53
+ html << '<div class="crumbs">'
54
+ @crumbs.each do |crumb|
55
+ html << crumb
56
+ html << '<span>&raquo;</span>'
57
+ end
58
+ html << '</div>'
59
+ html.join
60
+ end
61
+
62
+ def layout_body_tag
63
+ class_att = body_class ? %{ class="#{body_class}"} : nil
64
+ if @layout_nav
65
+ %{<body id="#{@layout_nav}"#{class_att}>}
66
+ else
67
+ '<body>'
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,6 @@
1
+ <div id="footer">
2
+ <div id="footer_content">
3
+ <%# NOTE: the const_defined? check is here to allow this to function if the nav startup wasn't installed, and should be removed after the initial setup. %>
4
+ <%= render :partial => 'layouts/footer_nav' if Object.const_defined? :NavHelper %>
5
+ </div>
6
+ </div>
@@ -0,0 +1,4 @@
1
+ <div id="masthead">
2
+ <%# NOTE: the const_defined? check is here to allow this to function if the nav startup wasn't installed, and should be removed after the initial setup. %>
3
+ <%= render :partial => 'layouts/top_nav' if Object.const_defined? :NavHelper %>
4
+ </div>
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+ <head>
4
+ <title><%%= layout_title %></title>
5
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6
+ <meta http-equiv="cache-control" content="no-cache"> <!-- tells browser not to cache -->
7
+ <meta http-equiv="expires" content="0"> <!-- says that the cache expires 'now' -->
8
+ <meta http-equiv="pragma" content="no-cache"> <!-- says not to use cached stuff, if there is any -->
9
+ <%%= javascript_include_tag :defaults %>
10
+ <%%= stylesheet_link_tag 'reset' %>
11
+ <%%# NOTE: the const_defined? check is here to allow this to function if the nav startup wasn't installed, and should be removed after the initial setup. %>
12
+ <%%= stylesheet_link_tag 'nav' if Object.const_defined? :NavHelper %>
13
+ <%%= stylesheet_link_tag 'application' %>
14
+ </head>
15
+
16
+ <%%= layout_body_tag %>
17
+ <div id="all">
18
+ <%%= render :partial => 'layouts/header' unless @omit_header %>
19
+ <div id="content">
20
+ <%%= layout_crumbs %>
21
+ <%%= layout_heading %>
22
+ <%% if flash[:notice] %>
23
+ <div class="notice confirm">
24
+ <%%= flash[:notice] %>
25
+ </div>
26
+ <%% end %>
27
+ <%% if flash[:error ] %>
28
+ <div class='notice error'>
29
+ <%%= flash[:error ]%>
30
+ </div>
31
+ <%% end %>
32
+ <%%#= fancy_heading unless @heading.blank? && @right_heading.blank? %>
33
+ <%%= yield %>
34
+ </div>
35
+ <%%= render :partial => 'layouts/footer' %>
36
+ </div>
37
+
38
+ </body>
39
+
40
+ </html>
@@ -0,0 +1,39 @@
1
+ <% presenter do |p| %>
2
+
3
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <title><%= p.layout_title %></title>
7
+ <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
8
+ <meta http-equiv="cache-control" content="no-cache"> <!-- tells browser not to cache -->
9
+ <meta http-equiv="expires" content="0"> <!-- says that the cache expires 'now' -->
10
+ <meta http-equiv="pragma" content="no-cache"> <!-- says not to use cached stuff, if there is any -->
11
+ <%= default_head_contents %>
12
+ <%= stylesheet_link_tag 'application' %>
13
+ </head>
14
+
15
+ <%= p.layout_body_tag %>
16
+ <div class="all">
17
+ <%= render :partial => 'layouts/header' unless @omit_header %>
18
+ <div class="content">
19
+ <% if flash[:notice ] %>
20
+ <div id='flash-notice'>
21
+ <%= flash[:notice ]%>
22
+ </div>
23
+ <% end %>
24
+ <% if flash[:error ] %>
25
+ <div id='flash-error'>
26
+ <%= flash[:error ]%>
27
+ </div>
28
+ <% end %>
29
+ <%#= fancy_heading unless @heading.blank? && @right_heading.blank? %>
30
+ <%= yield %>
31
+ </div>
32
+ <%= render :partial => 'layouts/footer' %>
33
+ </div>
34
+
35
+ </body>
36
+
37
+ </html>
38
+
39
+ <% end %>
@@ -0,0 +1,33 @@
1
+ html,body {background-color:white;font-family:Helvetica, Verdana, Arial, sans-serif;font-size:12px;height:100%;line-height:18px;margin:0px;padding:0px;}
2
+
3
+ h1 {font-size: 18px; margin: 10px 0;}
4
+ h2 {font-size: 14px; font-weight: bold;}
5
+ h3 {font-size: 12px; font-weight: bold;}
6
+
7
+ a {color:#5d5e5e;text-decoration: none;}
8
+ a:link {color:#5d5e5e;}
9
+ a:active,
10
+ a:hover {color:#5d5e5e; text-decoration: underline;}
11
+ a:visited {color:#5d5e5e;}
12
+
13
+ #all {background-color:white;color:#5d5e5e;min-height:100%;position:relative;}
14
+
15
+ .crumbs {font-size:10px;font-weight:normal;font-style:italic;text-transform:none;height:10px;padding:0;margin:0;}
16
+ .crumbs a {padding:0;margin:0;}
17
+ .crumbs span {font-size:12px;margin-left:5px;margin-right:5px;}
18
+
19
+ #content {overflow:auto;padding:10px 20px 0px 55px;padding-bottom:30px;width:950px;} /* bottom padding needs to match footer height */
20
+ #content_link {color:#5d5e5e;text-decoration:none;}
21
+ #content_link_underline {color:#5d5e5e;text-decoration:underline;}
22
+
23
+ #masthead {color:#a0a1a2;height:40px;padding-top:15px;width:100%;border-bottom:1px solid #e0e1e2;}
24
+ #masthead a {}
25
+ #masthead a:active {color:#5d5e5e;text-decoration:underline;}
26
+ #masthead a:hover {color:#5d5e5e;text-decoration:underline;}
27
+ #masthead a:link {color:#a0a1a2;text-decoration:none;}
28
+ #masthead a:visited {color:#a0a1a2;text-decoration:none;}
29
+ #masthead_link {color:#a0a1a2;text-decoration:none;}
30
+ #masthead_link_underline {color:#5d5e5e;text-decoration:underline;}
31
+
32
+ #footer {bottom:0px;color:#a0a1a2;height:30px;position:absolute;width:100%;border-top:1px solid #e0e1e2;font-size:10px;}
33
+ #footer_content {padding:5px 20px;padding-bottom:0px;width:950px;overflow:auto;}
@@ -0,0 +1,47 @@
1
+ /* reset reload by Eric Meyer: http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/ */
2
+ html, body, div, span, applet, object, iframe,
3
+ h1, h2, h3, h4, h5, h6, p, blockquote, pre,
4
+ a, abbr, acronym, address, big, cite, code,
5
+ del, dfn, em, font, img, ins, kbd, q, s, samp,
6
+ small, strike, strong, sub, sup, tt, var,
7
+ dl, dt, dd, ol, ul, li,
8
+ fieldset, form, label, legend,
9
+ table, caption, tbody, tfoot, thead, tr, th, td {
10
+ margin: 0;
11
+ padding: 0;
12
+ border: 0;
13
+ outline: 0;
14
+ font-weight: inherit;
15
+ font-style: inherit;
16
+ font-size: 100%;
17
+ font-family: inherit;
18
+ vertical-align: baseline;
19
+ }
20
+ /* remember to define focus styles! */
21
+ :focus {
22
+ outline: 0;
23
+ }
24
+ body {
25
+ line-height: 1;
26
+ color: black;
27
+ background: white;
28
+ }
29
+ ol, ul {
30
+ list-style: none;
31
+ }
32
+ /* tables still need 'cellspacing="0"' in the markup */
33
+ table {
34
+ border-collapse: separate;
35
+ border-spacing: 0;
36
+ }
37
+ caption, th, td {
38
+ text-align: left;
39
+ font-weight: normal;
40
+ }
41
+ blockquote:before, blockquote:after,
42
+ q:before, q:after {
43
+ content: "";
44
+ }
45
+ blockquote, q {
46
+ quotes: "" "";
47
+ }
@@ -0,0 +1,12 @@
1
+ Description:
2
+ The startup_nav generator creates generic navigation with a customizable helper and stylesheet.
3
+
4
+ With no arguments, a top_nav partial and helper_method will be generated.
5
+ All arguments given to the generator will add additional nav partial and helper method.
6
+
7
+ Examples:
8
+ script/generate startup_nav
9
+
10
+ Template: app/views/layouts/_top_nav.html.erb
11
+ Stylesheet: public/stylesheets/nav.css
12
+ Helper: app/helpers/nav_helper.rb
@@ -0,0 +1,65 @@
1
+ class StartupNavGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ m.directory 'app/views/layouts'
6
+ m.directory 'public/stylesheets'
7
+ m.directory 'app/helpers'
8
+
9
+ #add top and footer by default
10
+ unless @args.include? "top"
11
+ @args << "top"
12
+ @args << "footer"
13
+ end
14
+
15
+ m.template "nav.css", "public/stylesheets/nav.css", :assigns => { :names => @args }
16
+ m.template "nav_helper.rb", "app/helpers/nav_helper.rb", :assigns => { :names => @args }
17
+ @args.each do |name|
18
+ m.template "_nav.html.erb", "app/views/layouts/_#{name}_nav.html.erb", :assigns => { :name => name }
19
+ end
20
+ # m.file "nav.css", "public/stylesheets/nav.css"
21
+ end
22
+ end
23
+
24
+ def generate_nav(name)
25
+ end
26
+
27
+ protected
28
+
29
+ def banner
30
+ <<-EOS
31
+ Creates generic navigation with a customizable helper and stylesheet.
32
+
33
+ USAGE: #{$0} #{spec.name}
34
+ EOS
35
+ end
36
+
37
+ end
38
+
39
+
40
+
41
+ # def initialize(runtime_args, runtime_options = {})
42
+ # super
43
+ # @name = @args.first || 'application'
44
+ # end
45
+
46
+ # def file_name
47
+ # @name.underscore
48
+ # end
49
+
50
+ # protected
51
+
52
+ # def add_options!(opt)
53
+ # opt.separator ''
54
+ # opt.separator 'Options:'
55
+ # opt.on("--haml", "Generate HAML for view, and SASS for stylesheet.") { |v| options[:haml] = v }
56
+ # end
57
+
58
+ # def banner
59
+ # <<-EOS
60
+ # Creates generic layout, stylesheet, and helper files.
61
+ #
62
+ # USAGE: #{$0} #{spec.name} [layout_name]
63
+ # EOS
64
+ # end
65
+
@@ -0,0 +1,8 @@
1
+ <%- css_id = (name.to_s == 'top') ? 'nav' : "#{name}_nav" -%>
2
+ <ul id="<%= css_id %>">
3
+ <%% layout_nav_items.each do |nav_item|
4
+ next unless nav_item[:placement] == :top
5
+ %>
6
+ <li><%%= link_to(nav_item[:label], nav_item[:url], :id => "nav_#{nav_item[:id]}") %></li>
7
+ <%% end %>
8
+ </ul>
@@ -0,0 +1,34 @@
1
+ <% names.each do |name|
2
+ css_id = (name.to_s == 'top') ? 'nav' : "#{name}_nav"
3
+ selected_color = (name.to_s == 'footer') ? '#5d5e5e' : 'black'
4
+ %>
5
+
6
+ /************
7
+ <%= css_id.upcase %> STYLES
8
+ ************/
9
+ <% if name.to_s == 'footer' %>
10
+ #footer_nav {list-style-type:none;float:right;}
11
+ #footer_nav li {float:left;margin-right:20px;}
12
+ #footer_nav a {display:block;position:relative;text-decoration:none;text-transform:uppercase;}
13
+ #footer_nav a:active {color:#5d5e5e;text-decoration:underline;}
14
+ #footer_nav a:hover {color:#5d5e5e;text-decoration:underline;}
15
+ #footer_nav a:link {color:#a0a1a2;text-decoration:none;}
16
+ #footer_nav a:visited {color:#a0a1a2;text-decoration:none;}
17
+ <% else %>
18
+ #<%= css_id %> a {display:block;height:20px;padding:5px 10px;position:relative;text-decoration:none;text-transform:uppercase;}
19
+ #<%= css_id %> a:active {color:#5d5e5e;text-decoration:none;}
20
+ #<%= css_id %> a:hover {color:#5d5e5e;text-decoration:none;}
21
+ #<%= css_id %> a:link {color:#a0a1a2;text-decoration:none;}
22
+ #<%= css_id %> a:visited {color:#a0a1a2;text-decoration:none;}
23
+ #<%= css_id %> li {float:left;}
24
+ #<%= css_id %> {list-style-type:none;margin-left:22px;overflow:auto;}
25
+ <% end %>
26
+
27
+ /* any additional menu items need to be added here for them to be styled correctly when selected. */
28
+ body#home a#<%= css_id %>_home,
29
+ body#example a#<%= css_id %>_example,
30
+ body#help a#<%= css_id %>_help {
31
+ color:<%= selected_color %>;font-weight:bold;
32
+ }
33
+
34
+ <% end %>
@@ -0,0 +1,39 @@
1
+ module NavHelper
2
+
3
+ #change the hash below to include the actual items you need in your navs. Use the :placement option to specify which nav an item goes in if there are multiple navs.
4
+ def layout_nav_items
5
+ @layout_nav_items ||= [
6
+ <%- names.each do |name| -%>
7
+ #nav items for :<%= name %>
8
+ {:id => :home, :label => 'Home', :url => root_path, :placement => :<%= name %>, :title => 'Home Page'},
9
+ {:id => :help, :label => 'Help', :url => help_path, :placement => :<%= name %>},
10
+ {:id => :example, :label => 'Example', :url => placeholder_path(:example), :placement => :<%= name %>, :title => 'Placeholder Example Page'},
11
+ <%- end -%>
12
+ ]
13
+ end
14
+
15
+
16
+ attr_accessor :layout_nav
17
+
18
+ def layout_nav=(value)
19
+ @layout_nav = value
20
+ @selected_nav_title = (selected_nav_item ? selected_nav_item[:title] : nil)
21
+ end
22
+
23
+ def layout_nav_ids
24
+ @layout_nav_ids ||= layout_nav_items.collect{|nav_item|nav_item[:id]}
25
+ end
26
+
27
+ def selected_nav_item
28
+ @selected_nav_item ||= layout_nav_item(layout_nav)
29
+ end
30
+
31
+ def layout_nav_item(nav_id)
32
+ nav_id = nav_id.intern if nav_id.respond_to? :intern
33
+ layout_nav_items.each do |nav_item|
34
+ return nav_item if nav_item[:id] == nav_id
35
+ end
36
+ nil
37
+ end
38
+
39
+ end
data/startups.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{startups}
5
+ s.version = "0.0.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Ryan Owens"]
9
+ s.date = %q{2009-10-16}
10
+ s.description = %q{A collection of Rails "startups" for features such as a standard layout, navigation and forms with customizable error handling.}
11
+ s.email = %q{ryan (at) infoether (dot) com}
12
+ s.extra_rdoc_files = ["CHANGELOG", "lib/startups.rb", "LICENSE", "README", "TODO"]
13
+ s.files = ["CHANGELOG", "lib/startups.rb", "LICENSE", "Manifest", "rails_generators/startup_content/startup_content_generator.rb", "rails_generators/startup_content/templates/content_controller.rb", "rails_generators/startup_content/templates/content_controller_test.rb", "rails_generators/startup_content/templates/content_helper.rb", "rails_generators/startup_content/templates/example.html.erb", "rails_generators/startup_content/templates/help.html.erb", "rails_generators/startup_content/templates/home.html.erb", "rails_generators/startup_content/USAGE", "rails_generators/startup_layout/startup_layout_generator.rb", "rails_generators/startup_layout/templates/app/helpers/layout_helper.rb", "rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_footer.html.erb", "rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_header.html.erb", "rails_generators/startup_layout/templates/app/views/layouts/startup_layout.html.erb", "rails_generators/startup_layout/templates/app/views/layouts/startup_layout_shway.html.erb", "rails_generators/startup_layout/templates/public/stylesheets/startup_layout.css", "rails_generators/startup_layout/templates/public/stylesheets/startup_layout_reset.css", "rails_generators/startup_layout/USAGE", "rails_generators/startup_nav/startup_nav_generator.rb", "rails_generators/startup_nav/templates/_nav.html.erb", "rails_generators/startup_nav/templates/nav.css", "rails_generators/startup_nav/templates/nav_helper.rb", "rails_generators/startup_nav/USAGE", "Rakefile", "README", "TODO", "startups.gemspec"]
14
+ s.homepage = %q{http://rubyforge.org/projects/startups}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Startups", "--main", "README"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{startups}
18
+ s.rubygems_version = %q{1.3.5}
19
+ s.summary = %q{A collection of Rails "startups" for features such as a standard layout, navigation and forms with customizable error handling.}
20
+
21
+ if s.respond_to? :specification_version then
22
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
+ s.specification_version = 3
24
+
25
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
+ else
27
+ end
28
+ else
29
+ end
30
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: startups
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Owens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-16 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: A collection of Rails "startups" for features such as a standard layout, navigation and forms with customizable error handling.
17
+ email: ryan (at) infoether (dot) com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - CHANGELOG
24
+ - lib/startups.rb
25
+ - LICENSE
26
+ - README
27
+ - TODO
28
+ files:
29
+ - CHANGELOG
30
+ - lib/startups.rb
31
+ - LICENSE
32
+ - Manifest
33
+ - rails_generators/startup_content/startup_content_generator.rb
34
+ - rails_generators/startup_content/templates/content_controller.rb
35
+ - rails_generators/startup_content/templates/content_controller_test.rb
36
+ - rails_generators/startup_content/templates/content_helper.rb
37
+ - rails_generators/startup_content/templates/example.html.erb
38
+ - rails_generators/startup_content/templates/help.html.erb
39
+ - rails_generators/startup_content/templates/home.html.erb
40
+ - rails_generators/startup_content/USAGE
41
+ - rails_generators/startup_layout/startup_layout_generator.rb
42
+ - rails_generators/startup_layout/templates/app/helpers/layout_helper.rb
43
+ - rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_footer.html.erb
44
+ - rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_header.html.erb
45
+ - rails_generators/startup_layout/templates/app/views/layouts/startup_layout.html.erb
46
+ - rails_generators/startup_layout/templates/app/views/layouts/startup_layout_shway.html.erb
47
+ - rails_generators/startup_layout/templates/public/stylesheets/startup_layout.css
48
+ - rails_generators/startup_layout/templates/public/stylesheets/startup_layout_reset.css
49
+ - rails_generators/startup_layout/USAGE
50
+ - rails_generators/startup_nav/startup_nav_generator.rb
51
+ - rails_generators/startup_nav/templates/_nav.html.erb
52
+ - rails_generators/startup_nav/templates/nav.css
53
+ - rails_generators/startup_nav/templates/nav_helper.rb
54
+ - rails_generators/startup_nav/USAGE
55
+ - Rakefile
56
+ - README
57
+ - TODO
58
+ - startups.gemspec
59
+ has_rdoc: true
60
+ homepage: http://rubyforge.org/projects/startups
61
+ licenses: []
62
+
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --line-numbers
66
+ - --inline-source
67
+ - --title
68
+ - Startups
69
+ - --main
70
+ - README
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: "0"
78
+ version:
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "1.2"
84
+ version:
85
+ requirements: []
86
+
87
+ rubyforge_project: startups
88
+ rubygems_version: 1.3.5
89
+ signing_key:
90
+ specification_version: 3
91
+ summary: A collection of Rails "startups" for features such as a standard layout, navigation and forms with customizable error handling.
92
+ test_files: []
93
+