Repository navigation
Expand file tree
/
Copy pathHome.razor
More file actions
423 lines (377 loc) · 18.9 KB
/
Copy pathHome.razor
File metadata and controls
423 lines (377 loc) · 18.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
@page "/"
@inject IBetaAvailabilityService BetaAvailabilityService
@using Microsoft.Extensions.Options
@using RandomSteamGame.Options
@inject IOptions<ApplicationOptions> ApplicationSettings
@inject IOptions<LibraryExportOptions> ExportSettings
@inject IAppStatsService AppStatsService
@inject IRecentPickService RecentPickService
@inject IHttpContextAccessor HttpContextAccessor
@inject ILogger<Home> Logger
@inject CanonicalUrlService CanonicalUrls
<HeadContent>
<link rel="canonical" href="@CanonicalUrl" />
<meta name="description" content="@Description" />
<meta name="author" content="Kyle Givler" />
<SocialMetadata Title="@Title" Description="@Description" CanonicalUrl="@CanonicalUrl" />
@((MarkupString)StructuredDataScript)
</HeadContent>
<PageTitle>@Title</PageTitle>
<div class="container mt-5 home-shell">
<div class="row justify-content-center">
<div class="col-12 col-md-8 col-lg-6">
@if (ShowPublicBetaLinks && _isBetaSite)
{
<div class="home-beta-note-wrap mb-4">
<div class="home-beta-note" role="note">
<span class="home-beta-note-pill">Beta site</span>
<span class="home-beta-note-text">
You are on the beta build.
Stable release is at
<a href="https://randomsteam.kgivler.com/"
target="_blank"
rel="noopener noreferrer"
class="home-beta-note-link">randomsteam.kgivler.com</a>.
</span>
</div>
</div>
}
else if (ShowPublicBetaLinks && _betaAvailable)
{
<div class="home-beta-banner-wrap mb-4">
<div class="home-beta-banner">
<div class="text-center text-md-start">
<span class="home-beta-pill">Beta available</span>
<span class="home-beta-text">A live beta picker is running right now.</span>
</div>
<a href="https://randombeta.kgivler.com/"
target="_blank"
rel="noopener noreferrer"
class="home-beta-link">Click here to try it</a>
</div>
</div>
}
<div class="home-card rsg-led-breathe-purple">
<p class="home-eyebrow text-center mb-2">
Steam library roulette
</p>
<h1 class="home-title text-center mb-3">Random Steam Game Picker</h1>
<p class="home-lead text-center small mb-4">
Paste a Steam ID or vanity URL to pick a random game from your library.
</p>
<SteamPickerForm @rendermode="InteractiveAuto" />
<div class="d-flex justify-content-center align-items-center flex-wrap gap-3 mt-3 small">
<a href="https://ko-fi.com/joyfulreaper"
target="_blank"
rel="noopener noreferrer"
class="text-info">
☕ Support on Ko-fi
</a>
<a href="/support" class="text-info">
Sponsor or more support options
</a>
@if (ApplicationSettings.Value.NetworkMode == NetworkMode.Public)
{
<a href="/support#feature-voting" class="text-info">
Vote on features
</a>
}
</div>
</div>
@if (_recentPicks.Count > 0)
{
<section class="home-info-card home-recent-picks mt-3" aria-labelledby="recent-picks-heading">
<h2 id="recent-picks-heading" class="h5 mb-2">Recent Picks</h2>
<ul class="list-unstyled mb-0">
@foreach (var pick in _recentPicks)
{
<li>
<a href="https://store.steampowered.com/app/@(pick.AppId)/"
target="_blank" rel="noopener noreferrer" class="text-info">@pick.GameName</a>
<div class="home-recent-pick-details">
<time datetime="@pick.PickedAtUtc.ToString("O", System.Globalization.CultureInfo.InvariantCulture)">
@pick.PickedAtUtc.ToString("MMM d, HH:mm 'UTC'", System.Globalization.CultureInfo.InvariantCulture)
</time>
<a href="https://store.steampowered.com/app/@(pick.AppId)/"
target="_blank" rel="noopener noreferrer"
class="home-recent-pick-store-link text-info"
aria-label="View @pick.GameName on Steam">View on Steam</a>
</div>
</li>
}
</ul>
</section>
}
<div class="home-info-card home-library-export-card mt-3 text-center">
<h2 class="h5 mb-2">Need your whole Steam library?</h2>
<p class="small mb-3">
Export your public Steam library to CSV for Excel or another
spreadsheet app. The file includes game names, App IDs,
playtime, last-played dates, and Steam Deck compatibility.
</p>
<a href="/library-export"
class="btn btn-outline-info btn-sm">
Export Steam Library to CSV
</a>
</div>
<footer class="home-footer text-center mt-4 text-muted small">
<p>
Need help finding your Steam ID?
Check the
<a href="https://help.steampowered.com/en/faqs/view/2816-BE67-5B69-0FEC"
target="_blank"
class="text-info"
rel="noopener noreferrer">Steam ID guide</a>.
Ensure your
<a href="https://help.steampowered.com/en/faqs/view/588C-C67D-0251-C276"
target="_blank"
class="text-info"
rel="noopener noreferrer">profile is public</a>.
</p>
<HomeStats Stats="_appStats" />
<p>
Please Report Any <span class="text-danger">Bugs:</span>
<a href="https://github.com/JoyfulReaper/RandomSteamGame/issues"
target="_blank"
class="text-info"
rel="noopener noreferrer">GitHub Issues</a>
</p>
</footer>
</div>
</div>
<section class="home-guide mt-5" aria-labelledby="how-it-works-heading">
<div class="row g-4">
<div class="col-12 col-lg-6">
<div class="home-info-card h-100">
<h2 id="how-it-works-heading">How it works</h2>
<ol class="home-steps mb-0">
<li>Enter your 17-digit Steam ID or Steam vanity URL.</li>
<li>The picker reads the games in your public Steam library.</li>
<li>It randomly chooses a game you actually own.</li>
<li>Choose again immediately whenever the first pick does not fit.</li>
<li>Turn on unplayed-only mode to limit picks to games with no recorded playtime.</li>
</ol>
</div>
</div>
<div class="col-12 col-lg-6">
<div class="home-info-card h-100">
<h2>Useful Steam library features</h2>
<ul class="home-feature-list mb-0">
<li><strong>Unplayed-only picks:</strong> focus on games with no Steam playtime recorded.</li>
<li><strong>Quick rerolls:</strong> choose another owned game without returning to the form.</li>
<li><strong>Browser-based exclusions:</strong> block an unwanted game from future picks in this browser, then reset the list whenever you want.</li>
<li><strong>Fresh library data:</strong> refresh the cached Steam game list after buying new games if your picks look out of date.</li>
<li><strong>Launch through Steam:</strong> open the selected game directly in the Steam client.</li>
<li><strong>Steam library CSV export:</strong> download your public library as a spreadsheet-ready CSV for Excel, LibreOffice Calc, Google Sheets, or another spreadsheet tool.
</li>
</ul>
</div>
</div>
</div>
<section class="home-info-card home-finger-card mt-4" aria-labelledby="finger-heading">
<div class="home-finger-copy">
<p class="home-eyebrow mb-2">Old-school interface</p>
<h2 id="finger-heading">Pick a random Steam game over Finger</h2>
<p class="mb-0">
Use the Finger protocol as a fun alternative for choosing a game
from a public Steam library. It expects a 17-digit Steam ID;
vanity URLs are not supported.
</p>
</div>
<div class="home-finger-command-wrap">
<span class="home-finger-command-label">Command</span>
<code class="home-finger-command">finger <steamId>@finger.kgivler.com</code>
</div>
</section>
<section class="home-info-card home-irc-card mt-4" aria-labelledby="irc-heading">
<div class="home-irc-copy">
<p class="home-eyebrow mb-2">Chat interface</p>
<h2 id="irc-heading">Pick a random Steam game over IRC</h2>
<p class="mb-0">
Join the Random Steam Game channel on Libera.Chat and ask the bot
to pick a game from your public Steam library using either your
17-digit Steam ID or Steam vanity name.
</p>
</div>
<div class="home-finger-command-wrap">
<span class="home-finger-command-label">IRC</span>
<code class="home-finger-command">irc.libera.chat / #randomsteamgame</code>
</div>
<div class="home-finger-command-wrap mt-2">
<span class="home-finger-command-label">Command</span>
<code class="home-finger-command">!random <SteamID or vanity name></code>
</div>
</section>
<section class="home-info-card home-matrix-card mt-4" aria-labelledby="matrix-heading">
<p class="home-eyebrow mb-2">Chat interface</p>
<h2 id="matrix-heading">Pick a random Steam game over Matrix</h2>
<p>
Join the Random Steam Game room on Matrix and ask RandomSteamBot
to pick a game from your public Steam library using your
17-digit Steam ID or Steam vanity name.
</p>
<p class="mb-3">
<a href="https://matrix.to/#/!NTvCQirbQTeqzUiSoh:kgivler.com"
target="_blank"
rel="noopener noreferrer"
class="text-info">
Join the Random Steam Game Matrix room
</a>
</p>
<div class="home-finger-command-wrap">
<span class="home-finger-command-label">Command</span>
<code class="home-finger-command">!steam <SteamID or vanity name></code>
</div>
</section>
<div class="home-faq mt-4 mb-4" aria-labelledby="faq-heading">
<h2 id="faq-heading">Frequently asked questions</h2>
<div class="row g-3">
<div class="col-12 col-md-6">
<div class="home-faq-item h-100">
<h3>Does my Steam profile need to be public?</h3>
<p>
Yes. Steam must allow access to your profile and game details
so the picker can read your owned games.
</p>
</div>
</div>
<div class="col-12 col-md-6">
<div class="home-faq-item h-100">
<h3>Where do I find my Steam ID?</h3>
<p>
You can use your 17-digit Steam ID, or paste the custom name
or URL from your Steam Community profile.
</p>
</div>
</div>
<div class="col-12 col-md-6">
<div class="home-faq-item h-100">
<h3>Can it pick only games I have never played?</h3>
<p>
Yes. Select “Only pick unplayed games” to use games for which
Steam reports no recorded playtime.
</p>
</div>
</div>
<div class="col-12 col-md-6">
<div class="home-faq-item h-100">
<h3>Can I choose again or exclude a game?</h3>
<p>
Yes. You can choose again instantly, or block the current game
from future picks in this browser.
</p>
</div>
</div>
<div class="col-12 col-md-6">
<div class="home-faq-item h-100">
<h3>Can I export my Steam library?</h3>
<p>
Yes. Export your public Steam library as CSV, then open it in
Excel, LibreOffice Calc, Google Sheets, or another spreadsheet
app. It includes game names, App IDs, playtime, last-played
dates, and Steam Deck compatibility.
@if (ExportSettings.Value.RateLimitMode == LibraryExportRateLimitMode.Global)
{
@ExportSettings.Value.RateLimitDescription
}
else
{
<text>Exports are limited to one per IP address every
72 hours.</text>
}
</p>
</div>
</div>
<div class="col-12 col-md-6">
<div class="home-faq-item h-100">
<h3>Does Random Steam Game change anything in my library?</h3>
<p>
No. It reads your public game list to make a pick or export your
library; it does not add, remove, or organize games in Steam.
</p>
</div>
</div>
</div>
</div>
</section>
</div>
@code {
private const string Title = "Random Steam Game Picker – Pick From Your Library";
private const string Description = "Pick a random game from your public Steam library, filter to unplayed games, or export your Steam library to CSV for Excel and other spreadsheet apps.";
private string CanonicalUrl => CanonicalUrls.GetCanonicalUrl();
private bool ShowPublicBetaLinks =>
ApplicationSettings.Value.NetworkMode == NetworkMode.Public && ApplicationSettings.Value.BetaProbeEnabled;
private string StructuredDataJson => System.Text.Json.JsonSerializer.Serialize(
new Dictionary<string, object>
{
["@context"] = "https://schema.org",
["@type"] = "WebApplication",
["name"] = "Random Steam Game Picker",
["url"] = CanonicalUrl,
["description"] = Description,
["applicationCategory"] = "UtilitiesApplication",
["operatingSystem"] = "Any device with a web browser",
["isAccessibleForFree"] = true,
["featureList"] = new[]
{
"Random game selection from a public Steam library",
"Unplayed-only game filtering",
"Browser-based game exclusions",
"Steam library CSV export for Excel and other spreadsheet apps",
"Steam Deck compatibility included in library exports",
"Random Steam game selection over the Finger protocol",
"Random Steam game selection through an IRC bot on Libera.Chat",
"Random Steam game selection through a Matrix bot"
}
});
private string StructuredDataScript =>
$"<script type=\"application/ld+json\">{StructuredDataJson}</script>";
private bool _betaAvailable;
private bool _isBetaSite;
private AppStatsResponse? _appStats;
private IReadOnlyList<RecentPick> _recentPicks = [];
protected override async Task OnInitializedAsync()
{
_isBetaSite = CanonicalUrls.IsBetaHost(
HttpContextAccessor.HttpContext?.Request.Host.Host);
await LoadAppStatsAsync();
await LoadRecentPicksAsync();
if (ApplicationSettings.Value.BetaProbeEnabled && !_isBetaSite)
{
_betaAvailable = await BetaAvailabilityService.IsBetaAvailableAsync();
}
}
private async Task LoadRecentPicksAsync()
{
try
{
_recentPicks = await RecentPickService.GetRecentAsync(5);
}
catch (Exception exception)
{
_recentPicks = [];
Logger.LogWarning(exception, "Failed to load recent picks for homepage.");
}
}
private async Task LoadAppStatsAsync()
{
var httpContext = HttpContextAccessor.HttpContext;
var ip = httpContext?.Connection.RemoteIpAddress?.ToString();
var userAgent = httpContext?.Request.Headers["User-Agent"].ToString();
var ingressNetwork = RandomSteamIngressNetwork.FromHost(httpContext?.Request.Host.Host);
var recordHit = !string.IsNullOrWhiteSpace(ip);
try
{
_appStats = recordHit
? await AppStatsService.RecordHitAsync(ip!, userAgent, ingressNetwork)
: await AppStatsService.GetStatsAsync();
}
catch (Exception exception)
{
_appStats = null;
Logger.LogWarning(exception,
"Failed to load homepage statistics during {StatsOperation}.",
recordHit ? "hit recording" : "stats retrieval");
}
}
}