2

Refinery CMS (Rails 用の CMS) に精通している場合は、schema.org 属性を作成できないということです。

私はページを開き、編集に行き、次のように述べます。

<figure itemscope itemtype="http://schema.org/Person">
    <img src="#" alt="Example"/>
    <figcaption>
          <span itemprop="name">Bobby Orr</span> - CEO of Example.com
    </figcaption>
</figure>

そして、それは次のようになります。

<figure>
    <img src="#" alt="Example"/>
    <figcaption>
        <span>Bobby Orr</span> - CEO of Example.com
    </figcaption>
</figure>

Refineryがスキーマを削除せずにスキーマを保持する方法を知っている人はいますか?

4

1 に答える 1

0

これを行うには、config/initializers/refinery/core.rb の config.wymeditor_whitelist_tags ハッシュに適切なタグを追加します。

これはフィギュアタグで機能するはずです:

config.whitelist_tags = {'figure' => {'attributes' =>{ '1': 'itemscope', '2': 'itemtype'}}}

この方法を使用する場合は、アイテムの追加方法を変更する必要があることに注意してください。

html では、次のようにする必要があります。

<figure itemscope="itemscope" itemtype="http://schema.org/Person">

具体的には、そうである必要があることに注意してくださいitemscope="itemscope"。そうしないと、取り除かれます。

この質問によると、それは有効な HTML5 です: HTML5 有効なアイテムスコープ

ホワイトリストの詳細については、http: //ugisozols.com/blog/2013/06/20/whitelisting-html-tags-and-attributes-in-refinery-cms-wymeditor/をご覧ください。

多くのタグがあり、検証を完全にオフにしたい場合は、app/assets/javascripts/wymeditor/validators.js.erb をアプリにコピーして、次のように getValidTagAttributes 関数のほとんどをコメント アウトします。

  getValidTagAttributes: function(tag, attributes)
  {
    var valid_attributes = {};
    var possible_attributes = this.getPossibleTagAttributes(tag);
    var regexp_attributes = [];
    $.each((possible_attributes || []), function(i, val) {
      if (val.indexOf("*") > -1) {
        regexp_attributes.push(new RegExp(val));
      }
    });
    var h = WYMeditor.Helper;
    for(var attribute in attributes) {
      var value = attributes[attribute];
    //if(!h.contains(this.skipped_attributes, attribute) && !h.contains(this.skipped_attribute_values, value)){
    //  if (typeof value != 'function') {
    //    if (h.contains(possible_attributes, attribute)) {
    //      if (this.doesAttributeNeedsValidation(tag, attribute)) {
    //        if(this.validateAttribute(tag, attribute, value)){
    //          valid_attributes[attribute] = value;
    //        }
    //      }else{
              valid_attributes[attribute] = value;
    //      }
    //    }
    //    else {
    //      $.each(regexp_attributes, function(i, val) {
    //        if (attribute.match(val)) {
    //          valid_attributes[attribute] = value;
    //        }
    //      });
    //    }
    //  }
    //}
    }
    return valid_attributes;
  },

このようなタグの検証をすべて無効にすることは、潜在的に非常に危険であることに注意してください。

于 2015-07-29T22:04:33.770 に答える