inherited_rails_views 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in inherited_views.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/Readme.textile ADDED
@@ -0,0 +1,11 @@
1
+ h1. DRY views
2
+
3
+ The "old inherited views project":https://github.com/fredwu/inherited_resources_views by Fred was a great idea. With Rails 3.1, inherited views got even simpler. This Project provides you with basic views for your CRUD actions. No generators, no nothing ;)
4
+
5
+ h1. Install
6
+
7
+ Add the inherited_rails_views-rails gem to your Applications Gemfile:
8
+
9
+ bc. gem 'inherited_rails_views'
10
+
11
+ Now you can delete your scaffolded views folder.
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "inherited_rails_views/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "inherited_rails_views"
7
+ s.version = InheritedRailsViews::VERSION
8
+ s.authors = ["Robin Wenglewski"]
9
+ s.email = ["robin@wenglewski.de"]
10
+ s.homepage = "https://github.com/rweng/inherited_rails_views"
11
+ s.summary = %q{inherited views for Rails > 3.1}
12
+ # s.description = %q{TODO: Write a gem description}
13
+
14
+ # s.rubyforge_project = "inherited-views"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ s.add_dependency "haml-rails"
25
+ end
@@ -0,0 +1,12 @@
1
+ require "inherited_rails_views/version"
2
+ require "inherited_rails_views/helpers/application_helper"
3
+
4
+ module InheritedRailsViews
5
+ if defined?(::Rails) and Rails.version >="3.1"
6
+ class Engine < ::Rails::Engine
7
+ end
8
+
9
+ ActionController::Base.append_view_path( File.expand_path "../inherited_rails_views/views", __FILE__ )
10
+ ActionController::Base.extend ApplicationHelper
11
+ end
12
+ end
@@ -0,0 +1,6 @@
1
+ module ApplicationHelper
2
+ def shown_attrs
3
+ klass = collection.respond_to?(:klass) ? collection.klass : collection.class
4
+ klass.attribute_names - %w(id created_at updated_at)
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module InheritedRailsViews
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,19 @@
1
+ = form_for resource do |f|
2
+ -if resource.errors.any?
3
+ #error_explanation
4
+ %h2= "#{pluralize(resource.errors.count, "error")} prohibited this news from being saved:"
5
+ %ul
6
+ - resource.errors.full_messages.each do |msg|
7
+ %li= msg
8
+
9
+ %table
10
+ - shown_attrs.each do |attr|
11
+ %tr
12
+ %td.field
13
+ = f.label attr.titleize
14
+ %td.field
15
+ = f.text_field attr.to_sym
16
+ %tr
17
+ %td
18
+ %td.actions
19
+ = f.submit 'Save'
@@ -0,0 +1,10 @@
1
+ %h1
2
+ Editing
3
+ = resource.class.to_s.titleize
4
+
5
+ = render 'form'
6
+
7
+ = link_to 'Show', resource
8
+ \|
9
+ = link_to 'Back', collection_path
10
+
@@ -0,0 +1,23 @@
1
+ %h1
2
+ Listing
3
+ = collection.name
4
+
5
+ %table
6
+ %tr
7
+ - shown_attrs.each do |attr|
8
+ %th
9
+ = attr.titleize
10
+ %th
11
+ %th
12
+ %th
13
+
14
+ - collection.each do |res|
15
+ %tr
16
+ - shown_attrs.each do |attr|
17
+ %td= res.send(attr)
18
+ %td= link_to 'Show', res
19
+ %td= link_to 'Edit', edit_resource_path(res)
20
+ %td= link_to 'Destroy', res, :confirm => 'Are you sure?', :method => :delete
21
+ %br
22
+ = link_to "Create #{collection.name}", new_resource_path
23
+
@@ -0,0 +1,8 @@
1
+ %h1
2
+ New
3
+ = resource.class.to_s.titleize
4
+
5
+ = render 'form'
6
+
7
+ = link_to 'Back', collection_path
8
+
@@ -0,0 +1,15 @@
1
+ %p#notice= notice
2
+
3
+ %table
4
+ - shown_attrs.each do |attr|
5
+ %tr
6
+ %td
7
+ %b
8
+ = attr.titleize
9
+ %td
10
+ = resource.send attr
11
+
12
+ = link_to 'Edit', edit_resource_path(resource)
13
+ \|
14
+ = link_to 'Back', collection_path
15
+
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inherited_rails_views
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robin Wenglewski
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-30 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: haml-rails
16
+ requirement: &70339569922680 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70339569922680
25
+ description:
26
+ email:
27
+ - robin@wenglewski.de
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Rakefile
35
+ - Readme.textile
36
+ - inherited_rails_views.gemspec
37
+ - lib/inherited_rails_views.rb
38
+ - lib/inherited_rails_views/helpers/application_helper.rb
39
+ - lib/inherited_rails_views/version.rb
40
+ - lib/inherited_rails_views/views/application/_form.html.haml
41
+ - lib/inherited_rails_views/views/application/edit.html.haml
42
+ - lib/inherited_rails_views/views/application/index.html.haml
43
+ - lib/inherited_rails_views/views/application/new.html.haml
44
+ - lib/inherited_rails_views/views/application/show.html.haml
45
+ homepage: https://github.com/rweng/inherited_rails_views
46
+ licenses: []
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 1.8.10
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: inherited views for Rails > 3.1
69
+ test_files: []