Redmine与IronRuby(Windows)?

9

有人尝试过使用IronRuby运行Redmine吗?这是否可能?

2个回答

5
我在几个月前尝试使用IronRuby运行Redmine,取得了一些成功。我使用的Redmine版本是0.9.3,IronRuby版本为1.0v4,SQL Server 2005,并从IIS 6托管。这实际上需要很多工作才能使其运行起来。我不得不对一堆Redmine文件进行微小修改。我还添加了一些下载中不存在的文件,例如new_rails_defaults.rb。此外,我还必须从GitHub获取IronRuby源代码并稍加修改以使IronRack正常工作。
为了使IIS正常工作,我必须将所有流量重定向到我创建的Redmine IIS WebApplication中的.Net进行处理。这是通过向“C:\Windows\Microsoft.NET\Framework\v2.0.50727aspnet_isapi.dll”添加应用程序扩展映射来完成的。
然后我在我的Web.config文件中将所有流量重定向到IronRack。
<httpHandlers>
<clear />   
<add path="*" verb="*" type="IronRuby.Rack.HttpHandlerFactory, IronRuby.Rack"/></httpHandlers>

这导致IIS无法提供静态文件。为了解决这个问题,我创建了StaticFileHttpHandler。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;

namespace StaticFileHttpHandler
{
    public class StaticFileHttpHandler : IHttpHandler 
    {
        #region IHttpHandler Members

        public bool IsReusable
        {
            get 
            { 
                return true; 
            }
        }

        public void ProcessRequest(HttpContext context)
        {
            string staticFileUrl = context.Request.Url.LocalPath.Replace(@"/", @"\");
            string staticFilePath = context.Server.MapPath(@"~\..\..\");
            string defaultStaticFilePathForRemapping = @"\Redmine\public";
            string defaultRootDirectoryForRemapping = @"\Redmine";
            bool remapImage = !string.IsNullOrWhiteSpace(context.Request.QueryString.ToString());

            if (staticFilePath.EndsWith(@"\"))
            {
                staticFilePath = staticFilePath.Substring(0, staticFilePath.Length - 1);
            }

            if (remapImage)
            {
                staticFilePath += (defaultStaticFilePathForRemapping + staticFileUrl.Replace(defaultRootDirectoryForRemapping, ""));
            }
            else
            {
                staticFilePath += staticFileUrl;
            }

            if (File.Exists(staticFilePath))
            {
                context.Response.ContentType = GetMimeType(staticFilePath);
                context.Response.TransmitFile(staticFilePath);
            }
            else
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write("The File Does Not Exist!!! File: " + staticFilePath);
            }            

            context.Response.Flush();
            context.ApplicationInstance.CompleteRequest();
        }

        // Found Here: http://kseesharp.blogspot.com/2008/04/c-get-mimetype-from-file-name.html
        private string GetMimeType(string fileName)
        {
            string mimeType = "application/unknown";
            string ext = System.IO.Path.GetExtension(fileName).ToLower();

            Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);

            if (regKey != null && regKey.GetValue("Content Type") != null)
            {
                mimeType = regKey.GetValue("Content Type").ToString();
            }

            return mimeType;
        }

        #endregion
    }
}

这也需要添加到httpHandlers部分中。对于每种您想要它能够提供服务的静态文件类型。以下是提供PNG文件的示例。

<httpHandlers>
<clear />
<add path="*.png" verb="*" type="StaticFileHttpHandler.StaticFileHttpHandler, StaticFileHttpHandler"/>
<add path="*" verb="*" type="IronRuby.Rack.HttpHandlerFactory, IronRuby.Rack"/></httpHandlers>

我还需要创建一个 images_controller.rb 文件来指向静态文件。

# This is a place holder controller to allow for mapping static images

class ImagesController < ApplicationController
  def index
    0
  end
end

下一步,所有的*.yml文件中,带有百分号的值都需要用双引号括起来。
  field_done_ratio: "% ???????"

此外,我必须将db\migrate文件夹中数据库设置文件中的所有索引创建和删除注释掉。

总之,使用IronRuby、IronRack、IIS 6和SQL Server 2005基本上可以使Redmine正常工作,但需要进行一些修改。


5

我认为目前的答案是否定的......通过谷歌搜索,我发现有些人在尝试,一些人提出了问题......

https://serverfault.com/questions/165539/redmine-in-ironruby

目前,Redmine仅支持Ruby 1.8.6和1.8.7以及Ruby Enterprise Edition。目前正在努力让Redmine在jRuby和Rubinius上运行。由于没有太多的核心开发人员在Windows上运行,因此我不会认为有人积极开发IronRuby兼容性。 如果您愿意帮助编写所需的补丁,则欢迎在http://redmine.org上发言。

Redmine,yaml文件不能有%..

在我徒劳无功地尝试在IronRuby上运行redmine时,我发现像这样的行:"field_done_ratio:%完成"在区域设置yaml文件中抛出异常。如果我删除“%”,它就可以工作(或者至少我走了一步)。

(放弃后的16小时,我的最后障碍是在访问localhost:3000 /时进行无限重定向,虽然访问localhost:3000 / login很好,但之后你什么也做不了。)

http://ironruby.codeplex.com/workitem/list/basic?size=2147483647


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接