Sha256: 850f81ed89f8f64805d7ab1c19f06a23f96a169368e7882dcfc221198b20a75a

Contents?: true

Size: 1.53 KB

Versions: 16

Compression:

Stored size: 1.53 KB

Contents

format :json do

  def get_inclusion_defaults nested_card
    { :view=>:atom }
  end

  def default_item_view
    params[:item] || :atom
  end
  
  def max_depth
    params[:max_depth] || 1
  end
  
  def show view, args
    view ||= :content
    raw = render view, args
    case
    when String === raw    ;  raw
    when params[:compress] ;  JSON( raw )
    else                   ;  JSON.pretty_generate raw
    end
  end

  view :name_complete do |args|
    card.item_cards :complete=>params['term'], :limit=>8, :sort=>'name', :return=>'name', :context=>''
  end
  
  view :status, :tags=>:unknown_ok, :perms=>:none do |args|
    status = case
    when !card.known?       ;  :unknown
# do we want the following to prevent fishing?  of course, they can always post...        
    when !card.ok?(:read)   ;  :unknown
    when card.real?         ;  :real
    when card.virtual?      ;  :virtual
    else                    ;  :wtf
    end
    
    hash = { :key=>card.key, :url_key=>card.cardname.url_key, :status=>status }
    hash[:id] = card.id if status == :real
     
    hash
  end

  view :content do |args|
    req = controller.request
    {
      :url       => (req && req.original_url),
      :timestamp => Time.now.to_s,
      :card      => _render_atom
    }
  end
  
  view :atom do |args|
    h = {
      :name    => card.name,
      :type    => card.type_name
    }
    h[:content]  = card.content  unless card.structure
    h[:codename] = card.codename     if card.codename
    h[:value]    = _render_core args if @depth < max_depth
    h
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
card-1.16.6 mod/02_basic_types/set/all/json.rb
card-1.16.5 mod/02_basic_types/set/all/json.rb
card-1.16.4 mod/02_basic_types/set/all/json.rb
card-1.16.3 mod/02_basic_types/set/all/json.rb
card-1.16.2 mod/02_basic_types/set/all/json.rb
card-1.16.1 mod/02_basic_types/set/all/json.rb
card-1.16.0 mod/02_basic_types/set/all/json.rb
card-1.15.7 mod/02_basic_types/set/all/json.rb
card-1.15.6 mod/02_basic_types/set/all/json.rb
card-1.15.5 mod/02_basic_types/set/all/json.rb
card-1.15.4 mod/02_basic_types/set/all/json.rb
card-1.15.3 mod/02_basic_types/set/all/json.rb
card-1.15.2 mod/02_basic_types/set/all/json.rb
card-1.15.1 mod/02_basic_types/set/all/json.rb
card-1.15.0 mod/02_basic_types/set/all/json.rb
card-1.15.pre2 mod/02_basic_types/set/all/json.rb