<{assert_topic_editor %topic}>
<{header}>

<div class = 'main'>

<h1><{@"Story data"}></h1>

<form method = 'post' action = '<{url}>'>

	<input type = 'submit' class = 'button' value = 'OK'>

	<input type = 'hidden' name = 't' value = 'SAVE_STORY'>
	<input type = 'hidden' name = 'topic' value = '<{or %cp_topic %topic}>'>

	<p><{@"Publication date: (empty, today)"}><br>

    <label for = 'day'><{@"Day:"}></label>
    <input
        type    = 'text'
        size    = '2'
        name    = 'day'
        id      = 'day'
        value   = '<{story_date '%d' %topic %id}>'
    />
    <label for = 'month'><{@"Month:"}></label>
    <input
        type    = 'text'
        size    = '2'
        name    = 'month'
        id      = 'month'
        value   = '<{story_date '%m' %topic %id}>'
    />
    <label for = 'year'><{@"Year:"}></label>
    <input
        type    = 'text'
        size    = '4'
        name    = 'year'
        id      = 'year'
        value   = '<{story_date '%y' %topic %id}>'
    />

	<p><{@"Liberation date for non-subscribers: (empty, same as above)"}><br>

    <label for = 'day2'><{@"Day:"}></label>
    <input
        type    = 'text'
        size    = '2'
        name    = 'day2'
        id      = 'day2'
        value   = '<{story_date2 '%d' %topic %id}>'
    />
    <label for = 'month2'><{@"Month:"}></label>
    <input
        type    = 'text'
        size    = '2'
        name    = 'month2'
        id      = 'month2'
        value   = '<{story_date2 '%m' %topic %id}>'
    />
    <label for = 'year2'><{@"Year:"}></label>
    <input
        type    = 'text'
        size    = '4'
        name    = 'year2'
        id      = 'year2'
        value   = '<{story_date2 '%y' %topic %id}>'
    />

	<p><{@"Unpublish date (empty, never)"}><br>

    <label for = 'uday'><{@"Day:"}></label>
    <input
        type    = 'text'
        size    = '2'
        name    = 'uday'
        id      = 'uday'
        value   = '<{story_udate '%d' %topic %id}>'
    />
    <label for = 'umonth'><{@"Month:"}></label>
    <input
        type    = 'text'
        size    = '2'
        name    = 'umonth'
        id      = 'umonth'
        value   = '<{story_udate '%m' %topic %id}>'
    />
    <label for = 'uyear'><{@"Year:"}></label>
    <input
        type    = 'text'
        size    = '4'
        name    = 'uyear'
        id      = 'uyear'
        value   = '<{story_udate '%y' %topic %id}>'
    />

    <p><label for = 'hits'>
        <{@"Hits:"}>
    </label><br>
    <input
        size    = '15'
        type    = 'text'
        name    = 'hits'
        id      = 'hits'
        value   = '<{story_hits %topic %id}>'
    />

    <p><label for = 'description'>
        <{@"Description: (about 15 words)"}>
    </label><br>
    <input
        size    = '80'
        type    = 'text'
        name    = 'description'
        id      = 'description'
        value   = '<{story_description %topic %id}>'
    />

	<p><label for = 'format'><{@"Format:"}></label><br>
	<select name = 'format' id = 'format'>
	<{foreach renderers {
		option $0 $0
			{if {eq $0 {story_format %topic %id}} 'selected'}
		}
	}>
	</select>

	<{if {eq {or %cp_id %id} '[]'}
		{
			'<p><label for = "id">'
			@"Story id: (Optional; if you don't know what it means, leave it blank)"
			'</label><br>'
			"<input type = 'text' size = '32' name = 'id' id = 'id' value = ''>"
		}
		{
			"<input type = 'hidden' name = 'id' id = 'id' value = '"
			{or %cp_id %id}
			"'>"
		}
	}>

    <p><label for = 'tags'><{@"Tags: (comma-separated)"}></label><br>
    <input
        type    = 'text'
        size    = '60'
        name    = 'tags'
        id      = 'tags'
        value   = '<{foreach {story_tags %topic %id} $0 ', '}>'
    />

    <p><label for = 'toc'>
        <{@"Generate table of contents? (grutatxt only)"}>
    </label><br>
    <input
        type    = 'checkbox'
        name    = 'toc'
        id      = 'toc'
        <{if {story_toc %topic %id} "checked"}>
    />

    <p><label for = 'has_comments'>
        <{@"Allow comments from visitors?"}>
    </label><br>
    <input
        type    = 'checkbox'
        name    = 'has_comments'
        id      = 'has_comments'
        <{if {or
                {story_has_comments %topic %id}
                {if {eq %id '[]'} {not cfg_disable_comments}}
            }
            "checked"
        }>
    />

    <p><label for = 'full_story'>
        <{@"Show full story in indexes?"}>
    </label><br>
    <input
        type    = 'checkbox'
        name    = 'full_story'
        id      = 'full_story'
        <{if {or
                {story_full_story %topic %id}
                {if {eq %id '[]'} {cfg_full_story}}
            }
            "checked"
        }>
    />

	<p><label for = 'content'><{@"Content:"}></label>
    <span id='word_count'></span><br>

    <script>
    function count_words() {
        t = document.getElementById('content');
        l = document.getElementById('word_count');

        s = t.value;

        s = s.replace(/(^\s*)|(\s*$)/gi, "");
        s = s.replace(/[ ]{2,}/gi, "");
        s = s.replace(/\n /, "\n");

        l.textContent = s.split(' ').length;
    }
    </script>

    <textarea
        name    = 'content'
        id      = 'content'
        cols    = '80'
        rows    = '30'
        onkeyup = 'javascript:count_words();'
        wrap    = 'virtual'><{story_content %topic %id}></textarea>

    <p>
    <input type = 'submit' class = 'button' value = 'OK'>
</form>

<form method = 'post' onsubmit =
		'return confirm("<{@"Are you sure you want to delete this story?"}>");' action = '<{url}>'>
	<input type = 'hidden' name = 't'		value = 'DELETE_STORY'>
	<input type = 'hidden' name = 'topic'	value = '<{%topic}>'>
	<input type = 'hidden' name = 'id'		value = '<{%id}>'>
	<input type = 'submit' class = 'button'	value = '<{@"DELETE"}>'>
</form>

<form method = 'get' action = '<{url}>'>
	<input type = 'hidden' name = 't'		value = 'EDIT_STORY'>
	<input type = 'hidden' name = 'topic'	value = '<{%topic}>'>
	<input type = 'hidden' name = 'id'		value = '<{%id}>'>
	<input type = 'hidden' name = 'cp_id'	value = '[]'>
	<input type = 'submit' class = 'button'	value = '<{@"COPY"}>'>
	<select name = 'cp_topic'>
		<{foreach topics {option $0 {topic_name $0}}}>
	</select>
</form>

</div>

<{footer}>
