aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_loader.js
diff options
context:
space:
mode:
authoranekos2008-10-07 16:54:07 +0000
committeranekos2008-10-07 16:54:07 +0000
commite2e6f5157a4825f1b6f636f61a7de8e04584b768 (patch)
tree3c7f908636d36c4ff9c68fa3f13e8eefa666c5d8 /plugin_loader.js
parente883a59f577b3281f38e1986ec496b5d441379e1 (diff)
downloadvimperator-plugins-e2e6f5157a4825f1b6f636f61a7de8e04584b768.tar.bz2
initial release
git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@20935 d0d07461-0603-4401-acd4-de1884942a52
Diffstat (limited to 'plugin_loader.js')
-rw-r--r--plugin_loader.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/plugin_loader.js b/plugin_loader.js
new file mode 100644
index 0000000..af50912
--- /dev/null
+++ b/plugin_loader.js
@@ -0,0 +1,41 @@
+// ==VimperatorPlugin==
+// @name Plugin Loader
+// @description-ja 指定(ディレクトリ|プラグイン)を起動時にロードする
+// @license Creative Commons 2.1 (Attribution + Share Alike)
+// @version 2.2
+// @author anekos
+// ==/VimperatorPlugin==
+//
+// Usage:
+// let g:plugin_loader_roots = "<PLUGIN_DIRECTORIES>"
+// let g:plugin_loader_plugins = "<PLUGIN_NAMES>"
+//
+// Example:
+// let g:plugin_loader_roots = "/home/anekos/coderepos/vimp-plugins/ /home/anekos/my-vimp-plugins/"
+// let g:plugin_loader_plugins = "lo,migemized_find,nico_related_videos"
+//
+// Link:
+// http://d.hatena.ne.jp/nokturnalmortum/20081008#1223397705
+
+
+function toArray (obj) {
+ return obj instanceof Array ? obj
+ : obj.toString().split(/[,|\s]/);
+}
+
+let roots = toArray(globalVariables.plugin_loader_roots);
+let plugins = toArray(globalVariables.plugin_loader_plugins);
+let filter = new RegExp("[\\\\/](" + plugins.join('|') + ")\.(js|vimp)$");
+
+log('plugin_loader: loading');
+
+for each (let root in roots) {
+ let files = io.readDirectory(io.getFile(root), true);
+ for each (let file in files) {
+ if (!filter.test(file.path))
+ continue;
+ liberator.io.source(file.path, false);
+ }
+}
+
+log('plugin_loader: loaded');