From b6d01fff8fc8b356ff121635303d5191cc286697 Mon Sep 17 00:00:00 2001 From: Jagua Date: Sat, 16 Jun 2012 22:13:28 +0900 Subject: Now browsing and Now reading --- twittperator/browsing.tw | 131 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 twittperator/browsing.tw (limited to 'twittperator/browsing.tw') diff --git a/twittperator/browsing.tw b/twittperator/browsing.tw new file mode 100644 index 0000000..6eeeda7 --- /dev/null +++ b/twittperator/browsing.tw @@ -0,0 +1,131 @@ +/* NEW BSD LICENSE {{{ +Copyright (c) 2012, Jagua. +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 # +# に参考になる日本語訳がありますが、有効なのは上記英文となります。 # +################################################################################### + +}}} */ + +/* + * Please write the below line into .vimperatorrc. + * let g:twittperator_plugin_browsing = 1 + * + * You can add the settings for each site + * by setting liberator.globalVariables.tw_browsing_format. + */ + +// INFO {{{ +let INFO = +<> + + Jagua + New BSD License + +

twittperator plugin. assist to tweet about a site you are browsing now.

+ + :tw!browsing + :tw!reading + :tw!browsing comment +

make a :tw Now browsing prompt

+ g:tw_browsing_format + g:tw_browsing_format = FORMATS OF EACH SITE +

setting sample

+
+
+; +// }}} + + +(function () { + const TW = liberator.plugins.twittperator; + + var format = liberator.globalVariables.tw_browsing_format || []; + + const default_format = [{ + url: /.*/, + format: function (title, url, selection, comment) { + return (selection ? '"' + selection + '" ' : '') + (comment ? comment + ' ' : '') + 'Now browsing: ' + title + ' ' + url; + }, + }]; + + format = format.concat(default_format); + + function browsing(comment) { + var tweet = ''; + var title = buffer.title; + var url = buffer.URL; + var selection = window.content.getSelection().toString(); + + format.forEach(function (def) { + if (url.match(def.url) && tweet == '') + tweet = def.format(title, url, selection, comment); + }); + return tweet; + } + + ['browsing', 'reading'].forEach(function (cmdName) { + TW.SubCommands.add( + TW.SubCommand({ + command: [cmdName], + description: 'Now ' + cmdName, + action: function(arg) { + setTimeout(function () { + commandline.open(':', 'tw ' + browsing(arg), modes.EX); + }, 100); + }, + timelineComplete: false, + }) + ); + }); + +})(); + +// vim: set et fdm=syntax fenc= ft=javascript sts=2 sw=2 ts=2 : -- cgit v1.2.3