プロジェクト

全般

プロフィール

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

Satoshi Okuno, 2017-10-11 23:10

差分を表示:

core/plugin/photo/model/photo.rb
19 19
      when URI, Addressable::URI, Retriever::URI
20 20
        photos[uri.to_s.hash] ||= new(perma_link: uri)
21 21
      when String
22
        if uri.start_with?('http')
23
          photos[uri.hash] ||= new(perma_link: uri)
24
        elsif uri.start_with?('/')
25
          uri = Retriever::URI.new(scheme: 'file', path: uri)
26
          photos[uri.hash] ||= new(perma_link: uri)
22
        uri_obj = Plugin.filtering(:uri_from_string, nil, uri).first
23

  
24
        if uri_obj
25
          photos[uri.hash] ||= new(perma_link: uri_obj)
26
        else
27
          if uri.start_with?('http')
28
            photos[uri.hash] ||= new(perma_link: uri)
29
          elsif uri.start_with?('/')
30
            uri = Retriever::URI.new(scheme: 'file', path: uri)
31
            photos[uri.hash] ||= new(perma_link: uri)
32
          end
27 33
        end
28 34
      end
29 35
    end
core/plugin/windows_path_support/windows_path_support.rb
1
# -*- coding: utf-8 -*-
2
# windows_path_support.rb
3
#
4
# 
5

  
6
require "rbconfig"
7

  
8
Plugin.create :windows_path_support do
9
  filter_uri_from_string { |uri, str|
10
    # Windows?
11
    result = if RbConfig::CONFIG["host_os"] =~ /mswin|mingw|bccwin|wince/
12
      # has drive letter?
13
      if str =~ /^[a-zA-Z]\:/
14
        Retriever::URI.new(scheme: 'file', path: uri)
15
      else
16
        nil
17
      end
18
    else
19
      nil
20
    end
21

  
22
    [result, str]
23
  }
24

  
25
end
(1-1/5)