2

このバグを修正するために過去 2 日間を費やしましたが、それを解決するためのアイデアやツールはもうありません。ここスタックオーバーフローの誰かが私を助けてくれるのだろうか。

ckeditor gem を使用する Web サイトのソース コードを修正しようとしています。ckeditor gem は、組み込みの Web テキスト エディターを提供します。問題は、Web サイトがサブディレクトリに配置されている場合、gem が機能しないことです。Web サイトが www.domain.com のようなルート ディレクトリに配置されている場合は完全に機能しますが、www.domain.com/website のようなサブディレクトリに配置すると、テキスト エディターが表示されません。

エディターが表示されない原因は、アプリケーションがサーバーのルート ディレクトリにある ckeditor gem のアセットを見つけようとするためです。

Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/config.js?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/skins/kama/editor.css?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/lang/pt-br.js?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/plugins/embed/plugin.js?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/plugins/attachment/plugin.js?t=C3HA5RM

正しいアドレスが www.domain.com/ website /assets/ckeditor/config.js?t=C3HA5RMの場合

私はこれに対する解決策を見つけようとして、ウェブ全体を実際に検索しましたが、私が見つけたいくつかの同様の状況だけが解決策を提供しませんでした.

この問題では、github で、ユーザー jronallo が私とまったく同じ問題を抱えています。しかし、私は彼のソリューションを実装しようとしましたが、成功しませんでした. このコミットでは、ckeditor リポジトリでバグが修正されたようですが、私の gem (ckeditor 4.0.2 および rails 3.2.2) でこの修正を行っても、SubUri のアセットが失われ続けます。

また、CKEDITOR_BASEPATH と Ckeditor.relative_url を手動で操作しようとしましたが、再び成功しませんでした。

どのようにそれを解決できるかについて誰かが考えを持っていますか? よろしくお願いします。

4

2 に答える 2

2

ckeditor 構成の外部プラグインを削除します。

リソースの読み込みに失敗しました: サーバーは 404 (見つかりません) のステータスで応答しました http://domain.com/assets/ckeditor/plugins/embed/plugin.js?t=C3HA5RM リソースの読み込みに失敗しました: サーバーは a で応答しました404 のステータス (見つかりません ) http://domain.com/assets/ckeditor/plugins/attachment/plugin.js?t=C3HA5RM

私の設定:

/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

CKEDITOR.editorConfig = function( config )
{
    // Define changes to default configuration here. For example:
    config.language = I18n.locale;
    // config.uiColor = '#AADC6E';

  /* Filebrowser routes */
  // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
  config.filebrowserBrowseUrl = "/ckeditor/attachment_files";

  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
  config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";

  // The location of a script that handles file uploads in the Flash dialog.
  config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";

  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
  config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";

  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
  config.filebrowserImageBrowseUrl = "/ckeditor/pictures";

  // The location of a script that handles file uploads in the Image dialog.
  config.filebrowserImageUploadUrl = "/ckeditor/pictures";

  // The location of a script that handles file uploads.
  config.filebrowserUploadUrl = "/ckeditor/attachment_files";

  // Rails CSRF token
  config.filebrowserParams = function(){
    var csrf_token = jQuery('meta[name=csrf-token]').attr('content'),
        csrf_param = jQuery('meta[name=csrf-param]').attr('content'),
        params = new Object();

    if (csrf_param !== undefined && csrf_token !== undefined) {
      params[csrf_param] = csrf_token;
    }

    return params;
  };

  config.addQueryString = function (url, params) {
    var queryString = [];

    if (!params)
      return url;
    else {
      for (var i in params)
        queryString.push(i + "=" + encodeURIComponent(params[ i ]));
    }

    return url + ( ( url.indexOf("?") != -1 ) ? "&" : "?" ) + queryString.join("&");
  };

  // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
  CKEDITOR.on('dialogDefinition', function (ev) {
    // Take the dialog name and its definition from the event data.
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;
    var content, upload;

    if ($.inArray(dialogName, ['link', 'image', 'attachment', 'flash']) > -1) {
      content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
      upload = (content == null ? null : content.get('upload'));

      if (upload && upload.filebrowser['params'] == null) {
        upload.filebrowser['params'] = config.filebrowserParams();
        upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
      }
    }
  });

  /* Extra plugins */
  // works only with en, ru, uk locales
//  config.extraPlugins = "embed,attachment";

    //for orfografii
  config.disableNativeSpellChecker = false;
//  config.removePlugins = 'contextmenu';


  /* Toolbars */
  config.toolbar = 'Mini';
  config.toolbar_Mini =
    [
        ['Source','-','Preview'],
        ['Cut','Copy','Paste','PasteText','PasteFromWord'],
        ['Undo','Redo','-','SelectAll','RemoveFormat'],
//        ['Styles','Format'],
      ['Subscript', 'Superscript'],
//      ['Subscript', 'Superscript', 'TextColor'],
//        ['Maximize','-','About'],
        ['Bold','Italic','Underline'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote']//,
//        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
//        ['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash', 'Embed'],
//        ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
    ];

  config.toolbar = 'VeryEasy';
  config.toolbar_VeryEasy =
    [
        ['Source','-','Preview'],
        ['Cut','Copy','Paste','PasteText','PasteFromWord'],
        ['Undo','Redo','-','SelectAll','RemoveFormat'],
//        ['Styles','Format'],
      ['Subscript', 'Superscript', 'TextColor'],
        ['Maximize','-','About'],
        ['Bold','Italic','Underline','Strike'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
//        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
//        ['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash', 'Embed'],
        ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
    ];

  config.toolbar = 'Easy';
  config.toolbar_Easy =
      [
        ['Source', '-', 'Preview'],
        ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
        ['Undo', 'Redo', '-', 'SelectAll', 'RemoveFormat'],
        ['Styles', 'Format'],
        ['Subscript', 'Superscript', 'TextColor'],
        ['Maximize', '-', 'About'],
        '/',
        ['Bold', 'Italic', 'Underline', 'Strike'],
        ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'],
        ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
        ['Link', 'Unlink', 'Anchor'],
        ['Image', 'Attachment', 'Flash', 'Embed'],
        ['Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak']
      ];
  config.jqueryOverrideVal = true;
};
于 2013-02-27T09:48:23.473 に答える
0

ページ全体の読み込み後に ckeditor.js を動的に読み込んでいたため、ルートディレクトリでのスキンの ckeditor 検索に問題がありました。

このスレッドで見つけた解決策は 、ckeditor.js を呼び出す前にグローバル変数 CKEDITOR_BASEPATH を設定することでした。

于 2013-10-31T23:05:49.353 に答える