<commit_before><?php
/**
 * Web server entry point
 *
 * @author <NAME>
 * @license https://krinkle.mit-license.org/
 * @package mw-tool-snapshots
 */

require_once __DIR__ . '/../common.php';

$repoInfos = array(
	'mediawiki-core' => array(
		'display-title' => 'MediaWiki core',
		'img' => '//upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png',
		'site-url' => '//www.mediawiki.org/',
		'repo-browse-url' => 'https://github.com/wikimedia/mediawiki',
		'repo-branch-url' => 'https://github.com/wikimedia/mediawiki/tree/$1',
		'repo-commit-url' => 'https://github.com/wikimedia/mediawiki/commit/$1',
	),
);

$snapshotInfo = $kgTool->getInfoCache();

$kgBase->addOut( '<div class="container">' );
$pageHtml = '';

/**
 * Output (snapshot index check)
 * -------------------------------------------------
 */
if ( !$snapshotInfo ) {
	$pageHtml .= kfAlertHtml( 'danger', $I18N->msg( 'err-snapshotindex' ) );

/**
 * Output (show update log)
 * -------------------------------------------------
 */
} elseif ( $kgReq->getVal( 'action' ) === 'updatelog' ) {

	$kgBase->setHeadTitle( $I18N->msg( 'title-updatelog' ) );
	$kgBase->setLayout( 'header', array(
		'titleText' => $I18N->msg( 'title-updatelog' )
	) );

	$pageHtml .= Html::element( 'p', array( 'class' => 'lead' ), $I18N->msg( 'updatelog-intro' ) );

	if ( !$kgTool->getUpdateLogFilePath() ) {
		// Error: No update log
		$pageHtml .= kfAlertHtml( 'danger', $I18N->msg( 'err-noupdatelog' ) );
	} else {
		$notice = $kgTool->isUpdateLogActive()
			? kfAlertHtml( 'warning', $I18N->msg( 'updatelog-active' ) )
			: '';

		$pageHtml .= $notice
			. Html::element( 'pre', array(),
				$kgTool->getUpdateLogContent()
			)
			. $notice;
	}

/**
 * Output (get snapshot)
 * -------------------------------------------------
 */
} elseif (  $kgReq->wasPosted() && $kgReq->getVal( 'action' ) === 'getSnapshot' ) {

	$title = $I18N->msg( 'title-downloadpage' );
	$kgBase->setHeadTitle( $title );
	$kgBase->setLayout( 'header', array( 'titleText' => $title ) );

	$repoName = $kgReq->getVal( 'repo' );
	$branchName = $kgReq->getVal( 'branch' );
	$isAjax = $kgReq->getBool( 'ajax' );
	$downloadUrl = null;

	if ( !isset( $repoInfos[$repoName] ) || !isset( $snapshotInfo[$repoName] ) ) {
		// Error: Invalid repo
		$pageHtml .= MwSnapshots::getPanelHtml( 'warning', $I18N->msg( 'err-invalid-repo', array(
			'variables' => array( $repoName )
		) ) );
	} else {
		$repoInfo = $repoInfos[$repoName];
		$data = $snapshotInfo[$repoName];

		// Error: Invalid branch
		if ( !isset( $data['branches'][$branchName] ) ) {
		$pageHtml .= MwSnapshots::getPanelHtml( 'warning', $I18N->msg( 'err-invalid-branch', array(<commit_msg>Fixup: Use Request::getBool -> hasKey (removed in basetool v0.4.0)<commit_after><?php
/**
 * Web server entry point
 *
 * @author <NAME>
 * @license https://krinkle.mit-license.org/
 * @package mw-tool-snapshots
 */

require_once __DIR__ . '/../common.php';

$repoInfos = array(
	'mediawiki-core' => array(
		'display-title' => 'MediaWiki core',
		'img' => '//upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png',
		'site-url' => '//www.mediawiki.org/',
		'repo-browse-url' => 'https://github.com/wikimedia/mediawiki',
		'repo-branch-url' => 'https://github.com/wikimedia/mediawiki/tree/$1',
		'repo-commit-url' => 'https://github.com/wikimedia/mediawiki/commit/$1',
	),
);

$snapshotInfo = $kgTool->getInfoCache();

$kgBase->addOut( '<div class="container">' );
$pageHtml = '';

/**
 * Output (snapshot index check)
 * -------------------------------------------------
 */
if ( !$snapshotInfo ) {
	$pageHtml .= kfAlertHtml( 'danger', $I18N->msg( 'err-snapshotindex' ) );

/**
 * Output (show update log)
 * -------------------------------------------------
 */
} elseif ( $kgReq->getVal( 'action' ) === 'updatelog' ) {

	$kgBase->setHeadTitle( $I18N->msg( 'title-updatelog' ) );
	$kgBase->setLayout( 'header', array(
		'titleText' => $I18N->msg( 'title-updatelog' )
	) );

	$pageHtml .= Html::element( 'p', array( 'class' => 'lead' ), $I18N->msg( 'updatelog-intro' ) );

	if ( !$kgTool->getUpdateLogFilePath() ) {
		// Error: No update log
		$pageHtml .= kfAlertHtml( 'danger', $I18N->msg( 'err-noupdatelog' ) );
	} else {
		$notice = $kgTool->isUpdateLogActive()
			? kfAlertHtml( 'warning', $I18N->msg( 'updatelog-active' ) )
			: '';

		$pageHtml .= $notice
			. Html::element( 'pre', array(),
				$kgTool->getUpdateLogContent()
			)
			. $notice;
	}

/**
 * Output (get snapshot)
 * -------------------------------------------------
 */
} elseif (  $kgReq->wasPosted() && $kgReq->getVal( 'action' ) === 'getSnapshot' ) {

	$title = $I18N->msg( 'title-downloadpage' );
	$kgBase->setHeadTitle( $title );
	$kgBase->setLayout( 'header', array( 'titleText' => $title ) );

	$repoName = $kgReq->getVal( 'repo' );
	$branchName = $kgReq->getVal( 'branch' );
	$isAjax = $kgReq->hasKey( 'ajax' );
	$downloadUrl = null;

	if ( !isset( $repoInfos[$repoName] ) || !isset( $snapshotInfo[$repoName] ) ) {
		// Error: Invalid repo
		$pageHtml .= MwSnapshots::getPanelHtml( 'warning', $I18N->msg( 'err-invalid-repo', array(
			'variables' => array( $repoName )
		) ) );
	} else {
		$repoInfo = $repoInfos[$repoName];
		$data = $snapshotInfo[$repoName];

		// Error: Invalid branch
		if ( !isset( $data['branches'][$branchName] ) ) {
		$pageHtml .= MwSnapshots::getPanelHtml( 'warning', $I18N->msg( 'err-invalid-branch', array(
{'fraction_non_alphanumeric': 0.26811594202898553, 'fraction_numerical': 0.007989594946116686, 'mean_word_length': 3.078030303030303, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 78, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1963206', 'n_tokens_mistral': 2072, 'n_tokens_neox': 1976, 'n_words': 328}