WebApps

単純なProcessingの起動からだけでなく,Ruby.cgiと組み合わせて動作するように変更.簡単な構成図は,

  • users -[files] -> cgi.rb -[tmp.files]->Processing
  • users -[files] -> cgi.rb -[params]->Processing

cgiの設定

cgiが動作するようにapacheを設定する必要がある.hikiを動かすときにやった.

  • /etc/apache2/users/bob.confを編集
<Directory "/Users/bob/Sites/">
   AddHandler cgi-script .cgi .rb
   AllowOverride FileInfo AuthConfig Limit all
   Options MultiViews SymLinksIfOwnerMatch IncludesNoExec ExecCGI
   <Limit GET POST OPTIONS PROPFIND>
       Order allow,deny
       Allow from all
   </Limit>
   <LimitExcept GET POST OPTIONS PROPFIND>
       Order deny,allow
       Deny from all
   </LimitExcept>
   Options Indexes MultiViews +ExecCGI
   DirectoryIndex hiki.cgi
</Directory>
  • apacheのリスタート
sudo apachectl restart
  • /Users/bob/Sites以下にファイルをもっていく

rubyスクリプトの動作確認(Rubyアプリケーションプログラムp.67)

  1. 以下の二つのファイルを用意.
  2. http://127.0.0.1/~bob/openHP/Apps/ex01.htmlでアクセス(ファイルオープンではだめ)
  3. goボタンを押すと"Hello world!"が表示されるはず.
[bob-no-MacBook-Pro:~/Sites/openHP/Apps] bob% pwd
/Users/bob/Sites/openHP/Apps
[bob-no-MacBook-Pro:~/Sites/openHP/Apps] bob% cat ex01.rb
#!/usr/bin/ruby

print <<E
Content-Type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="jp" xml:lang="jp">
  <head>
    <title>Example 01</title>

  </head>
<body>
<p> Hello World! <\p>
</body>
</html>
E
[bob-no-MacBook-Pro:~/Sites/openHP/Apps] bob% cat ex01.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
          "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <title>Example 01</title>

  </head>
<body>
<FORM ACTION="./ex01.rb" METHOD="GET">
  <INPUT TYPE="SUBMIT" NAME="TASK" VALUE="GO">
</form>
</body>
</html>

leakproxy

http://www.notwork.org/ipr/3rd/leakproxy.rbよりleakproxy.rbをダウンロード. 今は,/Users/bob/Sites/CGIsに置いている.

ruby ./leakproxy.rb 8080 localhost:80

これでserverからの80-portをbrowserの8080に置き換えて,そこでleakさせる.

on safari http://127.0.0.1:8080/~bob/CGIs/public_html/ex01.html

など

組み込みlibのcgiを使ったfilter例

Appletの認証

Processingのreferenceにあるとおり,appletへの認証を明示的におこなうとうまく動いた.

  1. macのterminalのencodingをs-jisに変更
  2. keytoolを起動
  3. サーバへUpLoad
Sign an Applet
By default Java applications are considered safe to run, or in Java speak trusted, since they are executed explicitly by users on their own computers. Applets by comparison are considered untrusted since they are initiated automatically in the browser. This restriction prevents applets from doing certain things, such as loading content from a different domain than the one hosting the applet. The error generated will look something like:


Instructions

Assume you have a sketch named loadImage.pde
Export your sketch as an applet, creating loadImage.jar. (Please note that if core.jar was also created, you have "Use multiple .jar files when exporting applets" checked in Processing's preferences window. I recommend unchecking this setting and re-exporting the sketch. Otherwise you'll need to sign both .jar files.
Open a terminal program and navigate to the applet directory where loadImage.jar is located.
> keytool -genkey -keystore pKeyStore -alias p5geek
> keytool -selfcert -keystore pKeyStore -alias p5geek
> jarsigner -keystore pKeyStore //loadImage//.jar p5geek
Upload your applet
(Obviously, replace loadImage with the real name of your .jar file)

IEのエラー対策

49c49
<             height: 600,
---
>             height: 600
53c53
<             centerimage: 'true',
---
>             centerimage: 'true'

状態遷移図

Ruby-ProcessingConnect1.pdf

関連サイト

Last modified:2016/07/19 12:42:29
Keyword(s):
References:[ProgrammingMemo]