Module: JekyllAdmin::PathHelper
Instance Method Summary collapse
-
#absolute_path ⇒ Object
(also: #path)
Returns the sanitized absolute path to the requested object.
-
#filename ⇒ Object
Returns the basename + extension for the requested file.
-
#relative_path ⇒ Object
Returns the sanitized relative path to the requested object.
-
#relative_write_path ⇒ Object
Returns the sanitized relative path to write the requested object.
-
#renamed? ⇒ Boolean
Is this request renaming a file?.
- #sanitized_path(path) ⇒ Object
-
#sanitized_relative_path(path) ⇒ Object
Returns the sanitized path relative to the site source.
-
#write_path ⇒ Object
(also: #request_path)
Returns the sanitized absolute path to write the requested object.
Instance Method Details
#absolute_path ⇒ Object Also known as: path
Returns the sanitized absolute path to the requested object
20 21 22 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 20 def absolute_path sanitized_path File.join(directory_path, filename) end |
#filename ⇒ Object
Returns the basename + extension for the requested file
9 10 11 12 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 9 def filename params["ext"] ||= "yml" if namespace == "data" "#{params["path"]}.#{params["ext"]}" end |
#relative_path ⇒ Object
Returns the sanitized relative path to the requested object
26 27 28 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 26 def relative_path sanitized_relative_path absolute_path end |
#relative_write_path ⇒ Object
Returns the sanitized relative path to write the requested object
41 42 43 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 41 def relative_write_path sanitized_relative_path write_path end |
#renamed? ⇒ Boolean
Is this request renaming a file?
46 47 48 49 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 46 def renamed? return false unless request_payload["path"] ensure_leading_slash(request_payload["path"]) != relative_path end |
#sanitized_path(path) ⇒ Object
3 4 5 6 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 3 def sanitized_path(path) path = path_without_site_source(path) Jekyll.sanitized_path JekyllAdmin.site.source, path end |
#sanitized_relative_path(path) ⇒ Object
Returns the sanitized path relative to the site source
15 16 17 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 15 def sanitized_relative_path(path) path_without_site_source sanitized_path(path) end |
#write_path ⇒ Object Also known as: request_path
Returns the sanitized absolute path to write the requested object
31 32 33 34 35 36 37 |
# File 'lib/jekyll-admin-josercc/path_helper.rb', line 31 def write_path if renamed? sanitized_path request_payload["path"] else path end end |