mirror of
https://codeberg.org/ashley/poke.git
synced 2025-06-08 18:33:02 -04:00
owo
This commit is contained in:
parent
f431111611
commit
72143fede3
100 changed files with 12438 additions and 0 deletions
67
core/LightTube/Controllers/TogglesController.cs
Normal file
67
core/LightTube/Controllers/TogglesController.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LightTube.Controllers
|
||||
{
|
||||
[Route("/toggles")]
|
||||
public class TogglesController : Controller
|
||||
{
|
||||
[Route("theme")]
|
||||
public IActionResult ToggleTheme(string redirectUrl)
|
||||
{
|
||||
if (Request.Cookies.TryGetValue("theme", out string theme))
|
||||
Response.Cookies.Append("theme", theme switch
|
||||
{
|
||||
"light" => "dark",
|
||||
"dark" => "light",
|
||||
var _ => "dark"
|
||||
}, new CookieOptions
|
||||
{
|
||||
Expires = DateTimeOffset.MaxValue
|
||||
});
|
||||
else
|
||||
Response.Cookies.Append("theme", "light");
|
||||
|
||||
return Redirect(redirectUrl);
|
||||
}
|
||||
|
||||
[Route("compatibility")]
|
||||
public IActionResult ToggleCompatibility(string redirectUrl)
|
||||
{
|
||||
if (Request.Cookies.TryGetValue("compatibility", out string compatibility))
|
||||
Response.Cookies.Append("compatibility", compatibility switch
|
||||
{
|
||||
"true" => "false",
|
||||
"false" => "true",
|
||||
var _ => "true"
|
||||
}, new CookieOptions
|
||||
{
|
||||
Expires = DateTimeOffset.MaxValue
|
||||
});
|
||||
else
|
||||
Response.Cookies.Append("compatibility", "true");
|
||||
|
||||
return Redirect(redirectUrl);
|
||||
}
|
||||
|
||||
[Route("collapse_guide")]
|
||||
public IActionResult ToggleCollapseGuide(string redirectUrl)
|
||||
{
|
||||
if (Request.Cookies.TryGetValue("minmode", out string minmode))
|
||||
Response.Cookies.Append("minmode", minmode switch
|
||||
{
|
||||
"true" => "false",
|
||||
"false" => "true",
|
||||
var _ => "true"
|
||||
}, new CookieOptions
|
||||
{
|
||||
Expires = DateTimeOffset.MaxValue
|
||||
});
|
||||
else
|
||||
Response.Cookies.Append("minmode", "true");
|
||||
|
||||
return Redirect(redirectUrl);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue