serbea 0.8.0 → 0.8.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 +4 -4
 - data/lib/serbea.rb +1 -3
 - data/lib/serbea/rails_support.rb +27 -21
 - data/lib/version.rb +1 -1
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 439fb102e78e2208de075b03b058b77d1cc909a6fe9414c341a48370fd3988e2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d0ff78ac67f00a59fa1047f7f05795cee88051ff0fdb9c179601984601fecae4
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 6ca9922186315539c54e3a44fad5da81b3075425bb991dd8521e4777f5d46e515d4a65f9fd7fd54c52b870df21c8155b32beb3a24c84080c95367b1143526ff5
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ccb34f9d8129fe5c4e34f96d7cbce118f5dbf8538151ae554cca9c35f63e223a0d14b4456e1463c8a79661de6109831ca3058aaee184f2925af974acfbc5f6b1
         
     | 
    
        data/lib/serbea.rb
    CHANGED
    
    | 
         @@ -32,9 +32,7 @@ if defined?(Rails::Railtie) 
     | 
|
| 
       32 
32 
     | 
    
         
             
                  ActiveSupport.on_load(:action_view) do
         
     | 
| 
       33 
33 
     | 
    
         
             
                    require "serbea/rails_support"
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
       36 
     | 
    
         
            -
                      Serbea::Plugin.initialize_frontmatter
         
     | 
| 
       37 
     | 
    
         
            -
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
                    ActionController::Base.include Serbea::Rails::FrontmatterControllerActions
         
     | 
| 
       38 
36 
     | 
    
         
             
                  end
         
     | 
| 
       39 
37 
     | 
    
         
             
                end
         
     | 
| 
       40 
38 
     | 
    
         
             
              end
         
     | 
    
        data/lib/serbea/rails_support.rb
    CHANGED
    
    | 
         @@ -1,34 +1,40 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # inspired by https://github.com/haml/haml/blob/main/lib/haml/plugin.rb
         
     | 
| 
       4 
3 
     | 
    
         
             
            module Serbea
         
     | 
| 
       5 
     | 
    
         
            -
               
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
                   
     | 
| 
      
 4 
     | 
    
         
            +
              module Rails
         
     | 
| 
      
 5 
     | 
    
         
            +
                module FrontmatterHelpers
         
     | 
| 
      
 6 
     | 
    
         
            +
                  def set_page_frontmatter=(data)
         
     | 
| 
      
 7 
     | 
    
         
            +
                    @frontmatter ||= HashWithDotAccess::Hash.new
         
     | 
| 
      
 8 
     | 
    
         
            +
                    @frontmatter.update(data)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
       11 
10 
     | 
    
         
             
                end
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
                 
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
      
 12 
     | 
    
         
            +
                module FrontmatterControllerActions
         
     | 
| 
      
 13 
     | 
    
         
            +
                  extend ActiveSupport::Concern
         
     | 
| 
       15 
14 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
      
 15 
     | 
    
         
            +
                  included do
         
     | 
| 
      
 16 
     | 
    
         
            +
                    Serbea::TemplateEngine.front_matter_preamble = "self.set_page_frontmatter = local_frontmatter = YAML.load"
         
     | 
| 
      
 17 
     | 
    
         
            +
                
         
     | 
| 
      
 18 
     | 
    
         
            +
                    before_action { @frontmatter ||= HashWithDotAccess::Hash.new }
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                    helper Serbea::Rails::FrontmatterHelpers
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
       17 
22 
     | 
    
         
             
                end
         
     | 
| 
       18 
23 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
                 
     | 
| 
       20 
     | 
    
         
            -
                   
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                  
         
     | 
| 
       23 
     | 
    
         
            -
                     
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                class TemplateHandler
         
     | 
| 
      
 25 
     | 
    
         
            +
                  def handles_encoding?; true; end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  def compile(template, source)
         
     | 
| 
      
 28 
     | 
    
         
            +
                    "self.class.include(Serbea::Helpers);" + Tilt::SerbeaTemplate.new { source }.precompiled_template([])
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                  def self.call(template, source = nil)
         
     | 
| 
      
 32 
     | 
    
         
            +
                    source ||= template.source
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                    new.compile(template, source)
         
     | 
| 
       29 
35 
     | 
    
         
             
                  end
         
     | 
| 
       30 
36 
     | 
    
         
             
                end
         
     | 
| 
       31 
37 
     | 
    
         
             
              end
         
     | 
| 
       32 
38 
     | 
    
         
             
            end
         
     | 
| 
       33 
39 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
            ActionView::Template.register_template_handler(:serb, Serbea:: 
     | 
| 
      
 40 
     | 
    
         
            +
            ActionView::Template.register_template_handler(:serb, Serbea::Rails::TemplateHandler)
         
     | 
    
        data/lib/version.rb
    CHANGED