Embed inline Ruby & HTML?

travisbell

Well-Known Member
#1
Hey guys,

I am currently using eruby + Apache to use embedded Ruby like so:

Code:
This text is <% a = 100; puts "#{a}% Live!" %>
This is NOT a Rails site, just HTML with inline Ruby. I found out about it while reading through the Pragmatic Programmers guide here, http://www.ruby-doc.org/docs/ProgrammingRuby/html/web.html

For now, I am using LiteSpeed to serve the Apache pages via the LiteSpeed Web API but it would be way better if I could process the Ruby natively through LiteSpeed.

Is there a way I can get this done?
 

travisbell

Well-Known Member
#3
eRuby is CGI written in C, should be able to used together with LiteSpeed.
Yeah, I agree but couldn't get the MIME settings to work right in LS.

How can I go about adding the following MIME lines to LiteSpeed to make it work?

Code:
AddType application/x-httpd-eruby .rhtml
Action application/x-httpd-eruby /cgi-bin/eruby
Adding the AddType is easy but about about the Action?
 

mistwang

LiteSpeed Staff
#4
No need to use those configuration. try rewrite rule

RewriteRule (.*\.rhtml)$ /cgi-bin/eruby/$1

This should pass the rhtml file as PATH_TRANSLATED to eruby CGI. give it a try.
 

travisbell

Well-Known Member
#5
I disabled the Apache proxy and put that .htaccess in. Now LiteSpeed just wants to download the file instead of parsing it or throwing an error.

Should I still put a MIME type in to recognize the .rhtml?
 

mistwang

LiteSpeed Staff
#6
I tried the rewrite rule and it works.

Looks like your rewrite rule has not been configured properly. the request was not rewritten to /cgi-bin/eruby
 

travisbell

Well-Known Member
#7
My .htaccess looks like the following:

Code:
Options +Indexes

RewriteEngine On
RewriteRule (.*\.rhtml)$ /cgi-bin/eruby/$1
I have the .htaccess configured like so:


Click for full size - Uploaded with plasq's Skitch

Now what happens is I get a "500 Internal Server Error" with the following error in my logs:

Code:
[124.170.97.88:65109-6#iJabber] Maximum number of redirect reached.
Any ideas why this isn't working?
 

travisbell

Well-Known Member
#9
Got a little farther...

Disabled rewrite in /cgi-bin and now I get the following error in my logs:

Code:
[124.170.97.88:49646-0#iJabber] URI '/cgi-bin/eruby/register-gateway.rhtml' refers to a static file with PATH_INFO [/register-gateway.rhtml].
 
Top