OpenLaszlo Rails Plugin
- Announcing the OpenLaszlo Rails Plugin
- OpenLaszlo Rails Plugin
上記をよんでなんか簡単に導入できそうだったのでいれてみたけど Windowsだと。。。
install
Rails 1.0.0,OpenLaslo 3.1.1はすでにインストール済みです。
>gem install ropenlaszlo Attempting local installation of 'ropenlaszlo' Local gem file not found: ropenlaszlo*.gem Attempting remote installation of 'ropenlaszlo' Updating Gem source index for: http://gems.rubyforge.org Successfully installed ropenlaszlo-0.4.0 Installing RDoc documentation for ropenlaszlo-0.4.0... >rails ropenlaszlo >cd ropenlaszlo >ruby script\plugin install svn://rubyforge.org/var/svn/laszlo-plugin/tags/openlaszlo >ruby script\generate applet contact applet >rake applets The fork() function is unimplemented on this machine
rakeがこける
だめぽ。
ActiveRuby1.8.2.1 だと Open3.popen3 の forkのところで死ぬ。
googleでしらべたところ cygwin版をつかえばいいようだがいやなので
Win32Utils
http://rubyforge.org/projects/win32utils/
をいれてrequire "open3" を require "win32/open3"に書き換えた。
でも segment fault で落ちる。
最終的には lzc.bat をよびだしているだけなので適当に書き換えた。
>diff -u compiler.rb.orig compiler.rb --- compiler.rb.orig Sat Jan 21 18:28:26 2006 +++ compiler.rb Sat Jan 21 18:31:38 2006 @@ -138,7 +138,7 @@ raise "couldn't find bin/lzc in #{search.join(' or ')}" if found.empty? @lzc = found.first # Adjust the name for Windows: - @lzc += '.bat' if windows? + @lzc += '2.bat' if windows? end end @@ -158,6 +158,10 @@ args << '--profile' if options[:profile] args << "--dir '#{File.dirname output}'" unless File.dirname(source_file) == File.dirname(output) args << source_file + if windows? + command = "#{@lzc} #{args.join(' ')}".gsub("/", "\\").gsub("'", "") + system(command) + else # The compiler writes errors to stdout, warnings to stderr require "open3" stdin, stdout, stderr = Open3.popen3("#{@lzc} #{args.join(' ')}") @@ -168,6 +172,7 @@ raise CompilationError.new($'.strip) else results[:warnings] = stderr.readlines + end end return results end
lzc.bat はLaszloのlzxからswfを作成するバッチファイルなのだが
こいつも実装が腐っていて Windowsの場合bash上じゃないと動かないのとのでいつも使っているgroovyの起動バッチをパクッて自作した lzc2.bat を使った。
%OPENLASZLO_HOME%\bin に
- classworlds-1.1-alpha-2-SNAPSHOT-NO-SYSTEM-EXIT.jar
- lpz2.bat
- lzc-classworlds.conf
をおく。
>type lzc-classworlds.conf ############################################################################## ## ## ## Lzc Compiler Classworlds Configuration ## ## ## ############################################################################## # The main entry-point main is org.openlaszlo.compiler.Main from lzs # The core Lzc class-realm [lzs] # Load required libraries load ${LPS_HOME}/WEB-INF/lib/*.jar load ${LPS_HOME}/3rd-party/jars/dev/*.jar # load user specific libraries #load ${user.home}/.lzs/lib/* >type lzc2.bat @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem lzc.bat replace ## @rem ########################################################################## @rem Set local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" setlocal @rem The version of classworlds to boot with set CLASSWORLDS_VERSION=1.1-alpha-2-SNAPSHOT-NO-SYSTEM-EXIT if "%LASZLO_VERION%" == "" set LASZLO_VERION=3.1.1 :begin @rem Determine what directory it is in. set DIRNAME=%~dp0 if "%DIRNAME%" == "" set DIRNAME=.\ @rem Determine the command interpreter to execute the "CD" later set COMMAND_COM="cmd.exe" if exist "%SystemRoot%\system32\cmd.exe" set COMMAND_COM="%SystemRoot%\system32\cmd.exe" if exist "%SystemRoot%\command.com" set COMMAND_COM="%SystemRoot%\command.com" @rem Use explicit find.exe to prevent cygwin and others find.exe from being used set FIND_EXE="find.exe" if exist "%SystemRoot%\system32\find.exe" set FIND_EXE="%SystemRoot%\system32\find.exe" if exist "%SystemRoot%\command\find.exe" set FIND_EXE="%SystemRoot%\command\find.exe" :check_JAVA_HOME @rem Make sure we have a valid JAVA_HOME if not "%JAVA_HOME%" == "" goto have_JAVA_HOME echo. echo ERROR: Environment variable JAVA_HOME has not been set. echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. echo. goto end :have_JAVA_HOME @rem Validate JAVA_HOME %COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | %FIND_EXE% /I /C "%JAVA_HOME%" >nul if not errorlevel 1 goto check_LPS_HOME echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo. echo Please set the JAVA_HOME variable in your environment to match the echo location of your Java installation. echo. goto end :check_LPS_HOME @rem Define LPS_HOME if not set if "%LPS_HOME%" == "" set LPS_HOME=%DIRNAME%..\Server\lps-%LASZLO_VERION% :init @rem Get command-line arguments, handling Windowz variants if not "%OS%" == "Windows_NT" goto win9xME_args if "%eval[2+2]" == "4" goto 4NT_args @rem Regular WinNT shell set CMD_LINE_ARGS=%1 %2 %3 %4 %5 %6 %7 %8 %9 goto execute :win9xME_args @rem Slurp the command line arguments. This loop allows for an unlimited number set CMD_LINE_ARGS= :win9xME_args_slurp if "x%1" == "x" goto execute set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1 shift goto win9xME_args_slurp :4NT_args @rem Get arguments from the 4NT Shell from JP Software set CMD_LINE_ARGS=%$ :execute @rem Setup the command line set CLASSWORLDS_CLASSPATH=%DIRNAME%\classworlds-%CLASSWORLDS_VERSION%.jar;%CLASSPATH%;. set CLASSWORLDS_MAIN_CLASS=org.codehaus.classworlds.Launcher set CLASSWORLDS_CONF=%DIRNAME%\lzc-classworlds.conf set JAVA_EXE=%JAVA_HOME%\bin\java.exe set TOOLS_JAR=%JAVA_HOME%\lib\tools.jar if "%JAVA_OPTS%" == "" set JAVA_OPTS="-Xmx128m" set JAVA_OPTS=%JAVA_OPTS% -DLPS_HOME="%LPS_HOME%" set JAVA_OPTS=%JAVA_OPTS% -Dtools.jar="%TOOLS_JAR%" set JAVA_OPTS=%JAVA_OPTS% -Dclassworlds.conf="%CLASSWORLDS_CONF%" @rem Execute lzs "%JAVA_EXE%" %JAVA_OPTS% -classpath "%CLASSWORLDS_CLASSPATH%" %CLASSWORLDS_MAIN_CLASS% %CMD_LINE_ARGS% :end @rem End local scope for the variables with windows NT shell if "%OS%"=="Windows_NT" endlocal @rem Optional pause the batch file if "%LPS_BATCH_PAUSE%" == "on" pause
>rake applets (in E:/temp/ropenlaszlo) mkdir -p E:/temp/ropenlaszlo/config/../public/applets Compiling E:/temp/ropenlaszlo/config/../app/applets/applet/applet.lzx => E:/temp /ropenlaszlo/config/../public/applets/applet.swf
で public\applets\applet.swf ができあがる。
もちろんlzxがかわらかわらなければいちいちコンパイルには行かないようになっている。
ブラウザからアクセス
>ruby script\server
で起動して
http://localhost:3000/contact/applet
でアクセスすると
My source code is in app/applets/applet/applet.lzx.
と表示される。
日本語をだす
>type app\applets\applet\applet.lzx <canvas layout="axis: y"> <text>My source code is in app/applets/applet/applet.lzx.</text> <dataset name="contactData" src="http://localhost:3000/contacts/records" request="true"/> <grid datapath="contactData:/records" contentdatapath="contact"/> </canvas>
もちろん日本語のことなんか考えちゃいないXMLなので変更してUTF-8で保存。
>ruby script\generate applet contact applet_ja >type app\applets\applet\applet_ja.lzx <?xml version="1.0" encoding="UTF-8"?> <canvas layout="axis: y"> <text>ソースコードは app/applets/applet_ja/applet_ja.lzx.</text> <dataset name="contactData" src="http://localhost:3000/contact/records" request="true"/> <grid datapath="contactData:/records" contentdatapath="contact"/> </canvas> >rake applets
あとはブラウザから
http://localhost:3000/contact/applet_ja
でアクセスすると
ソースコードは app/applets/applet_ja/applet_ja.lzx.
と表示される。
ちかれた。。。