Class: Sitepress::Extensions::RailsRequestPaths

Inherits:
Object
  • Object
show all
Defined in:
lib/sitepress/extensions/rails_request_paths.rb

Overview

Removes the file extension from the file so that /hi/there/fun.html can be resolved via /hi/there/fun.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.format_path(request_path) ⇒ Object


15
16
17
# File 'lib/sitepress/extensions/rails_request_paths.rb', line 15

def self.format_path(request_path)
  File.join(File.dirname(File.join("/", request_path)), File.basename(request_path, ".*"))
end

Instance Method Details

#process_resources(node) ⇒ Object


6
7
8
9
10
11
12
13
# File 'lib/sitepress/extensions/rails_request_paths.rb', line 6

def process_resources(node)
  node.flatten.each do |r|
    asset = r.asset
    request_path = r.request_path
    r.node.remove
    node.add path: self.class.format_path(request_path), asset: asset
  end
end