【问题标题】:Redmine with IronRuby (Windows)?Redmine 与 IronRuby (Windows)?
【发布时间】:2010-05-06 19:05:11
【问题描述】:

有没有人尝试过使用 IronRuby 运行 Redmine?有可能吗?

【问题讨论】:

    标签: ruby-on-rails iis-7 ironruby redmine


    【解决方案1】:

    我认为目前的答案是否定的......做了一些谷歌搜索我发现了各种 人们提出了一些尝试和一些提出的问题......

    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 文件中不能有 %..

    在我为使 redmine 在 IronRuby 上运行而进行的徒劳无功的努力中,我发现其中一件事是语言环境 yaml 文件中的以下行:“field_done_ratio: % Done”引发了异常。如果我删除了“%”,它就起作用了(或者至少我更进一步)。

    (在这 16 小时后放弃了,我最后的障碍是访问 localhost:3000/ 时的无限重定向,虽然访问 localhost:3000/ 登录很顺利,但之后你什么都做不了..)

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

    【讨论】:

      【解决方案2】:

      几个月前,我试图让 Redmine 在 IronRuby 上运行并取得了一些成功。我使用的 Redmine 版本是 0.9.3,IronRuby 版本是 1.0v4,SQL Server 2005,它是从 IIS 6 托管的。实际上,要让它运行起来需要做很多工作。我不得不对一堆 Redmine 文件进行细微修改。我还添加了一些在我的下载中不存在的文件,例如 new_rails_defaults.rb。此外,我必须从 GitHub 获取 IronRuby 源代码并对其稍作修改以使 IronRack 正常工作。

      为了让 IIS 工作,我必须将所有流量重定向到 .Net,以便在我创建的 Redmine IIS WebApplication 中进行处理。这是通过将应用程序扩展映射添加到“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 文件夹中数据库设置文件中的所有索引创建和删除。

      总之,可以让 Redmine 主要与 IronRuby、IronRack、IIS 6 和 SQL Server 2005 一起工作,但并非没有一些修改。

      【讨论】:

        猜你喜欢
        • 2010-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-18
        • 1970-01-01
        • 2010-10-05
        相关资源
        最近更新 更多