Start a new Perron-powered site
to run in your site's root directory
View template source
gsub_file "Gemfile", /gem "sqlite3".*$/, ""
gsub_file "Gemfile", /gem "activerecord".*$/, ""
remove_file "config/database.yml"
remove_file "config/credentials.yml.enc"
remove_file "config/master.key"
remove_file "public/400.html"
remove_file "public/406-unsupported-browser.html"
remove_file "public/422.html"
remove_file "public/500.html"
run "rm -r app/views/pwa"
remove_file "app/controllers/application_controller.rb"
create_file "app/controllers/application_controller.rb", <<~RB
class ApplicationController < ActionController::Base
end
RB
remove_file "app/views/layouts/application.html.erb"
create_file "app/views/layouts/application.html.erb", <<~ERB
<!DOCTYPE html>
<html lang="en">
<head>
<%= meta_tags %>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= yield :head %>
<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">
<%= stylesheet_link_tag :app %>
</head>
<body>
<%= yield %>
</body>
</html>
ERB
append_to_file ".gitignore", "/output/\n"
gem "perron"
after_bundle do
rails_command("generate perron:install")
markdown_gem = ask("Which markdown parser would you like to use? (commonmarker/kramdown/redcarpet or leave blank to skip):")
VALID_MARKDOWN_GEMS = %w[commonmarker kramdown redcarpet]
gem_name = markdown_gem.strip.downcase
if VALID_MARKDOWN_GEMS.include?(gem_name)
uncomment_lines "Gemfile", /gem "#{gem_name}"/
Bundler.with_unbundled_env { run "bundle install" }
elsif markdown_gem.present?
say "Invalid markdown parser option. Skipping…", :yellow
end
end
remove_file "README.md"
create_file "README.md", <<~MARKDOWN
# #{app_name.titleize}
TBD
## Development
```
bin/dev
```
## Deploy/publish
```
RAILS_ENV=production rails perron:build
```
MARKDOWN
This snippet configures a Rails application to use with Perron. It removes database dependencies, cleans up unnecessary files and adds the Perron gem. With this template you have the quickest way to start a new static site with Perron.