<commit_before><%inherit file="base.mak"/>

<%block name="html_title">
    ${story.title} on ${site_name}
</%block>

% if logged_in:
    <script type="text/javascript">
    $(document).ready(function() {
        crf = $('#comment-reply-form').detach();
        $('.comment-reply').click(function(e) {
            crf.css('display', 'block');
            $($(e.target).closest('.comment')).append(crf);
            $('#comment_parent').attr('value', ($(e.target).attr('id')).replace('reply-', ''));
            $('#parent_type').attr('value', 'comment');
        });
        $('.comment-edit-link').click(function(e) {
            erf = crf.clone()
            $(erf).children('form').attr('action', '${request.route_url("full", sub_id = story.id)}?op=edit&comment_id=' + $(e.target).attr('data-comment-id'))
            erf.css('display', 'block');
            $($(erf).children('#reply-text')).text('Edit your Reply...')
            $(erf).find('#body-textarea').val($('#body-md-' + $(e.target).attr('data-comment-id')).text())
            $($(e.target).closest('.comment')).append(erf);
        });
        sef = $('#story-edit-form').detach();
        $('.story-edit-link').click(function(e) {
            sefi = sef.clone()
            sefi.css('display', 'block');
            $('#description').replaceWith(sefi);
        });

    });
    </script>
% endif

    % if success == False:
        <h1>${message}</h1>
    % else:
        <%include file="story_item.mak", args="story_obj = story, vote_dict = story_vote_dict"/>
        <div id="description" class="story-description">
            ${story.description | template_filters.render_md,n}
        </div>
        ##@TODO: make functionality to determine whether a user is logged in on display a reusable function
        ## I have vague memories of this but think it's on the server side, need to create a def that can
        ## be used in the Mako templates to determine this, would be much better that way.
        % if (logged_in and request.session['users.id'] == str(story.added_by)) or logged_in_admin:
            <a href="javascript:void(0)" class=" story-edit-link logged-in-only ">edit this description</a><br/>
        % endif
        <h2>Comments</h2>
        <h3> Add a new comment </h3>
        <form method="post" id="story-reply-form" action="${request.route_url('full', sub_id = story.id)}">
            <textarea name="body" cols="50" rows="10"></textarea>
            <input type="hidden" name="comment_parent" id="comment_parent-story" value="${story.id}" />
            <input type="hidden" name="parent_type" id="parent_type-story" value="story" />
            <br />
            <input type="submit" value="Add Comment"></input>
        </form>
        <%def name="print_comment_tree(c, margin)"><commit_msg>Do not display comment box if user is not logged in.<commit_after><%inherit file="base.mak"/>

<%block name="html_title">
    ${story.title} on ${site_name}
</%block>

% if logged_in:
    <script type="text/javascript">
    $(document).ready(function() {
        crf = $('#comment-reply-form').detach();
        $('.comment-reply').click(function(e) {
            crf.css('display', 'block');
            $($(e.target).closest('.comment')).append(crf);
            $('#comment_parent').attr('value', ($(e.target).attr('id')).replace('reply-', ''));
            $('#parent_type').attr('value', 'comment');
        });
        $('.comment-edit-link').click(function(e) {
            erf = crf.clone()
            $(erf).children('form').attr('action', '${request.route_url("full", sub_id = story.id)}?op=edit&comment_id=' + $(e.target).attr('data-comment-id'))
            erf.css('display', 'block');
            $($(erf).children('#reply-text')).text('Edit your Reply...')
            $(erf).find('#body-textarea').val($('#body-md-' + $(e.target).attr('data-comment-id')).text())
            $($(e.target).closest('.comment')).append(erf);
        });
        sef = $('#story-edit-form').detach();
        $('.story-edit-link').click(function(e) {
            sefi = sef.clone()
            sefi.css('display', 'block');
            $('#description').replaceWith(sefi);
        });

    });
    </script>
% endif

    % if success == False:
        <h1>${message}</h1>
    % else:
        <%include file="story_item.mak", args="story_obj = story, vote_dict = story_vote_dict"/>
        <div id="description" class="story-description">
            ${story.description | template_filters.render_md,n}
        </div>
        ##@TODO: make functionality to determine whether a user is logged in on display a reusable function
        ## I have vague memories of this but think it's on the server side, need to create a def that can
        ## be used in the Mako templates to determine this, would be much better that way.
        % if (logged_in and request.session['users.id'] == str(story.added_by)) or logged_in_admin:
            <a href="javascript:void(0)" class=" story-edit-link logged-in-only ">edit this description</a><br/>
        % endif
        <h2>Comments</h2>
        % if 'logged_in' in request.session:
            <h3> Add a new comment </h3>
            <form method="post" id="story-reply-form" action="${request.route_url('full', sub_id = story.id)}">
                <textarea name="body" cols="50" rows="10"></textarea>
                <input type="hidden" name="comment_parent" id="comment_parent-story" value="${story.id}" />
                <input type="hidden" name="parent_type" id="parent_type-story" value="story" />
                <br />
                <input type="submit" value="Add Comment"></input>
            </form>
        % else:
            You can leave a comment after you log in (use the box on the right of your screen).<br />
        % endif
        <%def name="print_comment_tree(c, margin)">
{'fraction_non_alphanumeric': 0.19399656946826757, 'fraction_numerical': 0.0037735849056603774, 'mean_word_length': 2.6239900559353635, 'pattern_counts': {'":': 0, '<': 58, '<?xml version=': 0, '>': 58, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '108769', 'n_tokens_mistral': 1779, 'n_tokens_neox': 1745, 'n_words': 371}