プロジェクト

全般

プロフィール

提案 #1282 » photo_support-github-fixed.patch

cob odo, 2018-07-24 15:59

差分を表示:

core/plugin/photo_support/photo_support.rb
5 5

  
6 6
module Plugin::PhotoSupport
7 7
  INSTAGRAM_PATTERN = %r{\Ahttps?://(?:instagr\.am|(?:www\.)?instagram\.com)/p/([a-zA-Z0-9_\-]+)/}
8
  GITHUB_IMAGE_PATTERN = %r<\Ahttps://github\.com/(\w+/\w+)/blob/(.*\.(?:#{GdkPixbuf::Pixbuf.formats.flat_map do |f| f.extensions end.join '|'}))\z>
8 9

  
9 10
  class << self
10 11
    extend Memoist
......
252 253
    img = Plugin::PhotoSupport.d250g2(display_url)
253 254
    open(img) if img
254 255
  end
256

  
257
  # GitHub
258
  defimageopener('github', Plugin::PhotoSupport::GITHUB_IMAGE_PATTERN) do |display_url|
259
    url = Plugin::PhotoSupport::GITHUB_IMAGE_PATTERN.match(display_url) do |m|
260
      "https://raw.githubusercontent.com/#{m[1]}/#{m[2]}"
261
    end
262
    open(url) if url
263
  end
255 264
end
    (1-1/1)