teramako / vimperator-plugin-httpdjs

httpd.js - Vimperator Plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#httpd.js - Vimperator Plugin

Vimperator で Web サーバーを立てるよ!

#インストール

  1. テキトウなところにgit cloneする。
  2. make -C httpd all で httpd.js と pagedown を取得
  3. Vimperator から :source ~/リポジトリのディレクトリ/httpd.js で読み込み
  • デフォルトでは自動でhttpdが開始される(httpd.js 内の SERVER_CONFIG.autoStart 参照)
  • ポートは8090(httpd.js 内の SERVER_CONFIG.port 参照)
  • デフォルトではループバックアドレスからのみの接続しか受け付けないので、リモートからも接続できるようにするには
    • SERVER_CONFIG.loopbackOnlyfalseに設定
    • SERVER_CONFIG.hostslocalhost127.0.0.1以外のホスト名またはIPアドレスを設定
  • 停止は:httpd stopで。(逆に起動は:httpd startで)

##/vimperator

POSTqパラメータに JavaScript または Vimperator コマンドを入れると、実行して結果を返す

  • type: 実行タイプ; cmd or js
    • js: JavaScript の実行
      • ot: 出力タイプ; text or html
        • text: return text/plain
        • html: return text/html
        • default: text
    • cmd: Vimperator コマンドの実行
    • default: js
  • q: 実行する文字列

###example

curl -X POST -d 'q=liberator.open("http://example.com")' -d ot=text http://localhost:8090/vimperator
curl -x POST -d 'q=tabopen http://example.com' -d type=cmd http://localhost:8090/vimperator

##/markdown

POSTメソッドでfileパラメータにデータを添えるとタブに Markdown を HTML 化してレンダリングするよ。

DELETEメソッドで開いているタブを閉じるよ。

動作には PageDown が必要です。 make -C httpd pagedown をして下さい。(Marcurialリポジトリから取得します)

また、instant-markdown-vim に vim 用のプラグインがあります。テキトウに~/.vim/bundle下にでも放り込んでください。

###example

cat <<EOM | curl -X POST --data-urlencode file@-" http://localhost:8090/markdown
#タイトル

  * abc
EOM

curl -X DELETE http://localhost:8090/markdown

##/html

POSTメソッドで送られたfileパラメータのデータを、typeに沿ってHTMLにコンバートしてレンダリングする。 pathパラメータにファイルのフルパスを添えると、<base href="..."> が付加されて、相対パスが有効になる。

  • type: コンバートするタイプ
    • ex.) plain, markdown
  • file: 入力データ
  • path: ファイルのフルパス

###example

cat <<EOM | curl -X POST --data-urlencode file=@- -d type=markdown --data-urlencode "path=$PWD" http://localhost:8090/html
#タイトル

 * abc
EOM

curl -X DELETE --data-urlencode "path=$PWD" http://localhost:8090/html

Cygwin 時はpathパラメータを cygpath -wa で変換する必要があるでしょう。

echo "OK" | curl -X POST ... --data-urlencode "path=`cygpath -wa .`" http://localhost:8090/html

#参考URL

HTTP サーバを立てる - Vimperator Advent Calendar 5日目 - Vimple Star Sprites - vimperatorグループ

About

httpd.js - Vimperator Plugin

License:Mozilla Public License 2.0


Languages

Language:JavaScript 100.0%