<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    子在川上曰

      逝者如斯夫不舍晝夜
    隨筆 - 71, 文章 - 0, 評論 - 915, 引用 - 0
    數據加載中……

    在Rails中使用FCKeditor插件實現WEB富文本編輯

    比如象BlogJava這里編輯器就應該是用的FCKeditor ,FCKeditor 相當有名,它有PHP、JSP、rails等多個版本,核心都是一些javascript代碼。

    文/陳剛? (www.chengang.com.cn)

    環境:ubuntu linux 7.0.4? +? ruby 1.8.5 + Rails 1.2.3 + FCKeditor 0.4.1

    直接從它的subversion庫里取得該Rails插件。先進入到你的項目根目錄,再執行如下命令
    ruby?script/plugin?install?svn://rubyforge.org/var/svn/fckeditorp/trunk/fckeditor

    其他說明:
    (1)你的linux必須先安裝了subversion。(ubuntu里用新立得搜subversion即得)
    (2)把命令中的install 改為 destory,可以刪除安裝。
    (3)我取到的是2007年4月份最后更新的, v 0.4.1版
    (4)FCKeditor安裝在項目根目錄下的vendor/plugins/fckeditor 里,
    (5)vendor/plugins/fckeditor里的README很值得一讀,我碰到Ajax問題,查了所以網上的中文資料都沒有提到,在這個README卻有。


    用如下語句在頁面里含入它的javascript庫
    <%=?javascript_include_tag?:fckeditor?%>??

    <%=?javascript_include_tag?"fckeditor/fckeditor"?%>


    在需要富文本的Form表單用如下語句生成一個富文件編輯框:
    <%=?fckeditor_textarea("topic",?"content",?:toolbarSet?=>?'Simple',?:width?=>?'100%',?:height?=>?'200px')?%>

    說明:topic對應模型對象,content對應它的字段。也就是要求當前頁要有@topic這個實例變量。


    如果是用了ajax,則需要在form_remote_tag加上一個before項
    ??<%=?form_remote_tag(:update?=>?update,
    ??????????????????????:before?
    =>?fckeditor_before_js('topic',?'content'),
    ??????????????????????:url?
    =>?{:controller?=>?'topics',?:action?=>?'create',?:template?=>?'show'}?)%>

    并且富文件編輯框要加一個ajax=true的選項:
    <%=?fckeditor_textarea(:topic,?:content,?:ajax?=>?true,?:toolbarKit?=>?'Simple',?:width?=>?'100%',?:height?=>?'600px')?%>





    在使上傳圖片的功能時碰到了錯誤。彈出出alert對話框,顯示:Error on file upload.Error number: 403

    在日志里顯示如下,表面上看好象是路由配置的問題

    ActionController::RoutingError (no route found to match "/fckblank.html" with {:method=>:get}):
    /var/lib/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1292:in `recognize_path'
    /var/lib/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1282:in `recognize'
    /var/lib/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:40:in `dispatch'
    /var/lib/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:113:in `handle_dispatch'
    /var/lib/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
    /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
    /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'


    最后在http://blog.caronsoftware.com/articles/2006/12/03/fckeditor-0-4-0-released#comment-1745找到了答案,這是一個BUG

    解決方法 :

    修改:vendor/plugins/fckeditor/app/controller/fckeditor_controller.rb
    將原來的

    unless?"#{file.class}"?==?"Tempfile"

    改為
    unless?"#{file.class}"?==?"Tempfile"?||?"#{file.class}"?==?"StringIO"



    posted on 2007-08-25 16:44 陳剛 閱讀(2348) 評論(2)  編輯  收藏 所屬分類: Rails&Ruby

    評論

    # re: 在Rails中使用FCKeditor插件實現WEB富文本編輯  回復  更多評論   

    bu cuo
    2008-04-20 17:04 | lii

    # re: 在Rails中使用FCKeditor插件實現WEB富文本編輯  回復  更多評論   

    頂一個,最后的那個bug最近的版本已經有修正。。。
    2009-07-24 10:11 | ycc
    主站蜘蛛池模板: 国产美女无遮挡免费网站| 久久久久久久国产免费看| 亚洲制服丝袜中文字幕| 亚洲毛片免费视频| 亚洲性色成人av天堂| 亚洲AV色吊丝无码| 亚洲av永久无码精品三区在线4| 亚洲一区二区三区久久久久| 亚洲av成人一区二区三区| 国产 亚洲 中文在线 字幕| 亚洲中文字幕乱码AV波多JI| 亚洲第一综合天堂另类专 | 亚洲日韩中文无码久久| 亚洲自偷自偷图片| 久久香蕉国产线看观看亚洲片| 久久久亚洲精品无码| 亚洲欧洲高清有无| 亚洲乱亚洲乱妇无码| 黄色网页免费观看| 成人国产精品免费视频| 免费福利电影在线观看| 4455永久在线观免费看| 成年男女免费视频网站| 亚洲AV永久无码精品一区二区国产| 久久精品国产精品亚洲艾草网美妙 | 免费夜色污私人影院网站| 毛片基地看看成人免费| 四虎成人精品永久免费AV| 1000部拍拍拍18勿入免费视频下载| 无码人妻精品中文字幕免费东京热| 久久亚洲中文字幕精品一区四| 在线亚洲97se亚洲综合在线| 亚洲成av人片天堂网| 亚洲成年人电影在线观看| 亚洲狠狠婷婷综合久久| 国产在线国偷精品免费看| 69视频在线观看免费| 在线看片无码永久免费aⅴ | 999国内精品永久免费视频| 国产男女猛烈无遮挡免费视频网站| 国产成人综合亚洲亚洲国产第一页 |