md-rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ *.gem
2
+ .bundle/
3
+ tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :gemcutter
2
+
3
+ # Specify your gem's dependencies in md-rails.gemspec
4
+ gemspec
@@ -0,0 +1,98 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ md-rails (0.0.1)
5
+ actionpack (>= 3.1, < 4.1)
6
+ activesupport (>= 3.1, < 4.1)
7
+ railties (>= 3.1, < 4.1)
8
+ redcarpet (>= 2.2.2)
9
+
10
+ GEM
11
+ remote: http://rubygems.org/
12
+ specs:
13
+ actionmailer (3.2.11)
14
+ actionpack (= 3.2.11)
15
+ mail (~> 2.4.4)
16
+ actionpack (3.2.11)
17
+ activemodel (= 3.2.11)
18
+ activesupport (= 3.2.11)
19
+ builder (~> 3.0.0)
20
+ erubis (~> 2.7.0)
21
+ journey (~> 1.0.4)
22
+ rack (~> 1.4.0)
23
+ rack-cache (~> 1.2)
24
+ rack-test (~> 0.6.1)
25
+ sprockets (~> 2.2.1)
26
+ activemodel (3.2.11)
27
+ activesupport (= 3.2.11)
28
+ builder (~> 3.0.0)
29
+ activerecord (3.2.11)
30
+ activemodel (= 3.2.11)
31
+ activesupport (= 3.2.11)
32
+ arel (~> 3.0.2)
33
+ tzinfo (~> 0.3.29)
34
+ activeresource (3.2.11)
35
+ activemodel (= 3.2.11)
36
+ activesupport (= 3.2.11)
37
+ activesupport (3.2.11)
38
+ i18n (~> 0.6)
39
+ multi_json (~> 1.0)
40
+ arel (3.0.2)
41
+ builder (3.0.4)
42
+ erubis (2.7.0)
43
+ hike (1.2.1)
44
+ i18n (0.6.1)
45
+ journey (1.0.4)
46
+ json (1.7.6)
47
+ mail (2.4.4)
48
+ i18n (>= 0.4.0)
49
+ mime-types (~> 1.16)
50
+ treetop (~> 1.4.8)
51
+ mime-types (1.19)
52
+ multi_json (1.5.0)
53
+ polyglot (0.3.3)
54
+ rack (1.4.4)
55
+ rack-cache (1.2)
56
+ rack (>= 0.4)
57
+ rack-ssl (1.3.2)
58
+ rack
59
+ rack-test (0.6.2)
60
+ rack (>= 1.0)
61
+ rails (3.2.11)
62
+ actionmailer (= 3.2.11)
63
+ actionpack (= 3.2.11)
64
+ activerecord (= 3.2.11)
65
+ activeresource (= 3.2.11)
66
+ activesupport (= 3.2.11)
67
+ bundler (~> 1.0)
68
+ railties (= 3.2.11)
69
+ railties (3.2.11)
70
+ actionpack (= 3.2.11)
71
+ activesupport (= 3.2.11)
72
+ rack-ssl (~> 1.3.2)
73
+ rake (>= 0.8.7)
74
+ rdoc (~> 3.4)
75
+ thor (>= 0.14.6, < 2.0)
76
+ rake (10.0.3)
77
+ rdoc (3.12)
78
+ json (~> 1.4)
79
+ redcarpet (2.2.2)
80
+ sprockets (2.2.2)
81
+ hike (~> 1.2)
82
+ multi_json (~> 1.0)
83
+ rack (~> 1.0)
84
+ tilt (~> 1.1, != 1.3.0)
85
+ thor (0.16.0)
86
+ tilt (1.3.3)
87
+ treetop (1.4.12)
88
+ polyglot
89
+ polyglot (>= 0.3.1)
90
+ tzinfo (0.3.35)
91
+
92
+ PLATFORMS
93
+ ruby
94
+
95
+ DEPENDENCIES
96
+ bundler (~> 1.1)
97
+ md-rails!
98
+ rails (>= 3.1, < 4.1)
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2010 Austin Spires
2
+
3
+ MIT Licence
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ # Md-Rails
2
+
3
+ Markdown in your stuff shouldn't suck!
4
+
5
+ ## (WIP) Usage
6
+
7
+ Add the following to your Gemfile:
8
+
9
+ gem "md-rails"
10
+
11
+ and now you're cookin with Markdown!
12
+
13
+ ## Contributors
14
+
15
+ Austin Spires, and whoever's crazy enough to send a PR
16
+
17
+ ## License
18
+
19
+ MIT
@@ -0,0 +1,5 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+ #add tests
@@ -0,0 +1,16 @@
1
+ require 'rails/generators/erb/controller/controller_generator'
2
+
3
+ module Md
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
+ :md
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ # <%%= class_name %>#<%#= @action %>
2
+
3
+ Find me in <%%= @path %>
@@ -0,0 +1,16 @@
1
+ require 'generators/md/controller/controller_generator'
2
+
3
+ module Md
4
+ module Generators
5
+ class MailerGenerator < ControllerGenerator
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ protected
9
+
10
+ def format
11
+ :text
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ <%%= class_name %>#<%%= @action %>
2
+
3
+ <%%= @greeting %> + ", find me in <%%= @path %>"
@@ -0,0 +1,36 @@
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+
3
+ module Md
4
+ module Generators
5
+ class ScaffoldGenerator < Erb::Generators::ScaffoldGenerator
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_view_files
9
+ available_views.each do |view|
10
+ filename = filename_with_extensions(view)
11
+ template "#{view}.html.md", File.join("app/views", controller_file_path, filename)
12
+ end
13
+ end
14
+
15
+ hook_for :form_builder, :as => :scaffold
16
+
17
+ def copy_form_file
18
+ if options[:form_builder].nil?
19
+ filename = filename_with_extensions("_form")
20
+ template "_form.html.erb", File.join("app/views", controller_file_path, filename)
21
+ end
22
+ end
23
+
24
+ protected
25
+
26
+ def available_views
27
+ %w(index edit show new)
28
+ end
29
+
30
+ def handler
31
+ :md
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,21 @@
1
+ <%%= form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%% if @<%= singular_table_name %>.errors.any? %>
3
+ <div id="error_explanation">
4
+ ## <%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
5
+
6
+ <%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
7
+ - <li><%%= msg %></li>
8
+ <%% end %>
9
+ </div>
10
+ <%% end %>
11
+
12
+ <% attributes.each do |attribute| -%>
13
+ <div class="field">
14
+ <%%= f.label :<%= attribute.name %> %><br />
15
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
16
+ </div>
17
+ <% end -%>
18
+ <div class="actions">
19
+ <%%= f.submit %>
20
+ </div>
21
+ <%% end %>
@@ -0,0 +1,6 @@
1
+ # Editing <%= singular_table_name %>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Show', @<%= singular_table_name %> %> |
6
+ <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -0,0 +1,29 @@
1
+ # Listing <%= plural_table_name %>
2
+
3
+ <table>
4
+ <tr>
5
+ <% for attribute in attributes -%>
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
+ <% for attribute in attributes -%>
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(<%=
20
+ singular_table_name %>) %></td>
21
+ <td><%%= link_to 'Destroy', <%= singular_table_name %>, :confirm =>
22
+ 'Are you sure?', :method => :delete %></td>
23
+ </tr>
24
+ <%% end %>
25
+ </table>
26
+
27
+ <br />
28
+
29
+ <%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path %>
@@ -0,0 +1,5 @@
1
+ # New <%= singular_table_name %>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Back', <%= index_helper %>_path %>
@@ -0,0 +1,7 @@
1
+ <p id="notice"><%%= notice %></p>
2
+ <% for attribute in attributes %>
3
+ **<%= attribute.human_name %>:** <%%= @<%= singular_table_name %>.<%= attribute.name %> %>
4
+ <% end %>
5
+
6
+ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>) %> |
7
+ <%%= link_to 'Back', <%= index_helper%>_path %>
@@ -0,0 +1,26 @@
1
+ require 'redcarpet/compat'
2
+ require 'rails'
3
+
4
+ module Md
5
+ module MarkdownHandler
6
+ def self.erb
7
+ @erb ||= ActionView::Template.registered_template_handler(:erb)
8
+ end
9
+
10
+ def self.call(template)
11
+ compiled_source = erb.call(template)
12
+ "Markdown.new(begin;#{compiled_source};end).to_html"
13
+ end
14
+ end
15
+
16
+ module Rails
17
+ class Railtie < ::Rails::Railtie
18
+ if ::Rails.version.to_f >= 3.1
19
+ config.app_generators.template_engine :md
20
+ else
21
+ config.generators.template_engine :md
22
+ end
23
+ ActionView::Template.register_template_handler :md, Md::MarkdownHandler
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,5 @@
1
+ module Md
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/md-rails/version", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "md-rails"
6
+ s.version = Md::Rails::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Austin Spires"]
9
+ s.email = ["austinspires@gmail.com"]
10
+ s.homepage = "http://github.com/aspires/md-rails"
11
+ s.summary = "Instant Markdown, just add... this"
12
+ s.description = "Md-rails gives you an instant Markdown template handler thats compatible with Rails 3. It also comes with some generators so you can automatically build with Markdown, not that you'd ever want to. But still, :boom:!"
13
+ s.licenses = ["MIT"]
14
+
15
+ s.required_rubygems_version = ">= 1.3.6"
16
+
17
+ s.add_dependency "redcarpet", ">= 2.2.2"
18
+ s.add_dependency "activesupport", [">= 3.1", "< 4.1"]
19
+ s.add_dependency "actionpack", [">= 3.1", "< 4.1"]
20
+ s.add_dependency "railties", [">= 3.1", "< 4.1"]
21
+
22
+ s.add_development_dependency "rails", [">= 3.1", "< 4.1"]
23
+ s.add_development_dependency "bundler", "~> 1.1"
24
+
25
+ s.files = `git ls-files`.split("\n")
26
+ s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
27
+ s.require_path = 'lib'
28
+ end
@@ -0,0 +1,5 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'rails/all'
4
+ require 'rails/generators'
5
+ require 'rails/generators/test_case'
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: md-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Austin Spires
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: redcarpet
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.2.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.2.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: activesupport
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.1'
38
+ - - <
39
+ - !ruby/object:Gem::Version
40
+ version: '4.1'
41
+ type: :runtime
42
+ prerelease: false
43
+ version_requirements: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '3.1'
49
+ - - <
50
+ - !ruby/object:Gem::Version
51
+ version: '4.1'
52
+ - !ruby/object:Gem::Dependency
53
+ name: actionpack
54
+ requirement: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '3.1'
60
+ - - <
61
+ - !ruby/object:Gem::Version
62
+ version: '4.1'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '3.1'
71
+ - - <
72
+ - !ruby/object:Gem::Version
73
+ version: '4.1'
74
+ - !ruby/object:Gem::Dependency
75
+ name: railties
76
+ requirement: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '3.1'
82
+ - - <
83
+ - !ruby/object:Gem::Version
84
+ version: '4.1'
85
+ type: :runtime
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '3.1'
93
+ - - <
94
+ - !ruby/object:Gem::Version
95
+ version: '4.1'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rails
98
+ requirement: !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '3.1'
104
+ - - <
105
+ - !ruby/object:Gem::Version
106
+ version: '4.1'
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ! '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '3.1'
115
+ - - <
116
+ - !ruby/object:Gem::Version
117
+ version: '4.1'
118
+ - !ruby/object:Gem::Dependency
119
+ name: bundler
120
+ requirement: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '1.1'
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: '1.1'
134
+ description: Md-rails gives you an instant Markdown template handler thats compatible
135
+ with Rails 3. It also comes with some generators so you can automatically build
136
+ with Markdown, not that you'd ever want to. But still, :boom:!
137
+ email:
138
+ - austinspires@gmail.com
139
+ executables: []
140
+ extensions: []
141
+ extra_rdoc_files: []
142
+ files:
143
+ - .gitignore
144
+ - Gemfile
145
+ - Gemfile.lock
146
+ - LICENSE
147
+ - README.md
148
+ - Rakefile
149
+ - lib/generators/md/controller/controller_generator.rb
150
+ - lib/generators/md/controller/templates/view.html.md
151
+ - lib/generators/md/mailer/mailer_generator.rb
152
+ - lib/generators/md/mailer/templates/view.text.md
153
+ - lib/generators/md/scaffold/scaffold_generator.rb
154
+ - lib/generators/md/scaffold/templates/_form.html.md
155
+ - lib/generators/md/scaffold/templates/edit.html.md
156
+ - lib/generators/md/scaffold/templates/index.html.md
157
+ - lib/generators/md/scaffold/templates/new.html.md
158
+ - lib/generators/md/scaffold/templates/show.html.md
159
+ - lib/md-rails.rb
160
+ - lib/md-rails/version.rb
161
+ - md-rails.gemspec
162
+ - test/test_helper.rb
163
+ homepage: http://github.com/aspires/md-rails
164
+ licenses:
165
+ - MIT
166
+ post_install_message:
167
+ rdoc_options: []
168
+ require_paths:
169
+ - lib
170
+ required_ruby_version: !ruby/object:Gem::Requirement
171
+ none: false
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: 1.3.6
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 1.8.25
185
+ signing_key:
186
+ specification_version: 3
187
+ summary: Instant Markdown, just add... this
188
+ test_files: []