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.
-
#new? ⇒ Boolean
Is this request creating a new 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
22 23 24 |
# File 'lib/jekyll-admin/path_helper.rb', line 22 def absolute_path sanitized_path File.join(directory_path, filename) end |
#filename ⇒ Object
Returns the basename + extension for the requested file
11 12 13 14 |
# File 'lib/jekyll-admin/path_helper.rb', line 11 def filename params["ext"] ||= "yml" if namespace == "data" "#{params["path"]}.#{params["ext"]}" end |
#new? ⇒ Boolean
Is this request creating a new file?
55 56 57 |
# File 'lib/jekyll-admin/path_helper.rb', line 55 def new? !request_payload["path"] end |
#relative_path ⇒ Object
Returns the sanitized relative path to the requested object
28 29 30 |
# File 'lib/jekyll-admin/path_helper.rb', line 28 def relative_path sanitized_relative_path absolute_path end |
#relative_write_path ⇒ Object
Returns the sanitized relative path to write the requested object
43 44 45 |
# File 'lib/jekyll-admin/path_helper.rb', line 43 def relative_write_path sanitized_relative_path write_path end |
#renamed? ⇒ Boolean
Is this request renaming a file?
48 49 50 51 52 |
# File 'lib/jekyll-admin/path_helper.rb', line 48 def renamed? return false unless request_payload["path"] ensure_leading_slash(request_payload["path"]) != relative_path end |
#sanitized_path(path) ⇒ Object
5 6 7 8 |
# File 'lib/jekyll-admin/path_helper.rb', line 5 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
17 18 19 |
# File 'lib/jekyll-admin/path_helper.rb', line 17 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
33 34 35 36 37 38 39 |
# File 'lib/jekyll-admin/path_helper.rb', line 33 def write_path if renamed? sanitized_path request_payload["path"] else path end end |