プロジェクト

全般

プロフィール

環境対応 #954 » 0001-Windows.patch

Satoshi Okuno, 2017-10-11 23:10

差分を表示:

core/plugin/photo/model/photo.rb
when URI, Addressable::URI, Retriever::URI
photos[uri.to_s.hash] ||= new(perma_link: uri)
when String
if uri.start_with?('http')
photos[uri.hash] ||= new(perma_link: uri)
elsif uri.start_with?('/')
uri = Retriever::URI.new(scheme: 'file', path: uri)
photos[uri.hash] ||= new(perma_link: uri)
uri_obj = Plugin.filtering(:uri_from_string, nil, uri).first
if uri_obj
photos[uri.hash] ||= new(perma_link: uri_obj)
else
if uri.start_with?('http')
photos[uri.hash] ||= new(perma_link: uri)
elsif uri.start_with?('/')
uri = Retriever::URI.new(scheme: 'file', path: uri)
photos[uri.hash] ||= new(perma_link: uri)
end
end
end
end
core/plugin/windows_path_support/windows_path_support.rb
# -*- coding: utf-8 -*-
# windows_path_support.rb
#
#
require "rbconfig"
Plugin.create :windows_path_support do
filter_uri_from_string { |uri, str|
# Windows?
result = if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|bccwin|wince/
# has drive letter?
if str =~ /^[a-zA-Z]\:/
Retriever::URI.new(scheme: 'file', path: uri)
else
nil
end
else
nil
end
[result, str]
}
end
(1-1/5)