krang_create_story - Create a story via the command line
$ bin/krang_create_story --type="article" --title="..." --slug="..."
This script creates a story in Krang and publishes it.
When the script succeeds it will print a single line and exit
OK ID URL
The ID and URL is the URL of the published form. Errors will result in a non-zero exit and an error message on STDERR.
For example, calling:
bin/krang_create_story --type="article" \
--title="Test Article" \
--slug="test_arcticle" \
--element paragraph='some text' \
--element metadata_title='some more text'
Might result in:
OK 10 mysite.com/test_article FA47EA5C-0F23-11DE-9999-71D3CB6E427A
Element class of story to create
Title of the story
Slug for the story
The url of the site the story will live in. Defaults to the first site found.
--site "mysite.com"
The path of the category the story will live in. Defaluts to the root category in the site. If the category doesn't already exist it will be created.
--category "/foo/bar"
Takes a name/value pair and adds the named element to the story with the specified value. This option can be used mutiple times to setup multiple elements.
If the element you are trying to setup uses an Array or a Hash as it's data store you can just format your data to look like a Perl Array or Hash:
--element foo="[1, 2, 3, 4]"
--element bar="['one', 'two', 'three']"
--element baz="{ asd => 1, qwe => 2 }"
If this is what you want, make sure to start and end your value with
the right opening and closing tokens (ie, either [] or {}).
If the element's name ends with _date then we will convert it into a Time::Piece
object and assume the date is in the format DD-MM-YYYY.
--element start_date="12-03-2009"
If the element's name ends with _time then we will convert it into a Time::Piece
object and assume the date is in the format HH:MM.
--element start_time="14:30"
If you need to handle a nested element then you can use a special syntax wrapping
your data in angle-brackets <>. The data inside of the angle-brackets is
syntactically treated as a Perl Hash which is used to create and fill any child elements.
We only handle the case of nesting 1 level deep. Anything else is more complicated
than this script can handle.
--element complex_element="< child_1 => 'foo', child_2 => 'bar' >"
If you want to specify Media objects to be added to the story you just give it the name of the child element and then the filename of the media object:
--media audio="itchyscratchy.mp3"
If the element you want to add is a Story Link you can specify the story's id, UUID or url:
--story-link more_info="123"
--story-link more_info="FA47EA5C-0F23-11DE-9999-71D3CB6E427A"
--story-link more_info="/foo/more_info"
If the element you want to add is a Story Link you can specify the Category's id, UUID or url:
--category-link more_info="123"
--category-link more_info="FA47EA5C-0F23-11DE-9999-71D3CB6E427A"
--story-link more_info="/foo/bar"
Flag that causes the story to be published to preview as well as to the normal publish path.
The cover date in the format DD-MM-YYYY.
If you want to edit an existing story instead of creating a new one,
you can specify the Story's uuid. If you do this than any --type,
--category or --site arguments are ignored.