aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorToshiaki Asai <toshi.alternative@gmail.com>2016-10-08 03:05:25 +0900
committerToshiaki Asai <toshi.alternative@gmail.com>2016-10-09 10:50:38 +0900
commitb9d54692272c105915284edbd3f1273d39f8a519 (patch)
tree2f1224ed645651f6f36b1874f0e3e6250012309a
parent9d354353f3d42151d3d12a0817ad474ab8c6e53e (diff)
downloadmikutter-b9d54692272c105915284edbd3f1273d39f8a519.tar.gz
openimg: Gtk::Timeline.openimgを使わず、intentを利用 refs #900
-rw-r--r--core/plugin/openimg/.mikutter.yml10
-rw-r--r--core/plugin/openimg/model/album.rb17
-rw-r--r--core/plugin/openimg/openimg.rb12
3 files changed, 27 insertions, 12 deletions
diff --git a/core/plugin/openimg/.mikutter.yml b/core/plugin/openimg/.mikutter.yml
index 599ffdc1..b4835f46 100644
--- a/core/plugin/openimg/.mikutter.yml
+++ b/core/plugin/openimg/.mikutter.yml
@@ -1,11 +1,13 @@
---
slug: :openimg
depends:
- mikutter: '3.2'
+ mikutter: '3.5'
plugin:
- gtk
- uitranslator
-version: '2.0'
+ - intent
+version: '2.1'
author: toshi_a
-name: 画像プレビュー
-description: メジャーな画像投稿サービスのURLがクリックされた時に、画像だけを専用のウィンドウに表示する
+name: 画像ビューア
+description: >-
+ 画像をmikutter上で表示する
diff --git a/core/plugin/openimg/model/album.rb b/core/plugin/openimg/model/album.rb
new file mode 100644
index 00000000..a120ff2f
--- /dev/null
+++ b/core/plugin/openimg/model/album.rb
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+
+module Plugin::Openimg
+ class Album < Retriever::Model
+ register :openimg_photo, name: Plugin[:openimg]._('画像ビューア')
+
+ field.uri :perma_link
+
+ handle ->uri{
+ uri_str = uri.to_s
+ openers = Plugin.filtering(:openimg_image_openers, Set.new).first
+ openers.any?{ |opener| opener.condition === uri_str } if !openers.empty?
+ } do |uri|
+ new(perma_link: uri)
+ end
+ end
+end
diff --git a/core/plugin/openimg/openimg.rb b/core/plugin/openimg/openimg.rb
index 0e81c8d8..79f3843e 100644
--- a/core/plugin/openimg/openimg.rb
+++ b/core/plugin/openimg/openimg.rb
@@ -2,6 +2,7 @@
require 'gtk2'
require 'cairo'
+require_relative 'model/album'
module Plugin::Openimg
ImageOpener = Struct.new(:name, :condition, :open)
@@ -30,7 +31,6 @@ Plugin.create :openimg do
prototype: [String, Message]
defdsl :defimageopener do |name, condition, &proc|
- type_strict condition => :===, name => String
opener = Plugin::Openimg::ImageOpener.new(name.freeze, condition, proc).freeze
filter_openimg_image_openers do |openers|
openers << opener
@@ -191,13 +191,9 @@ Plugin.create :openimg do
rescue => _
error _ end
- ::Gtk::TimeLine.addopenway(->_{
- openers = Plugin.filtering(:openimg_image_openers, Set.new).first
- openers.any?{ |opener| opener.condition === _ }
- }) do |shrinked_url, cancel|
- Thread.new do
- url = (Plugin.filtering(:expand_url, [shrinked_url]).first.first rescue shrinked_url)
- Plugin.call(:openimg_open, url) end end
+ intent Plugin::Openimg::Album do |intent|
+ Plugin.call(:openimg_open, intent.model.perma_link.to_s)
+ end
def addsupport(cond, element_rule = {}, &block); end