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

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

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

    老妖的博客
    現實的中沒有幾個人能夠真為對方去死,甚至山盟海誓很快就會在金錢面前變的微不足道,這才是生活。沒有永遠的愛,除了你的父母對你,當然也就沒有永遠的恨,更沒有永遠的痛,時間是最好的治療大師,它會很快撫平你心靈上累累的傷痕。很多年以后你想起來時,那些在你生命中洶涌來往的人群至多是個模糊的影子或者毫無意義的名字
    posts - 105,  comments - 171,  trackbacks - 0
    1.下載fckeditor_plugin-0.3.2.zip,目前版本為0.3.2
    2.解壓到vendor\plugins目錄下,并且重新命名為fckeditor
    3.到該應用程序根目錄下,然后運行rake fckeditor:install,則執行自動安裝
    4.在自己的view層中添加
    <%= javascript_include_tag :fckeditor %>
    以及在你需要編輯的字段textarea替換為
    <%= fckeditor_textarea("book", "desc", { :toolbarKit => 'Simple', :width => '100%', :height => '200px' }) %>
    第一個參數為你的domain對象,desc為你的編輯字段值,其他顧名思義
    然后運行你的頁面程序,發現simple upload有點bug,上傳后javascript報錯
    5.追蹤代碼發現
    vendor\plugins\fckeditor\app\controllers\fckeditor_controller.rb下的

    ??def?upload
    ????self.upload_file
    ??end
    調用了upload_file方法
    def?upload_file
    ????@new_file?
    =?params[:NewFile]
    ????@url?
    =?upload_directory_path
    ????begin
    ??????ftype?
    =?@new_file.content_type.strip
    ??????
    if?!?MIME_TYPES.include?(ftype)
    ????????@errorNumber?
    =?202
    ????????puts?
    "#{ftype}?is?invalid?MIME?type"
    ????????raise?
    "#{ftype}?is?invalid?MIME?type"
    ??????
    else
    ????????path?
    =?current_directory_path?+?"/"?+?@new_file.original_filename
    ????????File.open(path,
    "wb",0664)?do?|fp|
    ??????????FileUtils.copy_stream(@new_file,?fp)
    ????????end
    ????????@errorNumber?
    =?0
    ??????end
    ????rescue?
    =>?e
    ??????@errorNumber?
    =?110?if?@errorNumber.nil?
    ????end
    ????
    ????#?Fix?provided?by?Nicola?Piccinini?
    --?http://superfluo.org
    ????render?:text?=>?%Q'<script>window.parent.frames[\'frmUpload\'].OnUploadCompleted(#{@errorNumber});</script>'
    ????#render?:inline?
    =>?'page?<<?"window.parent.frames[\'frmUpload\'].OnUploadCompleted(#{@errorNumber},?\'#{@new_file}\');"',?:type?=>?:rjs
    ??end
    中的
    render?:text?=>?%Q'<script>window.parent.frames[\'frmUpload\'].OnUploadCompleted(#{@errorNumber});</script>'
    在瀏覽服務器時是正常的,但是在快速上傳中不應該返回這個script語句
    則修改upload方法
    def?upload
    ????@new_file?
    =?params[:NewFile]
    ????@url?
    =?upload_directory_path
    ????begin
    ??????ftype?
    =?@new_file.content_type.strip
    ??????
    if?!?MIME_TYPES.include?(ftype)
    ????????@errorNumber?
    =?202
    ????????puts?
    "#{ftype}?is?invalid?MIME?type"
    ????????raise?
    "#{ftype}?is?invalid?MIME?type"
    ??????
    else
    ????????path?
    =?current_directory_path?+?"/"?+?@new_file.original_filename
    ????????File.open(path,
    "wb",0664)?do?|fp|
    ??????????FileUtils.copy_stream(@new_file,?fp)
    ????????end
    ????????@errorNumber?
    =?0
    ??????end
    ????rescue?
    =>?e
    ??????@errorNumber?
    =?110?if?@errorNumber.nil?
    ????end
    ????
    ????#?Fix?provided?by?Nicola?Piccinini?
    --?http://superfluo.org
    ????render?:text?=>?%Q'<script>window.parent.OnUploadCompleted(#{@errorNumber},\"#{UPLOADED}/#{params[:Type]}\",\"#{@new_file.original_filename}\",\"\");</script>'
    ??end
    快速上傳問題修復

    6.發現文件夾里邊如果上傳圖片過多不好備份,故采用/年/月方式保存
    修改代碼如下:
    ???def?upload
    ????@new_file?
    =?params[:NewFile]
    ????@url?
    =?upload_directory_path
    ????begin
    ??????ftype?
    =?@new_file.content_type.strip
    ??????
    if?!?MIME_TYPES.include?(ftype)
    ????????@errorNumber?
    =?202
    ????????puts?
    "#{ftype}?is?invalid?MIME?type"
    ????????raise?
    "#{ftype}?is?invalid?MIME?type"
    ??????
    else
    ????????path?
    =?date_directory_path?+?"/"?+?@new_file.original_filename
    ????????File.open(path,
    "wb",0664)?do?|fp|
    ??????????FileUtils.copy_stream(@new_file,?fp)
    ????????end
    ????????@errorNumber?
    =?0
    ??????end
    ????rescue?
    =>?e
    ??????@errorNumber?
    =?110?if?@errorNumber.nil?
    ????end
    ????
    ????#?Fix?provided?by?Nicola?Piccinini?
    --?http://superfluo.org
    ????render?:text?=>?%Q'<script>window.parent.OnUploadCompleted(#{@errorNumber},\"#{UPLOADED}/#{params[:Type]}/#{Time.now.year}/#{Time.now.month}/#{@new_file.original_filename}\",\"#{@new_file.original_filename}\",\"\");</script>'
    ??end?
    ??
    private
    ??def?date_directory_path
    ????base_dir?
    =?"#{UPLOADED_ROOT}/#{params[:Type]}/#{Time.now.year}/#{Time.now.month}"
    ????#Dir.mkdir(base_dir,
    0775)?unless?File.exists?(base_dir)
    ????FileUtils.mkdir_p?base_dir
    ????
    "#{base_dir}"
    ??end
    7.同理可以對其上傳文件名稱進行隨機處理以防重名,就不多說了。
    做此筆記,拋磚引玉。

    發現rails的plugin機制挺不錯的,比較靈活,不過網上介紹plugin的文章真的不是很多
    posted on 2006-11-04 01:29 老妖 閱讀(4372) 評論(11)  編輯  收藏 所屬分類: rails

    FeedBack:
    # re: rails實戰--(四)FCKEditor與rails的集成
    2006-11-04 02:46 | li
    ROR plug-in is really cool stuff. It's more flexible than many other web framework's plug-in approach...

      回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2006-11-05 17:10 | jelly->
    呵呵, 變成blograils了,

    我一般簡單應用的時候,喜歡直接在helper里寫一個fckeditor的方法, 像在普通htm里使用一樣。   回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2006-11-06 19:41 | aotianlong
    Thank you . your article will posted at http://railser.com .  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2006-12-09 00:55 | Jerry[匿名]
    發現這個:toolbarKit => 'Simple',顯示的根本不是Simples方式,還是復雜方式。不知道為什么。  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2006-12-20 17:46 | raise
    很抱歉 打擾了。

    我按照你的方法配制了,但是沒有成功,不知您是否可以提供一個已經配制成功的例子給我。nmlnj@163.com

    謝謝了!!  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2006-12-20 17:51 | raise
    nmlnj@163.com

    已經成功了

    謝謝

    打擾了  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2007-08-29 16:44 | Fengbo
    @Jerry[匿名]
    看看fckeditor里面toolKitset有沒有一個Simple的定義。  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2007-09-20 17:36 | CFC
    :toolbarKit是錯誤的
    請改成
    :toolbarSet

    :)  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2007-09-25 16:38 | 陳剛
    如果是象博客那樣的多用戶系統,那么需要上傳文件的目錄需要分用戶存放。如何實現呢?  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成[未登錄]
    2007-11-30 16:01 | 小馬
    現實的中沒有幾個人能夠真為對方去死,甚至山盟海誓很快就會在金錢面前變的微不足道,這才是生活。沒有永遠的愛,除了你的父母對你,當然也就沒有永遠的恨,更沒有永遠的痛,時間是最好的治療大師,它會很快撫平你心靈上累累的傷痕。很多年以后你想起來時,那些在你生命中洶涌來往的人群至多是個模糊的影子或者毫無意義的名字

    一席話驚醒夢中人,命陪命陪命命陪……  回復  更多評論
      
    # re: rails實戰--(四)FCKEditor與rails的集成
    2014-09-04 14:29 | 我來學習
    提供基本的東西,但是允許輕松擴展自定義  回復  更多評論
      

    <2025年5月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    常用鏈接

    隨筆分類(48)

    隨筆檔案(104)

    好友鏈接

    我的豆瓣

    積分與排名

    • 積分 - 220769
    • 排名 - 257

    最新評論

    閱讀排行榜

    主站蜘蛛池模板: 国产精品成人亚洲| 国产成人+综合亚洲+天堂| 日本亚洲高清乱码中文在线观看| 亚洲精品视频免费观看| 最近免费最新高清中文字幕韩国 | 一级毛片免费视频网站| 免费播放一区二区三区| 国产91久久久久久久免费| 亚洲日产无码中文字幕| 亚洲色大网站WWW永久网站| 在线看片免费人成视频久网下载| 成人免费无码大片A毛片抽搐| 亚洲国产精品VA在线观看麻豆| 亚洲中文字幕AV每天更新| 久久er国产精品免费观看2| 日本19禁啪啪无遮挡免费动图| 亚洲av色福利天堂| 国产亚洲精品成人久久网站| 亚洲免费闲人蜜桃| 亚洲日韩欧洲无码av夜夜摸| 亚洲av永久无码精品网址 | 久久成人免费大片| 亚洲AV网站在线观看| 亚洲免费网站在线观看| 免费黄色电影在线观看| 免费一级毛片在播放视频| 亚洲国产精品日韩在线| av永久免费网站在线观看| 国产成人免费A在线视频| 亚洲人成在线中文字幕| 免费h视频在线观看| 亚洲色偷拍区另类无码专区| 亚洲人成未满十八禁网站| 2020因为爱你带字幕免费观看全集| 2022中文字字幕久亚洲| 亚洲Av无码国产一区二区| 无码国产精品一区二区免费虚拟VR| 久久精品国产亚洲AV麻豆~| kk4kk免费视频毛片| 亚洲 小说区 图片区 都市| 亚洲欧美日韩中文无线码|