<commit_before><?php
namespace app;
use attr;
/** @var callable $var */
?>
<section class="block-index">
    <?php if ($var('title')): ?>
    <h2><?php echo $var('title'); ?></h2>
    <?php endif; ?>
    <?php if ($var('filter')): ?>
    <details>
        <summary><?php echo i18n('Filter'); ?></summary>
        <?php echo $var('filter'); ?>
    </details>
    <?php endif; ?>
    <?php if ($var('data')): ?>
    <div class="content">
        <?php if ($var('head')): ?>
        <div class="thead">
            <?php foreach ($var('attr') as $attr): ?>
                <?php
                $qsort = ($attr['id'] === $var('sort') ? '-' : '') . $attr['id'];
                $sorted = $var('sort') && $attr['id'] === ltrim($var('sort'), '-');
                $sort = $var('sort') && $var('sort')[0] === '-' ? 'desc' : 'asc';
                ?>
            <a<?php if ($var('sortable')): ?> href="<?php echo urlquery(['sort' => $qsort], true); ?>"<?php if ($sorted): ?> data-sort="<?php echo $sort; ?>"<?php endif; ?><?php endif; ?>><?php echo $attr['name']; ?></a>
            <?php endforeach; ?>
            <?php if ($var('actions')): ?>
            <a><?php echo i18n('Actions'); ?></a>
            <?php endif; ?>
        </div>
        <?php endif; ?>
        <?php foreach ($var('data') as $data): ?>
            <?php
            $entity = !empty($data['entity_id']) ? cfg('entity', $data['entity_id']) : null;
            $entityId = $entity && $entity['parent_id'] === $data['_entity']['id'] ? $entity['id'] : $data['_entity']['id'];
            $id = ($entity && $entity['parent_id'] === 'block' ? $entity['id'] . '-' : '') . $data['id'];
            $src = $entity && $entity['parent_id'] === 'file' ? $data['name'] : null;
            $name = $data['name'] ?? $data['id'];
            ?>
        <article data-id="<?php echo $id; ?>" data-name="<?php echo $name; ?>"<?php if ($src): ?> data-src="<?php echo $src; ?>"<?php endif; ?>>
            <?php foreach ($var('attr') as $attr): ?>
            <?php echo attr\viewer($data, $attr, ['empty' => $var('head'), 'label' => true, 'subheading' => true, 'wrap' => true]); ?>
            <?php endforeach; ?>
            <?php if ($var('actions')): ?>
            <footer>
                <?php foreach ($var('actions') as $action): ?>
                    <?php
                    $label = i18n(ucwords($action));
                    $url = $action === 'view' && !empty($data['url']) ? $data['url'] : actionurl($entityId, $action, $data['id']);
                    $url = allowed(id($entityId, $action)) ? $url : null;
                    ?>
                <a<?php if ($url): ?> href="<?php echo $url; ?>"<?php endif; ?> data-action="<?php echo $action; ?>" title="<?php echo $label; ?>"><?php echo $label; ?></a>
                <?php endforeach; ?>
            </footer>
            <?php endif; ?>
        </article>
        <?php endforeach; ?>
    </div>
    <?php endif; ?>
    <?php echo $var('pager'); ?>
</section><commit_msg>Simplify index template<commit_after><?php
namespace app;
use attr;
/** @var callable $var */
?>
<section class="block-index">
    <?php if ($var('title')): ?>
    <h2><?php echo $var('title'); ?></h2>
    <?php endif; ?>
    <?php if ($var('filter')): ?>
    <details>
        <summary><?php echo i18n('Filter'); ?></summary>
        <?php echo $var('filter'); ?>
    </details>
    <?php endif; ?>
    <?php if ($var('data')): ?>
    <div class="content">
        <?php if ($var('head')): ?>
        <div class="thead">
            <?php foreach ($var('attr') as $attr): ?>
                <?php
                $qsort = ($attr['id'] === $var('sort') ? '-' : '') . $attr['id'];
                $sorted = $var('sort') && $attr['id'] === ltrim($var('sort'), '-');
                $sort = $var('sort') && $var('sort')[0] === '-' ? 'desc' : 'asc';
                ?>
            <a<?php if ($var('sortable')): ?> href="<?php echo urlquery(['sort' => $qsort], true); ?>"<?php if ($sorted): ?> data-sort="<?php echo $sort; ?>"<?php endif; ?><?php endif; ?>><?php echo $attr['name']; ?></a>
            <?php endforeach; ?>
            <?php if ($var('actions')): ?>
            <a><?php echo i18n('Actions'); ?></a>
            <?php endif; ?>
        </div>
        <?php endif; ?>
        <?php foreach ($var('data') as $data): ?>
            <?php
            $entity = !empty($data['entity_id']) ? cfg('entity', $data['entity_id']) : null;
            $entityId = $entity && $entity['parent_id'] === $data['_entity']['id'] ? $entity['id'] : $data['_entity']['id'];
            $id = ($entity && $entity['parent_id'] === 'block' ? $entity['id'] . '-' : '') . $data['id'];
            $src = $entity && $entity['parent_id'] === 'file' ? $data['name'] : null;
            $name = $data['name'] ?? $data['id'];
            ?>
        <article data-id="<?php echo $id; ?>" data-name="<?php echo $name; ?>"<?php if ($src): ?> data-src="<?php echo $src; ?>"<?php endif; ?>>
            <?php foreach ($var('attr') as $attr): ?>
            <?php echo attr\viewer($data, $attr, ['empty' => $var('head'), 'label' => true, 'subheading' => true, 'wrap' => true]); ?>
            <?php endforeach; ?>
            <?php if ($var('actions')): ?>
            <footer>
                <?php foreach ($var('actions') as $action): ?>
                    <?php if (!allowed(id($entityId, $action))) continue; ?>
                    <?php
                    $label = i18n(ucwords($action));
                    $url = $action === 'view' && !empty($data['url']) ? $data['url'] : actionurl($entityId, $action, $data['id']);
                    ?>
                <a href="<?php echo $url; ?>" data-action="<?php echo $action; ?>" title="<?php echo $label; ?>"><?php echo $label; ?></a>
                <?php endforeach; ?>
            </footer>
            <?php endif; ?>
        </article>
        <?php endforeach; ?>
    </div>
    <?php endif; ?>
    <?php echo $var('pager'); ?>
</section>
{'fraction_non_alphanumeric': 0.26453342268386665, 'fraction_numerical': 0.003015580499246105, 'mean_word_length': 2.19593147751606, 'pattern_counts': {'":': 0, '<': 142, '<?xml version=': 0, '>': 152, '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': '3659428', 'n_tokens_mistral': 1883, 'n_tokens_neox': 1867, 'n_words': 441}