startups 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -10,3 +10,16 @@
10
10
  * Added examples.
11
11
  * Generating all 3 startups will get you a working example with 3 pages.
12
12
 
13
+ 0.0.2 (Oct 16th, 2009)
14
+
15
+ * Added better wireframe styles
16
+ * changed the examples so that not all nav items appear in the footer and header
17
+ * added a 'startup' generator that runs them all at once.
18
+ * added support to the generator commands for removing a file and running a separate generator.
19
+ * fixed the destroy for custom route generator command to properly remove generated routes.
20
+ * Tweaked all the startups to play nice.
21
+ * Added examples.
22
+ * Running a single generator (startup) now generates all 3 startups and gets you a working example with 3 pages.
23
+
24
+
25
+
data/Manifest CHANGED
@@ -2,6 +2,8 @@ CHANGELOG
2
2
  lib/startups.rb
3
3
  LICENSE
4
4
  Manifest
5
+ rails_generators/startup/startup_generator.rb
6
+ rails_generators/startup/USAGE
5
7
  rails_generators/startup_content/startup_content_generator.rb
6
8
  rails_generators/startup_content/templates/content_controller.rb
7
9
  rails_generators/startup_content/templates/content_controller_test.rb
@@ -15,7 +17,6 @@ rails_generators/startup_layout/templates/app/helpers/layout_helper.rb
15
17
  rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_footer.html.erb
16
18
  rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_header.html.erb
17
19
  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
20
  rails_generators/startup_layout/templates/public/stylesheets/startup_layout.css
20
21
  rails_generators/startup_layout/templates/public/stylesheets/startup_layout_reset.css
21
22
  rails_generators/startup_layout/USAGE
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('startups', '0.0.1') do |p|
5
+ Echoe.new('startups', '0.0.2') do |p|
6
6
  p.project = "startups"
7
7
  p.description = "A collection of Rails \"startups\" for features such as a standard layout, navigation and forms with customizable error handling."
8
8
  p.url = "http://rubyforge.org/projects/startups"
data/lib/startups.rb CHANGED
@@ -1,3 +1,80 @@
1
1
  module Startups
2
2
  # look under rails_generators for the meat
3
3
  end
4
+
5
+ #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.
6
+ #modified from: http://patshaughnessy.net/2009/9/2/rails-generator-tutorial-part-2-writing-a-custom-manifest-action
7
+ module Rails
8
+ module Generator
9
+ module Commands
10
+
11
+ class Base
12
+ def route_code(route_options)
13
+ if route_options.is_a? Hash
14
+ "map.#{route_options[:name]} '#{route_options[:name]}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
15
+ else
16
+ route_options.to_s.gsub("\n ","\n").strip
17
+ end
18
+ end
19
+ def route_code_log_message(route_options)
20
+ code = route_code(route_options)
21
+ if code.index "\n"
22
+ code = code[0,code.index("\n")]
23
+ code = "#{code} ... end" if code.index ' do '
24
+ end
25
+ code
26
+ end
27
+ end
28
+
29
+ # Here's a readable version of the long string used above in route_code;
30
+ # but it should be kept on one line to avoid inserting extra whitespace
31
+ # into routes.rb when the generator is run:
32
+ # "map.#{route_options[:name]} '#{route_options[:name]}',
33
+ # :controller => '#{route_options[:controller]}',
34
+ # :action => '#{route_options[:action]}'"
35
+
36
+ class Create
37
+ def route(route_options)
38
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
39
+ logger.route route_code_log_message(route_options)
40
+ #TODO add something here to prevent duplicating the route. Like file_contains? or something.
41
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |m|
42
+ "#{m}\n #{route_code(route_options)}\n"
43
+ end
44
+ end
45
+
46
+ def generate(name)
47
+ logger.generate "running additional generator: #{name}"
48
+ Rails::Generator::Scripts::Generate.new.run([name])
49
+ end
50
+
51
+ def rm(relative_destination)
52
+ destination = destination_path('public/index.html')
53
+ if File.exist?(destination)
54
+ logger.rm relative_destination
55
+ FileUtils.rm(destination)
56
+ end
57
+ end
58
+ end
59
+
60
+ class Destroy
61
+ def route(route_options)
62
+ logger.remove_route route_code_log_message(route_options)
63
+ # to_remove = "\n #{route_code(route_options)}"
64
+ to_remove = "\n #{route_code(route_options)}\n"
65
+ gsub_file 'config/routes.rb', to_remove, ''
66
+ end
67
+
68
+ def generate(name)
69
+ logger.destroy "rewinding additional generator: #{name}"
70
+ Rails::Generator::Scripts::Destroy.new.run([name])
71
+ end
72
+
73
+ def rm(relative_destination)
74
+ logger.gone "can't replace rm'd file: #{relative_destination}"
75
+ end
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,11 @@
1
+ Description:
2
+ The startup generator runs all of the startup generators, creating a ready-to-go wireframe layout with navigation and example files.
3
+
4
+ Examples:
5
+ script/generate startup
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,23 @@
1
+ require 'startups'
2
+
3
+ class StartupGenerator < Rails::Generator::Base
4
+
5
+ def manifest
6
+ record do |m|
7
+ m.generate('startup_content')
8
+ m.generate('startup_layout')
9
+ m.generate('startup_nav')
10
+ end
11
+ end
12
+
13
+ protected
14
+
15
+ def banner
16
+ <<-EOS
17
+ Runs all of the startup generators, creating a ready-to-go wireframe layout with navigation and example files.
18
+
19
+ USAGE: #{$0} #{spec.name}
20
+ EOS
21
+ end
22
+
23
+ end
@@ -1,3 +1,5 @@
1
+ require 'startups'
2
+
1
3
  class StartupContentGenerator < Rails::Generator::Base
2
4
 
3
5
  def manifest
@@ -37,58 +39,3 @@ EOS
37
39
  end
38
40
 
39
41
  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
@@ -1,3 +1,5 @@
1
+ require 'startups'
2
+
1
3
  class StartupLayoutGenerator < Rails::Generator::Base
2
4
 
3
5
  def manifest
@@ -17,20 +19,12 @@ class StartupLayoutGenerator < Rails::Generator::Base
17
19
  m.file "public/stylesheets/startup_layout_reset.css", "public/stylesheets/reset.css"
18
20
  m.file "public/stylesheets/startup_layout.css", "public/stylesheets/application.css"
19
21
 
20
- remove_file 'public/index.html'
22
+ m.rm 'public/index.html'
21
23
  end
22
24
  end
23
25
 
24
26
  protected
25
27
 
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
28
  def banner
35
29
  <<-EOS
36
30
  Creates a basic layout with the necessary helpers, stylesheet etc.
@@ -1,3 +1,5 @@
1
+ require 'startups'
2
+
1
3
  class StartupNavGenerator < Rails::Generator::Base
2
4
 
3
5
  def manifest
@@ -17,13 +19,9 @@ class StartupNavGenerator < Rails::Generator::Base
17
19
  @args.each do |name|
18
20
  m.template "_nav.html.erb", "app/views/layouts/_#{name}_nav.html.erb", :assigns => { :name => name }
19
21
  end
20
- # m.file "nav.css", "public/stylesheets/nav.css"
21
22
  end
22
23
  end
23
24
 
24
- def generate_nav(name)
25
- end
26
-
27
25
  protected
28
26
 
29
27
  def banner
@@ -35,31 +33,3 @@ EOS
35
33
  end
36
34
 
37
35
  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
-
@@ -1,8 +1,8 @@
1
1
  <%- css_id = (name.to_s == 'top') ? 'nav' : "#{name}_nav" -%>
2
2
  <ul id="<%= css_id %>">
3
3
  <%% layout_nav_items.each do |nav_item|
4
- next unless nav_item[:placement] == :top
4
+ next unless nav_item[:placement] == :<%= name %>
5
5
  %>
6
- <li><%%= link_to(nav_item[:label], nav_item[:url], :id => "nav_#{nav_item[:id]}") %></li>
6
+ <li><%%= link_to(nav_item[:label], nav_item[:url], :id => "<%= css_id %>_#{nav_item[:id]}") %></li>
7
7
  <%% end %>
8
8
  </ul>
@@ -10,16 +10,16 @@
10
10
  #footer_nav {list-style-type:none;float:right;}
11
11
  #footer_nav li {float:left;margin-right:20px;}
12
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
13
  #footer_nav a:visited {color:#a0a1a2;text-decoration:none;}
14
+ #footer_nav a:link {color:#a0a1a2;text-decoration:none;}
15
+ #footer_nav a:hover {color:#5d5e5e;text-decoration:underline;}
16
+ #footer_nav a:active {color:#5d5e5e;text-decoration:underline;}
17
17
  <% else %>
18
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
19
  #<%= css_id %> a:visited {color:#a0a1a2;text-decoration:none;}
20
+ #<%= css_id %> a:link {color:#a0a1a2;text-decoration:none;}
21
+ #<%= css_id %> a:hover {color:#5d5e5e;text-decoration:none;}
22
+ #<%= css_id %> a:active {color:#5d5e5e;text-decoration:none;}
23
23
  #<%= css_id %> li {float:left;}
24
24
  #<%= css_id %> {list-style-type:none;margin-left:22px;overflow:auto;}
25
25
  <% end %>
@@ -5,9 +5,11 @@ module NavHelper
5
5
  @layout_nav_items ||= [
6
6
  <%- names.each do |name| -%>
7
7
  #nav items for :<%= name %>
8
+ <%- unless name.to_s == 'footer' %>
8
9
  {:id => :home, :label => 'Home', :url => root_path, :placement => :<%= name %>, :title => 'Home Page'},
9
- {:id => :help, :label => 'Help', :url => help_path, :placement => :<%= name %>},
10
10
  {:id => :example, :label => 'Example', :url => placeholder_path(:example), :placement => :<%= name %>, :title => 'Placeholder Example Page'},
11
+ <%- end -%>
12
+ {:id => :help, :label => 'Help', :url => help_path, :placement => :<%= name %>},
11
13
  <%- end -%>
12
14
  ]
13
15
  end
data/startups.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{startups}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ryan Owens"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{A collection of Rails "startups" for features such as a standard layout, navigation and forms with customizable error handling.}
11
11
  s.email = %q{ryan (at) infoether (dot) com}
12
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"]
13
+ s.files = ["CHANGELOG", "lib/startups.rb", "LICENSE", "Manifest", "rails_generators/startup/startup_generator.rb", "rails_generators/startup/USAGE", "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/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
14
  s.homepage = %q{http://rubyforge.org/projects/startups}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Startups", "--main", "README"]
16
16
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Owens
@@ -30,6 +30,8 @@ files:
30
30
  - lib/startups.rb
31
31
  - LICENSE
32
32
  - Manifest
33
+ - rails_generators/startup/startup_generator.rb
34
+ - rails_generators/startup/USAGE
33
35
  - rails_generators/startup_content/startup_content_generator.rb
34
36
  - rails_generators/startup_content/templates/content_controller.rb
35
37
  - rails_generators/startup_content/templates/content_controller_test.rb
@@ -43,7 +45,6 @@ files:
43
45
  - rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_footer.html.erb
44
46
  - rails_generators/startup_layout/templates/app/views/layouts/_startup_layout_header.html.erb
45
47
  - 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
48
  - rails_generators/startup_layout/templates/public/stylesheets/startup_layout.css
48
49
  - rails_generators/startup_layout/templates/public/stylesheets/startup_layout_reset.css
49
50
  - rails_generators/startup_layout/USAGE
@@ -1,39 +0,0 @@
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 %>