knaveofdiamonds-knave_extras 0.0.1 → 0.0.2

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 (28) hide show
  1. data/Rakefile +0 -1
  2. data/VERSION +1 -1
  3. data/knave_extras.gemspec +20 -2
  4. data/lib/knave_extras/tasks/vlad.rb +5 -2
  5. data/rails_generators/model/model_generator.rb +14 -13
  6. data/rails_generators/openid_scaffold/openid_scaffold_generator.rb +93 -0
  7. data/rails_generators/openid_scaffold/templates/application_controller.rb +24 -0
  8. data/rails_generators/openid_scaffold/templates/functional_test.rb +25 -0
  9. data/rails_generators/openid_scaffold/templates/helper.rb +2 -0
  10. data/rails_generators/openid_scaffold/templates/helper_test.rb +4 -0
  11. data/rails_generators/openid_scaffold/templates/migration.rb +18 -0
  12. data/rails_generators/openid_scaffold/templates/sessions_controller.rb +52 -0
  13. data/rails_generators/openid_scaffold/templates/sessions_new.erb +20 -0
  14. data/rails_generators/openid_scaffold/templates/user.rb +17 -0
  15. data/rails_generators/openid_scaffold/templates/user_edit.erb +14 -0
  16. data/rails_generators/openid_scaffold/templates/user_show.erb +18 -0
  17. data/rails_generators/openid_scaffold/templates/user_test.rb +8 -0
  18. data/rails_generators/openid_scaffold/templates/users_controller.rb +33 -0
  19. data/rails_generators/scaffold/scaffold_generator.rb +1 -5
  20. data/rails_generators/scaffold/templates/controller.rb +2 -2
  21. data/rails_generators/scaffold/templates/view_edit.html.erb +1 -15
  22. data/rails_generators/scaffold/templates/view_form.html.erb +9 -0
  23. data/rails_generators/scaffold/templates/view_new.html.erb +1 -15
  24. data/rails_generators/styles/USAGE +2 -0
  25. data/rails_generators/styles/styles_generator.rb +16 -0
  26. data/rails_generators/styles/templates/resets.css +31 -0
  27. data/rails_generators/styles/templates/typography.less +64 -0
  28. metadata +20 -2
data/Rakefile CHANGED
@@ -9,7 +9,6 @@ begin
9
9
  gem.email = "roland.swingler@gmail.com"
10
10
  gem.homepage = "http://github.com/knaveofdiamonds/knave-extras"
11
11
  gem.authors = ["Roland Swingler"]
12
- gem.files << "lib/knave_extras/tasks/vlad.rb"
13
12
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
13
  end
15
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/knave_extras.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{knave_extras}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Roland Swingler"]
9
- s.date = %q{2009-08-16}
9
+ s.date = %q{2009-08-22}
10
10
  s.email = %q{roland.swingler@gmail.com}
11
11
  s.extra_rdoc_files = [
12
12
  "LICENSE",
@@ -27,6 +27,19 @@ Gem::Specification.new do |s|
27
27
  "rails_generators/model/templates/migration.rb",
28
28
  "rails_generators/model/templates/model.rb",
29
29
  "rails_generators/model/templates/unit_test.rb",
30
+ "rails_generators/openid_scaffold/openid_scaffold_generator.rb",
31
+ "rails_generators/openid_scaffold/templates/application_controller.rb",
32
+ "rails_generators/openid_scaffold/templates/functional_test.rb",
33
+ "rails_generators/openid_scaffold/templates/helper.rb",
34
+ "rails_generators/openid_scaffold/templates/helper_test.rb",
35
+ "rails_generators/openid_scaffold/templates/migration.rb",
36
+ "rails_generators/openid_scaffold/templates/sessions_controller.rb",
37
+ "rails_generators/openid_scaffold/templates/sessions_new.erb",
38
+ "rails_generators/openid_scaffold/templates/user.rb",
39
+ "rails_generators/openid_scaffold/templates/user_edit.erb",
40
+ "rails_generators/openid_scaffold/templates/user_show.erb",
41
+ "rails_generators/openid_scaffold/templates/user_test.rb",
42
+ "rails_generators/openid_scaffold/templates/users_controller.rb",
30
43
  "rails_generators/scaffold/USAGE",
31
44
  "rails_generators/scaffold/scaffold_generator.rb",
32
45
  "rails_generators/scaffold/templates/controller.rb",
@@ -36,9 +49,14 @@ Gem::Specification.new do |s|
36
49
  "rails_generators/scaffold/templates/layout.html.erb",
37
50
  "rails_generators/scaffold/templates/style.css",
38
51
  "rails_generators/scaffold/templates/view_edit.html.erb",
52
+ "rails_generators/scaffold/templates/view_form.html.erb",
39
53
  "rails_generators/scaffold/templates/view_index.html.erb",
40
54
  "rails_generators/scaffold/templates/view_new.html.erb",
41
55
  "rails_generators/scaffold/templates/view_show.html.erb",
56
+ "rails_generators/styles/USAGE",
57
+ "rails_generators/styles/styles_generator.rb",
58
+ "rails_generators/styles/templates/resets.css",
59
+ "rails_generators/styles/templates/typography.less",
42
60
  "test/knave-extras_test.rb",
43
61
  "test/test_helper.rb"
44
62
  ]
@@ -20,8 +20,11 @@ namespace :vlad do
20
20
 
21
21
  remote_task :clone_code do
22
22
  run ["git clone -s #{scm_path} #{latest_release}",
23
- "chmod -R g+w #{latest_release}",
24
- "mkdir #{latest_release}/db #{latest_release}/tmp" ].join(" && ")
23
+ "cd #{latest_release}",
24
+ "git submodule init",
25
+ "git submodule update",
26
+ "chmod -R g+w .",
27
+ "mkdir -p #{latest_release}/db #{latest_release}/tmp" ].join(" && ")
25
28
  end
26
29
 
27
30
  remote_task :make_current do
@@ -27,18 +27,19 @@ class ModelGenerator < Rails::Generator::NamedBase
27
27
  end
28
28
 
29
29
  protected
30
- def banner
31
- "Usage: #{$0} #{spec.name} ModelName [field:type, field:type]"
32
- end
33
30
 
34
- def add_options!(opt)
35
- opt.separator ''
36
- opt.separator 'Options:'
37
- opt.on("--skip-timestamps",
38
- "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
39
- opt.on("--skip-migration",
40
- "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
41
- opt.on("--skip-blueprint",
42
- "Don't generation a blueprint for this model") { |v| options[:skip_blueprint] = v}
43
- end
31
+ def banner
32
+ "Usage: #{$0} #{spec.name} ModelName [field:type, field:type]"
33
+ end
34
+
35
+ def add_options!(opt)
36
+ opt.separator ''
37
+ opt.separator 'Options:'
38
+ opt.on("--skip-timestamps",
39
+ "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
40
+ opt.on("--skip-migration",
41
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
42
+ opt.on("--skip-blueprint",
43
+ "Don't generation a blueprint for this model") { |v| options[:skip_blueprint] = v}
44
+ end
44
45
  end
@@ -0,0 +1,93 @@
1
+ class OpenidScaffoldGenerator < Rails::Generator::NamedBase
2
+ default_options :force_plural => false
3
+
4
+ attr_reader :controller_name,
5
+ :controller_class_path,
6
+ :controller_file_path,
7
+ :controller_class_nesting,
8
+ :controller_class_nesting_depth,
9
+ :controller_class_name,
10
+ :controller_underscore_name,
11
+ :controller_singular_name,
12
+ :controller_plural_name
13
+ alias_method :controller_file_name, :controller_underscore_name
14
+ alias_method :controller_table_name, :controller_plural_name
15
+
16
+ def initialize(runtime_args, runtime_options = {})
17
+ super
18
+
19
+ if @name == @name.pluralize && !options[:force_plural]
20
+ logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural."
21
+ @name = @name.singularize
22
+ end
23
+
24
+ @controller_name = @name.pluralize
25
+
26
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
27
+ @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
28
+ @controller_singular_name=base_name.singularize
29
+ if @controller_class_nesting.empty?
30
+ @controller_class_name = @controller_class_name_without_nesting
31
+ else
32
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
33
+ end
34
+ end
35
+
36
+ def manifest
37
+ record do |m|
38
+ # Check for class naming collisions.
39
+ m.class_collisions("SessionsController", "#{controller_class_name}Controller", "#{controller_class_name}Helper")
40
+ m.class_collisions(class_name)
41
+
42
+ # Controller, helper, views, test and stylesheets directories.
43
+ m.directory(File.join('app/models', class_path))
44
+ m.directory(File.join('app/controllers', controller_class_path))
45
+ m.directory(File.join('app/helpers', controller_class_path))
46
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
47
+ m.directory('app/views/sessions')
48
+ m.directory(File.join('test/functional', controller_class_path))
49
+ m.directory(File.join('test/unit', class_path))
50
+ m.directory(File.join('test/unit/helpers', class_path))
51
+
52
+ m.template("sessions_new.erb", 'app/views/sessions/new.html.erb')
53
+ m.template("sessions_controller.rb", 'app/controllers/sessions_controller.rb')
54
+ m.template("application_controller.rb", 'app/controllers/application_controller.rb')
55
+ m.template("user_edit.erb", File.join('app/views', controller_class_path, controller_file_name, "edit.html.erb"))
56
+ m.template("user_show.erb", File.join('app/views', controller_class_path, controller_file_name, "show.html.erb"))
57
+ m.template(
58
+ 'users_controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
59
+ )
60
+
61
+ m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
62
+ m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
63
+ m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
64
+
65
+ # Model
66
+ m.template 'user.rb', File.join('app/models', class_path, "#{file_name}.rb")
67
+ m.template 'user_test.rb', File.join('test/unit', class_path, "#{file_name}_test.rb")
68
+ m.migration_template 'migration.rb', 'db/migrate', :assigns => {
69
+ :migration_name => "Create#{class_name.pluralize.gsub(/::/, '')}"
70
+ }, :migration_file_name => "create_#{file_path.gsub(/\//, '_').pluralize}"
71
+ # Routing
72
+ m.route_resources "sessions"
73
+ m.route_resources controller_file_name
74
+ end
75
+ end
76
+
77
+ protected
78
+ # Override with your own usage banner.
79
+ def banner
80
+ "Usage: #{$0} scaffold ModelName"
81
+ end
82
+
83
+ def add_options!(opt)
84
+ opt.separator ''
85
+ opt.separator 'Options:'
86
+ opt.on("--force-plural",
87
+ "Forces the generation of a plural ModelName") { |v| options[:force_plural] = v }
88
+ end
89
+
90
+ def model_name
91
+ class_name.demodulize
92
+ end
93
+ end
@@ -0,0 +1,24 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all
6
+ helper_method :current_<%= singular_name %>
7
+ protect_from_forgery # See ActionController::RequestForgeryProtection for details
8
+
9
+ protected
10
+
11
+ def current_<%= singular_name %>
12
+ return @current_<%= singular_name %> if defined?(@current_<%= singular_name %>)
13
+ @current_<%= singular_name %> = <%= class_name %>.find_by_id(session[:<%= singular_name %>_id])
14
+ end
15
+
16
+ def store_location
17
+ session[:return_to] = request.request_uri
18
+ end
19
+
20
+ def redirect_back_or_default(default)
21
+ redirect_to(session[:return_to] || default)
22
+ session[:return_to] = nil
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
4
+
5
+ def setup
6
+ super
7
+ @<%= singular_name %> = <%= class_name %>.make
8
+ end
9
+
10
+ test "GET /users/:id should show user" do
11
+ get :show, :id => @<%= singular_name %>.to_param
12
+ assert_response :success
13
+ end
14
+
15
+ test "GET /users/:id/edit" do
16
+ get :edit, :id => @<%= singular_name %>.to_param
17
+ assert_not_nil assigns(:<%= singular_name %>)
18
+ assert_response :success
19
+ end
20
+
21
+ test "PUT /users/:id should update user" do
22
+ put :update, :id => @<%= singular_name %>.to_param, :user => { }
23
+ assert_redirected_to <%= table_name %._path
24
+ end
25
+ end
@@ -0,0 +1,2 @@
1
+ module <%= controller_class_name %>Helper
2
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,18 @@
1
+ class <%= migration_name %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :<%= table_name %> do |t|
4
+ t.string :name, :limit => 80
5
+ t.string :email, :limit => 100
6
+ t.string :openid_identifier
7
+ t.datetime :current_login_at
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :<%= table_name %>, :openid_identifier
13
+ end
14
+
15
+ def self.down
16
+ drop_table :<%= table_name %>
17
+ end
18
+ end
@@ -0,0 +1,52 @@
1
+ class SessionsController < ApplicationController
2
+ def new
3
+ end
4
+
5
+ def create
6
+ open_id_authentication(params[:openid_identifier])
7
+ end
8
+
9
+ private
10
+
11
+ def open_id_authentication(oid)
12
+ # Pass optional :required and :optional keys to specify what sreg fields you want.
13
+ # Be sure to yield registration, a third argument in the #authenticate_with_open_id block.
14
+ authenticate_with_open_id(oid, :required => [:email,:fullname]) do |result, identity_url, registration|
15
+ case result.status
16
+ when :missing
17
+ failed_login "Sorry, the OpenID server couldn't be found"
18
+ when :invalid
19
+ failed_login "Sorry, but this does not appear to be a valid OpenID"
20
+ when :canceled
21
+ failed_login "OpenID verification was canceled"
22
+ when :failed
23
+ failed_login "Sorry, the OpenID verification failed"
24
+ when :successful
25
+ @<%= singular_name %> = <%= class_name %>.find_by_openid_identifier(identity_url)
26
+
27
+ if @<%= singular_name %>
28
+ flash[:notice] = "Welcome back."
29
+ else
30
+ @<%= singular_name %> = <%= class_name %>.create(:openid_identifier => identity_url)
31
+ @<%= singular_name %>.name = registration['fullname'] if registration['fullname'].present?
32
+ @<%= singular_name %>.email = registration['email'] if registration['email'].present?
33
+ @<%= singular_name %>.save
34
+
35
+ flash[:notice] = "Account created"
36
+ end
37
+
38
+ session[:<%= singular_name %>_id] = @<%= singular_name %>.id
39
+ redirect_to signed_in_destination
40
+ end
41
+ end
42
+ end
43
+
44
+ def signed_in_destination
45
+ (@<%= singular_name %>.email.blank? || @<%= singular_name %>.name.blank?) ? edit_user_url(@<%= singular_name %>) : user_url(@<%= singular_name %>)
46
+ end
47
+
48
+ def failed_login(message)
49
+ flash[:notice] = message
50
+ redirect_to root_url
51
+ end
52
+ end
@@ -0,0 +1,20 @@
1
+ <h1>Sign in</h1>
2
+
3
+ <style type="text/css">
4
+ input.openid {
5
+ background: url(http://openid.net/images/login-bg.gif) 0 50% no-repeat;
6
+ padding-left: 18px;
7
+ }
8
+ </style>
9
+
10
+ <%%= form_tag "/sessions" %>
11
+ <ol class="fields">
12
+ <li>
13
+ <label>Open ID URL</label>
14
+ <input type="text" class="openid" name="openid_identifier" />
15
+ </li>
16
+ <div class="buttons">
17
+ <input type="submit" />
18
+ </div>
19
+ </ol>
20
+ </form>
@@ -0,0 +1,17 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+ # name validation
3
+ validates_length_of :name, :allow_nil => true,
4
+ :in => 3..80,
5
+ :message => "should be between 3 and 80 letters long"
6
+
7
+ validates_format_of :name, :allow_nil => true,
8
+ :with => /^[^\:;!~`\@\#\$%&*\{\}\[\]|\^\\\/\?><"]+$/,
9
+ :message => "should be alphabetical"
10
+
11
+ # Email validation
12
+ validates_uniqueness_of :email, :allow_nil => true, :case_sensitive => false
13
+ validates_length_of :email, :allow_nil => true, :in => 6..100, :message => "should be between 6 and 100 letters long"
14
+ validates_format_of :email, :allow_nil => true,
15
+ :with => /(?i-mx:\\A[A-Z0-9_\\.%\\+\\-]+@(?:[A-Z0-9\\-]+\\.)+(?:[A-Z]{2,4}|museum|travel)\\z)/,
16
+ :message => "should look like an email address"
17
+ end
@@ -0,0 +1,14 @@
1
+ <h1>Edit your details</h1>
2
+
3
+ <%% semantic_form_for(@<%= singular_name %>) do |f| %>
4
+ <p><%%=h @<%= singular_name %>.openid_identifier %></p>
5
+
6
+ <ol class="fields">
7
+ <%%= f.input :name %>
8
+ <%%= f.input :email %>
9
+ </ol>
10
+
11
+ <%% f.buttons do %>
12
+ <%%= f.submit "Save details" %>
13
+ <%% end %>
14
+ <%% end %>
@@ -0,0 +1,18 @@
1
+ <p>
2
+ <b>Name:</b>
3
+ <%%=h @<%= singular_name %>.name %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Email:</b>
8
+ <%%=h @<%= singular_name %>.email %>
9
+ </p>
10
+
11
+ <p>
12
+ <b>Openid identifier:</b>
13
+ <%%=h @<%= singular_name %>.openid_identifier %>
14
+ </p>
15
+
16
+
17
+ <%%= link_to 'Edit', edit_user_path(@<%= singular_name %>) %> |
18
+ <%%= link_to 'Back', users_path %>
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "something" do
6
+ fail
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+
3
+ def show
4
+ @<%= singular_name %> = <%= class_name %>.find(params[:id])
5
+ end
6
+
7
+ def edit
8
+ @<%= singular_name %> = <%= class_name %>.find(params[:id])
9
+ end
10
+
11
+ def update
12
+ @<%= singular_name %> = <%= class_name %>.find(params[:id])
13
+ @<%= singular_name %>.attributes = params[:user]
14
+ if @<%= singular_name %>.save
15
+ flash[:notice] = 'Your account details have been changed.'
16
+ redirect_to(user_url(@<%= singular_name %>))
17
+ else
18
+ render :action => "edit"
19
+ end
20
+ end
21
+
22
+ # protected
23
+
24
+ # def check_user
25
+ # @<%= singular_name %> = <%= class_name %>.find_by_id(params[:id])
26
+ # if @<%= singular_name %>.nil? || @<%= singular_name %> != current_user
27
+ # store_location
28
+ # flash[:warning] = "You must sign in to access this page"
29
+ # redirect_to new_user_session_url
30
+ # return false
31
+ # end
32
+ # end
33
+ end
@@ -44,11 +44,9 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
44
44
  m.directory(File.join('app/controllers', controller_class_path))
45
45
  m.directory(File.join('app/helpers', controller_class_path))
46
46
  m.directory(File.join('app/views', controller_class_path, controller_file_name))
47
- m.directory(File.join('app/views/layouts', controller_class_path))
48
47
  m.directory(File.join('test/functional', controller_class_path))
49
48
  m.directory(File.join('test/unit', class_path))
50
49
  m.directory(File.join('test/unit/helpers', class_path))
51
- m.directory(File.join('public/stylesheets', class_path))
52
50
 
53
51
  for action in scaffold_views
54
52
  m.template(
@@ -56,11 +54,9 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
56
54
  File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb")
57
55
  )
58
56
  end
57
+ m.template("view_form.html.erb", File.join('app/views', controller_class_path, controller_file_name, "_form.html.erb"))
59
58
 
60
59
  # Layout and stylesheet.
61
- m.template('layout.html.erb', File.join('app/views/layouts', controller_class_path, "#{controller_file_name}.html.erb"))
62
- m.template('style.css', 'public/stylesheets/scaffold.css')
63
-
64
60
  m.template(
65
61
  'controller.rb', File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
66
62
  )
@@ -36,7 +36,7 @@ class <%= controller_class_name %>Controller < ApplicationController
36
36
  respond_to do |format|
37
37
  if @<%= file_name %>.save
38
38
  flash[:notice] = '<%= class_name %> was successfully created.'
39
- format.html { redirect_to(@<%= table_name %>_url) }
39
+ format.html { redirect_to(<%= table_name %>_url) }
40
40
  format.xml { render :xml => @<%= file_name %>, :status => :created, :location => @<%= file_name %> }
41
41
  else
42
42
  format.html { render :action => "new" }
@@ -51,7 +51,7 @@ class <%= controller_class_name %>Controller < ApplicationController
51
51
  respond_to do |format|
52
52
  if @<%= file_name %>.update_attributes(params[:<%= file_name %>])
53
53
  flash[:notice] = '<%= class_name %> was successfully updated.'
54
- format.html { redirect_to(@<%= table_name %>_url) }
54
+ format.html { redirect_to(<%= table_name %>_url) }
55
55
  format.xml { head :ok }
56
56
  else
57
57
  format.html { render :action => "edit" }
@@ -1,16 +1,2 @@
1
1
  <h1>Editing <%= singular_name %></h1>
2
-
3
- <%% form_for(@<%= singular_name %>) do |f| %>
4
- <%%= f.error_messages %>
5
-
6
- <% for attribute in attributes -%>
7
- <div class="fmElem">
8
- <%%= f.label :<%= attribute.name %> %>
9
- <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
10
- </div>
11
- <% end -%>
12
- <div class="controls">
13
- <%%= f.submit 'Create' %>
14
- <%%= link_to 'Cancel', <%= plural_name %>_path %>
15
- </div>
16
- <%% end %>
2
+ <%%= render "form" %>
@@ -0,0 +1,9 @@
1
+ <%% semantic_form_for(@<%= singular_name %>) do |f| %>
2
+ <% for attribute in attributes -%>
3
+ <%%= f.input :<%= attribute.name %> %>
4
+ <% end -%>
5
+ <%% f.buttons do %>
6
+ <%%= f.submit 'Create' %>
7
+ <%%= link_to 'Cancel', <%= plural_name %>_path %>
8
+ <%% end %>
9
+ <%% end %>
@@ -1,16 +1,2 @@
1
1
  <h1>New <%= singular_name %></h1>
2
-
3
- <%% form_for(@<%= singular_name %>) do |f| %>
4
- <%%= f.error_messages %>
5
-
6
- <% for attribute in attributes -%>
7
- <div class="fmElem">
8
- <%%= f.label :<%= attribute.name %> %>
9
- <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
10
- </div>
11
- <% end -%>
12
- <div class="controls">
13
- <%%= f.submit 'Create' %>
14
- <%%= link_to 'Cancel', <%= plural_name %>_path %>
15
- </div>
16
- <%% end %>
2
+ <%%= render "form" %>
@@ -0,0 +1,2 @@
1
+ Description:
2
+ Generates some CSS and LESS files to provide some sane defaults in your project.
@@ -0,0 +1,16 @@
1
+ class StylesGenerator < Rails::Generator::Base
2
+
3
+ def manifest
4
+ record do |m|
5
+ m.directory('public/stylesheets')
6
+ m.file "resets.css", "public/stylesheets/resets.css"
7
+ m.file "typography.less", "public/stylesheets/typography.less"
8
+ end
9
+ end
10
+
11
+ protected
12
+
13
+ def usage
14
+ "Usage: #{$0} #{spec.name}"
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ /*~~~~~~~~~~~~~~~~ Resets ~~~~~~~~~~~~~~~~*/
2
+
3
+ body, html, ol, ul, li, dl, dt, dd, p, pre, h1, h2, h3, h4, h5, h6, blockquote, table, caption, th, td, form, label, fieldset, legend, input, textarea, embed, object, img {
4
+ margin: 0;
5
+ padding: 0;
6
+ }
7
+
8
+ html { font-size: 62.5%; line-height: 1; }
9
+ h1, h2, h3, h4, h5, h6 { font-size: inherit; }
10
+ input, textarea, address, pre { font: inherit; }
11
+ td, th, caption { text-align: left; vertical-align: top; }
12
+ blockquote:before, blockquote:after, q:before, q:after { content: ""; }
13
+ blockquote, q { quotes: "" ""; }
14
+ ol, ul { list-style: none; }
15
+ textarea { vertical-align: bottom; }
16
+
17
+ legend, fieldset, a img, img { border: none; }
18
+ table { border-collapse: collapse; border-spacing: 0; }
19
+ :focus { outline: 0; }
20
+
21
+ hr {
22
+ background: #444;
23
+ border: none;
24
+ height: 1px;
25
+ width: 100%;
26
+ display: block;
27
+ margin: 0px;
28
+ margin-top: -1px;
29
+ }
30
+
31
+ /*~~~~~~~~~~~~~~~~ End Resets ~~~~~~~~~~~~~~~~*/
@@ -0,0 +1,64 @@
1
+ /**
2
+ * 1em == 10px. Each size is independent, so 2.3em here means 23px - actual em sizes are
3
+ * calculated by lessCss.
4
+ */
5
+ @baseline: 1.8em;
6
+ @bodysize: 1.2em;
7
+ @h1size: 2.4em;
8
+ @h2size: 1.8em;
9
+ @h3size: 1.4em;
10
+ @smallprint: 1.0em;
11
+
12
+ /** Calculations **/
13
+
14
+ html {
15
+ font-size: 62.5%;
16
+ line-height: @baseline
17
+ }
18
+
19
+ body {
20
+ font-size: @bodysize;
21
+ margin-top: @baseline / @bodysize;
22
+ }
23
+
24
+ p, ul, ol, dl, table, pre, blockquote, h4, h5, h6 {
25
+ margin-bottom: @baseline / @bodysize;
26
+ }
27
+
28
+ h1, h2, h3, .smallprint {
29
+ position: relative;
30
+ }
31
+
32
+ h1 {
33
+ top: (@baseline / 2 + @bodysize / 3 - @h1size / 3) / @h1size;
34
+ font-size: @h1size / @bodysize;
35
+ line-height: @baseline * 2 / @h1size;
36
+ margin-bottom: @baseline / @h1size;
37
+ }
38
+
39
+ h2 {
40
+ top: ((@baseline / 2) + (@bodysize / 3) - (@h2size / 3)) / @h2size;
41
+ font-size: @h2size / @bodysize;
42
+ line-height: @baseline * 2 / @h2size;
43
+ margin-bottom: @baseline / @h2size;
44
+ }
45
+
46
+ h3 {
47
+ font-size: @h3size / @bodysize;
48
+ line-height: @baseline / @h3size;
49
+ margin-bottom: @baseline / @h3size;
50
+ }
51
+
52
+ h4,h5,h6 {
53
+ font-size: 100%;
54
+ }
55
+
56
+ .smallprint {
57
+ font-size: @smallprint / @bodysize;
58
+ line-height: @baseline / @smallprint;
59
+ margin-bottom: @baseline / @smallprint;
60
+ }
61
+
62
+ table.padded td, table.padded th {
63
+ padding: @baseline / (@bodysize * 2)
64
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knaveofdiamonds-knave_extras
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
  - Roland Swingler
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-16 00:00:00 -07:00
12
+ date: 2009-08-22 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -37,6 +37,19 @@ files:
37
37
  - rails_generators/model/templates/migration.rb
38
38
  - rails_generators/model/templates/model.rb
39
39
  - rails_generators/model/templates/unit_test.rb
40
+ - rails_generators/openid_scaffold/openid_scaffold_generator.rb
41
+ - rails_generators/openid_scaffold/templates/application_controller.rb
42
+ - rails_generators/openid_scaffold/templates/functional_test.rb
43
+ - rails_generators/openid_scaffold/templates/helper.rb
44
+ - rails_generators/openid_scaffold/templates/helper_test.rb
45
+ - rails_generators/openid_scaffold/templates/migration.rb
46
+ - rails_generators/openid_scaffold/templates/sessions_controller.rb
47
+ - rails_generators/openid_scaffold/templates/sessions_new.erb
48
+ - rails_generators/openid_scaffold/templates/user.rb
49
+ - rails_generators/openid_scaffold/templates/user_edit.erb
50
+ - rails_generators/openid_scaffold/templates/user_show.erb
51
+ - rails_generators/openid_scaffold/templates/user_test.rb
52
+ - rails_generators/openid_scaffold/templates/users_controller.rb
40
53
  - rails_generators/scaffold/USAGE
41
54
  - rails_generators/scaffold/scaffold_generator.rb
42
55
  - rails_generators/scaffold/templates/controller.rb
@@ -46,9 +59,14 @@ files:
46
59
  - rails_generators/scaffold/templates/layout.html.erb
47
60
  - rails_generators/scaffold/templates/style.css
48
61
  - rails_generators/scaffold/templates/view_edit.html.erb
62
+ - rails_generators/scaffold/templates/view_form.html.erb
49
63
  - rails_generators/scaffold/templates/view_index.html.erb
50
64
  - rails_generators/scaffold/templates/view_new.html.erb
51
65
  - rails_generators/scaffold/templates/view_show.html.erb
66
+ - rails_generators/styles/USAGE
67
+ - rails_generators/styles/styles_generator.rb
68
+ - rails_generators/styles/templates/resets.css
69
+ - rails_generators/styles/templates/typography.less
52
70
  - test/knave-extras_test.rb
53
71
  - test/test_helper.rb
54
72
  has_rdoc: true