Extracted `sanitize_filename` from site.rb into reader.rb
- Extracted - Updated References - Ran Tests Signed-off-by: Martin Jorn Rogalla <martin@martinrogalla.com>
This commit is contained in:
parent
ddfecb0f53
commit
e586105b46
|
@ -73,5 +73,11 @@ module Jekyll
|
||||||
SafeYAML.load_file(path)
|
SafeYAML.load_file(path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sanitize_filename(name)
|
||||||
|
name.gsub!(/[^\w\s_-]+/, '')
|
||||||
|
name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
|
||||||
|
name.gsub(/\s+/, '_')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -232,7 +232,7 @@ module Jekyll
|
||||||
path = reader.in_source_dir(dir, entry)
|
path = reader.in_source_dir(dir, entry)
|
||||||
next if File.symlink?(path) && safe
|
next if File.symlink?(path) && safe
|
||||||
|
|
||||||
key = sanitize_filename(File.basename(entry, '.*'))
|
key = reader.sanitize_filename(File.basename(entry, '.*'))
|
||||||
if File.directory?(path)
|
if File.directory?(path)
|
||||||
read_data_to(path, data[key] = {})
|
read_data_to(path, data[key] = {})
|
||||||
else
|
else
|
||||||
|
@ -464,11 +464,5 @@ module Jekyll
|
||||||
def site_cleaner
|
def site_cleaner
|
||||||
@site_cleaner ||= Cleaner.new(self)
|
@site_cleaner ||= Cleaner.new(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def sanitize_filename(name)
|
|
||||||
name.gsub!(/[^\w\s_-]+/, '')
|
|
||||||
name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
|
|
||||||
name.gsub(/\s+/, '_')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue