fira 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  ##Description
4
4
 
5
- Fira adds ease-of-use functionality to HTML files. Instead of typing id="foo" or class="foo bar", you can simply type #foo or .foo .bar in HTML tags (in the normal place where you put id or class attributes)
5
+ Fira adds ease-of-use functionality to HTML files.
6
+
7
+ Instead of typing id="foo" or class="foo bar", you can simply type #foo or .foo .bar in HTML tags (in the normal place where you put id or class attributes)
6
8
 
7
9
  ## Installation
8
10
 
@@ -20,15 +22,17 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- To use Fira, rename HTML files to .html.fi and rails will automatically handle them. It will even evaluate embedded ruby code using Erubis. (note: Erubis runs after Fira)
25
+ To use Fira, rename HTML files to .html.fira and rails will automatically handle them. It will even evaluate embedded ruby code using Erubis. (note: Erubis runs after Fira)
26
+
27
+ Once in your Gemfile, Fira will be the default template_engine for <code>rails generate</code>, which means that view files that are normally .html.erb will now be .html.fira files.
24
28
 
25
29
  ##Examples
26
30
 
27
31
  ###Id's
28
- &lt;div #my_id &gt;
32
+ &lt;div #my_id &gt; becomes &lt;div id="my_id" &gt;
29
33
 
30
34
  ###Classes
31
- &lt;div .multiple .classes &gt;
35
+ &lt;div .multiple .classes &gt; becomes &lt;div class='multiple classes' &gt;
32
36
 
33
37
  ## Contributing
34
38
 
data/fira.gemspec CHANGED
@@ -12,6 +12,10 @@ Gem::Specification.new do |gem|
12
12
  gem.summary = %q{Smarter HTML}
13
13
  gem.homepage = "https://github.com/cameronsutter/fira"
14
14
 
15
+ gem.add_dependency "activesupport", [">= 3.1", "< 4.1"]
16
+ gem.add_dependency "actionpack", [">= 3.1", "< 4.1"]
17
+ gem.add_dependency "railties", [">= 3.1", "< 4.1"]
18
+
15
19
  gem.files = `git ls-files`.split($/)
16
20
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
21
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
data/lib/fira.rb CHANGED
@@ -11,4 +11,5 @@ module Fira
11
11
  end
12
12
 
13
13
  require 'fira/engine'
14
- require 'fira/helpers'
14
+ require 'fira/helpers'
15
+ require 'fira/fira-rails'
@@ -0,0 +1,15 @@
1
+ require 'fira'
2
+ require 'rails'
3
+
4
+ module Fira
5
+ module Rails
6
+ class Railtie < ::Rails::Railtie
7
+ if ::Rails.version.to_f >= 3.1
8
+ config.app_generators.template_engine :fira
9
+ else
10
+ config.generators.template_engine :fira
11
+ end
12
+
13
+ end
14
+ end
15
+ end
data/lib/fira/helpers.rb CHANGED
@@ -26,6 +26,7 @@ module Fira
26
26
  end
27
27
 
28
28
  end
29
+ #register as default template handler
29
30
  handler_klass = Fira::FiraHandler
30
- ActionView::Template::register_default_template_handler :fi, handler_klass
31
+ ActionView::Template::register_default_template_handler :fira, handler_klass
31
32
  end
data/lib/fira/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fira
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'rails/generators/erb/controller/controller_generator'
2
+
3
+ module Fira
4
+ module Generators
5
+ class ControllerGenerator < Erb::Generators::ControllerGenerator
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ protected
9
+
10
+ def handler
11
+ :fira
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,2 @@
1
+ <h1><%= class_name %>#<%= @action %></h1>
2
+ <p>Find me in <%= @path %></p>
@@ -0,0 +1,18 @@
1
+ require 'generators/fira/controller/controller_generator'
2
+
3
+ module Fira
4
+ module Generators
5
+
6
+ class MailerGenerator < ControllerGenerator
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ protected
10
+
11
+ def format
12
+ :text
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ <%= class_name %>#<%= @action %>
2
+
3
+ <%%= @greeting %>, find me in app/views/<%= @path %>
@@ -0,0 +1,37 @@
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+
3
+ module Fira
4
+ module Generators
5
+
6
+ class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
7
+ source_root File.expand_path("../templates", __FILE__)
8
+
9
+ def copy_view_files
10
+ available_views.each do |view|
11
+ filename = filename_with_extensions(view)
12
+ template "#{view}.html.fira", File.join("app/views", controller_file_path, filename)
13
+ end
14
+ end
15
+
16
+ hook_for :form_builder, :as => :scaffold
17
+
18
+ def copy_form_file
19
+ if options[:form_builder].nil?
20
+ filename = filename_with_extensions("_form")
21
+ template "_form.html.fira", File.join("app/views", controller_file_path, filename)
22
+ end
23
+ end
24
+
25
+ protected
26
+
27
+ def available_views
28
+ %w(index edit show new)
29
+ end
30
+
31
+ def handler
32
+ :fira
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,6 @@
1
+ <h1>Editing <%= singular_table_name %></h1>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Show', @<%= singular_table_name %> %> |
6
+ <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -0,0 +1,27 @@
1
+ <h1>Listing <%= plural_table_name %></h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <% attributes.each do |attribute| -%>
6
+ <th><%= attribute.human_name %></th>
7
+ <% end -%>
8
+ <th></th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
14
+ <tr>
15
+ <% attributes.each do |attribute| -%>
16
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
+ <% end -%>
18
+ <td><%%= link_to 'Show', <%= singular_table_name %> %></td>
19
+ <td><%%= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>) %></td>
20
+ <td><%%= link_to 'Destroy', <%= singular_table_name %>, <%= key_value :method, ":delete" %>, <%= key_value :data, "{ #{key_value :confirm, "'Are you sure?'"} }" %> %></td>
21
+ </tr>
22
+ <%% end %>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New <%= singular_table_name %></h1>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -0,0 +1,12 @@
1
+ <p id="notice"><%%= notice %></p>
2
+
3
+ <% attributes.each do |attribute| -%>
4
+ <p>
5
+ <b><%= attribute.human_name %>:</b>
6
+ <%%= @<%= singular_table_name %>.<%= attribute.name %> %>
7
+ </p>
8
+
9
+ <% end -%>
10
+
11
+ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
12
+ <%%= link_to 'Back', <%= index_helper %>_path %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fira
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,74 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2013-01-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ - - <
23
+ - !ruby/object:Gem::Version
24
+ version: '4.1'
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '3.1'
33
+ - - <
34
+ - !ruby/object:Gem::Version
35
+ version: '4.1'
36
+ - !ruby/object:Gem::Dependency
37
+ name: actionpack
38
+ requirement: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '3.1'
44
+ - - <
45
+ - !ruby/object:Gem::Version
46
+ version: '4.1'
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - - <
56
+ - !ruby/object:Gem::Version
57
+ version: '4.1'
58
+ - !ruby/object:Gem::Dependency
59
+ name: railties
60
+ requirement: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '3.1'
66
+ - - <
67
+ - !ruby/object:Gem::Version
68
+ version: '4.1'
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '3.1'
77
+ - - <
78
+ - !ruby/object:Gem::Version
79
+ version: '4.1'
14
80
  description: Adds improvements to HTML syntax for id and class attributes
15
81
  email:
16
82
  - cameronsutter0@gmail.com
@@ -28,8 +94,18 @@ files:
28
94
  - fira.gemspec
29
95
  - lib/fira.rb
30
96
  - lib/fira/engine.rb
97
+ - lib/fira/fira-rails.rb
31
98
  - lib/fira/helpers.rb
32
99
  - lib/fira/version.rb
100
+ - lib/generators/fira/controller/controller_generator.rb
101
+ - lib/generators/fira/controller/templates/view.html.fira
102
+ - lib/generators/fira/mailer/mailer_generator.rb
103
+ - lib/generators/fira/mailer/templates/view.text.fira
104
+ - lib/generators/fira/scaffold/scaffold_generator.rb
105
+ - lib/generators/fira/scaffold/templates/edit.html.fira
106
+ - lib/generators/fira/scaffold/templates/index.html.fira
107
+ - lib/generators/fira/scaffold/templates/new.html.fira
108
+ - lib/generators/fira/scaffold/templates/show.html.fira
33
109
  homepage: https://github.com/cameronsutter/fira
34
110
  licenses: []
35
111
  post_install_message: