aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PDF.js.js212
-rw-r--r--auto-bookmark.js74
-rw-r--r--twittperator.js607
-rw-r--r--twittperator/mstrans.tw24
-rw-r--r--twittperator/ril.tw21
-rw-r--r--twittperator/rt.tw44
6 files changed, 667 insertions, 315 deletions
diff --git a/PDF.js.js b/PDF.js.js
new file mode 100644
index 0000000..92c7eea
--- /dev/null
+++ b/PDF.js.js
@@ -0,0 +1,212 @@
+/* NEW BSD LICENSE {{{
+Copyright (c) 2012, anekos.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ 3. The names of the authors may not be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+
+###################################################################################
+# http://sourceforge.jp/projects/opensource/wiki/licenses%2Fnew_BSD_license #
+# に参考になる日本語訳がありますが、有効なのは上記英文となります。 #
+###################################################################################
+
+}}} */
+
+// INFO {{{
+let INFO =
+<>
+ <plugin name="PDF.js.js" version="1.0.0"
+ href="http://vimpr.github.com/"
+ summary="PDF.js controller."
+ lang="en-US"
+ xmlns="http://vimperator.org/namespaces/liberator">
+ <author email="anekos@snca.net">anekos</author>
+ <license>New BSD License</license>
+ <project name="Vimperator" minVersion="3.0"/>
+ <p></p>
+ <item>
+ <tags>:pdfjs-mapping-sample</tags>
+ <description><p>mapping sample</p><code><![CDATA[
+ nnoremap -urls ^\\.pdf$ i :<C-u>pdfjs index<Space>
+ nnoremap -urls ^\\.pdf$ z :<C-u>pdfjs zoom<Space>
+ ]]></code></description>
+ </item>
+ </plugin>
+</>;
+// }}}
+
+(function () {
+
+ let scrollCount = 1;
+
+ function getScrollHeight (count) {
+ let base = content.innerHeight / 10;
+ if (count > 0)
+ scrollCount = count;
+ return base * scrollCount;
+ }
+
+ function addMap (keys, desc, action) {
+ mappings.addUserMap(
+ [modes.NORMAL],
+ keys,
+ desc + ' - PDF.js.js',
+ action,
+ {
+ count: true,
+ matchingUrls: /\.pdf$/
+ }
+ );
+ }
+
+ function getOutline () {
+ return Array.slice(content.document.querySelector('#outlineView').querySelectorAll('.outlineItem > a'));
+ }
+
+ function getOutlineLevel (node) {
+ let level = 0;
+ while (node && (node.getAttribute('id') != 'outlineView')) {
+ node = node.parentNode;
+ level++;
+ }
+ return node ? (level / 2): 0;
+ }
+
+ function nSpace (level) {
+ let res = '';
+ for (i = 0; i < level; i++)
+ res += ' ';
+ return res;
+ }
+
+ addMap(
+ ['j'],
+ 'Scroll Down',
+ function (count) {
+ content.document.querySelector('#viewerContainer').scrollTop += getScrollHeight(count);
+ }
+ );
+
+ addMap(
+ ['k'],
+ 'Scroll up',
+ function (count) {
+ content.document.querySelector('#viewerContainer').scrollTop -= getScrollHeight(count);
+ }
+ );
+
+ addMap(
+ ['n'],
+ 'Next page',
+ function (count) {
+ content.window.wrappedJSObject.PDFView.page += (count > 0 ? count : 1);
+ }
+ );
+
+ addMap(
+ ['p'],
+ 'Previous page',
+ function (count) {
+ content.window.wrappedJSObject.PDFView.page -= (count > 0 ? count : 1);
+ }
+ );
+
+ addMap(
+ ['gg'],
+ 'Go to page top or N page.',
+ function (count) {
+ if (count > 0)
+ content.window.wrappedJSObject.PDFView.page = count;
+ else
+ content.window.wrappedJSObject.PDFView.page = 1;
+ }
+ );
+
+ commands.addUserCommand(
+ ['pdfjs'],
+ 'PDF.js',
+ function () void 'Meow is best',
+ {
+ subCommands: [
+ new Command(
+ ['i[ndex]'],
+ 'Jump page by index',
+ function (args) {
+ let index = args.literalArg.match(/^#(\d+)$/);
+ if (index) {
+ let os = getOutline();
+ buffer.followLink(os[parseInt(index[1], 10)], liberator.CURRENT_TAB);
+ } else {
+ content.window.wrappedJSObject.PDFView.page = parseInt(args.literalArg, 10);
+ }
+ },
+ {
+ literal: 0,
+ completer: function (context, args) {
+ function desc (o) {
+ const PageRE = /#page=(\d+)\&/;
+ if (o.href && PageRE.test(o.href)) {
+ return String(<>{nSpace(getOutlineLevel(o))} {o.textContent} (p{o.href.match(PageRE)[1]})</>);
+ } else {
+ return String(<>{nSpace(getOutlineLevel(o))} {o.textContent}</>);
+ }
+ }
+
+ let os = getOutline();
+ context.compare = void 0;
+ context.filters = [CompletionContext.Filter.textDescription];
+ context.completions = [
+ [
+ '#' + i, desc(o)
+ ]
+ for ([i, o] in Iterator(os))
+ ];
+ }
+ }
+ ),
+
+ new Command(
+ ['z[oom]'],
+ 'Zoom',
+ function (args) {
+ content.window.wrappedJSObject.PDFView.parseScale(args.literalArg);
+ },
+ {
+ literal: 0,
+ completer: function (context, args) {
+ let os = Array.slice(content.document.querySelector('#scaleSelect').querySelectorAll('option'));
+ context.completions = [
+ [o.value, o.textContent]
+ for ([, o] in Iterator(os))
+ ];
+ }
+ }
+ )
+ ]
+ },
+ true
+ );
+
+})();
+
+// vim:sw=2 ts=2 et si fdm=marker:
diff --git a/auto-bookmark.js b/auto-bookmark.js
index 829178c..a3ed359 100644
--- a/auto-bookmark.js
+++ b/auto-bookmark.js
@@ -35,7 +35,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
// INFO {{{
let INFO =
<>
- <plugin name="AutoBookmark" version="1.2.0"
+ <plugin name="AutoBookmark" version="1.3.1"
href="http://vimpr.github.com/"
summary="Auto update bookmark"
lang="en-US"
@@ -50,7 +50,7 @@ let INFO =
<description><p></p></description>
</item>
</plugin>
- <plugin name="AutoBookmark" version="1.2.0"
+ <plugin name="AutoBookmark" version="1.3.1"
href="http://vimpr.github.com/"
summary="自動更新するブックマーク"
lang="ja"
@@ -209,11 +209,32 @@ let INFO =
function namesCompleter (hidden) { // {{{
return function (context, args) {
+ function toTime (data) {
+ if (data.last && data.last.date)
+ return new Date(data.last.date).getTime();
+ return 0;
+ }
+
+ let bs = [
+ data
+ for ([, data] in Iterator(bookmarks))
+ if (!!data.hidden === !!hidden)
+ ];
+
context.title = ['Bookmark name'];
+ if (args['-sort'] == 'title') {
+ }else {
+ // default date sorting
+ context.compare = void 0;
+ bs.sort(function (a, b) {
+ let d = toTime(b) - toTime(a);
+ return (d == 0 ? a.name.localeCompare(b.name) : d);
+ });
+ }
+
context.completions = [
- [name, data.current.URL]
- for ([name, data] in Iterator(bookmarks))
- if (!!data.hidden === !!hidden)
+ [data.name, data.current.URL]
+ for ([, data] in Iterator(bs))
];
};
} // }}}
@@ -281,16 +302,28 @@ let INFO =
} // }}}
function updateCurrent (data, URL, title) { // {{{
+ let now = new Date().toString();
+
+ liberator.log('update-current: 1');
data.current = {
URL: URL,
- title: title
+ title: title,
+ added: now
+ };
+ liberator.log('update-current: 2');
+ data.last = {
+ date: now
};
if (data.pages) {
+ liberator.log('update-current: 3');
if (data.pages.some(function (it) (it.URL == URL)))
return;
+ liberator.log('update-current: 4');
} else {
data.pages = [];
+ liberator.log('update-current: 5');
}
+ liberator.log('update-current: 6');
data.pages.push(data.current);
} // }}}
@@ -308,7 +341,13 @@ let INFO =
true
); // }}}
- commands.addUserCommand( // {{{
+ // {{{
+ let commandOptions = [
+ [ ['-sort'], commands.OPTION_STRING, null,
+ [ ['last', 'Last updated date (default)'], ['name', 'By name'] ] ]
+ ];
+
+ commands.addUserCommand(
'autobookmark',
'Auto bookmarking',
function () {
@@ -364,7 +403,8 @@ let INFO =
},
{
literal: 0,
- completer: namesCompleter()
+ completer: namesCompleter(),
+ options: commandOptions
}
),
new Command(
@@ -379,7 +419,8 @@ let INFO =
},
{
literal: 0,
- completer: namesCompleter()
+ completer: namesCompleter(),
+ options: commandOptions
}
),
new Command(
@@ -395,7 +436,8 @@ let INFO =
},
{
literal: 0,
- completer: namesCompleter()
+ completer: namesCompleter(),
+ options: commandOptions
}
),
new Command(
@@ -429,7 +471,8 @@ let INFO =
},
{
literal: 0,
- completer: namesCompleter()
+ completer: namesCompleter(),
+ options: commandOptions
}
),
new Command(
@@ -453,7 +496,8 @@ let INFO =
},
{
literal: 0,
- completer: namesCompleter()
+ completer: namesCompleter(),
+ options: commandOptions
}
),
new Command(
@@ -470,7 +514,8 @@ let INFO =
},
{
literal: 0,
- completer: namesCompleter(true)
+ completer: namesCompleter(true),
+ options: commandOptions
}
),
new Command(
@@ -481,7 +526,8 @@ let INFO =
},
{
literal: 0,
- completer: namesCompleter(false)
+ completer: namesCompleter(false),
+ options: commandOptions
}
)
]
diff --git a/twittperator.js b/twittperator.js
index a28d2ba..b840e9b 100644
--- a/twittperator.js
+++ b/twittperator.js
@@ -2,7 +2,7 @@
* The MIT License
*
* Copyright (c) 2010 teramako
- * Copyright (c) 2010-2011 anekos
+ * Copyright (c) 2010-2012 anekos
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,7 +26,7 @@
// INFO {{{
let INFO =
<>
- <plugin name="Twittperator" version="1.17.1"
+ <plugin name="Twittperator" version="1.18.0"
href="https://github.com/vimpr/vimperator-plugins/raw/master/twittperator.js"
summary="Twitter Client using OAuth and Streaming API">
<author email="teramako@gmail.com" href="http://d.hatena.ne.jp/teramako/">teramako</author>
@@ -174,7 +174,7 @@ let INFO =
Write the plugin.
</p>
</plugin>
- <plugin name="Twittperator" version="1.17.1"
+ <plugin name="Twittperator" version="1.18.0"
href="https://github.com/vimpr/vimperator-plugins/raw/master/twittperator.js"
lang="ja"
summary="OAuth/StreamingAPI対応Twitterクライアント">
@@ -2123,34 +2123,19 @@ let INFO =
Store.set("consumerKey", "GQWob4E5tCHVQnEVPvmorQ");
Store.set("consumerSecret", "gVwj45GaW6Sp7gdua6UFyiF910ffIety0sD1dv36Cz8");
// }}}
-
- // アクセストークン取得前 {{{
- function preSetup() {
- commands.addUserCommand(["tw[ittperator]"], "Twittperator setup command",
- function(args) {
- if (args["-getPIN"]) {
- tw.getRequestToken(function(url) {
- liberator.open(url, { where: liberator.NEW_TAB });
- });
- Twittperator.echo("Please get PIN code and execute\n :tw -setPIN {PINcode}");
- } else if (args["-setPIN"]) {
- tw.setPin(args["-setPIN"]);
- }
- }, {
- options: [
- [["-getPIN"], commands.OPTION_NOARG],
- [["-setPIN"], commands.OPTION_STRING, null, null]
- ],
- }, true);
- } // }}}
- // アクセストークン取得後 {{{
- function setup() {
- function rejectMine(st)
+ let Predicates = { // {{{
+ notMine: function (st)
let (n = setting.screenName)
- (n ? (!st.user || st.user.screen_name !== n) : st);
+ (n ? (!st.user || st.user.screen_name !== n) : st),
+ mine: function (st)
+ (!Predicates.notMine(st))
+ }; // }}}
+ let Completers = (function() { // {{{
+ function rt(st)
+ ("retweeted_status" in st ? st.retweeted_status : st);
- function seleceMine(st)
- (!rejectMine(st));
+ function removeNewLine(text)
+ text.replace(/\r\n|[\r\n]/g, ' ');
function setTimelineCompleter(context) { // {{{
function statusObjectFilter(item)
@@ -2193,290 +2178,307 @@ let INFO =
}
} // }}}
- const Completers = (function() { // {{{
- function rt(st)
- ("retweeted_status" in st ? st.retweeted_status : st);
-
- function removeNewLine(text)
- text.replace(/\r\n|[\r\n]/g, ' ');
-
- function completer(generator, nort) {
- let getHistory = nort ? function() history
- : function() history.map(rt);
- return function(filter) {
- function completer(context, args) {
- let cs = [];
- for (let [, it] in Iterator(getHistory())) {
- if (filter && !filter(it))
- continue;
- let item = generator(it);
- if (item[0])
- cs.push(item);
- }
- context.completions = cs;
+ function completer(generator, nort) {
+ let getHistory = nort ? function() history
+ : function() history.map(rt);
+ return function(filter) {
+ function completer(context, args) {
+ let cs = [];
+ for (let [, it] in Iterator(getHistory())) {
+ if (filter && !filter(it))
+ continue;
+ let item = generator(it);
+ if (item[0])
+ cs.push(item);
}
- return makeTimelineCompleter(completer);
+ context.completions = cs;
}
+ return makeTimelineCompleter(completer);
}
+ }
- return {
- name:
- completer(function(s) [s.user.screen_name, s]),
- atname:
- completer(function(s) ['@' + s.user.screen_name, s]),
- text:
- completer(function(s) [removeNewLine(s.text), s]),
- id:
- completer(function(s) [s.id, s]),
- rawid:
- completer(function(s) [s.id, s], true),
- name_id:
- completer(function(s) ["@" + s.user.screen_name + "#" + s.id, s]),
- name_id_text:
- completer(function(s) ["@" + s.user.screen_name + "#" + s.id + ": " + removeNewLine(s.text), s]),
- screenName:
- completer(function(s) [s.user.screen_name, s]),
- statusPage:
- completer(function(s) [s.user.screen_name + '/status/' + s.id , s]),
- hashtag:
- function(filter) {
- return makeTimelineCompleter(function(context, args){
- context.completions = [
- [
- ['#' + h.text for ([, h] in Iterator(s.entities.hashtags))].join(' '),
- s
- ]
- for ([, s] in Iterator(history))
- if (s.entities && s.entities.hashtags && s.entities.hashtags[0])
+ return {
+ name:
+ completer(function(s) [s.user.screen_name, s]),
+ atname:
+ completer(function(s) ['@' + s.user.screen_name, s]),
+ text:
+ completer(function(s) [removeNewLine(s.text), s]),
+ id:
+ completer(function(s) [s.id, s]),
+ rawid:
+ completer(function(s) [s.id, s], true),
+ name_id:
+ completer(function(s) ["@" + s.user.screen_name + "#" + s.id, s]),
+ name_id_text:
+ completer(function(s) ["@" + s.user.screen_name + "#" + s.id + ": " + removeNewLine(s.text), s]),
+ screenName:
+ completer(function(s) [s.user.screen_name, s]),
+ statusPage:
+ completer(function(s) [s.user.screen_name + '/status/' + s.id , s]),
+ hashtag:
+ function(filter) {
+ return makeTimelineCompleter(function(context, args){
+ context.completions = [
+ [
+ ['#' + h.text for ([, h] in Iterator(s.entities.hashtags))].join(' '),
+ s
]
- });
- }
- };
- })(); // }}}
-
- const SubCommand = function(init) { // {{{
- if (!(init.completer instanceof Array))
- init.completer = [init.completer];
-
- return {
- __proto__: init,
- get expr() {
- return RegExp(
- "^" +
- this.command.map(function(c)
- let (r = util.escapeRegex(c))
- (/^\W$/.test(c) ? r : r + "( |$)")
- ).join("|")
- );
- },
- match: function(s) s.match(this.expr),
- action: function(args) init.action(args.literalArg.replace(this.expr, "").trim())
- };
- }; // }}}
-
- const SubCommands = [ // {{{
- SubCommand({
- command: ["+"],
- description: "Fav a tweet",
- action: function(arg) {
- let m = arg.match(/^\d+/);
- if (m)
- Twitter.favorite(m[0]);
- },
- timelineCompleter: true,
- completer: Completers.id(rejectMine)
- }),
- SubCommand({
- command: ["-"],
- description: "Unfav a tweet",
- action: function(arg) {
- let m = arg.match(/^\d+/);
- if (m)
- Twitter.favorite(m[0]);
+ for ([, s] in Iterator(history))
+ if (s.entities && s.entities.hashtags && s.entities.hashtags[0])
+ ]
+ });
+ }
+ };
+ })(); // }}}
+ let SubCommand = function(init) { // {{{
+ if (!(init.completer instanceof Array))
+ init.completer = [init.completer];
+
+ return {
+ __proto__: init,
+ get expr() {
+ return RegExp(
+ "^" +
+ this.command.map(function(c)
+ let (r = util.escapeRegex(c))
+ (/^\W$/.test(c) ? r : r + "( |$)")
+ ).join("|")
+ );
+ },
+ match: function(s) s.match(this.expr),
+ action: function(args) init.action(args.literalArg.replace(this.expr, "").trim())
+ };
+ }; // }}}
+ let SubCommands = [ // {{{
+ SubCommand({
+ command: ["+"],
+ description: "Fav a tweet",
+ action: function(arg) {
+ let m = arg.match(/^\d+/);
+ if (m)
+ Twitter.favorite(m[0]);
+ },
+ timelineCompleter: true,
+ completer: Completers.id(Predicates.notMine)
+ }),
+ SubCommand({
+ command: ["-"],
+ description: "Unfav a tweet",
+ action: function(arg) {
+ let m = arg.match(/^\d+/);
+ if (m)
+ Twitter.favorite(m[0]);
+ },
+ timelineCompleter: true,
+ completer: Completers.id(Predicates.notMine)
+ }),
+ SubCommand({
+ command: ["@"],
+ description: "Show mentions or follower tweets",
+ action: function(arg) {
+ if (arg.length > 0) {
+ Twittperator.showUserTimeline(arg);
+ } else {
+ Twittperator.showTwitterMentions();
+ }
+ },
+ timelineCompleter: true,
+ completer: Completers.name()
+ }),
+ SubCommand({
+ command: ["?"],
+ description: "Twitter search",
+ action: function(arg) Twittperator.showTwitterSearchResult(arg),
+ completer: [
+ function (context, args) {
+ let lst = [[buffer.URL, 'Current Tab']];
+ let w = buffer.getCurrentWord();
+ if (w && w.length)
+ lst.push([w, 'Current word']);
+ context.completions = lst;
},
- timelineCompleter: true,
- completer: Completers.id(rejectMine)
- }),
- SubCommand({
- command: ["@"],
- description: "Show mentions or follower tweets",
- action: function(arg) {
- if (arg.length > 0) {
- Twittperator.showUserTimeline(arg);
- } else {
- Twittperator.showTwitterMentions();
+ Completers.text()
+ ]
+ }),
+ SubCommand({
+ command: ["/"],
+ description: "Open link",
+ action: function(arg) Twittperator.openLink(arg),
+ timelineCompleter: true,
+ completer: Completers.text(function(s) /https?:\/\//.test(s.text))
+ }),
+ SubCommand({
+ command: ["delete"],
+ description: "Delete status",
+ action: function(arg) {
+ let m = arg.match(/^\d+/);
+ if (m)
+ Twitter.destroy(m[0]);
+ },
+ timelineCompleter: true,
+ completer: Completers.rawid(Predicates.selectMine)
+ }),
+ SubCommand({
+ command: ["activity"],
+ description: "Activity Summary",
+ action: function(arg) {
+ Twittperator.activitySummary(arg);
+ },
+ timelineCompleter: true,
+ completer: Completers.id(function(st) st.id)
+ }),
+ SubCommand({
+ command: ["info"],
+ description: "Display status information",
+ action: function(arg) {
+ function dtdd(obj) {
+ let items = <></>;
+ for (let [n, v] in Iterator(obj)) {
+ let cont = (v && typeof v === "object") ? dtdd(v) : v;
+ items += <><dt>{n}</dt><dd>{cont}</dd></>;
}
- },
- timelineCompleter: true,
- completer: Completers.name()
- }),
- SubCommand({
- command: ["?"],
- description: "Twitter search",
- action: function(arg) Twittperator.showTwitterSearchResult(arg),
- completer: [
- function (context, args) {
- let lst = [[buffer.URL, 'Current Tab']];
- let w = buffer.getCurrentWord();
- if (w && w.length)
- lst.push([w, 'Current word']);
- context.completions = lst;
- },
- Completers.text()
- ]
- }),
- SubCommand({
- command: ["/"],
- description: "Open link",
- action: function(arg) Twittperator.openLink(arg),
- timelineCompleter: true,
- completer: Completers.text(function(s) /https?:\/\//.test(s.text))
- }),
- SubCommand({
- command: ["delete"],
- description: "Delete status",
- action: function(arg) {
- let m = arg.match(/^\d+/);
- if (m)
- Twitter.destroy(m[0]);
- },
- timelineCompleter: true,
- completer: Completers.rawid(seleceMine)
- }),
- SubCommand({
- command: ["activity"],
- description: "Activity Summary",
- action: function(arg) {
- Twittperator.activitySummary(arg);
- },
- timelineCompleter: true,
- completer: Completers.id(function(st) st.id)
- }),
- SubCommand({
- command: ["info"],
- description: "Display status information",
- action: function(arg) {
- function dtdd(obj) {
- let items = <></>;
- for (let [n, v] in Iterator(obj)) {
- let cont = (v && typeof v === "object") ? dtdd(v) : v;
- items += <><dt>{n}</dt><dd>{cont}</dd></>;
- }
- return <dl>{items}</dl>;
- }
+ return <dl>{items}</dl>;
+ }
- let m = arg.match(/^\d+/);
- if (!m)
- return;
- let id = m[0];
- history.filter(function(st) st.id === id).map(dtdd).forEach(liberator.echo);
- },
- timelineCompleter: true,
- completer: Completers.rawid(function(st) st.id)
- }),
- SubCommand({
- command: ["lookupuser"],
- description: "Lookup users",
- action: function(arg) {
- Twittperator.lookupUser(arg.split(/\s+/));
- },
- timelineCompleter: true,
- completer: Completers.screenName()
- }),
- SubCommand({
- command: ["track"],
- description: "Track the specified words.",
- action: function(arg) {
- if (arg.trim().length > 0) {
- Store.set("trackWords", arg);
- TrackingStream.start({track: arg});
- } else {
- TrackingStream.stop();
- }
- },
- completer: function(context, args) {
- let cs = [];
- if (setting.trackWords)
- cs.push([setting.trackWords, "Global variable"]);
- if (Store.get("trackWords"))
- cs.push([Store.get("trackWords"), "Current tracking words"]);
- context.completions = cs;
+ let m = arg.match(/^\d+/);
+ if (!m)
+ return;
+ let id = m[0];
+ history.filter(function(st) st.id === id).map(dtdd).forEach(liberator.echo);
+ },
+ timelineCompleter: true,
+ completer: Completers.rawid(function(st) st.id)
+ }),
+ SubCommand({
+ command: ["lookupuser"],
+ description: "Lookup users",
+ action: function(arg) {
+ Twittperator.lookupUser(arg.split(/\s+/));
+ },
+ timelineCompleter: true,
+ completer: Completers.screenName()
+ }),
+ SubCommand({
+ command: ["track"],
+ description: "Track the specified words.",
+ action: function(arg) {
+ if (arg.trim().length > 0) {
+ Store.set("trackWords", arg);
+ TrackingStream.start({track: arg});
+ } else {
+ TrackingStream.stop();
}
- }),
- SubCommand({
- command: ["home"],
- description: "Open user home.",
- action: function(arg) liberator.open("http://twitter.com/" + arg, liberator.NEW_TAB),
- timelineCompleter: true,
- completer: Completers.screenName(rejectMine)
- }),
- SubCommand({
- command: ["status"],
- description: "Open status page.",
- action: function(arg) liberator.open("http://twitter.com/" + arg, liberator.NEW_TAB),
- timelineCompleter: true,
- completer: Completers.statusPage(function (s) s.id)
- }),
- SubCommand({
- command: ["thread"],
- description: "Show tweets thread.",
- action: function(arg) {
- function showThread () {
- Twittperator.showTL(thread);
- }
- function getStatus(id, next) {
- let result;
- if (history.some(function (it) (it.id == id && (result = it)))) {
- return next(result);
- }
- // XXX エラーの時はなにか表示しておくべき?
- tw.jsonGet("statuses/show/" + id, null, function(res) next(res), showThread);
+ },
+ completer: function(context, args) {
+ let cs = [];
+ if (setting.trackWords)
+ cs.push([setting.trackWords, "Global variable"]);
+ if (Store.get("trackWords"))
+ cs.push([Store.get("trackWords"), "Current tracking words"]);
+ context.completions = cs;
+ }
+ }),
+ SubCommand({
+ command: ["home"],
+ description: "Open user home.",
+ action: function(arg) liberator.open("http://twitter.com/" + arg, liberator.NEW_TAB),
+ timelineCompleter: true,
+ completer: Completers.screenName(Predicates.notMine)
+ }),
+ SubCommand({
+ command: ["status"],
+ description: "Open status page.",
+ action: function(arg) liberator.open("http://twitter.com/" + arg, liberator.NEW_TAB),
+ timelineCompleter: true,
+ completer: Completers.statusPage(function (s) s.id)
+ }),
+ SubCommand({
+ command: ["thread"],
+ description: "Show tweets thread.",
+ action: function(arg) {
+ function showThread () {
+ Twittperator.showTL(thread);
+ }
+ function getStatus(id, next) {
+ let result;
+ if (history.some(function (it) (it.id == id && (result = it)))) {
+ return next(result);
}
- function trace(st) {
- thread.push(st);
- if (st.in_reply_to_status_id) {
- getStatus(st.in_reply_to_status_id, trace);
- } else {
- showThread();
- }
+ // XXX エラーの時はなにか表示しておくべき?
+ tw.jsonGet("statuses/show/" + id, null, function(res) next(res), showThread);
+ }
+ function trace(st) {
+ thread.push(st);
+ if (st.in_reply_to_status_id) {
+ getStatus(st.in_reply_to_status_id, trace);
+ } else {
+ showThread();
}
+ }
- Twittperator.echo("Start thread tracing..");
- let thread = [];
- getStatus(parseInt(arg), trace);
- },
- timelineCompleter: true,
- completer: Completers.id(function (it) it.in_reply_to_status_id)
- }),
- SubCommand({
- command: ["resetoauth"],
- description: "Reset OAuth Information",
- action: function(arg) {
- Twittperator.confirm(
- 'Do you want to reset OAuth information?',
- function () {
- Store.remove("consumerKey");
- Store.remove("consumerSecret");
- Store.remove("token");
- Store.remove("tokenSecret");
- Store.save();
- Twittperator.echo("OAuth information were reset.");
- }
- );
- },
- timelineCompleter: false,
- completer: Completers.id(function (it) it.in_reply_to_status_id)
- }),
- SubCommand({
- command: ["findpeople"],
- description: "Find people with the words.",
- action: function(arg) Twittperator.showUsersSeachResult(arg),
- }),
- ]; // }}}
+ Twittperator.echo("Start thread tracing..");
+ let thread = [];
+ getStatus(parseInt(arg), trace);
+ },
+ timelineCompleter: true,
+ completer: Completers.id(function (it) it.in_reply_to_status_id)
+ }),
+ SubCommand({
+ command: ["resetoauth"],
+ description: "Reset OAuth Information",
+ action: function(arg) {
+ Twittperator.confirm(
+ 'Do you want to reset OAuth information?',
+ function () {
+ Store.remove("consumerKey");
+ Store.remove("consumerSecret");
+ Store.remove("token");
+ Store.remove("tokenSecret");
+ Store.save();
+ Twittperator.echo("OAuth information were reset.");
+ }
+ );
+ },
+ timelineCompleter: false,
+ completer: Completers.id(function (it) it.in_reply_to_status_id)
+ }),
+ SubCommand({
+ command: ["findpeople"],
+ description: "Find people with the words.",
+ action: function(arg) Twittperator.showUsersSeachResult(arg),
+ }),
+ ];
+
+ SubCommands.add = function(subCmd) {
+ this.push(subCmd);
+ return;
+ }; // }}}
+ // アクセストークン取得前 {{{
+ function preSetup() {
+ commands.addUserCommand(["tw[ittperator]"], "Twittperator setup command",
+ function(args) {
+ if (args["-getPIN"]) {
+ tw.getRequestToken(function(url) {
+ liberator.open(url, { where: liberator.NEW_TAB });
+ });
+ Twittperator.echo("Please get PIN code and execute\n :tw -setPIN {PINcode}");
+ } else if (args["-setPIN"]) {
+ tw.setPin(args["-setPIN"]);
+ }
+ }, {
+ options: [
+ [["-getPIN"], commands.OPTION_NOARG],
+ [["-setPIN"], commands.OPTION_STRING, null, null]
+ ],
+ }, true);
+ } // }}}
+ // アクセストークン取得後 {{{
+ function setup() {
function findSubCommand(s) { // {{{
- for (let [, cmd] in Iterator(SubCommands)) {
+ for (let [, cmd] in util.Array(SubCommands)) {
let m = cmd.match(s);
if (m)
return [cmd, m];
@@ -2531,15 +2533,15 @@ let INFO =
if (m = arg.match(/^D\s+/)) {
context.title = "Entry";
context.advance(m[0].length);
- Completers.name(rejectMine)(context, args);
+ Completers.name(Predicates.notMine)(context, args);
return;
} else if (m = arg.match(/(RT\s+)@.*$/)) {
(m.index === 0 ? Completers.name_id
- : Completers.name_id_text)(m.index === 0 && rejectMine)(context, args);
+ : Completers.name_id_text)(m.index === 0 && Predicates.notMine)(context, args);
} else if (m = tailMatch(/(^|\b|\s)#[^#\s]*$/, arg)) {
Completers.hashtag()(context, args);
} else if (m = tailMatch(/(^|\b|\s)@[^@\s]*$/, arg)) {
- (m.index === 0 ? Completers.name_id(rejectMine) : Completers.atname(rejectMine))(context, args);
+ (m.index === 0 ? Completers.name_id(Predicates.notMine) : Completers.atname(Predicates.notMine))(context, args);
}
if (m)
@@ -2655,6 +2657,9 @@ let INFO =
__context__.Twitter = Twitter;
__context__.Utils = Utils;
__context__.Store = Store;
+ __context__.SubCommand = SubCommand;
+ __context__.SubCommands = SubCommands;
+ __context__.Completers = Completers;
Twittperator.loadPlugins();
diff --git a/twittperator/mstrans.tw b/twittperator/mstrans.tw
new file mode 100644
index 0000000..9f4a582
--- /dev/null
+++ b/twittperator/mstrans.tw
@@ -0,0 +1,24 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_mstrans = 1
+ *
+ * Require: mstrans.js
+ */
+
+(function () {
+ const TW = liberator.plugins.twittperator;
+
+ TW.SubCommands.add(
+ TW.SubCommand({
+ command: ['mstrans'],
+ description: "Translate a tweet",
+ action: function(arg) {
+ liberator.execute('mstrans ' + arg);
+ },
+ timelineComplete: true,
+ completer: TW.Completers.text(function(s) s.id)
+ })
+ );
+})();
+
+// vim: set et fdm=syntax fenc= ft=javascript sts=2 sw=2 ts=2 :
diff --git a/twittperator/ril.tw b/twittperator/ril.tw
new file mode 100644
index 0000000..2b9c430
--- /dev/null
+++ b/twittperator/ril.tw
@@ -0,0 +1,21 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_ril = 1
+ */
+
+(function () {
+ const TW = liberator.plugins.twittperator;
+
+ TW.SubCommands.add(
+ TW.SubCommand({
+ command: ['ril'],
+ action: function(arg) {
+ liberator.execute('readitlater add https://twitter.com/' + arg);
+ },
+ timelineCompleter: true,
+ completer: TW.Completers.statusPage(function(s) s.id)
+ })
+ );
+})();
+
+// vim: sw=2 ts=2 et fdm=marker ft=javascript:
diff --git a/twittperator/rt.tw b/twittperator/rt.tw
new file mode 100644
index 0000000..fde9194
--- /dev/null
+++ b/twittperator/rt.tw
@@ -0,0 +1,44 @@
+/*
+ * Please write the below line into .vimperatorrc.
+ * let g:twittperator_plugin_rt = 1
+ */
+
+(function () {
+ const TW = liberator.plugins.twittperator;
+
+ TW.SubCommands.add(
+ TW.SubCommand({
+ command: ['rt'],
+ description: 'Official retweet',
+ action: function(arg) {
+ setTimeout(function () {
+ commandline.open(':', 'tw RT ' + arg, modes.EX);
+ }, 100);
+ },
+ timelineComplete: true,
+ completer: TW.Completers.name_id(function(s) s.id)
+ })
+ );
+
+ TW.SubCommands.add(
+ TW.SubCommand({
+ command: ['urt'],
+ description: 'Unofficial retweet',
+ action: function(arg) {
+ arg.match(/^@([a-zA-Z0-9_]+)#\d+: (.*)$/);
+ var screen_name = RegExp.$1;
+ var text = RegExp.$2;
+ if (screen_name && text) {
+ setTimeout(function () {
+ commandline.open(':', 'tw RT @' + screen_name + ': ' + text, modes.EX);
+ }, 100);
+ }
+ },
+ timelineComplete: true,
+ completer: TW.Completers.name_id_text(function(s) s.id)
+ })
+ );
+
+})();
+
+// vim: set et fdm=syntax fenc= ft=javascript sts=2 sw=2 ts=2 :