comfy_blog 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/issue_template.md +22 -0
- data/.github/pull_request_template.md +6 -0
- data/.rubocop.yml +96 -0
- data/.travis.yml +2 -1
- data/CONTRIBUTING.md +32 -0
- data/Gemfile +8 -8
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/app/controllers/comfy/admin/blog/posts_controller.rb +19 -11
- data/app/controllers/comfy/admin/blog/revisions/post_controller.rb +9 -3
- data/app/controllers/comfy/blog/posts_controller.rb +15 -12
- data/app/models/comfy/blog/post.rb +13 -12
- data/app/views/comfy/admin/blog/posts/_form.html.haml +2 -2
- data/app/views/comfy/admin/blog/posts/form_fragments.js.erb +1 -0
- data/app/views/comfy/blog/posts/index.rss.builder +4 -4
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/bin/setup +36 -0
- data/bin/update +31 -0
- data/bin/yarn +11 -0
- data/comfy_blog.gemspec +6 -6
- data/config.ru +2 -2
- data/config/application.rb +5 -4
- data/config/boot.rb +3 -3
- data/config/environment.rb +1 -1
- data/config/environments/development.rb +2 -2
- data/config/environments/test.rb +1 -1
- data/config/initializers/comfy_blog.rb +0 -2
- data/lib/comfy_blog.rb +10 -10
- data/lib/comfy_blog/configuration.rb +1 -1
- data/lib/comfy_blog/engine.rb +12 -7
- data/lib/comfy_blog/routes/blog.rb +8 -8
- data/lib/comfy_blog/routes/blog_admin.rb +5 -3
- data/lib/comfy_blog/routing.rb +2 -2
- data/lib/comfy_blog/version.rb +3 -1
- data/lib/generators/comfy/blog/blog_generator.rb +9 -9
- data/test/controllers/comfy/admin/blog/posts_controller_test.rb +53 -32
- data/test/controllers/comfy/admin/blog/revisions/post_controller_test.rb +6 -6
- data/test/controllers/comfy/blog/posts_controller_test.rb +7 -6
- data/test/gemfiles/Gemfile.rails.5.2 +5 -4
- data/test/generators/blog_generator_test.rb +7 -6
- data/test/integration/i18n_test.rb +8 -7
- data/test/lib/configuration_test.rb +4 -3
- data/test/models/posts_test.rb +12 -11
- data/test/test_helper.rb +24 -21
- metadata +15 -5
- data/script/rails +0 -6
@@ -4,9 +4,9 @@
|
|
4
4
|
= form.text_field :slug, data: {slug: true}
|
5
5
|
|
6
6
|
- if (options = ::Comfy::Cms::Layout.options_for_select(@site)).present?
|
7
|
-
= form.select :layout_id, options, {}, {data: {url:
|
7
|
+
= form.select :layout_id, options, {}, {data: {url: form_fragments_comfy_admin_blog_post_path(@site, @post.id.to_i)}, id: "fragments-toggle"}
|
8
8
|
|
9
|
-
= render "comfy/admin/cms/
|
9
|
+
= render "comfy/admin/cms/fragments/form_fragments", form: form, record: @post
|
10
10
|
|
11
11
|
= render 'comfy/admin/cms/categories/form', form: form
|
12
12
|
|
@@ -0,0 +1 @@
|
|
1
|
+
$('#form-fragments').replaceWith('<%= escape_javascript(render("comfy/admin/cms/fragments/form_fragments", record: @post)) %>');
|
@@ -1,8 +1,8 @@
|
|
1
|
-
xml.instruct! :xml, version:
|
2
|
-
xml.rss version:
|
1
|
+
xml.instruct! :xml, version: "1.0"
|
2
|
+
xml.rss version: "2.0" do
|
3
3
|
xml.channel do
|
4
|
-
xml.title
|
5
|
-
xml.description
|
4
|
+
xml.title "My Blog"
|
5
|
+
xml.description "My Blog Description"
|
6
6
|
xml.link comfy_blog_posts_url(@cms_site.path)
|
7
7
|
|
8
8
|
@blog_posts.each do |post|
|
data/bin/bundle
ADDED
data/bin/rails
ADDED
data/bin/rake
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a starting point to setup your application.
|
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
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
# puts "\n== Copying sample files =="
|
24
|
+
# unless File.exist?('config/database.yml')
|
25
|
+
# cp 'config/database.yml.sample', 'config/database.yml'
|
26
|
+
# end
|
27
|
+
|
28
|
+
puts "\n== Preparing database =="
|
29
|
+
system! 'bin/rails db:setup'
|
30
|
+
|
31
|
+
puts "\n== Removing old logs and tempfiles =="
|
32
|
+
system! 'bin/rails log:clear tmp:clear'
|
33
|
+
|
34
|
+
puts "\n== Restarting application server =="
|
35
|
+
system! 'bin/rails restart'
|
36
|
+
end
|
data/bin/update
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'fileutils'
|
3
|
+
include FileUtils
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
7
|
+
|
8
|
+
def system!(*args)
|
9
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
10
|
+
end
|
11
|
+
|
12
|
+
chdir APP_ROOT do
|
13
|
+
# This script is a way to update your development environment automatically.
|
14
|
+
# Add necessary update steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# Install JavaScript dependencies if using Yarn
|
21
|
+
# system('bin/yarn')
|
22
|
+
|
23
|
+
puts "\n== Updating database =="
|
24
|
+
system! 'bin/rails db:migrate'
|
25
|
+
|
26
|
+
puts "\n== Removing old logs and tempfiles =="
|
27
|
+
system! 'bin/rails log:clear tmp:clear'
|
28
|
+
|
29
|
+
puts "\n== Restarting application server =="
|
30
|
+
system! 'bin/rails restart'
|
31
|
+
end
|
data/bin/yarn
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
VENDOR_PATH = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(VENDOR_PATH) do
|
4
|
+
begin
|
5
|
+
exec "yarnpkg #{ARGV.join(' ')}"
|
6
|
+
rescue Errno::ENOENT
|
7
|
+
$stderr.puts "Yarn executable was not detected in the system."
|
8
|
+
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
end
|
data/comfy_blog.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
2
|
|
3
|
-
require
|
3
|
+
require "comfy_blog/version"
|
4
4
|
|
5
5
|
# Describe your gem and declare its dependencies:
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
7
|
+
s.name = "comfy_blog"
|
8
8
|
s.version = ComfyBlog::VERSION
|
9
9
|
s.authors = ["Oleg Khabarov"]
|
10
10
|
s.email = ["oleg@khabarov.ca"]
|
11
11
|
s.homepage = "http://github.com/comfy/comfy-blog"
|
12
12
|
s.summary = "Simple Blog Engine for ComfortableMexicanSofa"
|
13
13
|
s.description = "Simple Blog Engine for ComfortableMexicanSofa"
|
14
|
-
s.license =
|
14
|
+
s.license = "MIT"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.platform = Gem::Platform::RUBY
|
18
|
-
s.require_paths = [
|
18
|
+
s.require_paths = ["lib"]
|
19
19
|
|
20
20
|
s.required_ruby_version = ">= 2.2.2"
|
21
21
|
|
22
|
-
s.add_dependency
|
22
|
+
s.add_dependency "comfortable_mexican_sofa", ">= 2.0.3"
|
23
23
|
end
|
data/config.ru
CHANGED
data/config/application.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require_relative
|
1
|
+
require_relative "boot"
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rails/all"
|
4
4
|
|
5
5
|
# Require the gems listed in Gemfile, including any gems
|
6
6
|
# you've limited to :test, :development, or :production.
|
@@ -9,7 +9,7 @@ Bundler.require(*Rails.groups)
|
|
9
9
|
module ComfyBlog
|
10
10
|
class Application < Rails::Application
|
11
11
|
|
12
|
-
require_relative
|
12
|
+
require_relative "../lib/comfy_blog"
|
13
13
|
|
14
14
|
config.load_defaults 5.2
|
15
15
|
|
@@ -29,8 +29,9 @@ module ComfyBlog
|
|
29
29
|
config.railties_order = [ActiveStorage::Engine, :main_app, :all]
|
30
30
|
|
31
31
|
# Making sure we don't load our dev routes as part of the engine
|
32
|
-
config.paths[
|
32
|
+
config.paths["config/routes.rb"] << "config/blog_routes.rb"
|
33
33
|
|
34
34
|
config.i18n.enforce_available_locales = true
|
35
|
+
|
35
36
|
end
|
36
37
|
end
|
data/config/boot.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Set up gems listed in the Gemfile.
|
2
|
-
ENV[
|
2
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
|
3
3
|
|
4
|
-
require
|
5
|
-
File.
|
4
|
+
require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
|
5
|
+
File.exist?(ENV["BUNDLE_GEMFILE"])
|
data/config/environment.rb
CHANGED
@@ -14,12 +14,12 @@ defined?(ComfyBlog::Application) && ComfyBlog::Application.configure do
|
|
14
14
|
|
15
15
|
# Enable/disable caching. By default caching is disabled.
|
16
16
|
# Run rails dev:cache to toggle caching.
|
17
|
-
if Rails.root.join(
|
17
|
+
if Rails.root.join("tmp/caching-dev.txt").exist?
|
18
18
|
config.action_controller.perform_caching = true
|
19
19
|
|
20
20
|
config.cache_store = :memory_store
|
21
21
|
config.public_file_server.headers = {
|
22
|
-
|
22
|
+
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
23
23
|
}
|
24
24
|
else
|
25
25
|
config.action_controller.perform_caching = false
|
data/config/environments/test.rb
CHANGED
@@ -15,7 +15,7 @@ defined?(ComfyBlog::Application) && ComfyBlog::Application.configure do
|
|
15
15
|
# Configure public file server for tests with Cache-Control for performance.
|
16
16
|
config.public_file_server.enabled = true
|
17
17
|
config.public_file_server.headers = {
|
18
|
-
|
18
|
+
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
19
19
|
}
|
20
20
|
|
21
21
|
# Show full error reports and disable caching.
|
data/lib/comfy_blog.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
3
|
-
require_relative
|
4
|
-
require_relative
|
1
|
+
require_relative "comfy_blog/version"
|
2
|
+
require_relative "comfy_blog/engine"
|
3
|
+
require_relative "comfy_blog/configuration"
|
4
|
+
require_relative "comfy_blog/routing"
|
5
5
|
|
6
6
|
module ComfyBlog
|
7
|
-
|
7
|
+
|
8
8
|
class << self
|
9
|
-
|
9
|
+
|
10
10
|
# Modify Blog configuration
|
11
11
|
# Example:
|
12
12
|
# ComfyBlog.configure do |config|
|
@@ -15,13 +15,13 @@ module ComfyBlog
|
|
15
15
|
def configure
|
16
16
|
yield configuration
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
# Accessor for ComfyBlog::Configuration
|
20
20
|
def configuration
|
21
21
|
@configuration ||= ComfyBlog::Configuration.new
|
22
22
|
end
|
23
|
-
alias
|
24
|
-
|
23
|
+
alias config configuration
|
24
|
+
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
end
|
data/lib/comfy_blog/engine.rb
CHANGED
@@ -1,25 +1,30 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "rubygems"
|
2
|
+
require "rails"
|
3
|
+
require "comfortable_mexican_sofa"
|
4
|
+
require "comfy_blog"
|
5
5
|
|
6
6
|
module ComfyBlog
|
7
7
|
|
8
8
|
module CmsSiteExtensions
|
9
|
+
|
9
10
|
extend ActiveSupport::Concern
|
10
11
|
included do
|
11
12
|
has_many :blog_posts,
|
12
|
-
class_name:
|
13
|
+
class_name: "Blog::Post",
|
13
14
|
dependent: :destroy
|
14
15
|
end
|
16
|
+
|
15
17
|
end
|
16
18
|
|
17
19
|
class Engine < ::Rails::Engine
|
18
|
-
|
19
|
-
|
20
|
+
|
21
|
+
initializer "comfy_blog.configuration" do
|
22
|
+
ComfortableMexicanSofa::ViewHooks.add(:navigation, "/comfy/admin/blog/partials/navigation")
|
20
23
|
config.to_prepare do
|
21
24
|
Comfy::Cms::Site.send :include, ComfyBlog::CmsSiteExtensions
|
22
25
|
end
|
23
26
|
end
|
27
|
+
|
24
28
|
end
|
29
|
+
|
25
30
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
class ActionDispatch::Routing::Mapper
|
2
2
|
|
3
3
|
def comfy_route_blog(options = {})
|
4
|
-
|
5
|
-
ComfyBlog.configuration.public_blog_path
|
6
|
-
path = ['(:cms_path)', ComfyBlog.configuration.public_blog_path].join('/')
|
4
|
+
ComfyBlog.configuration.public_blog_path = options[:path] || "blog"
|
5
|
+
path = ["(:cms_path)", ComfyBlog.configuration.public_blog_path].join("/")
|
7
6
|
|
8
7
|
scope module: :comfy, as: :comfy do
|
9
8
|
namespace :blog, path: path do
|
10
|
-
with_options constraints: {year:
|
11
|
-
o.get
|
12
|
-
o.get
|
13
|
-
o.get
|
14
|
-
o.get
|
9
|
+
with_options constraints: { year: %r{\d{4}}, month: %r{\d{1,2}} } do |o|
|
10
|
+
o.get ":year", to: "posts#index", as: :posts_of_year
|
11
|
+
o.get ":year/:month", to: "posts#index", as: :posts_of_month
|
12
|
+
o.get ":year/:month/:slug", to: "posts#show", as: :post
|
13
|
+
o.get "/", to: "posts#index", as: :posts
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
18
|
+
|
19
19
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
class ActionDispatch::Routing::Mapper
|
2
2
|
|
3
3
|
def comfy_route_blog_admin(options = {})
|
4
|
-
options[:path] ||=
|
5
|
-
path = [options[:path],
|
4
|
+
options[:path] ||= "admin"
|
5
|
+
path = [options[:path], "sites", ":site_id"].join("/")
|
6
6
|
|
7
7
|
scope module: :comfy, as: :comfy do
|
8
8
|
scope module: :admin do
|
9
9
|
namespace :blog, as: :admin, path: path, except: [:show] do
|
10
10
|
resources :posts, as: :blog_posts, path: "blog-posts" do
|
11
|
-
|
11
|
+
get :form_fragments, on: :member
|
12
|
+
resources :revisions, only: %i[index show], controller: "revisions/post" do
|
12
13
|
patch :revert, on: :member
|
13
14
|
end
|
14
15
|
end
|
@@ -16,4 +17,5 @@ class ActionDispatch::Routing::Mapper
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
20
|
+
|
19
21
|
end
|
data/lib/comfy_blog/routing.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require_relative
|
2
|
-
require_relative
|
1
|
+
require_relative "routes/blog_admin"
|
2
|
+
require_relative "routes/blog"
|
data/lib/comfy_blog/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "rails/generators/active_record"
|
2
2
|
|
3
3
|
module Comfy
|
4
4
|
module Generators
|
@@ -7,27 +7,27 @@ module Comfy
|
|
7
7
|
include Rails::Generators::Migration
|
8
8
|
include Thor::Actions
|
9
9
|
|
10
|
-
source_root File.expand_path(
|
10
|
+
source_root File.expand_path("../../../../..", __FILE__)
|
11
11
|
|
12
12
|
def self.next_migration_number(dirname)
|
13
13
|
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
14
14
|
end
|
15
15
|
|
16
16
|
def generate_migration
|
17
|
-
destination = File.expand_path(
|
17
|
+
destination = File.expand_path("db/migrate/01_create_blog.rb", destination_root)
|
18
18
|
migration_dir = File.dirname(destination)
|
19
|
-
destination = self.class.migration_exists?(migration_dir,
|
19
|
+
destination = self.class.migration_exists?(migration_dir, "create_blog")
|
20
20
|
|
21
21
|
if destination
|
22
22
|
puts "\e[0m\e[31mFound existing create_blog migration. Remove it if you want to regenerate.\e[0m"
|
23
23
|
else
|
24
|
-
migration_template
|
24
|
+
migration_template "db/migrate/01_create_blog.rb", "db/migrate/create_blog.rb"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def generate_initialization
|
29
|
-
copy_file
|
30
|
-
|
29
|
+
copy_file "config/initializers/comfy_blog.rb",
|
30
|
+
"config/initializers/comfy_blog.rb"
|
31
31
|
end
|
32
32
|
|
33
33
|
def generate_routing
|
@@ -39,11 +39,11 @@ module Comfy
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def generate_views
|
42
|
-
directory
|
42
|
+
directory "app/views/comfy/blog", "app/views/comfy/blog"
|
43
43
|
end
|
44
44
|
|
45
45
|
def show_readme
|
46
|
-
readme
|
46
|
+
readme "lib/generators/comfy/blog/README"
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|