<{
{content_type "application/json"}

{case %c
"topics" {
    {?
        '['
        {foreach topics {? '"' $0 '"'} ","}
        ']'
    }
}

"stories_by_date" {
    {?
        '['
        {foreach
            {stories_by_date %topics {or %num 10} {or %offset 0} '' '' 0 %tags}
            {story_as_json $0 $1 %full}
            ",\n"
        }
        ']'
    }
}

"stories_by_tag" {
    {?
        '['
        {foreach
            {stories_by_tag {or %topics ""} %tags}
            {story_as_json $0 $1 %full}
            ",\n"
        }
        ']'
    }
}

"touch" {
    {touch_story %topic_id %id}
    {? '{"hits":' {story_hits %topic_id %id} '}' }
}

"story" {
    {story_as_json %topic_id %id 1}
}

}>