aboutsummaryrefslogtreecommitdiffstats
path: root/core/plugin/intent/model
diff options
context:
space:
mode:
authorToshiaki Asai <toshi.alternative@gmail.com>2016-10-05 08:29:24 +0900
committerToshiaki Asai <toshi.alternative@gmail.com>2016-10-05 08:35:41 +0900
commit7990f5cc37c87840e3790599244604d7d97419a7 (patch)
tree029b0357c09433810236ed84316aaa4e77d8276c /core/plugin/intent/model
parent8e67ab4a8aeb93198f0aa9949c9710c9c24c2c60 (diff)
downloadmikutter-7990f5cc37c87840e3790599244604d7d97419a7.tar.gz
Web Modelを追加し、openイベントにURLを渡すと外部ブラウザで開く refs #866
Diffstat (limited to 'core/plugin/intent/model')
-rw-r--r--core/plugin/intent/model/web.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/core/plugin/intent/model/web.rb b/core/plugin/intent/model/web.rb
new file mode 100644
index 00000000..5380d05a
--- /dev/null
+++ b/core/plugin/intent/model/web.rb
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+
+=begin rdoc
+Web上のリソースを示す汎用的なModel。
+これ自体が特別な機能は提供せず、単にURLがWeb上のリソースを指し示していることを表わすために使う。
+
+例えば、URLはWebブラウザで開くことができるが、intentは最終的に全てModelに変換できなければならないため、Modelが用意されていない多くのURLは取り扱うことができない。
+=end
+module Plugin::Intent
+ class Web < Retriever::Model
+ register :web
+
+ field.uri :perma_link
+
+ handle ->uri{ %w<http https>.include?(uri.scheme) }
+
+ def self.find_by_uri(uri)
+ new(perma_link: uri)
+ end
+ end
+end