<commit_before><?php namespace ProcessWire; ?>
<?php

$for = $sanitizer->text($input->get->for);

if($for):
    $input->whitelist('for', $for);
    $for = $sanitizer->selectorValue($for);

    $selector = "tags|summary|text|code|textgrid.text%=$for, limit=50, template=page|content-text|content-code|content-cta|content-media";

    if($user->isLoggedin()) $selector .= ", has_parent!=2";

    // Find pages that match the selector
    $matches = $pages->find($selector);
    // did we find any matches?
    if($matches->count):
?>
        <span>
            Found <?=$matches->count?> Pages
        </span>
        <?php foreach ($matches as $match): ?>
            <?php
                if(!in_array($match->template->title, ['content-cta', 'content-code', 'content-media', 'content-text', ])) {
                    $match = $match->parent;
                }
            ?>
            <article flex="100" flex-gt-sm="45" flex-gt-md="30">
                <?=articlePreview($match)?>
            </article>
        <?php endforeach; ?>
    <? else:?>
        <h2>Sorry, no results were found.</h2>
    <? endif; ?>
<? else: ?>
    <h2>Please enter a search term in the search box (upper right corner)</h2>
<? endif; ?><commit_msg>Updated search to use article excerpts<commit_after><?php namespace ProcessWire; ?>
<?php

$for = $sanitizer->text($input->get->for);

if($for):
    $input->whitelist('for', $for);
    $for = $sanitizer->selectorValue($for);

    $selector = "title|summary|codegrid.code|name|tags|summary|text|code|textgrid.text*=$for, limit=30, template=page|content-text|content-code|content-cta|content-media|overview";

    if($user->isLoggedin()) $selector .= ", has_parent!=2";

    // Find pages that match the selector
    $matches = $pages->find($selector)->not($homepage);
    // did we find any matches?
    if($matches->count):
    $filteredMatches = [];
    foreach ($matches as $match) {
        if(!in_array($match->template->title, ['content-cta', 'content-code', 'content-media', 'content-text'])) {
            $match = $match->parent;
        }
        array_push($filteredMatches, (string) $match);
    }
    $matches = array_unique($filteredMatches);
?>
        <h3>
            Found <?=count($matches)?> article<?=count($matches) > 1 ? 's' : ''?> for <strong><?=$for?></strong>.
        </h3>
        <?php foreach ($matches as $match): ?>
            <?php
                $match = $pages->get($match);
            ?>
            <article flex="100" flex-gt-sm="45" flex-gt-md="30">
                <?=articlePreview($match)?>
            </article>
        <?php endforeach; ?>
    <? else:?>
        <h2>Sorry, no results were found.</h2>
    <? endif; ?>
<? else: ?>
    <h2>Please enter a search term in the search box (upper right corner)</h2>
<? endif; ?>
{'fraction_non_alphanumeric': 0.19464285714285715, 'fraction_numerical': 0.01107142857142857, 'mean_word_length': 2.6903820816864297, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 71, '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': '3683232', 'n_tokens_mistral': 900, 'n_tokens_neox': 867, 'n_words': 179}