├── .gitignore ├── Gemfile ├── MIT-LICENSE ├── README.md ├── Rakefile ├── app ├── assets │ └── config │ │ └── markdown_rails_manifest.js └── helpers │ └── .keep ├── bin ├── rails └── test ├── lib ├── generators │ └── markdown_rails │ │ └── install │ │ ├── USAGE │ │ ├── install_generator.rb │ │ └── templates │ │ ├── app │ │ └── markdown │ │ │ ├── application_markdown.rb │ │ │ └── erb_markdown.rb │ │ └── config │ │ └── initializers │ │ └── markdown.rb ├── markdown-rails.rb ├── markdown-rails │ ├── engine.rb │ ├── handler.rb │ ├── helper │ │ └── rouge.rb │ ├── railtie.rb │ ├── renderer │ │ ├── base.rb │ │ └── rails.rb │ └── version.rb └── tasks │ └── markdown │ └── rails_tasks.rake ├── markdown-rails.gemspec └── test ├── dummy ├── .ruby-version ├── Gemfile ├── README.md ├── Rakefile ├── app │ ├── assets │ │ ├── config │ │ │ └── manifest.js │ │ ├── images │ │ │ └── .keep │ │ └── stylesheets │ │ │ └── application.css │ ├── channels │ │ └── application_cable │ │ │ ├── channel.rb │ │ │ └── connection.rb │ ├── controllers │ │ ├── application_controller.rb │ │ └── concerns │ │ │ └── .keep │ ├── helpers │ │ └── application_helper.rb │ ├── jobs │ │ └── application_job.rb │ ├── mailers │ │ └── application_mailer.rb │ ├── models │ │ ├── application_record.rb │ │ └── concerns │ │ │ └── .keep │ └── views │ │ └── layouts │ │ ├── application.html.erb │ │ ├── mailer.html.erb │ │ └── mailer.text.erb ├── bin │ ├── rails │ ├── rake │ └── setup ├── config.ru ├── config │ ├── application.rb │ ├── boot.rb │ ├── cable.yml │ ├── database.yml │ ├── environment.rb │ ├── environments │ │ ├── development.rb │ │ ├── production.rb │ │ └── test.rb │ ├── initializers │ │ ├── content_security_policy.rb │ │ ├── filter_parameter_logging.rb │ │ ├── inflections.rb │ │ └── permissions_policy.rb │ ├── locales │ │ └── en.yml │ ├── puma.rb │ ├── routes.rb │ └── storage.yml ├── lib │ └── assets │ │ └── .keep ├── log │ ├── .keep │ └── development.log ├── public │ ├── 404.html │ ├── 422.html │ ├── 500.html │ ├── apple-touch-icon-precomposed.png │ ├── apple-touch-icon.png │ └── favicon.ico ├── storage │ └── .keep └── tmp │ ├── .keep │ ├── development_secret.txt │ ├── pids │ └── .keep │ └── storage │ └── .keep ├── lib └── generators │ └── markdown │ └── install_generator_test.rb ├── markdown └── rails_test.rb └── test_helper.rb /.gitignore: -------------------------------------------------------------------------------- 1 | Gemfile.lock 2 | *.gem 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | # Specify your gem's dependencies in markdown-rails.gemspec. 5 | gemspec 6 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Brad Gessler 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # markdown-rails 2 | 3 | This gem allows you to write static Rails views and partials using the [Markdown](http://daringfireball.net/projects/markdown/syntax) syntax. No more editing prose in HTML! 4 | 5 | It is a comprehensive Markdown library for Rails that addresses the following pain points: 6 | 7 | * Renders markdown files and partials that you can throw in your Rails view paths, like `./app/views/people/profile.html.md`. 8 | * Parse Erb blocks in markdown files. 9 | * Customize markdown tags like `![]()` to support embeds beyond images like YouTube links, code fences for syntax highlighting, etc. 10 | * Plug into Rails asset pipeline so images defined in Markdown will be loaded from the forever-cached image assets. 11 | * Define multiple markdown renders so you can render more dangerous-user upload markdown content vs markdown that you can trust, like content files checked into your Rails project. 12 | 13 | This project is used heavily by https://sitepress.cc to manage content files in Rails, but it can be used on its own for Rails views. 14 | 15 | ## Usage 16 | 17 | Add the following to your application's Gemfile: 18 | 19 | ```sh 20 | $ bundle add 'markdown-rails' 21 | ``` 22 | 23 | Then from the root of your Rails project, run: 24 | 25 | ```sh 26 | $ bin/rails g markdown_rails:install 27 | ``` 28 | 29 | This adds a `config/initializers/markdown.rb` file where you can register template handler for your Markdown renders that are located in `./app/markdown/*.rb`. 30 | 31 | Now add views or partials ending in `.md` in your `./app/views/**/**` directories and behold! 32 | 33 | ### Upgrading from 1.x 34 | 35 | Change your applications Gemfile to read: 36 | 37 | ```ruby 38 | gem "markdown-rails", "~> 2.0.0" 39 | ``` 40 | 41 | Then from the root of your Rails project, run: 42 | 43 | ```sh 44 | $ bin/rails g markdown_rails:install 45 | ``` 46 | 47 | If you have an existing file in `config/initializers/markdown.rb` you'll need to move those settings over. Note that 1.x used `RDiscount` as the default renderer, which was replaced by `Redcarpet` in 2.x. 48 | 49 | ## Configuration 50 | 51 | Applications commonly need various markdown variants within one application. For example, 52 | 53 | ```ruby 54 | # ./config/initializers/markdown.rb 55 | # Restart the server to see changes made to this file. 56 | 57 | # Setup markdown stacks to work with different template handler in Rails. 58 | MarkdownRails.handle :md do 59 | ApplicationMarkdown.new 60 | end 61 | 62 | MarkdownRails.handle :crazymd do 63 | MyCrazyMarkdown.new 64 | end 65 | ``` 66 | 67 | ### Enable Erb in Markdown 68 | 69 | Only enable Erb in Markdown if you trust the source of the file. Do not enable it for markdown provided by users or they will be able to execute arbitrary Ruby code. 70 | 71 | ```ruby 72 | # ./config/initializers/markdown.rb 73 | MarkdownRails.handle :markerb do 74 | ErbMarkdown.new 75 | end 76 | ``` 77 | 78 | You *could* change `:markerb` to `:md`, but I don't recommend it for all Markdown files or you'll run into problems if you have content like `<%= Time.current %>` inside of an `erb` codefence. You're better off having two configurations: one that handles Erb and another that doesn't, like this: 79 | 80 | ```ruby 81 | # ./config/initializers/markdown.rb 82 | # Restart the server to see changes made to this file. 83 | 84 | # Setup markdown stacks to work with different template handler in Rails. 85 | MarkdownRails.handle :md do 86 | ApplicationMarkdown.new 87 | end 88 | 89 | MarkdownRails.handle :markerb do 90 | ErbMarkdown.new 91 | end 92 | ``` 93 | 94 | The same technique can be used for preprocessing Markdown with other handlers, like liquid. 95 | 96 | ## Customizing renderer 97 | 98 | You might want to customize your Markdown handler to do things like syntax code highlighting, etc. 99 | 100 | ```ruby 101 | # ./app/markdown/application_markdown.rb 102 | require "rouge" 103 | 104 | class ApplicationMarkdown < RailsMarkdown 105 | include Redcarpet::Render::SmartyPants 106 | 107 | FORMATTER = Rouge::Formatters::HTMLInline.new("monokai.sublime") 108 | 109 | def enable 110 | [:fenced_code_blocks] 111 | end 112 | 113 | def block_code(code, language) 114 | lexer = Rouge::Lexer.find(language) 115 | content_tag :pre, class: language do 116 | raw FORMATTER.format(lexer.lex(code)) 117 | end 118 | end 119 | end 120 | ``` 121 | 122 | Consider using a componet farmework, like [phlex](https://www.phlex.fun) to generate tags outside of the Rails view context. 123 | 124 | ## Examples 125 | 126 | There's a lot of ways to use Markdown in your Rails app. 127 | 128 | ### The easy way 129 | 130 | Your best bet is to use this with a content management site like https://sitepress.cc/ if you're going to be dealing with a lot of markdown content on your website. 131 | 132 | ### Static view 133 | 134 | In `app/views/home/about.html.md`: 135 | 136 | ```markdown 137 | # About This Site 138 | 139 | *Markdown code goes here ...* 140 | ``` 141 | 142 | Keep in mind that unlike static files dropped in `public`, you still need a matching route, such as `get ':action', :controller => :home`, to route `/about` to `home#about`. You could also [use Sitepress](https://sitepress.cc) to automatically manage these routes for you if you're dealing with a lot of pages. 143 | 144 | ### Static partial 145 | 146 | In `app/views/posts/edit.html.erb`: 147 | 148 | ```erb 149 |
150 |` blocks inside your Markdown may be indented when Haml is not in ["ugly" (production) mode](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#ugly-option), causing leading white-space to appear in development mode. To fix this, set `Haml::Template.options[:ugly] = true`. 164 | 165 | ## Security 166 | 167 | Despite Markdown being a static language, you should not use this gem to process untrusted Markdown views (or partials). In other words, do not add Markdown views from a source if you wouldn't trust Erb views from them. 168 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/setup" 2 | 3 | load "rails/tasks/statistics.rake" 4 | 5 | require "bundler/gem_tasks" 6 | -------------------------------------------------------------------------------- /app/assets/config/markdown_rails_manifest.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/app/assets/config/markdown_rails_manifest.js -------------------------------------------------------------------------------- /app/helpers/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/app/helpers/.keep -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails gems 3 | # installed from the root of your application. 4 | 5 | ENGINE_ROOT = File.expand_path("..", __dir__) 6 | ENGINE_PATH = File.expand_path("../lib/markdown-rails/engine", __dir__) 7 | 8 | # Set up gems listed in the Gemfile. 9 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 10 | require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) 11 | 12 | require "rails" 13 | # Pick the frameworks you want: 14 | require "active_model/railtie" 15 | require "active_job/railtie" 16 | require "active_record/railtie" 17 | require "active_storage/engine" 18 | require "action_controller/railtie" 19 | require "action_mailer/railtie" 20 | require "action_view/railtie" 21 | require "action_cable/engine" 22 | # require "rails/test_unit/railtie" 23 | require "rails/engine/commands" 24 | -------------------------------------------------------------------------------- /bin/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $: << File.expand_path("../test", __dir__) 3 | 4 | require "bundler/setup" 5 | require "rails/plugin/test" 6 | -------------------------------------------------------------------------------- /lib/generators/markdown_rails/install/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Installs MarkdownRails to your Rails project 3 | 4 | Example: 5 | bin/rails generate markdown_rails:install 6 | 7 | This will create: 8 | config/initializers/markdown.rb 9 | app/markdown/application_markdown.rb 10 | -------------------------------------------------------------------------------- /lib/generators/markdown_rails/install/install_generator.rb: -------------------------------------------------------------------------------- 1 | class MarkdownRails::InstallGenerator < Rails::Generators::Base 2 | source_root File.expand_path("templates", __dir__) 3 | 4 | def copy_files 5 | directory "app" 6 | directory "config" 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /lib/generators/markdown_rails/install/templates/app/markdown/application_markdown.rb: -------------------------------------------------------------------------------- 1 | # You should read the docs at https://github.com/vmg/redcarpet and probably 2 | # delete a bunch of stuff below if you don't need it. 3 | 4 | class ApplicationMarkdown < MarkdownRails::Renderer::Rails 5 | # Reformats your boring punctation like " and " into “ and ” so you can look 6 | # and feel smarter. Read the docs at https://github.com/vmg/redcarpet#also-now-our-pants-are-much-smarter 7 | include Redcarpet::Render::SmartyPants 8 | 9 | # Run `bundle add rouge` and uncomment the include below for syntax highlighting 10 | # include MarkdownRails::Helper::Rouge 11 | 12 | # If you need access to ActionController::Base.helpers, you can delegate by uncommenting 13 | # and adding to the list below. Several are already included for you in the `MarkdownRails::Renderer::Rails`, 14 | # but you can add more here. 15 | # 16 | # To see a list of methods available run `bin/rails runner "puts ActionController::Base.helpers.public_methods.sort"` 17 | # 18 | # delegate \ 19 | # :request, 20 | # :cache, 21 | # :turbo_frame_tag, 22 | # to: :helpers 23 | 24 | # These flags control features in the Redcarpet renderer, which you can read 25 | # about at https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use 26 | # Make sure you know what you're doing if you're using this to render user inputs. 27 | def enable 28 | [:fenced_code_blocks] 29 | end 30 | 31 | # Example of how you might override the images to show embeds, like a YouTube video. 32 | def image(link, title, alt) 33 | url = URI(link) 34 | case url.host 35 | when "www.youtube.com" 36 | youtube_tag url, alt 37 | else 38 | super 39 | end 40 | end 41 | 42 | private 43 | # This is provided as an example; there's many more YouTube URLs that this wouldn't catch. 44 | def youtube_tag(url, alt) 45 | embed_url = "https://www.youtube-nocookie.com/embed/#{CGI.parse(url.query).fetch("v").first}" 46 | content_tag :iframe, 47 | src: embed_url, 48 | width: 560, 49 | height: 325, 50 | allow: "encrypted-media; picture-in-picture", 51 | allowfullscreen: true \ 52 | do alt end 53 | end 54 | end 55 | -------------------------------------------------------------------------------- /lib/generators/markdown_rails/install/templates/app/markdown/erb_markdown.rb: -------------------------------------------------------------------------------- 1 | # DANGER! This parses Erb, which means arbitrary Ruby can be run. Make sure 2 | # you trust the source of your markdown and that its not user input. 3 | 4 | class ErbMarkdown < ApplicationMarkdown 5 | # Enables Erb to render for the entire doc before the markdown is rendered. 6 | # This works great, except when you have an `erb` code fence. 7 | def preprocess(html) 8 | # Read more about this render call at https://guides.rubyonrails.org/layouts_and_rendering.html 9 | render inline: html, handler: :erb 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/generators/markdown_rails/install/templates/config/initializers/markdown.rb: -------------------------------------------------------------------------------- 1 | # Restart the server to see changes made to this file. 2 | 3 | # Setup markdown stacks to work with different template handler in Rails. 4 | MarkdownRails.handle :md, :markdown do 5 | ApplicationMarkdown.new 6 | end 7 | 8 | # Don't use Erb for untrusted markdown content created by users; otherwise they 9 | # can execute arbitrary code on your server. This should only be used for input you 10 | # trust, like content files from your code repo. 11 | MarkdownRails.handle :markerb do 12 | ErbMarkdown.new 13 | end 14 | -------------------------------------------------------------------------------- /lib/markdown-rails.rb: -------------------------------------------------------------------------------- 1 | require "markdown-rails/version" 2 | require "markdown-rails/engine" 3 | 4 | module MarkdownRails 5 | def self.handle(*extensions, &block) 6 | Handler.handle(*extensions, &block) 7 | end 8 | 9 | autoload :Handler, "markdown-rails/handler" 10 | 11 | module Renderer 12 | autoload :Base, "markdown-rails/renderer/base" 13 | autoload :Rails, "markdown-rails/renderer/rails" 14 | end 15 | 16 | module Helper 17 | autoload :Rouge, "markdown-rails/helper/rouge" 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /lib/markdown-rails/engine.rb: -------------------------------------------------------------------------------- 1 | module MarkdownRails 2 | class Engine < ::Rails::Engine 3 | # Check if the `.md` extension has been registered after the 4 | # config/initializer files are processed. This makes the `:md` 5 | # extension work if the user forgot to install the initializers. 6 | config.before_initialize do 7 | MarkdownRails::Handler.register_default 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /lib/markdown-rails/handler.rb: -------------------------------------------------------------------------------- 1 | module MarkdownRails 2 | # We cannot use MarkdownRails because it conflicts with RDiscount's Markdown class 3 | class Handler 4 | DEFAULT_EXTENSION = :md 5 | 6 | def initialize(&block) 7 | @markdown = block 8 | end 9 | 10 | def call(template, source = template.source) 11 | renderer.render(source).inspect + '.html_safe' 12 | end 13 | 14 | def self.handle(*extensions, &block) 15 | Array(extensions).each do |extension| 16 | handler = new &block 17 | ActionView::Template.register_template_handler extension, handler 18 | end 19 | end 20 | 21 | # Registers a default `.md` handler for Rails templates. This might be 22 | # replaced by a handler in the `config/initializers/markdown.rb` file. 23 | def self.register_default 24 | handle(DEFAULT_EXTENSION) { MarkdownRails::Renderer::Rails.new } 25 | end 26 | 27 | private 28 | 29 | def markdown 30 | @cache = nil unless cache_enabled? 31 | @cache ||= @markdown.call 32 | end 33 | 34 | def renderer 35 | @renderer = nil unless cache_enabled? 36 | @renderer ||= markdown.renderer 37 | end 38 | 39 | def cache_enabled? 40 | ::Rails.configuration.cache_classes 41 | end 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /lib/markdown-rails/helper/rouge.rb: -------------------------------------------------------------------------------- 1 | require "rouge" 2 | 3 | module MarkdownRails 4 | module Helper 5 | module Rouge 6 | def rouge_theme 7 | "gruvbox".freeze 8 | end 9 | 10 | def rouge_formatter 11 | ::Rouge::Formatters::HTMLInline.new(rouge_theme) 12 | end 13 | 14 | def rouge_fallback_lexer 15 | rouge_lexer "text" 16 | end 17 | 18 | def highlight_code(code, language) 19 | lexer = rouge_lexer(language) || rouge_fallback_lexer 20 | rouge_formatter.format(lexer.lex(code)) 21 | end 22 | 23 | def block_code(code, language) 24 | content_tag :pre, class: language do 25 | raw highlight_code code, language 26 | end 27 | end 28 | 29 | def rouge_lexer(language) 30 | ::Rouge::Lexer.find language 31 | end 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /lib/markdown-rails/railtie.rb: -------------------------------------------------------------------------------- 1 | module MarkdownRails 2 | class Railtie < ::Rails::Railtie 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /lib/markdown-rails/renderer/base.rb: -------------------------------------------------------------------------------- 1 | require "redcarpet" 2 | 3 | module MarkdownRails 4 | module Renderer 5 | class Base < Redcarpet::Render::HTML 6 | def enable 7 | # This is a very restrictive Markdown renderer that errs on the side of safety. 8 | # For more details read the docs at https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderer-for-lunch 9 | [ 10 | :filter_html, 11 | :no_images, 12 | :no_links, 13 | :no_styles, 14 | :safe_links_only 15 | ] 16 | end 17 | 18 | def renderer 19 | # I can get away passing fatures into this class because they don't 20 | # overlap and RedCarpet is happy accepting both. 21 | ::Redcarpet::Markdown.new(self.class.new(**features), **features) 22 | end 23 | 24 | private 25 | def features 26 | Hash[Array(enable).map{ |feature| [ feature, true ] }] 27 | end 28 | end 29 | end 30 | end 31 | -------------------------------------------------------------------------------- /lib/markdown-rails/renderer/rails.rb: -------------------------------------------------------------------------------- 1 | module MarkdownRails 2 | module Renderer 3 | class Rails < Base 4 | include ::Rails.application.routes.url_helpers 5 | 6 | # Rendering from Markdown is actually outside of the view 7 | # context, so we need to delegate render to the ApplicationController 8 | # render method that can render outside of the view context. 9 | delegate \ 10 | :helpers, 11 | :render, 12 | to: :base_controller 13 | 14 | delegate \ 15 | :asset_digest_path, 16 | :asset_path, 17 | :asset_url, 18 | :audio_path, 19 | :audio_tag, 20 | :audio_url, 21 | :font_path, 22 | :font_url, 23 | :image_path, 24 | :image_tag, 25 | :image_url, 26 | :video_path, 27 | :video_tag, 28 | :video_url, 29 | :tag, 30 | :content_tag, 31 | :request, 32 | :turbo_frame_tag, 33 | :controller, 34 | :raw, 35 | to: :helpers 36 | 37 | def image(link, title, alt) 38 | image_tag link, title: title, alt: alt 39 | end 40 | 41 | protected 42 | def base_controller 43 | ::ApplicationController 44 | end 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /lib/markdown-rails/version.rb: -------------------------------------------------------------------------------- 1 | module MarkdownRails 2 | VERSION = "2.1.0" 3 | end 4 | -------------------------------------------------------------------------------- /lib/tasks/markdown/rails_tasks.rake: -------------------------------------------------------------------------------- 1 | # desc "Explaining what the task does" 2 | # task :markdown_rails do 3 | # # Task goes here 4 | # end 5 | -------------------------------------------------------------------------------- /markdown-rails.gemspec: -------------------------------------------------------------------------------- 1 | require_relative "lib/markdown-rails/version" 2 | 3 | Gem::Specification.new do |spec| 4 | spec.name = "markdown-rails" 5 | spec.version = MarkdownRails::VERSION 6 | spec.authors = ["Brad Gessler"] 7 | spec.email = ["bradgessler@gmail.com"] 8 | spec.homepage = "https://github.com/sitepress/markdown-rails" 9 | spec.summary = "Markdown templates and partials in Rails." 10 | spec.description = "Markdown Rails is a comprehensive stack for rendering Markdown templates and partials in Rails." 11 | spec.license = "MIT" 12 | 13 | # Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host" 14 | # to allow pushing to a single host or delete this section to allow pushing to any host. 15 | spec.metadata["allowed_push_host"] = "https://rubygems.org/" 16 | 17 | spec.metadata["homepage_uri"] = spec.homepage 18 | spec.metadata["source_code_uri"] = spec.homepage 19 | spec.metadata["changelog_uri"] = spec.homepage 20 | 21 | spec.files = Dir.chdir(File.expand_path(__dir__)) do 22 | Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] 23 | end 24 | 25 | rails_version = ">= 6.0.0" 26 | spec.add_dependency "railties", rails_version 27 | spec.add_dependency "actionview", rails_version 28 | spec.add_dependency "activesupport", rails_version 29 | spec.add_dependency "redcarpet", ">= 3.0.0" 30 | end 31 | -------------------------------------------------------------------------------- /test/dummy/.ruby-version: -------------------------------------------------------------------------------- 1 | 3.1.2 2 | -------------------------------------------------------------------------------- /test/dummy/Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby "3.1.2" 5 | 6 | # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" 7 | gem "rails", "~> 7.0.4" 8 | 9 | # Use sqlite3 as the database for Active Record 10 | gem "sqlite3", "~> 1.4" 11 | 12 | # Use the Puma web server [https://github.com/puma/puma] 13 | gem "puma", "~> 5.0" 14 | 15 | # Build JSON APIs with ease [https://github.com/rails/jbuilder] 16 | gem "jbuilder" 17 | 18 | # Use Redis adapter to run Action Cable in production 19 | # gem "redis", "~> 4.0" 20 | 21 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] 22 | # gem "kredis" 23 | 24 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] 25 | # gem "bcrypt", "~> 3.1.7" 26 | 27 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 28 | gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] 29 | 30 | # Reduces boot times through caching; required in config/boot.rb 31 | gem "bootsnap", require: false 32 | 33 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] 34 | # gem "image_processing", "~> 1.2" 35 | 36 | group :development, :test do 37 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem 38 | gem "debug", platforms: %i[ mri mingw x64_mingw ] 39 | end 40 | 41 | group :development do 42 | # Use console on exceptions pages [https://github.com/rails/web-console] 43 | gem "web-console" 44 | 45 | # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] 46 | # gem "rack-mini-profiler" 47 | 48 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring] 49 | # gem "spring" 50 | end 51 | 52 | group :test do 53 | # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] 54 | gem "capybara" 55 | gem "selenium-webdriver" 56 | gem "webdrivers" 57 | end 58 | -------------------------------------------------------------------------------- /test/dummy/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /test/dummy/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /test/dummy/app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../stylesheets .css 3 | -------------------------------------------------------------------------------- /test/dummy/app/assets/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/app/assets/images/.keep -------------------------------------------------------------------------------- /test/dummy/app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* Application styles */ 2 | -------------------------------------------------------------------------------- /test/dummy/app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /test/dummy/app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /test/dummy/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | end 3 | -------------------------------------------------------------------------------- /test/dummy/app/controllers/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/app/controllers/concerns/.keep -------------------------------------------------------------------------------- /test/dummy/app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /test/dummy/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /test/dummy/app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "from@example.com" 3 | layout "mailer" 4 | end 5 | -------------------------------------------------------------------------------- /test/dummy/app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /test/dummy/app/models/concerns/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/app/models/concerns/.keep -------------------------------------------------------------------------------- /test/dummy/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |Dummy 5 | 6 | <%= csrf_meta_tags %> 7 | <%= csp_meta_tag %> 8 | 9 | <%= stylesheet_link_tag "application" %> 10 | 11 | 12 | 13 | <%= yield %> 14 | 15 | 16 | -------------------------------------------------------------------------------- /test/dummy/app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /test/dummy/app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /test/dummy/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /test/dummy/bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /test/dummy/bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path("..", __dir__) 6 | 7 | def system!(*args) 8 | system(*args) || abort("\n== Command #{args} failed ==") 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts "== Installing dependencies ==" 17 | system! "gem install bundler --conservative" 18 | system("bundle check") || system!("bundle install") 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?("config/database.yml") 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! "bin/rails db:prepare" 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! "bin/rails log:clear tmp:clear" 30 | 31 | puts "\n== Restarting application server ==" 32 | system! "bin/rails restart" 33 | end 34 | -------------------------------------------------------------------------------- /test/dummy/config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /test/dummy/config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require "rails/all" 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | require "markdown-rails" 9 | 10 | module Dummy 11 | class Application < Rails::Application 12 | config.load_defaults Rails::VERSION::STRING.to_f 13 | 14 | # Configuration for the application, engines, and railties goes here. 15 | # 16 | # These settings can be overridden in specific environments using the files 17 | # in config/environments, which are processed later. 18 | # 19 | # config.time_zone = "Central Time (US & Canada)" 20 | # config.eager_load_paths << Rails.root.join("extras") 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /test/dummy/config/boot.rb: -------------------------------------------------------------------------------- 1 | # Set up gems listed in the Gemfile. 2 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) 3 | 4 | require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) 5 | $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) 6 | -------------------------------------------------------------------------------- /test/dummy/config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: test 6 | 7 | production: 8 | adapter: redis 9 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 10 | channel_prefix: dummy_production 11 | -------------------------------------------------------------------------------- /test/dummy/config/database.yml: -------------------------------------------------------------------------------- 1 | # SQLite. Versions 3.8.0 and up are supported. 2 | # gem install sqlite3 3 | # 4 | # Ensure the SQLite 3 gem is defined in your Gemfile 5 | # gem "sqlite3" 6 | # 7 | default: &default 8 | adapter: sqlite3 9 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 10 | timeout: 5000 11 | 12 | development: 13 | <<: *default 14 | database: db/development.sqlite3 15 | 16 | # Warning: The database defined as "test" will be erased and 17 | # re-generated from your development database when you run "rake". 18 | # Do not set this db to the same as development or production. 19 | test: 20 | <<: *default 21 | database: db/test.sqlite3 22 | 23 | production: 24 | <<: *default 25 | database: db/production.sqlite3 26 | -------------------------------------------------------------------------------- /test/dummy/config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /test/dummy/config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded any time 7 | # it changes. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.cache_classes = false 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable server timing 18 | config.server_timing = true 19 | 20 | # Enable/disable caching. By default caching is disabled. 21 | # Run rails dev:cache to toggle caching. 22 | if Rails.root.join("tmp/caching-dev.txt").exist? 23 | config.action_controller.perform_caching = true 24 | config.action_controller.enable_fragment_cache_logging = true 25 | 26 | config.cache_store = :memory_store 27 | config.public_file_server.headers = { 28 | "Cache-Control" => "public, max-age=#{2.days.to_i}" 29 | } 30 | else 31 | config.action_controller.perform_caching = false 32 | 33 | config.cache_store = :null_store 34 | end 35 | 36 | # Store uploaded files on the local file system (see config/storage.yml for options). 37 | config.active_storage.service = :local 38 | 39 | # Don't care if the mailer can't send. 40 | config.action_mailer.raise_delivery_errors = false 41 | 42 | config.action_mailer.perform_caching = false 43 | 44 | # Print deprecation notices to the Rails logger. 45 | config.active_support.deprecation = :log 46 | 47 | # Raise exceptions for disallowed deprecations. 48 | config.active_support.disallowed_deprecation = :raise 49 | 50 | # Tell Active Support which deprecation messages to disallow. 51 | config.active_support.disallowed_deprecation_warnings = [] 52 | 53 | # Raise an error on page load if there are pending migrations. 54 | config.active_record.migration_error = :page_load 55 | 56 | # Highlight code that triggered database queries in logs. 57 | config.active_record.verbose_query_logs = true 58 | 59 | 60 | # Raises error for missing translations. 61 | # config.i18n.raise_on_missing_translations = true 62 | 63 | # Annotate rendered view with file names. 64 | # config.action_view.annotate_rendered_view_with_filenames = true 65 | 66 | # Uncomment if you wish to allow Action Cable access from any origin. 67 | # config.action_cable.disable_request_forgery_protection = true 68 | end 69 | -------------------------------------------------------------------------------- /test/dummy/config/environments/production.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Code is not reloaded between requests. 7 | config.cache_classes = true 8 | 9 | # Eager load code on boot. This eager loads most of Rails and 10 | # your application in memory, allowing both threaded web servers 11 | # and those relying on copy on write to perform better. 12 | # Rake tasks automatically ignore this option for performance. 13 | config.eager_load = true 14 | 15 | # Full error reports are disabled and caching is turned on. 16 | config.consider_all_requests_local = false 17 | config.action_controller.perform_caching = true 18 | 19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 21 | # config.require_master_key = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? 26 | 27 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 28 | # config.asset_host = "http://assets.example.com" 29 | 30 | # Specifies the header that your server uses for sending files. 31 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache 32 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX 33 | 34 | # Store uploaded files on the local file system (see config/storage.yml for options). 35 | config.active_storage.service = :local 36 | 37 | # Mount Action Cable outside main process or domain. 38 | # config.action_cable.mount_path = nil 39 | # config.action_cable.url = "wss://example.com/cable" 40 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] 41 | 42 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 43 | # config.force_ssl = true 44 | 45 | # Include generic and useful information about system operation, but avoid logging too much 46 | # information to avoid inadvertent exposure of personally identifiable information (PII). 47 | config.log_level = :info 48 | 49 | # Prepend all log lines with the following tags. 50 | config.log_tags = [ :request_id ] 51 | 52 | # Use a different cache store in production. 53 | # config.cache_store = :mem_cache_store 54 | 55 | # Use a real queuing backend for Active Job (and separate queues per environment). 56 | # config.active_job.queue_adapter = :resque 57 | # config.active_job.queue_name_prefix = "dummy_production" 58 | 59 | config.action_mailer.perform_caching = false 60 | 61 | # Ignore bad email addresses and do not raise email delivery errors. 62 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 63 | # config.action_mailer.raise_delivery_errors = false 64 | 65 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 66 | # the I18n.default_locale when a translation cannot be found). 67 | config.i18n.fallbacks = true 68 | 69 | # Don't log any deprecations. 70 | config.active_support.report_deprecations = false 71 | 72 | # Use default logging formatter so that PID and timestamp are not suppressed. 73 | config.log_formatter = ::Logger::Formatter.new 74 | 75 | # Use a different logger for distributed setups. 76 | # require "syslog/logger" 77 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") 78 | 79 | if ENV["RAILS_LOG_TO_STDOUT"].present? 80 | logger = ActiveSupport::Logger.new(STDOUT) 81 | logger.formatter = config.log_formatter 82 | config.logger = ActiveSupport::TaggedLogging.new(logger) 83 | end 84 | 85 | # Do not dump schema after migrations. 86 | config.active_record.dump_schema_after_migration = false 87 | end 88 | -------------------------------------------------------------------------------- /test/dummy/config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | # Turn false under Spring and add config.action_view.cache_template_loading = true. 12 | config.cache_classes = true 13 | 14 | # Eager loading loads your whole application. When running a single test locally, 15 | # this probably isn't necessary. It's a good idea to do in a continuous integration 16 | # system, or in some way before deploying your code. 17 | config.eager_load = ENV["CI"].present? 18 | 19 | # Configure public file server for tests with Cache-Control for performance. 20 | config.public_file_server.enabled = true 21 | config.public_file_server.headers = { 22 | "Cache-Control" => "public, max-age=#{1.hour.to_i}" 23 | } 24 | 25 | # Show full error reports and disable caching. 26 | config.consider_all_requests_local = true 27 | config.action_controller.perform_caching = false 28 | config.cache_store = :null_store 29 | 30 | # Raise exceptions instead of rendering exception templates. 31 | config.action_dispatch.show_exceptions = false 32 | 33 | # Disable request forgery protection in test environment. 34 | config.action_controller.allow_forgery_protection = false 35 | 36 | # Store uploaded files on the local file system in a temporary directory. 37 | config.active_storage.service = :test 38 | 39 | config.action_mailer.perform_caching = false 40 | 41 | # Tell Action Mailer not to deliver emails to the real world. 42 | # The :test delivery method accumulates sent emails in the 43 | # ActionMailer::Base.deliveries array. 44 | config.action_mailer.delivery_method = :test 45 | 46 | # Print deprecation notices to the stderr. 47 | config.active_support.deprecation = :stderr 48 | 49 | # Raise exceptions for disallowed deprecations. 50 | config.active_support.disallowed_deprecation = :raise 51 | 52 | # Tell Active Support which deprecation messages to disallow. 53 | config.active_support.disallowed_deprecation_warnings = [] 54 | 55 | # Raises error for missing translations. 56 | # config.i18n.raise_on_missing_translations = true 57 | 58 | # Annotate rendered view with file names. 59 | # config.action_view.annotate_rendered_view_with_filenames = true 60 | end 61 | -------------------------------------------------------------------------------- /test/dummy/config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy. 4 | # See the Securing Rails Applications Guide for more information: 5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header 6 | 7 | # Rails.application.configure do 8 | # config.content_security_policy do |policy| 9 | # policy.default_src :self, :https 10 | # policy.font_src :self, :https, :data 11 | # policy.img_src :self, :https, :data 12 | # policy.object_src :none 13 | # policy.script_src :self, :https 14 | # policy.style_src :self, :https 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | # 19 | # # Generate session nonces for permitted importmap and inline scripts 20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } 21 | # config.content_security_policy_nonce_directives = %w(script-src) 22 | # 23 | # # Report violations without enforcing the policy. 24 | # # config.content_security_policy_report_only = true 25 | # end 26 | -------------------------------------------------------------------------------- /test/dummy/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of 4 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported 5 | # notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 8 | ] 9 | -------------------------------------------------------------------------------- /test/dummy/config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym "RESTful" 16 | # end 17 | -------------------------------------------------------------------------------- /test/dummy/config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Define an application-wide HTTP permissions policy. For further 2 | # information see https://developers.google.com/web/updates/2018/06/feature-policy 3 | # 4 | # Rails.application.config.permissions_policy do |f| 5 | # f.camera :none 6 | # f.gyroscope :none 7 | # f.microphone :none 8 | # f.usb :none 9 | # f.fullscreen :self 10 | # f.payment :self, "https://secure.example.com" 11 | # end 12 | -------------------------------------------------------------------------------- /test/dummy/config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # "true": "foo" 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /test/dummy/config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 9 | threads min_threads_count, max_threads_count 10 | 11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 12 | # terminating a worker in development environments. 13 | # 14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" 15 | 16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 17 | # 18 | port ENV.fetch("PORT") { 3000 } 19 | 20 | # Specifies the `environment` that Puma will run in. 21 | # 22 | environment ENV.fetch("RAILS_ENV") { "development" } 23 | 24 | # Specifies the `pidfile` that Puma will use. 25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 26 | 27 | # Specifies the number of `workers` to boot in clustered mode. 28 | # Workers are forked web server processes. If using threads and workers together 29 | # the concurrency of the application would be max `threads` * `workers`. 30 | # Workers do not work on JRuby or Windows (both of which do not support 31 | # processes). 32 | # 33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 34 | 35 | # Use the `preload_app!` method when specifying a `workers` number. 36 | # This directive tells Puma to first boot the application and load code 37 | # before forking the application. This takes advantage of Copy On Write 38 | # process behavior so workers use less memory. 39 | # 40 | # preload_app! 41 | 42 | # Allow puma to be restarted by `bin/rails restart` command. 43 | plugin :tmp_restart 44 | -------------------------------------------------------------------------------- /test/dummy/config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html 3 | 4 | # Defines the root path route ("/") 5 | # root "articles#index" 6 | end 7 | -------------------------------------------------------------------------------- /test/dummy/config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /test/dummy/lib/assets/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/lib/assets/.keep -------------------------------------------------------------------------------- /test/dummy/log/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/log/.keep -------------------------------------------------------------------------------- /test/dummy/log/development.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/log/development.log -------------------------------------------------------------------------------- /test/dummy/public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |60 |66 | 67 | 68 | -------------------------------------------------------------------------------- /test/dummy/public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |61 |64 |The page you were looking for doesn't exist.
62 |You may have mistyped the address or the page may have moved.
63 |If you are the application owner check the logs for more information.
65 |The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |60 |66 | 67 | 68 | -------------------------------------------------------------------------------- /test/dummy/public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |61 |64 |The change you wanted was rejected.
62 |Maybe you tried to change something you didn't have access to.
63 |If you are the application owner check the logs for more information.
65 |We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |60 |65 | 66 | 67 | -------------------------------------------------------------------------------- /test/dummy/public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/public/apple-touch-icon-precomposed.png -------------------------------------------------------------------------------- /test/dummy/public/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/public/apple-touch-icon.png -------------------------------------------------------------------------------- /test/dummy/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/public/favicon.ico -------------------------------------------------------------------------------- /test/dummy/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/storage/.keep -------------------------------------------------------------------------------- /test/dummy/tmp/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/tmp/.keep -------------------------------------------------------------------------------- /test/dummy/tmp/development_secret.txt: -------------------------------------------------------------------------------- 1 | 6841ac3bbf9decdfa6c565be3e3de941cce8f3aefcba5ab12831be787e927ea1d2a7bbf845af5c6ae54f74f434497e95849080ece86ea177975b200544ddeec6 -------------------------------------------------------------------------------- /test/dummy/tmp/pids/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/tmp/pids/.keep -------------------------------------------------------------------------------- /test/dummy/tmp/storage/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitepress/markdown-rails/4724ecc8f2e2d7d5faa98ca2e99b6deff4ca81c5/test/dummy/tmp/storage/.keep -------------------------------------------------------------------------------- /test/lib/generators/markdown/install_generator_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "generators/markdown/install/install_generator" 3 | 4 | class Markdown::InstallGeneratorTest < Rails::Generators::TestCase 5 | tests Markdown::InstallGenerator 6 | destination Rails.root.join("tmp/generators") 7 | setup :prepare_destination 8 | 9 | # test "generator runs without errors" do 10 | # assert_nothing_raised do 11 | # run_generator ["arguments"] 12 | # end 13 | # end 14 | end 15 | -------------------------------------------------------------------------------- /test/markdown/rails_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class MarkdownRailsTest < ActiveSupport::TestCase 4 | test "it has a version number" do 5 | assert MarkdownRails::VERSION 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # Configure Rails Environment 2 | ENV["RAILS_ENV"] = "test" 3 | 4 | require_relative "../test/dummy/config/environment" 5 | ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] 6 | require "rails/test_help" 7 | 8 | # Load fixtures from the engine 9 | if ActiveSupport::TestCase.respond_to?(:fixture_path=) 10 | ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__) 11 | ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path 12 | ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files" 13 | ActiveSupport::TestCase.fixtures :all 14 | end 15 | --------------------------------------------------------------------------------61 |63 |We're sorry, but something went wrong.
62 |If you are the application owner check the logs for more information.
64 |