sitepress-rails 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +34 -0
  3. data/Rakefile +37 -0
  4. data/app/controllers/concerns/sitepress/site_pages.rb +62 -0
  5. data/app/controllers/sitepress/site_controller.rb +7 -0
  6. data/app/helpers/sitepress/application_helper.rb +4 -0
  7. data/config/routes.rb +7 -0
  8. data/lib/sitepress/engine.rb +15 -0
  9. data/lib/sitepress/extensions/index_request_path.rb +24 -0
  10. data/lib/sitepress/extensions/partials_remover.rb +19 -0
  11. data/lib/sitepress/extensions/rails_request_paths.rb +20 -0
  12. data/lib/sitepress/rails.rb +38 -0
  13. data/lib/sitepress/rails_configuration.rb +34 -0
  14. data/lib/sitepress/route_constraint.rb +12 -0
  15. data/lib/sitepress-rails.rb +1 -0
  16. data/lib/tasks/sitepress_tasks.rake +4 -0
  17. data/spec/dummy/Rakefile +6 -0
  18. data/spec/dummy/app/assets/config/manifest.js +5 -0
  19. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  20. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  21. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  22. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  23. data/spec/dummy/app/controllers/baseline_controller.rb +3 -0
  24. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  25. data/spec/dummy/app/jobs/application_job.rb +2 -0
  26. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  27. data/spec/dummy/app/models/application_record.rb +3 -0
  28. data/spec/dummy/app/pages/_stupid.html +1 -0
  29. data/spec/dummy/app/pages/hi.html +3 -0
  30. data/spec/dummy/app/pages/time.html.erb +8 -0
  31. data/spec/dummy/app/views/baseline/show.html.erb +1 -0
  32. data/spec/dummy/app/views/layouts/application.html.erb +10 -0
  33. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  34. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  35. data/spec/dummy/app/views/layouts/sitepress_test_layout.html.erb +10 -0
  36. data/spec/dummy/bin/bundle +3 -0
  37. data/spec/dummy/bin/rails +4 -0
  38. data/spec/dummy/bin/rake +4 -0
  39. data/spec/dummy/bin/setup +34 -0
  40. data/spec/dummy/bin/update +29 -0
  41. data/spec/dummy/config/application.rb +15 -0
  42. data/spec/dummy/config/boot.rb +5 -0
  43. data/spec/dummy/config/cable.yml +9 -0
  44. data/spec/dummy/config/database.yml +25 -0
  45. data/spec/dummy/config/environment.rb +5 -0
  46. data/spec/dummy/config/environments/development.rb +38 -0
  47. data/spec/dummy/config/environments/production.rb +78 -0
  48. data/spec/dummy/config/environments/test.rb +35 -0
  49. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  50. data/spec/dummy/config/initializers/assets.rb +11 -0
  51. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  52. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  53. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  54. data/spec/dummy/config/initializers/inflections.rb +16 -0
  55. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  56. data/spec/dummy/config/initializers/null_logger.rb +2 -0
  57. data/spec/dummy/config/initializers/session_store.rb +3 -0
  58. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  59. data/spec/dummy/config/locales/en.yml +23 -0
  60. data/spec/dummy/config/puma.rb +47 -0
  61. data/spec/dummy/config/routes.rb +3 -0
  62. data/spec/dummy/config/secrets.yml +22 -0
  63. data/spec/dummy/config/spring.rb +6 -0
  64. data/spec/dummy/config.ru +5 -0
  65. data/spec/dummy/db/test.sqlite3 +0 -0
  66. data/spec/dummy/log/test.log +190 -0
  67. data/spec/dummy/public/404.html +67 -0
  68. data/spec/dummy/public/422.html +67 -0
  69. data/spec/dummy/public/500.html +66 -0
  70. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  71. data/spec/dummy/public/apple-touch-icon.png +0 -0
  72. data/spec/dummy/public/favicon.ico +0 -0
  73. data/spec/pages/index.html.erb +1 -0
  74. data/spec/pages/nothing +1 -0
  75. data/spec/pages/sin_frontmatter.html.haml +8 -0
  76. data/spec/pages/super.duper/index.html +3 -0
  77. data/spec/pages/test.html.haml +14 -0
  78. data/spec/pages/text.txt +1 -0
  79. data/spec/sitepress/extensions/index_request_path_spec.rb +15 -0
  80. data/spec/sitepress/extensions/partials_remover_spec.rb +12 -0
  81. data/spec/sitepress/extensions/rails_request_paths_spec.rb +9 -0
  82. data/spec/sitepress/rails_configuration_spec.rb +10 -0
  83. data/spec/sitepress/route_constraint_spec.rb +16 -0
  84. data/spec/sitepress/routes_spec.rb +28 -0
  85. data/spec/sitepress/sitepress_site_controller_spec.rb +55 -0
  86. data/spec/sitepress-rails_spec.rb +21 -0
  87. data/spec/spec_helper.rb +22 -0
  88. metadata +257 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6994698f567bafa62b4fc8ed645b43ca5061429
4
+ data.tar.gz: c8618d2cedbeadcda10293e08b8ee4c285f51da7
5
+ SHA512:
6
+ metadata.gz: 33adf2a91c339f4c25d28ccff7c04275fc06a336c712c781101a754dde2ce2dd55b3ee6091601a999373e8911d67f790169296c41046b760ddfa0eed0185024e
7
+ data.tar.gz: 76da5e6f5ad5462326f94803faa1b4521286a591ae0dfb5a039e82c29bd824cea0a1b47aa3e0c6a48b1b5862172f4d9a9b0c2b8903df5c3aba7f153c9b0ed0a9
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Sitepress
2
+
3
+ Sitepress is a file-backed website content manager that can be embedded in popular web frameworks like Rails. Inspired by [Middleman](https://middlemanapp.com), Sitepress is stripped down with less dependencies to work better within Rails. That mean it ships with Frontmatter, the Site API, and a few templating features. [Learn more about Sitepress](https://github.com/bradgessler/sitepress).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'sitepress-rails'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Then mount the engine into your `config/routes.rb` file:
20
+
21
+ ```ruby
22
+ mount Sitepress::Engine => "/"
23
+ ```
24
+
25
+ Then add pages to the `app/views/pages` directory:
26
+
27
+ ```bash
28
+ $ echo "<h1>Hello</h1><p>It is <%= Time.now %> o'clock</p>" > app/views/pages/hello.html.erb
29
+ ```
30
+
31
+ Point your browser to `http://127.0.0.1:3000/hello` and if all went well you should see the page you just created.
32
+
33
+ ## License
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Sitepress'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,62 @@
1
+ module Sitepress
2
+ # Serves up Sitepress site pages in a rails application. This is mixed into the
3
+ # Sitepress::SiteController, but may be included into other controllers for static
4
+ # page behavior.
5
+ module SitePages
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ rescue_from Sitepress::PageNotFoundError, with: :page_not_found
10
+ helper_method :current_page, :site
11
+ end
12
+
13
+ def show
14
+ render inline: current_page.body,
15
+ type: current_page.asset.template_extensions.last,
16
+ layout: current_page.data.fetch("layout", controller_layout),
17
+ content_type: current_page.mime_type.to_s
18
+ end
19
+
20
+ protected
21
+ def current_page
22
+ @_current_page ||= find_resource
23
+ end
24
+
25
+ def site
26
+ Sitepress.site
27
+ end
28
+
29
+ def page_not_found(e)
30
+ raise ActionController::RoutingError, e.message
31
+ end
32
+
33
+ private
34
+
35
+ # Sitepress::PageNotFoundError is handled in the default Sitepress::SiteController
36
+ # with an execption that Rails can use to display a 404 error.
37
+ def get(path)
38
+ resource = Sitepress.site.resources.get(path)
39
+ if resource.nil?
40
+ # TODO: Display error in context of Reources class root.
41
+ raise Sitepress::PageNotFoundError, "No such page: #{path}"
42
+ else
43
+ resource
44
+ end
45
+ end
46
+
47
+ # Default finder of the resource for the current controller context.###
48
+ def find_resource
49
+ get params[:resource_path]
50
+ end
51
+
52
+ # Returns the current layout for the inline Sitepress renderer.
53
+ def controller_layout
54
+ layout = self.send(:_layout)
55
+ if layout.instance_of? String
56
+ layout
57
+ else
58
+ File.basename(layout.identifier).split('.').first
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,7 @@
1
+ module Sitepress
2
+ class SiteController < ::ApplicationController
3
+ # Extracted into a module because other controllers may need
4
+ # to be capable of serving Sitepress pages.
5
+ include Sitepress::SitePages
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ module Sitepress
2
+ module ApplicationHelper
3
+ end
4
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ Sitepress.configuration.parent_engine.routes.draw do
2
+ if Sitepress.configuration.routes
3
+ constraints Sitepress::RouteConstraint.new do
4
+ get "*resource_path", controller: "sitepress/site", action: "show", as: :page, format: false
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module Sitepress
2
+ class Engine < ::Rails::Engine
3
+ initializer "Add site root to view paths" do |app|
4
+ ActionController::Base.prepend_view_path Sitepress.site.root_path
5
+ end
6
+
7
+ initializer "Require concerns path" do |app|
8
+ concerns_path = "app/controllers/concerns"
9
+
10
+ unless app.paths.keys.include?(concerns_path)
11
+ app.paths.add(concerns_path)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ module Sitepress
2
+ module Extensions
3
+ # Removes files beginning with "_" from the resource collection.
4
+ class IndexRequestPath
5
+ # Name of the file that we'll want to change to a / path
6
+ FILE_NAME = "index.html".freeze
7
+
8
+ def initialize(file_name: FILE_NAME)
9
+ @file_name = file_name
10
+ end
11
+
12
+ def process_resources(node)
13
+ node.flatten.each do |r|
14
+ asset = r.asset
15
+ if asset.path.basename.to_s.start_with? @file_name
16
+ request_path = Pathname.new("/").join(r.request_path).dirname.cleanpath.to_s
17
+ node.formats.remove(r)
18
+ node.add(path: request_path, asset: asset)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ module Sitepress
2
+ module Extensions
3
+ # Removes files beginning with "_" from the resource collection.
4
+ class PartialsRemover
5
+ # Partial rails prefix.
6
+ PARTIAL_PREFIX = "_".freeze
7
+
8
+ def process_resources(node)
9
+ node.flatten.each do |r|
10
+ r.node.remove if self.class.partial? r.asset.path # Looks like a smiley face, doesn't it?
11
+ end
12
+ end
13
+
14
+ def self.partial?(path)
15
+ File.basename(path).starts_with? PARTIAL_PREFIX
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module Sitepress
2
+ module Extensions
3
+ # Removes the file extension from the file so that /hi/there/fun.html can be
4
+ # resolved via /hi/there/fun.
5
+ class RailsRequestPaths
6
+ def process_resources(node)
7
+ node.flatten.each do |r|
8
+ asset = r.asset
9
+ request_path = r.request_path
10
+ r.node.remove
11
+ node.add path: self.class.format_path(request_path), asset: asset
12
+ end
13
+ end
14
+
15
+ def self.format_path(request_path)
16
+ File.join(File.dirname(File.join("/", request_path)), File.basename(request_path, ".*"))
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,38 @@
1
+ require "sitepress"
2
+
3
+ module Sitepress
4
+ # Contains singletons for rails and some configuration data.
5
+ Configuration = Struct.new(:site, :routes, :parent_engine)
6
+
7
+ # Rescued by ActionController to display page not found error.
8
+ PageNotFoundError = Class.new(StandardError)
9
+
10
+ autoload :RailsConfiguration, "sitepress/rails_configuration"
11
+ autoload :RouteConstraint, "sitepress/route_constraint"
12
+ module Extensions
13
+ autoload :RailsRequestPaths, "sitepress/extensions/rails_request_paths"
14
+ autoload :PartialsRemover, "sitepress/extensions/partials_remover"
15
+ autoload :IndexRequestPath, "sitepress/extensions/index_request_path"
16
+ end
17
+
18
+ # Make site available via Sitepress.site from Rails app.
19
+ def self.site
20
+ configuration.site
21
+ end
22
+
23
+ # Default configuration object for Sitepress Rails integration.
24
+ def self.configuration
25
+ @configuration ||= RailsConfiguration.new
26
+ end
27
+
28
+ def self.reset_configuration
29
+ @configuration = nil
30
+ end
31
+
32
+ def self.configure(&block)
33
+ block.call configuration
34
+ end
35
+ end
36
+
37
+ # This can't be autoloaded; otherwise Rails won't pick up the engine.
38
+ require "sitepress/engine"
@@ -0,0 +1,34 @@
1
+ require "forwardable"
2
+
3
+ module Sitepress
4
+ # Configuration object for rails application.
5
+ class RailsConfiguration
6
+ # Store in ./app/pages by default.
7
+ DEFAULT_SITE_ROOT = "app/pages".freeze
8
+
9
+ attr_accessor :site, :parent_engine, :routes, :cache_resources
10
+
11
+ # Delegates configuration points into the Sitepress site.
12
+ extend Forwardable
13
+ def_delegators :site, :cache_resources, :cache_resources=, :cache_resources?
14
+
15
+ # Set defaults.
16
+ def initialize
17
+ self.routes = true
18
+ self.parent_engine = Rails.application
19
+ self.cache_resources = parent_engine.config.cache_classes
20
+ end
21
+
22
+ def site
23
+ @site ||= Site.new(root_path: default_root, cache_resources: @cache_resources).tap do |site|
24
+ site.resources_pipeline << Extensions::PartialsRemover.new
25
+ site.resources_pipeline << Extensions::RailsRequestPaths.new
26
+ end
27
+ end
28
+
29
+ private
30
+ def default_root
31
+ Rails.root.join(DEFAULT_SITE_ROOT)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ module Sitepress
2
+ # Route constraint for rails routes.rb file.
3
+ class RouteConstraint
4
+ def initialize(resources: Sitepress.site.resources)
5
+ @resources = resources
6
+ end
7
+
8
+ def matches?(request)
9
+ !!@resources.get(request.path)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1 @@
1
+ require "sitepress/rails"
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :sitepress-rails do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,6 @@
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
@@ -0,0 +1,5 @@
1
+
2
+ //= link_tree ../images
3
+ //= link_directory ../javascripts .js
4
+ //= link_directory ../stylesheets .css
5
+ //= link sitepress-rails_manifest.js
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ // Action Cable provides the framework to deal with WebSockets in Rails.
2
+ // You can generate new channels where WebSocket features live using the rails generate channel command.
3
+ //
4
+ //= require action_cable
5
+ //= require_self
6
+ //= require_tree ./channels
7
+
8
+ (function() {
9
+ this.App || (this.App = {});
10
+
11
+ App.cable = ActionCable.createConsumer();
12
+
13
+ }).call(this);
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
3
+ end
@@ -0,0 +1,3 @@
1
+ class BaselineController < ApplicationController
2
+ # Renders views/show.html.erb
3
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: 'from@example.com'
3
+ layout 'mailer'
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1 @@
1
+ Stupid partial
@@ -0,0 +1,3 @@
1
+ <h1>Hi!</h1>
2
+
3
+ <p>I'm a sitepress page</p>
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: sitepress_test_layout
3
+ title: Tick tock, tick tock
4
+ ---
5
+
6
+ <h1><%= current_page.data["title"] %></h1>
7
+
8
+ <p>Its <%= Time.now %> o'clock</p>
@@ -0,0 +1 @@
1
+ <h1>Hi! I'm a basic page with a layout.</h1>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= csrf_meta_tags %>
6
+ </head>
7
+ <body>
8
+ <%= yield %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Test layout</title>
5
+ <%= csrf_meta_tags %>
6
+ </head>
7
+ <body>
8
+ <%= yield %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a starting point to setup your application.
15
+ # Add necessary setup steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ # puts "\n== Copying sample files =="
22
+ # unless File.exist?('config/database.yml')
23
+ # cp 'config/database.yml.sample', 'config/database.yml'
24
+ # end
25
+
26
+ puts "\n== Preparing database =="
27
+ system! 'bin/rails db:setup'
28
+
29
+ puts "\n== Removing old logs and tempfiles =="
30
+ system! 'bin/rails log:clear tmp:clear'
31
+
32
+ puts "\n== Restarting application server =="
33
+ system! 'bin/rails restart'
34
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ # path to your application root.
7
+ APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8
+
9
+ def system!(*args)
10
+ system(*args) || abort("\n== Command #{args} failed ==")
11
+ end
12
+
13
+ chdir APP_ROOT do
14
+ # This script is a way to update your development environment automatically.
15
+ # Add necessary update steps to this file.
16
+
17
+ puts '== Installing dependencies =='
18
+ system! 'gem install bundler --conservative'
19
+ system('bundle check') || system!('bundle install')
20
+
21
+ puts "\n== Updating database =="
22
+ system! 'bin/rails db:migrate'
23
+
24
+ puts "\n== Removing old logs and tempfiles =="
25
+ system! 'bin/rails log:clear tmp:clear'
26
+
27
+ puts "\n== Restarting application server =="
28
+ system! 'bin/rails restart'
29
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'boot'
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "sitepress-rails"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+ end
14
+ end
15
+
@@ -0,0 +1,5 @@
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__)
@@ -0,0 +1,9 @@
1
+ development:
2
+ adapter: async
3
+
4
+ test:
5
+ adapter: async
6
+
7
+ production:
8
+ adapter: redis
9
+ url: redis://localhost:6379/1
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
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: 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
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!