From 6b90db535074071ef20d3839c58f406147e3bfc5 Mon Sep 17 00:00:00 2001
From: anekos
Date: Sun, 29 Aug 2010 23:01:37 +0000
Subject: showTL でユーザ名にリンクを貼るようにした。
:tw!@screen_name を実行すべきか?
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38378 d0d07461-0603-4401-acd4-de1884942a52
---
twittperator.js | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
(limited to 'twittperator.js')
diff --git a/twittperator.js b/twittperator.js
index 54d47da..922d7a7 100755
--- a/twittperator.js
+++ b/twittperator.js
@@ -1221,7 +1221,7 @@ let PLUGIN_INFO =
// }}}
// Twittperator
- let ChirpUserStream = (function() { // {{{
+ function Stream({host, path}) { // {{{
function extractURL(s)
let (m = s.match(/https?:\/\/\S+/))
(m && m[0]);
@@ -1366,7 +1366,8 @@ let PLUGIN_INFO =
removeListener: function(func) (listeners = listeners.filter(function(l) (l != func))),
clearPluginData: clearPluginData
};
- })(); // }}}
+ }; // }}}
+ let ChirpUserStream = Stream({host: "chirpstream.twitter.com", path: "/2b/user.json"});
let Twitter = { // {{{
destroy: function(id) { // {{{
tw.post("http://api.twitter.com/1/statuses/destroy/" + id + ".json", null, function(text) {
@@ -1472,12 +1473,15 @@ let PLUGIN_INFO =
}; // }}}
let Utils = { // {{{
anchorLink: function(str) { // {{{
- let m = str.match(/https?:\/\/\S+/);
+ let m = str.match(/https?:\/\/\S+|@\S+/);
if (m) {
let left = str.substr(0, m.index);
- let url = m[0];
+ let center = m[0];
+ let [head, tail] = [center[0], center.slice(1)];
let right = str.substring(m.index + m[0].length);
- return <>{Utils.anchorLink(left)} {url} {Utils.anchorLink(right)}>;
+ let content = head === "@" ? {center}
+ : {center}
+ return <>{Utils.anchorLink(left)}{content}{Utils.anchorLink(right)}>;
}
return str;
}, // }}}
--
cgit v1.2.3