Example Script

The following example bash script shows how to construct a content creation URL and submit it to CUE.

#!/bin/bash

urlencode() {
    # urlencode <string>
    old_lc_collate=$LC_COLLATE
    LC_COLLATE=C

    local length="${#1}"
    for (( i = 0; i < length; i++ )); do
        local c="${1:i:1}"
        case $c in
            [a-zA-Z0-9.~_-]) printf "$c" ;;
            *) printf '%%%02X' "'$c" ;;
        esac
    done
    LC_COLLATE=$old_lc_collate
}

cue="http://your-cue-host/cue-web"
webservice="http://your-escenic-webservice-host/webservice"
homesection="$webservice/escenic/section/section-id"
modeluri="$webservice/escenic/publication/demopub/model/content-type/story"
relations=("Content_ID1|group1" "Content_ID2|group2") # eg. ("2015|images" "2016|images")

mimetype="x-ece/new-content; type=story"
sourceid=`date '+%y%m%d-%H%M%S'`
title="My Title"
body="<p>My first paragraph.</p><p>My second paragraph.</p>"

relationsJSON="["
for i in "${relations[@]}"
do :
   contentUri=`echo $i | cut -d'|' -f1`
   contentUri="$webservice/escenic/content/$contentUri"
   group=`echo $i | cut -d'|' -f2`
   relationsJSON="$relationsJSON{\"group\":\"${group}\",\"contentUri\":\"${contentUri}\"},"
done
if [ ${#relationsJSON} -gt 1 ]
then
    relationsJSON="${relationsJSON%?}]"
else
    relationsJSON="$relationsJSON]"
fi
extra="{\"modelURI\":{\"string\":\"${modeluri}\",\"\$class\":\"URI\"},\"homeSectionUri\":\"${homesection}\",\"values\":{\"title\":\"${title}\",\"body\":\"${body}\"},\"relations\":${relationsJSON}}"

url=$cue/#/main?uri=$(urlencode "$sourceid")\&mimetype=$(urlencode "$mimetype")\&extra=$(urlencode "$extra")

google-chrome $url &

If you edit this script to match your installation, then running it should start the Chrome browser and create a draft content item with the title "My Title". You would need to replace your-cue-host and your-escenic-webservice-host with the correct host names and replace section-id with the ID of a section in one of your publications before running it. Otherwise, as long as you have a content type called story, it should work.