Address Steam Workshop search review notes

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-31 20:23:40 +00:00
parent 18b6bc1a14
commit 5af47cdcd1
3 changed files with 16 additions and 13 deletions

View file

@ -5,6 +5,7 @@ class SteamWorkshopService
{
private const MIN_INTERVAL = 15;
private const MAX_INTERVAL = 360;
private const STEAM_WORKSHOP_DETAIL_URL = 'https://steamcommunity.com/sharedfiles/filedetails/';
private OGPDatabase $db;
private string $configDir;
@ -714,16 +715,16 @@ class SteamWorkshopService
private function fetchWorkshopItemByScrape(string $id): array
{
$id = preg_replace('/[^0-9]/', '', $id);
$sanitizedId = preg_replace('/[^0-9]/', '', $id);
$request = [
'backend' => 'scraper_http',
'url' => 'https://steamcommunity.com/sharedfiles/filedetails/',
'params' => ['id' => $id],
'url' => self::STEAM_WORKSHOP_DETAIL_URL,
'params' => ['id' => $sanitizedId],
'http_code' => null,
'transport_error' => null,
];
if ($id === '') {
if ($sanitizedId === '') {
$request['summary'] = $this->formatRequestSummary($request);
return ['item' => null, 'request' => $request, 'error' => 'Invalid Workshop ID.'];
}
@ -745,12 +746,12 @@ class SteamWorkshopService
$title = $this->parseWorkshopTitle((string)$response['body']);
if ($title === '') {
$title = '@' . $id;
$title = '@' . $sanitizedId;
}
return [
'item' => [
'id' => $id,
'id' => $sanitizedId,
'label' => $title,
'author' => '',
'preview_url' => '',
@ -960,7 +961,7 @@ class SteamWorkshopService
$results = [];
foreach ($sliceIds as $id) {
$detailResponse = $this->httpGet('https://steamcommunity.com/sharedfiles/filedetails/', ['id' => $id], $this->getScraperUserAgent());
$detailResponse = $this->httpGet(self::STEAM_WORKSHOP_DETAIL_URL, ['id' => $id], $this->getScraperUserAgent());
$title = '';
if ($detailResponse['error'] === null && $detailResponse['http_code'] >= 200 && $detailResponse['http_code'] < 300 && $detailResponse['body'] !== null) {
$title = $this->parseWorkshopTitle((string)$detailResponse['body']);

View file

@ -5,6 +5,7 @@
function Picker(root) {
this.root = root;
this.endpoint = root.getAttribute('data-endpoint') || '';
this.detailBase = root.getAttribute('data-detail-base') || 'https://steamcommunity.com/sharedfiles/filedetails/?id=';
this.lang = {
add: root.getAttribute('data-lang-add') || 'Add',
remove: root.getAttribute('data-lang-remove') || 'Remove',
@ -260,9 +261,10 @@
this.requestSummary.textContent = base;
return;
}
var isId = /^\d+$/.test(term);
if (isId) {
this.requestSummary.textContent = 'https://steamcommunity.com/sharedfiles/filedetails/?id=' + encodeURIComponent(term);
// Numeric-only terms are treated as Workshop item IDs and link to detail pages instead of search.
var isWorkshopId = /^\d+$/.test(term);
if (isWorkshopId) {
this.requestSummary.textContent = this.detailBase + encodeURIComponent(term);
return;
}
this.requestSummary.textContent = base + encodeURIComponent(term);

View file

@ -15,7 +15,7 @@ if ($scriptPath[0] !== '/') {
}
$endpoint = sprintf('%s?m=steam_workshop&p=main&action=search&home_id=%d', $scriptPath, $homeId);
$steamBase = 'https://steamcommunity.com/workshop/browse/?appid=';
$steamAppId = isset($appId) && $appId !== '' ? $appId : '0';
$steamAppIdParam = $appId ?? '';
$initialItems = [];
foreach ($config['workshop_items'] ?? [] as $item) {
if (!is_array($item)) {
@ -46,7 +46,7 @@ $langAttrs = [
'sync' => $lang['mod_picker_toggle_label'] ?? 'Sync',
];
?>
<div class="sw-picker" id="<?php echo $pickerId; ?>" data-endpoint="<?php echo htmlspecialchars($endpoint, ENT_QUOTES, 'UTF-8'); ?>"
<div class="sw-picker" id="<?php echo $pickerId; ?>" data-endpoint="<?php echo htmlspecialchars($endpoint, ENT_QUOTES, 'UTF-8'); ?>" data-detail-base="https://steamcommunity.com/sharedfiles/filedetails/?id="
<?php foreach ($langAttrs as $key => $value): ?>data-lang-<?php echo $key; ?>="<?php echo htmlspecialchars($value, ENT_QUOTES, 'UTF-8'); ?>" <?php endforeach; ?>>
<div class="sw-picker__header">
<h4><?php echo htmlspecialchars($lang['mod_picker_heading'] ?? 'Workshop library'); ?></h4>
@ -65,7 +65,7 @@ $langAttrs = [
<span class="sw-picker__request-label"><?php echo htmlspecialchars($lang['mod_picker_request_label'] ?? 'Submitting request'); ?></span>
<small class="sw-picker__request-hint"><?php echo htmlspecialchars($lang['mod_picker_request_hint'] ?? 'Exact URL preview. The field below mirrors your search text.'); ?></small>
<div class="sw-picker__request-line">
<?php $baseRequest = $steamBase . $steamAppId . '&browsesort=textsearch&section=readytouseitems&searchtext='; ?>
<?php $baseRequest = $steamAppIdParam !== '' ? $steamBase . $steamAppIdParam . '&browsesort=textsearch&section=readytouseitems&searchtext=' : ''; ?>
<code class="sw-picker__request-summary js-sw-request-summary" data-base="<?php echo htmlspecialchars($baseRequest, ENT_QUOTES, 'UTF-8'); ?>"><?php echo htmlspecialchars($baseRequest, ENT_QUOTES, 'UTF-8'); ?></code>
<input type="text" class="sw-picker__request-input js-sw-request-input" value="" readonly aria-label="<?php echo htmlspecialchars($lang['mod_picker_request_input_label'] ?? 'Workshop search text preview'); ?>" />
</div>