aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranekos2010-08-29 23:01:37 +0000
committeranekos2010-08-29 23:01:37 +0000
commit6b90db535074071ef20d3839c58f406147e3bfc5 (patch)
tree3ae6b96e2896e569d6e6e474e427b4ef5fad50b7
parent7ff18d4f6cdb4cdc8ac55ded36c69aec90da8ccb (diff)
downloadvimperator-plugins-6b90db535074071ef20d3839c58f406147e3bfc5.tar.bz2
showTL でユーザ名にリンクを貼るようにした。
:tw!@screen_name を実行すべきか? git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38378 d0d07461-0603-4401-acd4-de1884942a52
-rwxr-xr-xtwittperator.js14
1 files changed, 9 insertions, 5 deletions
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)}<a highlight="URL" href={url}> {url} </a>{Utils.anchorLink(right)}</>;
+ let content = head === "@" ? <a highlight="URL" href={"http://twitter.com/" + tail}> {center} </a>
+ : <a highlight="URL" href={center}> {center} </a>
+ return <>{Utils.anchorLink(left)}{content}{Utils.anchorLink(right)}</>;
}
return str;
}, // }}}