]> gitweb @ CieloNegro.org - sugar.git/commitdiff
Auto commit by The Sugar System.
authorPHO <pho@cielonegro.org>
Thu, 29 Oct 2015 07:53:58 +0000 (16:53 +0900)
committerPHO <pho@cielonegro.org>
Thu, 29 Oct 2015 07:53:58 +0000 (16:53 +0900)
IGNORE
dot-files/_vimperator/plugin/amazon_simple_uri_js [new file with mode: 0644]
dot-files/_vimperator/plugin/minecraft-wiki_js [new file with mode: 0644]
dot-files/_vimperatorrc

diff --git a/IGNORE b/IGNORE
index f9d0b888b77947a2add1e3c900e0c66fae0106ac..3a2167e454c6fd5290546011f20c581a3a8f04c7 100644 (file)
--- a/IGNORE
+++ b/IGNORE
@@ -95,6 +95,7 @@
 .lesshst
 .local
 .localized
+.lsof_*
 .macports
 .macromedia
 .metacity/sessions
diff --git a/dot-files/_vimperator/plugin/amazon_simple_uri_js b/dot-files/_vimperator/plugin/amazon_simple_uri_js
new file mode 100644 (file)
index 0000000..e21c79a
--- /dev/null
@@ -0,0 +1,95 @@
+// PLUGIN_INFO//{{{
+var PLUGIN_INFO = xml`
+<VimperatorPlugin>
+  <name>amazon_simple_uri</name>
+  <description>Copy Amazon Simple URI.</description>
+  <description lang="ja">シンプルなAmazon URIをクリップボードにコピーします。</description>
+  <author mail="from.kyushu.island@gmail.com" homepage="http://iddy.jp/profile/from_kyushu">from_kyushu</author>
+  <version>0.1</version>
+  <license>GPL</license>
+  <minVersion>1.2</minVersion>
+  <maxVersion>2.1</maxVersion>
+  <updateURL>https://github.com/vimpr/vimperator-plugins/raw/master/amazon_simple_uri.js</updateURL>
+  <detail><![CDATA[
+
+== Option ==
+>||
+  let g:amazon_asamashi = "hogehoge-22"
+||<
+と設定することにより、Amazon アソシエイトID(上の例ではhogehoge-22)をURLに追加します。
+
+  ]]></detail>
+</VimperatorPlugin>`;
+//}}}
+//
+(function()
+{
+  // URLを正規表現でチェックしてISBNっぽい10桁,13桁の数字と取り出す
+  function getIsbn(uri)
+  {
+    var regex = new RegExp("([0-9]{9,13}[0-9Xx])");
+    var match = uri.match(regex);
+    var isbn = match[0];
+    if (isbn.length == 13)
+    {
+      isbn = getIsbn10(isbn);
+    }
+    return isbn;
+  }
+
+  // SSBのAPIを使ってISBNから書籍情報を取得
+  function getBookInfo(isbn)
+  {
+    var uri = "http://stack.nayutaya.jp/api/book/";
+    if (isbn.length == 10)
+    {
+      uri += "isbn10/" + isbn + ".json";
+    }
+    else if (isbn.length == 13)
+    {
+      uri += "isbn13/" + isbn + ".json";
+    }
+    var xhr = new XMLHttpRequest();
+    xhr.open('GET', uri, false);
+    xhr.send(null);
+    if (xhr.status != 200) {
+        liberator.echoerr('false');
+        return;
+    }
+    return window.eval('(' + xhr.responseText + ')');
+  }
+
+  //SSBのAPIから書籍情報を取り、そこからISBN10を取得
+  function getIsbn10(isbn13)
+  {
+    var info = getBookInfo(isbn13);
+    return info.response.book.isbn10;
+  }
+
+  commands.addUserCommand(
+    ['amazoncopy','asc'],
+    'Copy Amazon Short URI',
+    function(args)
+    {
+      var asin = window.content.document.getElementById('ASIN');
+      // ASINが取得できなかった場合 / Amazon以外の書籍情報ページから取得する場合
+      if (asin == null)
+      {
+        asin = getIsbn(buffer.URL);
+      }
+      else
+      {
+        asin = asin.value
+      }
+
+      var uri = "http://www.amazon.co.jp/dp/" + asin + "/";
+      var asamashi = typeof liberator.globalVariables.amazon_asamashi == "undefined" ? '' : liberator.globalVariables.amazon_asamashi;
+      if (args == "+a")
+      {
+        uri += asamashi;
+      }
+      util.copyToClipboard(uri);
+      liberator.echo("[ASC] Copy to clipboard.");
+    }
+  );
+})();
diff --git a/dot-files/_vimperator/plugin/minecraft-wiki_js b/dot-files/_vimperator/plugin/minecraft-wiki_js
new file mode 100644 (file)
index 0000000..83516c9
--- /dev/null
@@ -0,0 +1,43 @@
+var INFO = xml`
+  <plugin name="minecraft-wiki" version="0.1"
+          href=""
+          summary="Search the Official Minecraft Wiki"
+          lang="en-US"
+          xmlns="http://vimperator.org/namespaces/liberator">
+    <author email="pho@cielonegro.org">PHO</author>
+    <license href="http://creativecommons.org/publicdomain/zero/1.0/legalcode">CC0 1.0 Universal</license>
+    <project name="Vimperator" minVersion="3.0"/>
+  </plugin>
+`;
+
+(function () {
+
+var base_URI = 'http://minecraft.gamepedia.com/';
+
+function mcwiki(opts) {
+    if (opts.query) {
+        var URI = base_URI + '/index.php?search=' + encodeURIComponent(opts.query);
+        liberator.open(URI, opts.tab);
+    }
+    else {
+        liberator.open(base_URI, opts.tab);
+    }
+}
+
+liberator.modules.commands.addUserCommand(
+    ['mcwiki'],
+    'Search the Official Minecraft Wiki',
+    function (args) {
+        mcwiki({
+            query: args.string.length > 0 ? args.string : null,
+            tab:   args.bang ? liberator.NEW_TAB : liberator.CURRENT_TAB
+        });
+    },
+    {
+        bang:     true,
+        argCount: '*'
+    },
+    true
+);
+
+})();
index f44a8806c99b26ec87b315650902c7e0bef6025b..1fc1efb5f17c9ad9f35a5459a874e24c00ce2b13 100644 (file)
@@ -36,6 +36,9 @@ command! -description="Way back the current page" wayback open javascript:(locat
 map ma :mr alc 
 map mg :mr goo 
 
+" plugin/minecraft-wiki.js
+map <C-x><C-m> :mcwiki! 
+
 " Smokeping
 qmark p http://aria.cielonegro.org/cgi-bin/smokeping.cgi