template 0.6.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
- 1296741572
2
- SkeletonGenerator C:/Users/paul.brennan/workspace/template/lib/generators/skeleton/skeleton_generator.rb class SkeletonGenerator
1
+ 1296835840
2
+ TemplateGenerator C:/Users/paul.brennan/workspace/template/lib/generators/template/template_generator.rb class TemplateGenerator
3
3
  TestCase C:/Users/paul.brennan/workspace/template/test/helper.rb class Test::Unit::TestCase
4
4
  TestTemplate C:/Users/paul.brennan/workspace/template/test/test_template.rb class TestTemplate
5
- WelcomeController C:/Users/paul.brennan/workspace/template/lib/generators/skeleton/templates/app/controllers/welcome_controller.rb class WelcomeController
6
- copy_skeleton_files C:/Users/paul.brennan/workspace/template/lib/generators/skeleton/skeleton_generator.rb def copy_skeleton_files
7
- index C:/Users/paul.brennan/workspace/template/lib/generators/skeleton/templates/app/controllers/welcome_controller.rb def index
5
+ add_routes C:/Users/paul.brennan/workspace/template/lib/generators/template/template_generator.rb def add_routes
6
+ copy_template_files C:/Users/paul.brennan/workspace/template/lib/generators/template/template_generator.rb def copy_template_files
7
+ generate_navigation C:/Users/paul.brennan/workspace/template/lib/generators/template/template_generator.rb def generate_navigation
8
+ setup_db C:/Users/paul.brennan/workspace/template/lib/generators/template/template_generator.rb def setup_db
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.1
1
+ 1.0.0
@@ -4,8 +4,7 @@ Description:
4
4
  Example:
5
5
  gem install template
6
6
  add to gem file: gem 'template'
7
- rails g skeleton APPNAME
8
- rails plugin install http://github.com/rahim/easypg.git
7
+ rails g template APPNAME
9
8
  rake db:setup
10
9
  rails s
11
10
 
@@ -0,0 +1,34 @@
1
+ class TemplateGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def copy_template_files
5
+ copy_file 'app/controllers/welcome_controller.rb','app/controllers/welcome_controller.rb'
6
+ template 'app/views/layouts/application.html.erb'
7
+ template 'app/views/welcome/index.html.erb'
8
+ template 'config/database.yml'
9
+ template 'public/stylesheets/screen.css'
10
+ end
11
+
12
+
13
+ def add_routes
14
+ route 'root :to => "welcome#index"'
15
+ end
16
+
17
+ def generate_navigation
18
+ generate('navigation_config',"--force")
19
+ @navigation = ''
20
+ while !(controller_name = ask("Enter controller name: [no more controllers]")).blank? do
21
+ c_name = controller_name.scan(/\w+/)[0] #get only first arg.
22
+ generate('controller', c_name+' show') #TODO: push all other args onto end.
23
+ @navigation += 'primary.item :'+controller_name.downcase+' ,\''+controller_name.capitalize+'\', '+controller_name.downcase+'_show_url'+'
24
+ '
25
+ end
26
+ template 'config/navigation.rb'
27
+ end
28
+
29
+
30
+ def setup_db
31
+ plugin('easypg', :git=>'git://github.com/rahim/easypg.git')
32
+ end
33
+
34
+ end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Site title <%= @name %></title>
4
+ <title><%= @name %></title>
5
5
  <%%= stylesheet_link_tag :all %>
6
6
  <%%= javascript_include_tag 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'%>
7
7
  <%%= javascript_include_tag 'application' %>
@@ -11,7 +11,7 @@
11
11
 
12
12
  <div id="container">
13
13
  <div id="header">
14
- <!-- Main header here -->header
14
+ <%= @name %>
15
15
  </div>
16
16
  <div id="top-nav">
17
17
  <%%= render_navigation(:level => 1) %>
@@ -27,11 +27,11 @@
27
27
  </div>
28
28
  </div>
29
29
  <div id="right-nav">
30
- <!-- Place right navigation here -->right nav
30
+
31
31
  </div>
32
32
  </div>
33
33
  <div id="footer">
34
- <!-- Main footer here -->footer
34
+ generated by template
35
35
  </div>
36
36
  </div>
37
37
  </body>
@@ -0,0 +1,67 @@
1
+ # Configures your navigation
2
+ SimpleNavigation::Configuration.run do |navigation|
3
+ # Specify a custom renderer if needed.
4
+ # The default renderer is SimpleNavigation::Renderer::List which renders HTML lists.
5
+ # The renderer can also be specified as option in the render_navigation call.
6
+ # navigation.renderer = Your::Custom::Renderer
7
+
8
+ # Specify the class that will be applied to active navigation items. Defaults to 'selected'
9
+ # navigation.selected_class = 'your_selected_class'
10
+
11
+ # Item keys are normally added to list items as id.
12
+ # This setting turns that off
13
+ # navigation.autogenerate_item_ids = false
14
+
15
+ # You can override the default logic that is used to autogenerate the item ids.
16
+ # To do this, define a Proc which takes the key of the current item as argument.
17
+ # The example below would add a prefix to each key.
18
+ # navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"}
19
+
20
+ # The auto highlight feature is turned on by default.
21
+ # This turns it off globally (for the whole plugin)
22
+ # navigation.auto_highlight = false
23
+
24
+ # Define the primary navigation
25
+ navigation.items do |primary|
26
+ # Add an item to the primary navigation. The following params apply:
27
+ # key - a symbol which uniquely defines your navigation item in the scope of the primary_navigation
28
+ # name - will be displayed in the rendered navigation. This can also be a call to your I18n-framework.
29
+ # url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
30
+ # options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
31
+ # some special options that can be set:
32
+ # :if - Specifies a proc to call to determine if the item should
33
+ # be rendered (e.g. <tt>:if => Proc.new { current_user.admin? }</tt>). The
34
+ # proc should evaluate to a true or false value and is evaluated in the context of the view.
35
+ # :unless - Specifies a proc to call to determine if the item should not
36
+ # be rendered (e.g. <tt>:unless => Proc.new { current_user.admin? }</tt>). The
37
+ # proc should evaluate to a true or false value and is evaluated in the context of the view.
38
+ # :method - Specifies the http-method for the generated link - default is :get.
39
+ # :highlights_on - if autohighlighting is turned off and/or you want to explicitly specify
40
+ # when the item should be highlighted, you can set a regexp which is matched
41
+ # against the current URI.
42
+ #
43
+ #primary.item :key_1, 'name', url, options
44
+
45
+ # Add an item which has a sub navigation (same params, but with block)
46
+ #primary.item :key_2, 'name', url, options do |sub_nav|
47
+ # # Add an item to the sub navigation (same params again)
48
+ # sub_nav.item :key_2_1, 'name', url, options
49
+ #end
50
+ <%= @navigation %>
51
+ # You can also specify a condition-proc that needs to be fullfilled to display an item.
52
+ # Conditions are part of the options. They are evaluated in the context of the views,
53
+ # thus you can use all the methods and vars you have available in the views.
54
+ # primary.item :key_3, 'Admin', url, :class => 'special', :if => Proc.new { current_user.admin? }
55
+ # primary.item :key_4, 'Account', url, :unless => Proc.new { logged_in? }
56
+
57
+ # you can also specify a css id or class to attach to this particular level
58
+ # works for all levels of the menu
59
+ # primary.dom_id = 'menu-id'
60
+ # primary.dom_class = 'menu-class'
61
+
62
+ # You can turn off auto highlighting for a specific level
63
+ # primary.auto_highlight = false
64
+
65
+ end
66
+
67
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{template}
8
- s.version = "0.6.1"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Yule"]
12
- s.date = %q{2011-02-03}
12
+ s.date = %q{2011-02-04}
13
13
  s.description = %q{Creates a bunch of files that most apps will have. Shoudl be used at the beginning of the project. Stops the tedious job of having to set up page templates etc}
14
14
  s.email = %q{paul.brennan@ahc.uk.com}
15
15
  s.extra_rdoc_files = [
@@ -25,14 +25,15 @@ Gem::Specification.new do |s|
25
25
  "README.rdoc",
26
26
  "Rakefile",
27
27
  "VERSION",
28
- "lib/generators/skeleton/USAGE",
29
- "lib/generators/skeleton/skeleton_generator.rb",
30
- "lib/generators/skeleton/templates/app/controllers/welcome_controller.rb",
31
- "lib/generators/skeleton/templates/app/views/layouts/application.html.erb",
32
- "lib/generators/skeleton/templates/app/views/welcome/index.html.erb",
33
- "lib/generators/skeleton/templates/config/database.yml",
34
- "lib/generators/skeleton/templates/public/stylesheets/.gitkeep",
35
- "lib/generators/skeleton/templates/public/stylesheets/screen.css",
28
+ "lib/generators/template/USAGE",
29
+ "lib/generators/template/template_generator.rb",
30
+ "lib/generators/template/templates/app/controllers/welcome_controller.rb",
31
+ "lib/generators/template/templates/app/views/layouts/application.html.erb",
32
+ "lib/generators/template/templates/app/views/welcome/index.html.erb",
33
+ "lib/generators/template/templates/config/database.yml",
34
+ "lib/generators/template/templates/config/navigation.rb",
35
+ "lib/generators/template/templates/public/stylesheets/.gitkeep",
36
+ "lib/generators/template/templates/public/stylesheets/screen.css",
36
37
  "lib/template.rb",
37
38
  "template.gemspec",
38
39
  "test/helper.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: template
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
- - 0
8
- - 6
9
7
  - 1
10
- version: 0.6.1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Yule
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-03 00:00:00 +00:00
18
+ date: 2011-02-04 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -111,14 +111,15 @@ files:
111
111
  - README.rdoc
112
112
  - Rakefile
113
113
  - VERSION
114
- - lib/generators/skeleton/USAGE
115
- - lib/generators/skeleton/skeleton_generator.rb
116
- - lib/generators/skeleton/templates/app/controllers/welcome_controller.rb
117
- - lib/generators/skeleton/templates/app/views/layouts/application.html.erb
118
- - lib/generators/skeleton/templates/app/views/welcome/index.html.erb
119
- - lib/generators/skeleton/templates/config/database.yml
120
- - lib/generators/skeleton/templates/public/stylesheets/.gitkeep
121
- - lib/generators/skeleton/templates/public/stylesheets/screen.css
114
+ - lib/generators/template/USAGE
115
+ - lib/generators/template/template_generator.rb
116
+ - lib/generators/template/templates/app/controllers/welcome_controller.rb
117
+ - lib/generators/template/templates/app/views/layouts/application.html.erb
118
+ - lib/generators/template/templates/app/views/welcome/index.html.erb
119
+ - lib/generators/template/templates/config/database.yml
120
+ - lib/generators/template/templates/config/navigation.rb
121
+ - lib/generators/template/templates/public/stylesheets/.gitkeep
122
+ - lib/generators/template/templates/public/stylesheets/screen.css
122
123
  - lib/template.rb
123
124
  - template.gemspec
124
125
  - test/helper.rb
@@ -1,15 +0,0 @@
1
- class SkeletonGenerator < Rails::Generators::NamedBase
2
- source_root File.expand_path('../templates', __FILE__)
3
-
4
- def copy_skeleton_files
5
- copy_file 'app/controllers/welcome_controller.rb','app/controllers/welcome_controller.rb'
6
- template 'app/views/layouts/application.html.erb'
7
- template 'app/views/welcome/index.html.erb'
8
- template 'config/database.yml'
9
- template 'public/stylesheets/screen.css'
10
- route 'root :to => "welcome#index"'
11
- generate('navigation_config')
12
- plugin('easypg', :git=>'git://github.com/rahim/easypg.git')
13
- end
14
-
15
- end