Class: Markdown::Generators::ScaffoldGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Markdown::Generators::ScaffoldGenerator
- Defined in:
- lib/markdown-scaffold.rb
Instance Method Summary collapse
-
#generate_scaffold ⇒ Object
——————-# generate_scaffold # ——————-#.
Instance Method Details
#generate_scaffold ⇒ Object
——————-# generate_scaffold # ——————-#
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/markdown-scaffold.rb', line 15 def generate_scaffold # stylesheets/pygments.css copy_file( "templates/pygments.css", "app/assets/stylesheets/pygments.css" ) # models/html_with_pygments.rb copy_file( "templates/html_with_pygments.rb", "app/models/html_with_pygments.rb" ) # controllers/application_controller.rb content = "\n" content += " #---------------#\n" content += " # show_markdown #\n" content += " #---------------#\n" content += " # Markdown変換\n" content += " def show_markdown( text )\n" content += " html_render = HtmlWithPygments.new( hard_wrap: true, filter_html: true )\n" content += " markdown = Redcarpet::Markdown.new( html_render, autolink: true, fenced_code_blocks: true, space_after_headers: true )\n" content += "\n" content += " return markdown.render( text )\n" content += " end\n" content += "\n" content += " helper_method :show_markdown\n" insert_into_file( "app/controllers/application_controller.rb", content.force_encoding('ASCII-8BIT'), after: "private\n" ) # initializers/ruby_python.rb copy_file( "templates/ruby_python.rb", "config/initializers/ruby_python.rb" ) end |