EtsComfyBlog 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.
- checksums.yaml +7 -0
 - data/.github/issue_template.md +22 -0
 - data/.github/pull_request_template.md +6 -0
 - data/.gitignore +16 -0
 - data/.rubocop.yml +96 -0
 - data/.travis.yml +21 -0
 - data/CONTRIBUTING.md +32 -0
 - data/Gemfile +27 -0
 - data/LICENSE +20 -0
 - data/README.md +42 -0
 - data/Rakefile +5 -0
 - data/app/controllers/comfy/admin/blog/posts_controller.rb +84 -0
 - data/app/controllers/comfy/admin/blog/revisions/post_controller.rb +30 -0
 - data/app/controllers/comfy/blog/posts_controller.rb +50 -0
 - data/app/models/comfy/blog/post.rb +55 -0
 - data/app/views/comfy/admin/blog/partials/_navigation.html.haml +4 -0
 - data/app/views/comfy/admin/blog/posts/_form.html.haml +22 -0
 - data/app/views/comfy/admin/blog/posts/edit.html.haml +9 -0
 - data/app/views/comfy/admin/blog/posts/index.html.haml +37 -0
 - data/app/views/comfy/admin/blog/posts/new.html.haml +5 -0
 - data/app/views/comfy/blog/posts/index.html.haml +28 -0
 - data/app/views/comfy/blog/posts/index.rss.builder +22 -0
 - data/app/views/comfy/blog/posts/show.html.haml +8 -0
 - data/app/views/layouts/comfy/blog/application.html.erb +22 -0
 - 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 +28 -0
 - data/config.ru +6 -0
 - data/config/application.rb +39 -0
 - data/config/blog_routes.rb +8 -0
 - data/config/boot.rb +7 -0
 - data/config/database.yml +11 -0
 - data/config/environment.rb +7 -0
 - data/config/environments/development.rb +64 -0
 - data/config/environments/test.rb +51 -0
 - data/config/initializers/comfy_blog.rb +9 -0
 - data/config/locales/ca.yml +38 -0
 - data/config/locales/cs.yml +38 -0
 - data/config/locales/da.yml +38 -0
 - data/config/locales/de.yml +38 -0
 - data/config/locales/en.yml +38 -0
 - data/config/locales/es.yml +38 -0
 - data/config/locales/fi.yml +38 -0
 - data/config/locales/fr.yml +38 -0
 - data/config/locales/gr.yml +38 -0
 - data/config/locales/it.yml +38 -0
 - data/config/locales/ja.yml +38 -0
 - data/config/locales/nb.yml +38 -0
 - data/config/locales/nl.yml +38 -0
 - data/config/locales/pl.yml +38 -0
 - data/config/locales/pt-BR.yml +38 -0
 - data/config/locales/ru.yml +38 -0
 - data/config/locales/sv.yml +38 -0
 - data/config/locales/tr.yml +38 -0
 - data/config/locales/uk.yml +38 -0
 - data/config/locales/zh-CN.yml +38 -0
 - data/config/locales/zh-TW.yml +38 -0
 - data/config/storage.yml +35 -0
 - data/db/migrate/00_create_cms.rb +167 -0
 - data/db/migrate/01_create_blog.rb +24 -0
 - data/lib/comfy_blog.rb +29 -0
 - data/lib/comfy_blog/configuration.rb +24 -0
 - data/lib/comfy_blog/engine.rb +32 -0
 - data/lib/comfy_blog/routes/blog.rb +21 -0
 - data/lib/comfy_blog/routes/blog_admin.rb +23 -0
 - data/lib/comfy_blog/routing.rb +4 -0
 - data/lib/comfy_blog/version.rb +7 -0
 - data/lib/generators/comfy/blog/README +10 -0
 - data/lib/generators/comfy/blog/blog_generator.rb +53 -0
 - metadata +129 -0
 
| 
         @@ -0,0 +1,55 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            class Comfy::Blog::Post < ActiveRecord::Base
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              self.table_name = "comfy_blog_posts"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              include Comfy::Cms::WithFragments
         
     | 
| 
      
 8 
     | 
    
         
            +
              include Comfy::Cms::WithCategories
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              cms_has_revisions_for :fragments_attributes
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              # -- Relationships -----------------------------------------------------------
         
     | 
| 
      
 13 
     | 
    
         
            +
              belongs_to :site,
         
     | 
| 
      
 14 
     | 
    
         
            +
                class_name: "Comfy::Cms::Site"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              # -- Validations -------------------------------------------------------------
         
     | 
| 
      
 17 
     | 
    
         
            +
              validates :title, :slug, :year, :month,
         
     | 
| 
      
 18 
     | 
    
         
            +
                presence: true
         
     | 
| 
      
 19 
     | 
    
         
            +
              validates :slug,
         
     | 
| 
      
 20 
     | 
    
         
            +
                uniqueness: { scope: %i[site_id year month] },
         
     | 
| 
      
 21 
     | 
    
         
            +
                format:     { with: %r{\A%*\w[a-z0-9_%-]*\z}i }
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # -- Scopes ------------------------------------------------------------------
         
     | 
| 
      
 24 
     | 
    
         
            +
              scope :published, -> { where(is_published: true) }
         
     | 
| 
      
 25 
     | 
    
         
            +
              scope :for_year,  ->(year) { where(year: year) }
         
     | 
| 
      
 26 
     | 
    
         
            +
              scope :for_month, ->(month) { where(month: month) }
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              # -- Callbacks ---------------------------------------------------------------
         
     | 
| 
      
 29 
     | 
    
         
            +
              before_validation :set_slug,
         
     | 
| 
      
 30 
     | 
    
         
            +
                                :set_published_at,
         
     | 
| 
      
 31 
     | 
    
         
            +
                                :set_date
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              # -- Instance Mathods --------------------------------------------------------
         
     | 
| 
      
 34 
     | 
    
         
            +
              def url(relative: false)
         
     | 
| 
      
 35 
     | 
    
         
            +
                public_blog_path = ComfyBlog.config.public_blog_path
         
     | 
| 
      
 36 
     | 
    
         
            +
                post_path = ["/", public_blog_path, year, month, slug].join("/").squeeze("/")
         
     | 
| 
      
 37 
     | 
    
         
            +
                [site.url(relative: relative), post_path].join
         
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            protected
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              def set_slug
         
     | 
| 
      
 43 
     | 
    
         
            +
                self.slug ||= title.to_s.parameterize
         
     | 
| 
      
 44 
     | 
    
         
            +
              end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
              def set_date
         
     | 
| 
      
 47 
     | 
    
         
            +
                self.year   = published_at.year
         
     | 
| 
      
 48 
     | 
    
         
            +
                self.month  = published_at.month
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
              def set_published_at
         
     | 
| 
      
 52 
     | 
    
         
            +
                self.published_at ||= Time.zone.now
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = comfy_admin_partial "comfy/admin/blog/partials/post_form_before", form: form
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            = form.text_field :title, data: {slugify: @post.new_record?}
         
     | 
| 
      
 4 
     | 
    
         
            +
            = form.text_field :slug, data: {slug: true}
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            - if (options = ::Comfy::Cms::Layout.options_for_select(@site)).present?
         
     | 
| 
      
 7 
     | 
    
         
            +
              = form.select :layout_id, options, {}, {data: {url: form_fragments_comfy_admin_blog_post_path(@site, @post.id.to_i)}, id: "fragments-toggle"}
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            #form-fragments-container
         
     | 
| 
      
 10 
     | 
    
         
            +
              = render "comfy/admin/cms/fragments/form_fragments", record: @post, scope: :post
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            = render "comfy/admin/cms/categories/form", form: form
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            = form.text_field :published_at, value: @post.published_at.try(:to_s, :db), data: {'cms-datetime' => true}
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            = form.check_box :is_published
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            = comfy_admin_partial "comfy/admin/blog/partials/post_form_after", form: form
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            = form.form_actions do
         
     | 
| 
      
 21 
     | 
    
         
            +
              = submit_tag t(@post.new_record?? ".create" : ".update"), class: "btn btn-primary ml-sm-1", data: {disable_with: false}
         
     | 
| 
      
 22 
     | 
    
         
            +
              = link_to t(".cancel"), comfy_admin_blog_posts_path(@site, @blog), class: "btn btn-link"
         
     | 
| 
         @@ -0,0 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            - content_for :right_column do
         
     | 
| 
      
 2 
     | 
    
         
            +
              - link = comfy_admin_blog_post_revisions_path(@site, @post)
         
     | 
| 
      
 3 
     | 
    
         
            +
              = render "comfy/admin/cms/revisions/sidebar", record: @post, link: link
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            .page-header
         
     | 
| 
      
 6 
     | 
    
         
            +
              %h2= t('.title')
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            = comfy_form_with model: @post, scope: :post, url: {action: :update}, html: {multipart: true} do |form|
         
     | 
| 
      
 9 
     | 
    
         
            +
              = render form
         
     | 
| 
         @@ -0,0 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            - content_for :right_column do
         
     | 
| 
      
 2 
     | 
    
         
            +
              = render "comfy/admin/cms/categories/index", type: "Comfy::Blog::Post"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            .page-header
         
     | 
| 
      
 5 
     | 
    
         
            +
              = link_to t('.new_link'), new_comfy_admin_blog_post_path(@site), class: 'btn btn-secondary float-right'
         
     | 
| 
      
 6 
     | 
    
         
            +
              %h2= t('.title')
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            = comfy_admin_partial "comfy/admin/blog/partials/posts_before"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            = comfy_paginate @posts
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            %ul.list
         
     | 
| 
      
 13 
     | 
    
         
            +
              - @posts.each do |post|
         
     | 
| 
      
 14 
     | 
    
         
            +
                %li
         
     | 
| 
      
 15 
     | 
    
         
            +
                  .row
         
     | 
| 
      
 16 
     | 
    
         
            +
                    .col-md-8.item
         
     | 
| 
      
 17 
     | 
    
         
            +
                      .item-content
         
     | 
| 
      
 18 
     | 
    
         
            +
                        .item-title
         
     | 
| 
      
 19 
     | 
    
         
            +
                          - published_css_class = post.is_published? ? "published" : "draft"
         
     | 
| 
      
 20 
     | 
    
         
            +
                          = link_to post.title, edit_comfy_admin_blog_post_path(@site, post), class: published_css_class
         
     | 
| 
      
 21 
     | 
    
         
            +
                        .item-meta
         
     | 
| 
      
 22 
     | 
    
         
            +
                          - link = post.url
         
     | 
| 
      
 23 
     | 
    
         
            +
                          = link_to link, link, target: "_blank"
         
     | 
| 
      
 24 
     | 
    
         
            +
                          %br
         
     | 
| 
      
 25 
     | 
    
         
            +
                          = post.published_at.try(:to_s, :db)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                      .item-categories.ml-auto.d-flex.align-items-center
         
     | 
| 
      
 28 
     | 
    
         
            +
                        = render "comfy/admin/cms/categories/categories", object: post
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                    .col-md-4.d-flex.align-items-center.justify-content-md-end
         
     | 
| 
      
 31 
     | 
    
         
            +
                      .btn-group.btn-group-sm
         
     | 
| 
      
 32 
     | 
    
         
            +
                        = link_to t('.edit'), edit_comfy_admin_blog_post_path(@site, post), class: 'btn btn-outline-secondary'
         
     | 
| 
      
 33 
     | 
    
         
            +
                        = link_to t('.delete'), comfy_admin_blog_post_path(@site, post), method: :delete, data: {confirm: t('.are_you_sure')}, class: 'btn btn-danger'
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            = comfy_paginate @posts
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            = comfy_admin_partial "comfy/admin/blog/partials/posts_after"
         
     | 
| 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            .container
         
     | 
| 
      
 2 
     | 
    
         
            +
              .row
         
     | 
| 
      
 3 
     | 
    
         
            +
                .col-md-8
         
     | 
| 
      
 4 
     | 
    
         
            +
                  %h1 Blog Posts
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                  - @blog_posts.each do |post|
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                    %h2
         
     | 
| 
      
 9 
     | 
    
         
            +
                      = link_to post.title, comfy_blog_post_path(@cms_site.path, post.year, post.month, post.slug)
         
     | 
| 
      
 10 
     | 
    
         
            +
                    .date
         
     | 
| 
      
 11 
     | 
    
         
            +
                      = post.published_at.to_s(:db)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  = comfy_paginate @blog_posts
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                .col-md-4
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                  %h3 Archive
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - dates_with_counts = @cms_site.blog_posts.published.group(:year, :month).order(year: :desc, month: :desc).count
         
     | 
| 
      
 19 
     | 
    
         
            +
                  - dates_with_counts.each do |(year, month), count|
         
     | 
| 
      
 20 
     | 
    
         
            +
                    %li
         
     | 
| 
      
 21 
     | 
    
         
            +
                      - date = [I18n.t("date.month_names")[month.to_i], year].join(" ")
         
     | 
| 
      
 22 
     | 
    
         
            +
                      - site_path = @cms_site.url(relative: true)
         
     | 
| 
      
 23 
     | 
    
         
            +
                      = link_to date, comfy_blog_posts_of_month_path(site_path, year: year, month: month)
         
     | 
| 
      
 24 
     | 
    
         
            +
                      %small (#{count})
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  %h3 Tags
         
     | 
| 
      
 27 
     | 
    
         
            +
                  - Comfy::Cms::Category.of_type('Comfy::Blog::Post').all.each do |tag|
         
     | 
| 
      
 28 
     | 
    
         
            +
                    = link_to tag.label, category: tag.label
         
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            xml.instruct! :xml, version: "1.0"
         
     | 
| 
      
 4 
     | 
    
         
            +
            xml.rss version: "2.0" do
         
     | 
| 
      
 5 
     | 
    
         
            +
              xml.channel do
         
     | 
| 
      
 6 
     | 
    
         
            +
                xml.title "My Blog"
         
     | 
| 
      
 7 
     | 
    
         
            +
                xml.description "My Blog Description"
         
     | 
| 
      
 8 
     | 
    
         
            +
                xml.link comfy_blog_posts_url(@cms_site.path)
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                @blog_posts.each do |post|
         
     | 
| 
      
 11 
     | 
    
         
            +
                  url = comfy_blog_post_url(@cms_site.path, post.year, post.month, post.slug)
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                  xml.item do
         
     | 
| 
      
 14 
     | 
    
         
            +
                    xml.title post.title
         
     | 
| 
      
 15 
     | 
    
         
            +
                    xml.description "blog post content"
         
     | 
| 
      
 16 
     | 
    
         
            +
                    xml.pubDate post.published_at.to_s(:rfc822)
         
     | 
| 
      
 17 
     | 
    
         
            +
                    xml.link url
         
     | 
| 
      
 18 
     | 
    
         
            +
                    xml.guid url
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
                end
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            <!doctype html>
         
     | 
| 
      
 2 
     | 
    
         
            +
            <html lang="en">
         
     | 
| 
      
 3 
     | 
    
         
            +
              <head>
         
     | 
| 
      
 4 
     | 
    
         
            +
                <title>Hello, world!</title>
         
     | 
| 
      
 5 
     | 
    
         
            +
                <!-- Required meta tags -->
         
     | 
| 
      
 6 
     | 
    
         
            +
                <meta charset="utf-8">
         
     | 
| 
      
 7 
     | 
    
         
            +
                <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                <!-- Bootstrap CSS -->
         
     | 
| 
      
 10 
     | 
    
         
            +
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
         
     | 
| 
      
 11 
     | 
    
         
            +
              </head>
         
     | 
| 
      
 12 
     | 
    
         
            +
              <body>
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                <%= yield %>
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                <!-- Optional JavaScript -->
         
     | 
| 
      
 17 
     | 
    
         
            +
                <!-- jQuery first, then Popper.js, then Bootstrap JS -->
         
     | 
| 
      
 18 
     | 
    
         
            +
                <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
         
     | 
| 
      
 19 
     | 
    
         
            +
                <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
         
     | 
| 
      
 20 
     | 
    
         
            +
                <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>
         
     | 
| 
      
 21 
     | 
    
         
            +
              </body>
         
     | 
| 
      
 22 
     | 
    
         
            +
            </html>
         
     | 
    
        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
    ADDED
    
    | 
         @@ -0,0 +1,28 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            $LOAD_PATH.push File.expand_path("lib", __dir__)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "comfy_blog/version"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            # Describe your gem and declare its dependencies:
         
     | 
| 
      
 8 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.name        = "EtsComfyBlog"
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.version     = ComfyBlog::VERSION
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.authors     = ["PG9-SEP"]
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.email       = ["PG9@SEP"]
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.homepage    = "https://github.com/changyukang/comfy-blog"
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.summary     = "Self-customized Simple Blog Engine for ComfortableMexicanSofa"
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.description = "Self-customized Simple Blog Engine for ComfortableMexicanSofa"
         
     | 
| 
      
 16 
     | 
    
         
            +
              s.license     = "MIT"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              s.files = `git ls-files -z`.split("\x0").reject do |f|
         
     | 
| 
      
 19 
     | 
    
         
            +
                f.match(%r{^(test|doc)/})
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              s.required_ruby_version = ">= 2.3.0"
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              s.add_dependency "PixelForce_ETS", ">= 0.0.1"
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
    
        data/config.ru
    ADDED
    
    
| 
         @@ -0,0 +1,39 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require_relative "boot"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            require "rails/all"
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            # Require the gems listed in Gemfile, including any gems
         
     | 
| 
      
 8 
     | 
    
         
            +
            # you've limited to :test, :development, or :production.
         
     | 
| 
      
 9 
     | 
    
         
            +
            Bundler.require(*Rails.groups)
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            module ComfyBlog
         
     | 
| 
      
 12 
     | 
    
         
            +
              class Application < Rails::Application
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                require_relative "../lib/comfy_blog"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                config.load_defaults 5.2
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                # Settings in config/environments/* take precedence over those specified here.
         
     | 
| 
      
 19 
     | 
    
         
            +
                # Application configuration should go into files in config/initializers
         
     | 
| 
      
 20 
     | 
    
         
            +
                # -- all .rb files in that directory are automatically loaded.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
         
     | 
| 
      
 23 
     | 
    
         
            +
                # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
         
     | 
| 
      
 24 
     | 
    
         
            +
                # config.time_zone = 'Central Time (US & Canada)'
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
         
     | 
| 
      
 27 
     | 
    
         
            +
                # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
         
     | 
| 
      
 28 
     | 
    
         
            +
                # config.i18n.default_locale = :de
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                # Ensuring that all ActiveStorage routes are loaded before out globbing route.
         
     | 
| 
      
 31 
     | 
    
         
            +
                config.railties_order = [ActiveStorage::Engine, :main_app, :all]
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                # Making sure we don't load our dev routes as part of the engine
         
     | 
| 
      
 34 
     | 
    
         
            +
                config.paths["config/routes.rb"] << "config/blog_routes.rb"
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                config.i18n.enforce_available_locales = true
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              end
         
     | 
| 
      
 39 
     | 
    
         
            +
            end
         
     | 
    
        data/config/boot.rb
    ADDED
    
    
    
        data/config/database.yml
    ADDED