From fefb0f3368cc880e8878316ecd074a046718c4f6 Mon Sep 17 00:00:00 2001 From: Toshiaki Asai Date: Tue, 21 Nov 2017 00:33:36 +0900 Subject: search spellを実装 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/plugin/search/.mikutter.yml | 1 + core/plugin/search/search.rb | 6 +++++- core/plugin/spell/struct.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/plugin/search/.mikutter.yml b/core/plugin/search/.mikutter.yml index 179ae011..876d3260 100644 --- a/core/plugin/search/.mikutter.yml +++ b/core/plugin/search/.mikutter.yml @@ -8,6 +8,7 @@ depends: - uitranslator - skin - twitter + - spell version: '1.0' author: toshi_a name: 検索 diff --git a/core/plugin/search/search.rb b/core/plugin/search/search.rb index c05e4dca..bc6d9932 100644 --- a/core/plugin/search/search.rb +++ b/core/plugin/search/search.rb @@ -6,6 +6,10 @@ Plugin.create :search do Plugin.call(:search_start, token.model.query) end + defspell(:search, :twitter) do |twitter, options| + twitter.search(options) + end + querybox = ::Gtk::Entry.new() querycont = ::Gtk::VBox.new(false, 0) searchbtn = ::Gtk::Button.new(_('検索')) @@ -37,7 +41,7 @@ Plugin.create :search do searchbtn.signal_connect('clicked'){ |elm| elm.sensitive = querybox.sensitive = false timeline(:search).clear - Service.primary.search(q: querybox.text, count: 100).next{ |res| + spell(:search, Service.primary, q: querybox.text, count: 100).next{ |res| timeline(:search) << res if res.is_a? Array elm.sensitive = querybox.sensitive = true }.trap{ |e| diff --git a/core/plugin/spell/struct.rb b/core/plugin/spell/struct.rb index 039a8c01..39ddc1cf 100644 --- a/core/plugin/spell/struct.rb +++ b/core/plugin/spell/struct.rb @@ -4,7 +4,7 @@ module Plugin::Spell Spell = Struct.new(:name, :constraint, :condition, :proc) do def match(models, optional) - Set.new(constraint.map{|a| Diva::Model(a) }) == Set.new(models.map{|a| a.class }) and condition?(models) + Set.new(constraint.map{|a| Diva::Model(a) }) == Set.new(models.map{|a| a.class }) and condition?(models, optional) end def call(models, optional) -- cgit v1.2.3