Sha256: a5792cc50e8354531a51bdb646c7e122b1ac6aed6a9705980dd65480186688ba

Contents?: true

Size: 511 Bytes

Versions: 13

Compression:

Stored size: 511 Bytes

Contents

event :validate_json, :validate, on: :save, changed: :content do
  check_json_syntax if content.present?
end

def check_json_syntax
  parse_content
rescue JSON::ParserError => e
  errors.add tr(:invalid_json), e.message.sub(/^\d+: /, "").to_s
end

def parse_content
  JSON.parse content
end

def item_names _args={}
  parse_content.keys
end

format :html do
  view :core do
    process_content ::CodeRay.scan(_render_raw, :json).div
  end

  def editor
    :ace_editor
  end

  def ace_mode
    :json
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
card-1.98.3 mod/basic_types/set/type/json.rb
card-1.98.2 mod/basic_types/set/type/json.rb
card-1.98.1 mod/basic_types/set/type/json.rb
card-1.98.0 mod/basic_types/set/type/json.rb
card-1.97.0.1 mod/basic_types/set/type/json.rb
card-1.97.0 mod/basic_types/set/type/json.rb
card-1.96.8 mod/basic_types/set/type/json.rb
card-1.96.7 mod/basic_types/set/type/json.rb
card-1.96.6 mod/basic_types/set/type/json.rb
card-1.96.5 mod/basic_types/set/type/json.rb
card-1.96.4 mod/basic_types/set/type/json.rb
card-1.96.3 mod/basic_types/set/type/json.rb
card-1.96.2 mod/basic_types/set/type/json.rb