next_rails_scaffold 0.1.8 → 0.1.9
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/app/controllers/next_rails/static_pages_controller.rb +27 -0
- data/config/routes.rb +16 -0
- data/lib/next_rails/engine.rb +8 -0
- data/lib/next_rails/version.rb +1 -1
- data/lib/next_rails.rb +1 -0
- metadata +5 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: b9e43c5ca53fb69e1b2ad36d222316f092d83adcf22771de34838c9b176c5aa1
         | 
| 4 | 
            +
              data.tar.gz: 383a69fa52d27c05645ae3db30a9e36a8b628ea7fab6f7c29dfc7c9c40162824
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 0fc1ab34055af28a30ba72b57d9e1c9e59aec332dc6e1e8c4a141537193d2fe11a8ba7f554e79f75e760eca6ffc2765ba055453c250218da22de0f653fddb546
         | 
| 7 | 
            +
              data.tar.gz: beddbe982618623580da842ee049380f033739eb6dc5b1039ee6c342be06ecf37c890da19c938cf09053bde8049c9e40fb0fad556791707a157eb29deb5ada96
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module NextRails
         | 
| 4 | 
            +
              class StaticPagesController < ApplicationController
         | 
| 5 | 
            +
                STATIC_FILES_PATH = Rails.root.join("public").to_s
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def index
         | 
| 8 | 
            +
                  send_file file_path, type: "text/html", disposition: "inline"
         | 
| 9 | 
            +
                rescue ActionController::ResourceNotFound
         | 
| 10 | 
            +
                  send_file File.join(STATIC_FILES_PATH, "404.html"), type: "text/html", disposition: "inline", status: 404
         | 
| 11 | 
            +
                rescue StandardError => e
         | 
| 12 | 
            +
                  Rails.logger.error "StaticPagesController (#{e.class}): #{e.message}"
         | 
| 13 | 
            +
                  raise e
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                private
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                def file_path
         | 
| 19 | 
            +
                  path = params.require(:file_path)
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  raise ActionController::ResourceNotFound, "Not Found" unless File.exist?(path)
         | 
| 22 | 
            +
                  raise ActionController::RoutingError, "Forbidden" unless path.start_with?(STATIC_FILES_PATH)
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  path
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/config/routes.rb
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Rails.application.routes.draw do
         | 
| 4 | 
            +
              parameter_regex = /\[([a-zA-Z0-9_-]+)\]/
         | 
| 5 | 
            +
              static_files_path = Rails.root.join("public").to_s
         | 
| 6 | 
            +
              static_files = File.join(static_files_path, "**", "index.html")
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              Dir.glob(static_files).each do |path|
         | 
| 9 | 
            +
                next unless path.match?(parameter_regex)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                route = path[%r{#{Regexp.escape(static_files_path)}(.*)/index.html}, 1]
         | 
| 12 | 
            +
                route = route.gsub(parameter_regex, ':\1')
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                get route, to: "next_rails/static_pages#index", file_path: path
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
    
        data/lib/next_rails/version.rb
    CHANGED
    
    
    
        data/lib/next_rails.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: next_rails_scaffold
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.9
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Raphael Araújo
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023-11- | 
| 11 | 
            +
            date: 2023-11-24 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rails
         | 
| @@ -50,12 +50,15 @@ files: | |
| 50 50 | 
             
            - LICENSE.txt
         | 
| 51 51 | 
             
            - README.md
         | 
| 52 52 | 
             
            - Rakefile
         | 
| 53 | 
            +
            - app/controllers/next_rails/static_pages_controller.rb
         | 
| 54 | 
            +
            - config/routes.rb
         | 
| 53 55 | 
             
            - lib/generators/next_rails/USAGE
         | 
| 54 56 | 
             
            - lib/generators/next_rails/install_generator.rb
         | 
| 55 57 | 
             
            - lib/generators/next_rails/templates/config/initializers/next_rails.rb
         | 
| 56 58 | 
             
            - lib/generators/rails/next_rails/next_rails_generator.rb
         | 
| 57 59 | 
             
            - lib/next_rails.rb
         | 
| 58 60 | 
             
            - lib/next_rails/actions.rb
         | 
| 61 | 
            +
            - lib/next_rails/engine.rb
         | 
| 59 62 | 
             
            - lib/next_rails/version.rb
         | 
| 60 63 | 
             
            - sig/next_rails.rbs
         | 
| 61 64 | 
             
            homepage: https://github.com/raphox/next-rails#readme
         |