refinery / refinerycms

An extendable Ruby on Rails CMS that supports Rails 6.0+
https://www.refinerycms.com/
MIT License
3.9k stars 1.26k forks source link

Treating a type text field of a Refinery extension as html in Refinery's WYMeditor #3131

Closed ekonotek closed 8 years ago

ekonotek commented 8 years ago

Is it possible to edit and store html in a Refinery extension text field like for Refinery pages? ie. like in the column body of refinery_page_part_translations.

Thank you in advance.

bricesanchez commented 8 years ago

@ekonotek Did you see this ? https://github.com/refinery/refinerycms/blob/master/core/lib/generators/refinery/engine/USAGE

ekonotek commented 8 years ago

Thanks for the quick response Brice, yes, indeed that is precisely what I'm asking about.

I used the "text- text area with a visual editor" for my extension, but when I go to edit that field in the WYMeditor the HTML (source view) is not functional. It generates an error msg: Uncaught Error: Syntax error, unrecognized expression: Whom would you like ..... ( btw Whom would you like ..... is the content of that field.)

What I would like is to have access to edit the HTML just like in the Blog extension.

Regards, Rafael

On Fri, Mar 11, 2016 at 11:01 AM, Brice Sanchez notifications@github.com wrote:

@ekonotek https://github.com/ekonotek Did you see this ? https://github.com/refinery/refinerycms/blob/master/core/lib/generators/refinery/engine/USAGE

— Reply to this email directly or view it on GitHub https://github.com/refinery/refinerycms/issues/3131#issuecomment-195454624 .

bricesanchez commented 8 years ago

Could you copy/paste your Gemfile.lock and your error stacktrace ?

ekonotek commented 8 years ago

Thanks again,

The error is a js/jquery error in the browser console:

Uncaught Error: Syntax error, unrecognized expression: Whom would you
like to invite ....?Sizzle.error

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:1464Sizzle.tokenize

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:2121Sizzle.select

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:2542Sizzle

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:865jQuery.fn.extend.find

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:2788jQuery.fn.init

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:2905jQuery

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:76WYMeditor.editor.update

@ prototypes.self-4f05b2b82988bfd8ae3e20cf25043020f64bd6f2ad3c4e23e66a885ef7888c6a.js?body=1:603WYMeditor.editor.exec

@ prototypes.self-4f05b2b82988bfd8ae3e20cf25043020f64bd6f2ad3c4e23e66a885ef7888c6a.js?body=1:314(anonymous
function)

@ prototypes.self-4f05b2b82988bfd8ae3e20cf25043020f64bd6f2ad3c4e23e66a885ef7888c6a.js?body=1:178jQuery.event.dispatch

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:4733elemData.handle

@ jquery.self-0a6570c8f60714fcfb2147cecaf229b5c0ffff626fe407344d3b00a2ad441b7c.js?body=1:4545

Here is the Gemfile.lock:

GIT
  remote: git://github.com/bisscomm/refinerycms-products.git
  revision: 920c3c86de3ad8bb19f7611857d8889470e27e60
  branch: master
  specs:
    refinerycms-products (3.0.0)
      awesome_nested_set (~> 3.0.0)
      friendly_id (~> 5.1.0)
      globalize (>= 4.0.0, < 5.2)
      refinerycms-acts-as-indexed (~> 2.0.0)
      refinerycms-core (~> 3.0.0)
      refinerycms-page-images (~> 3.0.0)

GIT
  remote: git://github.com/bisscomm/refinerycms-retailers.git
  revision: af832fd74d22713d322d3f82e7f6bb580ee310fb
  branch: master
  specs:
    refinerycms-retailers (3.0.0)
      actionview-encoded_mail_to (~> 1.0.5)
      acts_as_indexed (~> 0.8.0)
      carmen-rails (~> 1.0.1)
      globalize (>= 4.0.0, < 5.2)
      refinerycms-core (~> 3.0.0)

GIT
  remote: git://github.com/fernandoaleman/refinerycms-bootstrap.git
  revision: b90e39e106abeb77dca7ae4586229b29fe5c68b4
  branch: master
  specs:
    refinerycms-bootstrap (0.0.1)
      bootstrap-sass-rails

GIT
  remote: git://github.com/refinery/refinerycms-page-images.git
  revision: 9b5f16e8266cb3c823c4d310ec3e733245258dde
  branch: master
  specs:
    refinerycms-page-images (3.0.0)
      decorators (~> 2.0.0)
      globalize (~> 5.0)
      refinerycms-pages (~> 3.0.0)

GIT
  remote: https://github.com/refinery/refinerycms
  revision: 8ec74957f0a88244e139ec8eb4d4d669cb94ea77
  branch: master
  specs:
    refinerycms (3.0.1)
      refinerycms-core (= 3.0.1)
      refinerycms-images (= 3.0.1)
      refinerycms-pages (= 3.0.1)
      refinerycms-resources (= 3.0.1)
    refinerycms-core (3.0.1)
      actionpack (>= 4.2.3, < 5.0)
      activerecord (>= 4.2.3, < 5.0)
      awesome_nested_set (~> 3.0.0)
      coffee-rails (~> 4.0, >= 4.0.0)
      decorators (~> 2.0.0)
      font-awesome-sass (>= 4.3.0, < 5.0)
      jquery-rails (>= 2.3.0)
      jquery-ui-rails (~> 5.0.0)
      railties (>= 4.2.3, < 5.0)
      refinerycms-i18n (~> 3.0.0)
      sass-rails (>= 4.0, < 5.1)
      truncate_html (~> 0.9)
      will_paginate (~> 3.0.2)
      zilch-authorisation
    refinerycms-images (3.0.1)
      dragonfly (~> 1.0.0)
      globalize (>= 4.0.0, < 5.2)
      refinerycms-core (= 3.0.1)
    refinerycms-pages (3.0.1)
      awesome_nested_set (~> 3.0.0)
      babosa (!= 0.3.6)
      friendly_id (~> 5.1.0)
      globalize (>= 4.0.0, < 5.2)
      refinerycms-core (= 3.0.1)
      seo_meta (~> 2.0.0.rc.1)
      speakingurl-rails (~> 8.0.0)
    refinerycms-resources (3.0.1)
      acts_as_indexed (~> 0.8.0)
      dragonfly (~> 1.0.0)
      globalize (>= 4.0.0, < 5.2)
      refinerycms-core (= 3.0.1)

GIT
  remote: https://github.com/refinery/refinerycms-blog
  revision: 8d052c50e20da74a17b284225f69b5d4c1beb52e
  branch: master
  specs:
    refinerycms-blog (3.0.0)
      acts-as-taggable-on
      filters_spam (~> 0.2)
      friendly_id (~> 5.1.0)
      globalize (>= 4.0.0, < 5.2)
      jquery-ui-rails (~> 5.0.0)
      rails_autolink (~> 1.1.3)
      refinerycms-core (~> 3.0.0)
      refinerycms-settings (~> 3.0.0)
      seo_meta (~> 2.0.0.rc.1)

PATH
  remote: vendor/extensions
  specs:
    refinerycms-authorized_emails (1.0)
      acts_as_indexed (~> 0.8.0)
      refinerycms-core (~> 3.0.1)
    refinerycms-members (1.0)
      acts_as_indexed (~> 0.8.0)
      refinerycms-core (~> 3.0.0)
    refinerycms-wiz_steps (1.0)
      acts_as_indexed (~> 0.8.0)
      refinerycms-core (~> 3.0.1)

GEM
  remote: https://rubygems.org/
  specs:
    CFPropertyList (2.3.2)
    actionmailer (4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.5)
      actionview (= 4.2.5)
      activesupport (= 4.2.5)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview-encoded_mail_to (1.0.7)
      rails
    activejob (4.2.5)
      activesupport (= 4.2.5)
      globalid (>= 0.3.0)
    activemodel (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
    activerecord (4.2.5)
      activemodel (= 4.2.5)
      activesupport (= 4.2.5)
      arel (~> 6.0)
    activesupport (4.2.5)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    acts-as-taggable-on (3.5.0)
      activerecord (>= 3.2, < 5)
    acts_as_indexed (0.8.3)
    addressable (2.4.0)
    angular-rails-templates (1.0.0)
      railties (>= 4.2, < 6)
      sprockets (~> 3.0)
      tilt
    arel (6.0.3)
    awesome_nested_set (3.0.3)
      activerecord (>= 4.0.0, < 5)
    babosa (1.0.2)
    bcrypt (3.1.10)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    bootstrap-sass (3.1.0.2)
      sass (~> 3.2)
    bootstrap-sass-rails (3.1.0.0)
      bootstrap-sass (~> 3.1.0.0)
      railties (>= 3.2.0)
      sass-rails (>= 3.2.0)
    bower-rails (0.10.0)
    builder (3.2.2)
    byebug (8.2.2)
    carmen (1.0.2)
      activesupport (>= 3.0.0)
    carmen-rails (1.0.1)
      carmen (~> 1.0.0)
      rails
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    concurrent-ruby (1.0.0)
    debug_inspector (0.0.2)
    decorators (2.0.1)
      railties (>= 4.0.0, < 5.0.0)
    devise (3.5.6)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      responders
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    dragonfly (1.0.12)
      addressable (~> 2.3)
      multi_json (~> 1.0)
      rack (>= 1.3.0)
    dragonfly-s3_data_store (1.2)
      dragonfly (~> 1.0)
      fog-aws
    erubis (2.7.0)
    excon (0.45.4)
    execjs (2.6.0)
    filters_spam (0.5)
    fission (0.5.0)
      CFPropertyList (~> 2.2)
    fog (1.37.0)
      fog-aliyun (>= 0.1.0)
      fog-atmos
      fog-aws (>= 0.6.0)
      fog-brightbox (~> 0.4)
      fog-core (~> 1.32)
      fog-dynect (~> 0.0.2)
      fog-ecloud (~> 0.1)
      fog-google (<= 0.1.0)
      fog-json
      fog-local
      fog-powerdns (>= 0.1.1)
      fog-profitbricks
      fog-radosgw (>= 0.0.2)
      fog-riakcs
      fog-sakuracloud (>= 0.0.4)
      fog-serverlove
      fog-softlayer
      fog-storm_on_demand
      fog-terremark
      fog-vmfusion
      fog-voxel
      fog-vsphere (>= 0.4.0)
      fog-xenserver
      fog-xml (~> 0.1.1)
      ipaddress (~> 0.5)
    fog-aliyun (0.1.0)
      fog-core (~> 1.27)
      fog-json (~> 1.0)
      ipaddress (~> 0.8)
      xml-simple (~> 1.1)
    fog-atmos (0.1.0)
      fog-core
      fog-xml
    fog-aws (0.8.1)
      fog-core (~> 1.27)
      fog-json (~> 1.0)
      fog-xml (~> 0.1)
      ipaddress (~> 0.8)
    fog-brightbox (0.10.1)
      fog-core (~> 1.22)
      fog-json
      inflecto (~> 0.0.2)
    fog-core (1.36.0)
      builder
      excon (~> 0.45)
      formatador (~> 0.2)
    fog-dynect (0.0.2)
      fog-core
      fog-json
      fog-xml
    fog-ecloud (0.3.0)
      fog-core
      fog-xml
    fog-google (0.1.0)
      fog-core
      fog-json
      fog-xml
    fog-json (1.0.2)
      fog-core (~> 1.0)
      multi_json (~> 1.10)
    fog-local (0.2.1)
      fog-core (~> 1.27)
    fog-powerdns (0.1.1)
      fog-core (~> 1.27)
      fog-json (~> 1.0)
      fog-xml (~> 0.1)
    fog-profitbricks (0.0.5)
      fog-core
      fog-xml
      nokogiri
    fog-radosgw (0.0.5)
      fog-core (>= 1.21.0)
      fog-json
      fog-xml (>= 0.0.1)
    fog-riakcs (0.1.0)
      fog-core
      fog-json
      fog-xml
    fog-sakuracloud (1.7.5)
      fog-core
      fog-json
    fog-serverlove (0.1.2)
      fog-core
      fog-json
    fog-softlayer (1.1.0)
      fog-core
      fog-json
    fog-storm_on_demand (0.1.1)
      fog-core
      fog-json
    fog-terremark (0.1.0)
      fog-core
      fog-xml
    fog-vmfusion (0.1.0)
      fission
      fog-core
    fog-voxel (0.1.0)
      fog-core
      fog-xml
    fog-vsphere (0.6.0)
      fog-core
      rbvmomi (~> 1.8)
    fog-xenserver (0.2.3)
      fog-core
      fog-xml
    fog-xml (0.1.2)
      fog-core
      nokogiri (~> 1.5, >= 1.5.11)
    font-awesome-sass (4.5.0)
      sass (>= 3.2)
    formatador (0.2.5)
    friendly_id (5.1.0)
      activerecord (>= 4.0.0)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    globalize (5.0.1)
      activemodel (>= 4.2.0, < 4.3)
      activerecord (>= 4.2.0, < 4.3)
    hirb (0.7.3)
    i18n (0.7.0)
    inflecto (0.0.2)
    ipaddress (0.8.3)
    jbuilder (2.4.1)
      activesupport (>= 3.0.0, < 5.1)
      multi_json (~> 1.2)
    jquery-rails (4.1.0)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (5.0.5)
      railties (>= 3.2.16)
    json (1.8.3)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mime-types (2.99.1)
    mini_portile2 (2.0.0)
    minitest (5.8.4)
    multi_json (1.11.2)
    nokogiri (1.6.7.2)
      mini_portile2 (~> 2.0.0.rc2)
    orm_adapter (0.5.0)
    pg (0.18.4)
    quiet_assets (1.1.0)
      railties (>= 3.1, < 5.0)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.5)
      actionmailer (= 4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      activemodel (= 4.2.5)
      activerecord (= 4.2.5)
      activesupport (= 4.2.5)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.5)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    rails-i18n (4.0.8)
      i18n (~> 0.7)
      railties (~> 4.0)
    rails_autolink (1.1.6)
      rails (> 3.1)
    railties (4.2.5)
      actionpack (= 4.2.5)
      activesupport (= 4.2.5)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.5.0)
    rbvmomi (1.8.2)
      builder
      nokogiri (>= 1.4.1)
      trollop
    rdoc (4.2.2)
      json (~> 1.4)
    refinerycms-acts-as-indexed (2.0.1)
      acts_as_indexed (~> 0.8.0)
      decorators (~> 2.0.0)
      refinerycms-core (~> 3.0.0)
    refinerycms-authentication-devise (1.0.4)
      actionmailer (~> 4.2, >= 4.2.0)
      devise (~> 3.0, >= 3.2.4)
      friendly_id (~> 5.1.0)
      refinerycms-core (~> 3.0, >= 3.0.0)
    refinerycms-i18n (3.0.1)
      rails-i18n (~> 4.0.1)
      routing-filter (>= 0.4.0)
    refinerycms-settings (3.0.0)
      friendly_id (~> 5.0, >= 5.0.1)
      refinerycms-core (~> 3.0, >= 3.0.0)
    refinerycms-wymeditor (1.0.6)
      refinerycms-core (~> 3.0, >= 3.0.0)
    responders (2.1.1)
      railties (>= 4.2.0, < 5.1)
    routing-filter (0.5.1)
      actionpack (~> 4.2)
      activesupport (~> 4.2)
    sass (3.4.21)
    sass-rails (5.0.4)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    seo_meta (2.0.0.rc.1)
      railties (>= 3.0.0)
    speakingurl-rails (8.0.2)
      railties (>= 3.1)
    spring (1.6.3)
    sprockets (3.5.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.0.3)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    sqlite3 (1.3.11)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (2.0.2)
    trollop (2.1.2)
    truncate_html (0.9.3)
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (2.7.2)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    underscore-rails (1.8.3)
    warden (1.2.6)
      rack (>= 1.0)
    web-console (2.3.0)
      activemodel (>= 4.0)
      binding_of_caller (>= 0.7.2)
      railties (>= 4.0)
      sprockets-rails (>= 2.0, < 4.0)
    will_paginate (3.0.7)
    xml-simple (1.1.5)
    zilch-authorisation (0.0.1)

PLATFORMS
  ruby

DEPENDENCIES
  angular-rails-templates
  bower-rails
  byebug
  coffee-rails (~> 4.1.0)
  dragonfly-s3_data_store
  fog
  font-awesome-sass
  hirb
  jbuilder (~> 2.0)
  jquery-rails
  pg
  quiet_assets
  rails (= 4.2.5)
  refinerycms!
  refinerycms-acts-as-indexed (~> 2.0, >= 2.0.0)
  refinerycms-authentication-devise (~> 1.0)
  refinerycms-authorized_emails!
  refinerycms-blog!
  refinerycms-bootstrap!
  refinerycms-members!
  refinerycms-page-images!
  refinerycms-products!
  refinerycms-retailers!
  refinerycms-wiz_steps!
  refinerycms-wymeditor (~> 1.0, >= 1.0.6)
  sass-rails (~> 5.0)
  sdoc (~> 0.4.0)
  spring
  sprockets
  sqlite3
  turbolinks
  uglifier (>= 1.3.0)
  underscore-rails
  web-console (~> 2.0)

On Fri, Mar 11, 2016 at 11:36 AM, Brice Sanchez notifications@github.com wrote:

Could you copy/paste your Gemfile.lock and your error stacktrace ?

— Reply to this email directly or view it on GitHub https://github.com/refinery/refinerycms/issues/3131#issuecomment-195469876 .

bricesanchez commented 8 years ago

I don't what happens, perhaps a step-to-reproduce this error could help me.

parndt commented 8 years ago

Agreed, Brice. We're going to need a sample application or step by step for how to generate an extension with this issue.

ekonotek commented 8 years ago

I think I found a good explanation. I remembered that had modified the Refinery's core.rb for the app in question adding:

Register extra javascript for backend

config.register_javascript "custom"

Register extra stylesheet for backend (optional options)

config.register_stylesheet "custom", :media => 'screen'

And custom.js does not @include the WYMeditor (which I still need to find out how.)

I must apologize for sounding the alarm before checking throughly, and I really appriciate your rapid response.

Thank you again, Rafael.

P.S.

After Brice's response yesterday I went ahead and repeated step by step Generate an Extension to Use Your MVCs http://www.refinerycms.com/guides/generate-an-extension-to-use-your-mvcs in a sample very basic app I had stashed away. And to my surprise the text field did work as I wanted! The HTML editor was active. This led me to believe my other application (the one not working) must have something blocking the Javascript, I have not tested my theory but I'm almost sure now that is the cause. I'll let you know.

Refinery works great, I've been using it on and off since V 1.x with no complaints. Now I have even combined it with Angular 1.5 and every thing behaves as expected. This is why I needed the html to be saved in Refinery's extensions (html with embedded Angular directives and interpolations) which I then let Angular compile and display. This way the admins can make changes and see (or get an idea of) how it will look like. CMS and UI driven dynamic HTML. It's just GREAT!

On Mon, Mar 14, 2016 at 5:40 PM, Philip Arndt notifications@github.com wrote:

Agreed, Brice. We're going to need a sample application or step by step for how to generate an extension with this issue.

— Reply to this email directly or view it on GitHub https://github.com/refinery/refinerycms/issues/3131#issuecomment-196551934 .

parndt commented 8 years ago

Thanks a lot!!