PixelForce_ComfyBlog 0.0.1

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.
Files changed (74) hide show
  1. checksums.yaml +7 -0
  2. data/.github/issue_template.md +22 -0
  3. data/.github/pull_request_template.md +6 -0
  4. data/.gitignore +16 -0
  5. data/.rubocop.yml +96 -0
  6. data/.travis.yml +21 -0
  7. data/CONTRIBUTING.md +32 -0
  8. data/Gemfile +27 -0
  9. data/LICENSE +20 -0
  10. data/README.md +42 -0
  11. data/Rakefile +5 -0
  12. data/app/controllers/comfy/admin/blog/posts_controller.rb +84 -0
  13. data/app/controllers/comfy/admin/blog/revisions/post_controller.rb +30 -0
  14. data/app/controllers/comfy/blog/posts_controller.rb +50 -0
  15. data/app/models/comfy/blog/post.rb +55 -0
  16. data/app/views/comfy/admin/blog/partials/_navigation.html.haml +4 -0
  17. data/app/views/comfy/admin/blog/posts/_form.html.haml +22 -0
  18. data/app/views/comfy/admin/blog/posts/edit.html.haml +9 -0
  19. data/app/views/comfy/admin/blog/posts/index.html.haml +37 -0
  20. data/app/views/comfy/admin/blog/posts/new.html.haml +5 -0
  21. data/app/views/comfy/blog/posts/index.html.haml +28 -0
  22. data/app/views/comfy/blog/posts/index.rss.builder +22 -0
  23. data/app/views/comfy/blog/posts/show.html.haml +8 -0
  24. data/app/views/layouts/comfy/blog/application.html.erb +22 -0
  25. data/bin/bundle +3 -0
  26. data/bin/rails +4 -0
  27. data/bin/rake +4 -0
  28. data/bin/setup +36 -0
  29. data/bin/update +31 -0
  30. data/bin/yarn +11 -0
  31. data/comfy_blog.gemspec +29 -0
  32. data/config.ru +6 -0
  33. data/config/application.rb +39 -0
  34. data/config/blog_routes.rb +8 -0
  35. data/config/boot.rb +7 -0
  36. data/config/database.yml +11 -0
  37. data/config/environment.rb +7 -0
  38. data/config/environments/development.rb +64 -0
  39. data/config/environments/test.rb +51 -0
  40. data/config/initializers/comfy_blog.rb +9 -0
  41. data/config/locales/ca.yml +38 -0
  42. data/config/locales/cs.yml +38 -0
  43. data/config/locales/da.yml +38 -0
  44. data/config/locales/de.yml +38 -0
  45. data/config/locales/en.yml +38 -0
  46. data/config/locales/es.yml +38 -0
  47. data/config/locales/fi.yml +38 -0
  48. data/config/locales/fr.yml +38 -0
  49. data/config/locales/gr.yml +38 -0
  50. data/config/locales/it.yml +38 -0
  51. data/config/locales/ja.yml +38 -0
  52. data/config/locales/nb.yml +38 -0
  53. data/config/locales/nl.yml +38 -0
  54. data/config/locales/pl.yml +38 -0
  55. data/config/locales/pt-BR.yml +38 -0
  56. data/config/locales/ru.yml +38 -0
  57. data/config/locales/sv.yml +38 -0
  58. data/config/locales/tr.yml +38 -0
  59. data/config/locales/uk.yml +38 -0
  60. data/config/locales/zh-CN.yml +38 -0
  61. data/config/locales/zh-TW.yml +38 -0
  62. data/config/storage.yml +35 -0
  63. data/db/migrate/00_create_cms.rb +167 -0
  64. data/db/migrate/01_create_blog.rb +24 -0
  65. data/lib/comfy_blog.rb +29 -0
  66. data/lib/comfy_blog/configuration.rb +24 -0
  67. data/lib/comfy_blog/engine.rb +32 -0
  68. data/lib/comfy_blog/routes/blog.rb +21 -0
  69. data/lib/comfy_blog/routes/blog_admin.rb +23 -0
  70. data/lib/comfy_blog/routing.rb +4 -0
  71. data/lib/comfy_blog/version.rb +7 -0
  72. data/lib/generators/comfy/blog/README +10 -0
  73. data/lib/generators/comfy/blog/blog_generator.rb +53 -0
  74. metadata +129 -0
@@ -0,0 +1,38 @@
1
+ zh-TW:
2
+ activerecord:
3
+ models:
4
+ comfy/blog/post: 網誌
5
+ attributes:
6
+ comfy/blog/post:
7
+ title: 標題
8
+ slug: 路徑名
9
+ published_at: 發佈于
10
+ is_published: 發佈
11
+
12
+ comfy:
13
+ admin:
14
+ cms:
15
+ base:
16
+ posts: 網誌
17
+ blog:
18
+ posts:
19
+ created: 網誌創建成功
20
+ create_failure: 網誌創建失敗
21
+ updated: 網誌更新成功
22
+ update_failure: 網誌更新失敗
23
+ deleted: 網誌刪除成功
24
+ not_found: 網誌不存在
25
+ index:
26
+ title: 網誌
27
+ new_link: 創建新網誌
28
+ edit: 編輯
29
+ delete: 刪除
30
+ are_you_sure: 確定刪除該網誌嗎?
31
+ new:
32
+ title: 新網誌
33
+ edit:
34
+ title: 編輯網誌
35
+ form:
36
+ create: 創建網誌
37
+ update: 跟新網誌
38
+ cancel: 取消
@@ -0,0 +1,35 @@
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 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
16
+
17
+ # Remember not to checkin your GCS keyfile to a repository
18
+ # google:
19
+ # service: GCS
20
+ # project: your_project
21
+ # keyfile: <%= Rails.root.join("path/to/gcs.keyfile") %>
22
+ # bucket: your_own_bucket
23
+
24
+ # Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)
25
+ # microsoft:
26
+ # service: AzureStorage
27
+ # path: your_azure_storage_path
28
+ # storage_account_name: your_account_name
29
+ # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
30
+ # container: your_container_name
31
+
32
+ # mirror:
33
+ # service: Mirror
34
+ # primary: local
35
+ # mirrors: [ amazon, google, microsoft ]
@@ -0,0 +1,167 @@
1
+ class CreateCms < ActiveRecord::Migration[5.2]
2
+
3
+ LIMIT = 16777215
4
+
5
+ def change
6
+
7
+ # -- Active Storage --------------------------------------------------------
8
+ create_table :active_storage_blobs do |t|
9
+ t.string :key, null: false
10
+ t.string :filename, null: false
11
+ t.string :content_type
12
+ t.text :metadata
13
+ t.bigint :byte_size, null: false
14
+ t.string :checksum, null: false
15
+ t.datetime :created_at, null: false
16
+
17
+ t.index [:key], unique: true
18
+ end
19
+
20
+ create_table :active_storage_attachments do |t|
21
+ t.string :name, null: false
22
+ t.references :record, null: false, polymorphic: true, index: false
23
+ t.references :blob, null: false
24
+ t.datetime :created_at, null: false
25
+
26
+ t.index [:record_type, :record_id, :name, :blob_id],
27
+ name: "index_active_storage_attachments_uniqueness",
28
+ unique: true
29
+ end
30
+
31
+ # -- Sites -----------------------------------------------------------------
32
+ create_table :comfy_cms_sites, force: true do |t|
33
+ t.string :label, null: false
34
+ t.string :identifier, null: false
35
+ t.string :hostname, null: false
36
+ t.string :path
37
+ t.string :locale, null: false, default: "en"
38
+ t.timestamps
39
+
40
+ t.index :hostname
41
+ end
42
+
43
+ # -- Layouts ---------------------------------------------------------------
44
+ create_table :comfy_cms_layouts, force: true do |t|
45
+ t.integer :site_id, null: false
46
+ t.integer :parent_id
47
+ t.string :app_layout
48
+ t.string :label, null: false
49
+ t.string :identifier, null: false
50
+ t.text :content, limit: LIMIT
51
+ t.text :css, limit: LIMIT
52
+ t.text :js, limit: LIMIT
53
+ t.integer :position, null: false, default: 0
54
+ t.timestamps
55
+
56
+ t.index [:parent_id, :position]
57
+ t.index [:site_id, :identifier], unique: true
58
+ end
59
+
60
+ # -- Pages -----------------------------------------------------------------
61
+ create_table :comfy_cms_pages, force: true do |t|
62
+ t.integer :site_id, null: false
63
+ t.integer :layout_id
64
+ t.integer :parent_id
65
+ t.integer :target_page_id
66
+ t.string :label, null: false
67
+ t.string :slug
68
+ t.string :full_path, null: false
69
+ t.text :content_cache, limit: LIMIT
70
+ t.integer :position, null: false, default: 0
71
+ t.integer :children_count, null: false, default: 0
72
+ t.boolean :is_published, null: false, default: true
73
+ t.timestamps
74
+
75
+ t.index [:site_id, :full_path]
76
+ t.index [:parent_id, :position]
77
+ t.index [:is_published]
78
+ end
79
+
80
+ # -- Translations ----------------------------------------------------------
81
+ create_table :comfy_cms_translations, force: true do |t|
82
+ t.string :locale, null: false
83
+ t.integer :page_id, null: false
84
+ t.integer :layout_id
85
+ t.string :label, null: false
86
+ t.text :content_cache, limit: LIMIT
87
+ t.boolean :is_published, null: false, default: true
88
+ t.timestamps
89
+
90
+ t.index [:page_id]
91
+ t.index [:locale]
92
+ t.index [:is_published]
93
+ end
94
+
95
+ # -- Fragments -------------------------------------------------------------
96
+ create_table :comfy_cms_fragments, force: true do |t|
97
+ t.references :record, polymorphic: true
98
+ t.string :identifier, null: false
99
+ t.string :tag, null: false, default: "text"
100
+ t.text :content, limit: LIMIT
101
+ t.boolean :boolean, null: false, default: false
102
+ t.datetime :datetime
103
+ t.timestamps
104
+
105
+ t.index [:identifier]
106
+ t.index [:datetime]
107
+ t.index [:boolean]
108
+ end
109
+
110
+ # -- Snippets --------------------------------------------------------------
111
+ create_table :comfy_cms_snippets, force: true do |t|
112
+ t.integer :site_id, null: false
113
+ t.string :label, null: false
114
+ t.string :identifier, null: false
115
+ t.text :content, limit: LIMIT
116
+ t.integer :position, null: false, default: 0
117
+ t.timestamps
118
+
119
+ t.index [:site_id, :identifier], unique: true
120
+ t.index [:site_id, :position]
121
+ end
122
+
123
+ # -- Files -----------------------------------------------------------------
124
+ create_table :comfy_cms_files, force: true do |t|
125
+ t.integer :site_id, null: false
126
+ t.string :label, null: false, default: ""
127
+ t.text :description, limit: 2048
128
+ t.integer :position, null: false, default: 0
129
+ t.timestamps
130
+
131
+ t.index [:site_id, :position]
132
+ end
133
+
134
+ # -- Revisions -------------------------------------------------------------
135
+ create_table :comfy_cms_revisions, force: true do |t|
136
+ t.string :record_type, null: false
137
+ t.integer :record_id, null: false
138
+ t.text :data, limit: LIMIT
139
+ t.datetime :created_at
140
+
141
+ t.index [:record_type, :record_id, :created_at],
142
+ name: "index_cms_revisions_on_rtype_and_rid_and_created_at"
143
+ end
144
+
145
+ # -- Categories ------------------------------------------------------------
146
+ create_table :comfy_cms_categories, force: true do |t|
147
+ t.integer :site_id, null: false
148
+ t.string :label, null: false
149
+ t.string :categorized_type, null: false
150
+
151
+ t.index [:site_id, :categorized_type, :label],
152
+ unique: true,
153
+ name: "index_cms_categories_on_site_id_and_cat_type_and_label"
154
+ end
155
+
156
+ create_table :comfy_cms_categorizations, force: true do |t|
157
+ t.integer :category_id, null: false
158
+ t.string :categorized_type, null: false
159
+ t.integer :categorized_id, null: false
160
+
161
+ t.index [:category_id, :categorized_type, :categorized_id],
162
+ unique: true,
163
+ name: "index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id"
164
+ end
165
+
166
+ end
167
+ end
@@ -0,0 +1,24 @@
1
+ class CreateBlog < ActiveRecord::Migration[5.2]
2
+
3
+ LIMIT = 16777215
4
+
5
+ def change
6
+ create_table :comfy_blog_posts do |t|
7
+ t.integer :site_id, null: false
8
+ t.string :title, null: false
9
+ t.string :slug, null: false
10
+ t.integer :layout_id
11
+ t.text :content_cache, limit: LIMIT
12
+ t.integer :year, null: false, limit: 4
13
+ t.integer :month, null: false, limit: 2
14
+ t.boolean :is_published, null: false, default: true
15
+ t.datetime :published_at, null: false
16
+ t.timestamps
17
+
18
+ t.index [:site_id, :is_published]
19
+ t.index [:year, :month, :slug]
20
+ t.index [:created_at]
21
+ end
22
+
23
+ end
24
+ end
data/lib/comfy_blog.rb ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "comfy_blog/version"
4
+ require_relative "comfy_blog/engine"
5
+ require_relative "comfy_blog/configuration"
6
+ require_relative "comfy_blog/routing"
7
+
8
+ module ComfyBlog
9
+
10
+ class << self
11
+
12
+ # Modify Blog configuration
13
+ # Example:
14
+ # ComfyBlog.configure do |config|
15
+ # config.posts_per_page = 5
16
+ # end
17
+ def configure
18
+ yield configuration
19
+ end
20
+
21
+ # Accessor for ComfyBlog::Configuration
22
+ def configuration
23
+ @configuration ||= ComfyBlog::Configuration.new
24
+ end
25
+ alias config configuration
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ComfyBlog
4
+ class Configuration
5
+
6
+ # Application layout to be used to index blog posts.
7
+ # Default is 'comfy/blog/application'
8
+ attr_accessor :app_layout
9
+
10
+ # Number of posts per page. Default is 10
11
+ attr_accessor :posts_per_page
12
+
13
+ # Auto-setting parameter derived from the routes
14
+ attr_accessor :public_blog_path
15
+
16
+ # Configuration defaults
17
+ def initialize
18
+ @posts_per_page = 10
19
+ @app_layout = "comfy/blog/application"
20
+ @public_blog_path = nil
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubygems"
4
+ require "rails"
5
+ require "comfortable_mexican_sofa"
6
+ require "comfy_blog"
7
+
8
+ module ComfyBlog
9
+
10
+ module CmsSiteExtensions
11
+
12
+ extend ActiveSupport::Concern
13
+ included do
14
+ has_many :blog_posts,
15
+ class_name: "Blog::Post",
16
+ dependent: :destroy
17
+ end
18
+
19
+ end
20
+
21
+ class Engine < ::Rails::Engine
22
+
23
+ initializer "comfy_blog.configuration" do
24
+ ComfortableMexicanSofa::ViewHooks.add(:navigation, "/comfy/admin/blog/partials/navigation")
25
+ config.to_prepare do
26
+ Comfy::Cms::Site.send :include, ComfyBlog::CmsSiteExtensions
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ActionDispatch::Routing::Mapper
4
+
5
+ def comfy_route_blog(options = {})
6
+ ComfyBlog.configuration.public_blog_path = options[:path] || "blog"
7
+ path = ["(:cms_path)", ComfyBlog.configuration.public_blog_path].join("/")
8
+
9
+ scope module: :comfy, as: :comfy do
10
+ namespace :blog, path: path do
11
+ with_options constraints: { year: %r{\d{4}}, month: %r{\d{1,2}} } do |o|
12
+ o.get ":year", to: "posts#index", as: :posts_of_year
13
+ o.get ":year/:month", to: "posts#index", as: :posts_of_month
14
+ o.get ":year/:month/:slug", to: "posts#show", as: :post
15
+ o.get "/", to: "posts#index", as: :posts
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ActionDispatch::Routing::Mapper
4
+
5
+ def comfy_route_blog_admin(options = {})
6
+ options[:path] ||= "admin"
7
+ path = [options[:path], "sites", ":site_id"].join("/")
8
+
9
+ scope module: :comfy, as: :comfy do
10
+ scope module: :admin do
11
+ namespace :blog, as: :admin, path: path, except: [:show] do
12
+ resources :posts, as: :blog_posts, path: "blog-posts" do
13
+ get :form_fragments, on: :member
14
+ resources :revisions, only: %i[index show], controller: "revisions/post" do
15
+ patch :revert, on: :member
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "routes/blog_admin"
4
+ require_relative "routes/blog"
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ComfyBlog
4
+
5
+ VERSION = "0.0.1"
6
+
7
+ end
@@ -0,0 +1,10 @@
1
+ ____ __ ____ _
2
+ / ___|___ _ __ ___ / _|_ _| __ )| | ___ __ _
3
+ | | / _ \| '_ ` _ \| |_| | | | _ \| |/ _ \ / _` |
4
+ | |__| (_) | | | | | | _| |_| | |_) | | (_) | (_| |
5
+ \____\___/|_| |_| |_|_| \__, |____/|_|\___/ \__, |
6
+ |___/ |___/
7
+
8
+ Hey! Everything is almost done. Please don't forget to
9
+
10
+ * run migrations -> `rake db:migrate`
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/active_record"
4
+
5
+ module Comfy
6
+ module Generators
7
+ class BlogGenerator < Rails::Generators::Base
8
+
9
+ include Rails::Generators::Migration
10
+ include Thor::Actions
11
+
12
+ source_root File.expand_path("../../../..", __dir__)
13
+
14
+ def self.next_migration_number(dirname)
15
+ ActiveRecord::Generators::Base.next_migration_number(dirname)
16
+ end
17
+
18
+ def generate_migration
19
+ destination = File.expand_path("db/migrate/01_create_blog.rb", destination_root)
20
+ migration_dir = File.dirname(destination)
21
+ destination = self.class.migration_exists?(migration_dir, "create_blog")
22
+
23
+ if destination
24
+ puts "\e[0m\e[31mFound existing create_blog migration. Remove it if you want to regenerate.\e[0m"
25
+ else
26
+ migration_template "db/migrate/01_create_blog.rb", "db/migrate/create_blog.rb"
27
+ end
28
+ end
29
+
30
+ def generate_initialization
31
+ copy_file "config/initializers/comfy_blog.rb",
32
+ "config/initializers/comfy_blog.rb"
33
+ end
34
+
35
+ def generate_routing
36
+ route_string = <<-RUBY.strip_heredoc
37
+ comfy_route :blog_admin, path: "/admin"
38
+ comfy_route :blog, path: "/blog"
39
+ RUBY
40
+ route route_string
41
+ end
42
+
43
+ def generate_views
44
+ directory "app/views/comfy/blog", "app/views/comfy/blog"
45
+ end
46
+
47
+ def show_readme
48
+ readme "lib/generators/comfy/blog/README"
49
+ end
50
+
51
+ end
52
+ end
53
+ end