トップ «前の日記(2008-04-09(Wed)) 最新 次の日記(2008-04-12(Sat))» 編集

ぽっぺん日記@karashi.org


2008-04-10(Thu) [長年日記]

雨 最高気温:12℃

_ copy.jsのtemplateをvimperatorrcで設定できるpatchを書いた

autoIgnoreKey.jsがvimperatorrcにURLリストを書けるようになっていたので、それを参考にしてcopy.jsでもvimperatorrcでtemplateを指定できるようにしてみた。

説明書きはautoIgnoreKey.jsからもろパクリ。:-)

--- copy.js.orig	2008-04-03 03:56:46.000000000 +0900
+++ copy.js	2008-04-10 21:24:11.000002000 +0900
@@ -31,8 +31,25 @@
  *        %URL%     -> to the URL of the current page
  *        %SEL%     -> to the string of selection
  *        %HTMLSEL% -> to the html string of selection
+ *
+ * The copy_templates is a string variable which can set on
+ * vimperatorrc as following.
+ *
+ * let copy_templates = "[ {label:'titleAndURL', value:'%TITLE%\n%URL%'}, {label:'title', value:'%TITLE%'} ]"
+ *
+ * or your can set it using inline JavaScript.
+ *
+ * javascript <<EOM
+ * liberator.globalVariables.copy_templates = uneval([
+ *   { label: 'titleAndURL',    value: '%TITLE%\n%URL%' },
+ *   { label: 'title',          value: '%TITLE%' },
+ *   { label: 'anchor',         value: '<a href="%URL%">%TITLE%</a>' },
+ *   { label: 'selanchor',      value: '<a href="%URL%" title="%TITLE%">%SEL%</a>' },
+ *   { label: 'htmlblockquote', value: '<blockquote cite="%URL%" title="%TITLE%">%HTMLSEL%</blockquote>' },
+ * ]);
+ * EOM
  */
-const templates = [
+const templates = window.eval(liberator.globalVariables.copy_templates) || [
 	{ label: 'titleAndURL',    value: '%TITLE%\n%URL%' },
 	{ label: 'title',          value: '%TITLE%' },
 	{ label: 'anchor',         value: '<a href="%URL%">%TITLE%</a>' },
本日のツッコミ(全2件) [ツッコミを入れる]
_ teramako (2008-04-13(Sun) 20:24)

パッチありがとうございます。勝手ながら適用させていただきました。 <br>http://coderepos.org/share/changeset/9404

_ poppen (2008-04-13(Sun) 20:45)

パッチの取り込みありがとうございます。 <br>copy_templatesという変数名はどうかなぁということで、codereposへのcommitを躊躇していたのですが、teramakoさんに採用して頂いたので安心しました。:-)

[]
本日のPingbacks(全0件)

トップ «前の日記(2008-04-09(Wed)) 最新 次の日記(2008-04-12(Sat))» 編集