This commit is contained in:
Ashley
2022-08-05 22:33:38 +03:00
committed by GitHub
parent f431111611
commit 72143fede3
100 changed files with 12438 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
@using LightTube.Database
@using System.Web
@model LightTube.Contexts.BaseContext
@{
ViewBag.Title = "Account";
Layout = "_Layout";
Context.Request.Cookies.TryGetValue("theme", out string theme);
if (!new[] { "light", "dark" }.Contains(theme)) theme = "light";
string newTheme = theme switch {
"light" => "dark",
"dark" => "light",
var _ => "dark"
};
bool compatibility = false;
if (Context.Request.Cookies.TryGetValue("compatibility", out string compatibilityString))
bool.TryParse(compatibilityString, out compatibility);
}
<div class="login-container">
<div>
<div class="fullscreen-account-menu">
<h1>Settings</h1>
<br>
<div class="guide-item">
<a href="/toggles/theme?redirectUrl=@(HttpUtility.UrlEncode($"{Context.Request.Path}{Context.Request.QueryString}"))">Switch to @(newTheme) theme</a>
</div>
<br>
@if (Context.TryGetUser(out LTUser user, "web"))
{
<div class="guide-item">
<a href="/Account/Settings">Settings</a>
</div>
@if (user.PasswordHash != "local_account")
{
<div class="guide-item">
<a href="/Account/Logins">Active logins</a>
</div>
}
<div class="guide-item">
<a href="/Account/Logout">Log out</a>
</div>
}
else
{
<div class="guide-item">
<a href="/Account/Login">Log in</a>
</div>
<div class="guide-item">
<a href="/Account/Register">Register</a>
</div>
}
</div>
</div>
<div>
</div>
</div>

View File

@@ -0,0 +1,52 @@
@using System.Web
@using LightTube.Database
@model LightTube.Contexts.AddToPlaylistContext
@{
ViewBag.Metadata = new Dictionary<string, string>();
ViewBag.Metadata["author"] = Model.Video.Channel.Name;
ViewBag.Metadata["og:title"] = Model.Video.Title;
ViewBag.Metadata["og:url"] = $"{Url.ActionContext.HttpContext.Request.Scheme}://{Url.ActionContext.HttpContext.Request.Host}{Url.ActionContext.HttpContext.Request.Path}{Url.ActionContext.HttpContext.Request.QueryString}";
ViewBag.Metadata["og:image"] = $"{Url.ActionContext.HttpContext.Request.Scheme}://{Url.ActionContext.HttpContext.Request.Host}/proxy/image?url={HttpUtility.UrlEncode(Model.Thumbnail)}";
ViewBag.Metadata["twitter:card"] = $"{Url.ActionContext.HttpContext.Request.Scheme}://{Url.ActionContext.HttpContext.Request.Host}/proxy/image?url={HttpUtility.UrlEncode(Model.Thumbnail)}";
ViewBag.Title = Model.Video.Title;
Layout = "_Layout";
}
<div class="playlist-page">
<div class="playlist-info">
<div class="thumbnail" style="background-image: url('@Model.Thumbnail')">
<a href="/watch?v=@Model.Video.Id">Watch</a>
</div>
<p class="title">@Model.Video.Title</p>
<span class="info">@Model.Video.Views • @Model.Video.UploadDate</span>
<div class="channel-info">
<a href="/channel/@Model.Video.Channel.Id" class="avatar">
<img src="@Model.Video.Channel.Avatars.LastOrDefault()?.Url">
</a>
<div class="name">
<a class="name" href="/channel/@Model.Video.Channel.Id">@Model.Video.Channel.Name</a>
</div>
</div>
</div>
<div class="video-list playlist-list playlist-video-list">
<h3>Add to one of these playlists:</h3>
<a class="login-button" href="/Account/CreatePlaylist" style="margin:unset;">Create playlist</a>
@foreach (LTPlaylist playlist in Model.Playlists)
{
<div class="playlist-video">
<a href="/playlist?list=@playlist.Id&add=@Model.Id" class="thumbnail"
style="background-image: url('https://i.ytimg.com/vi_webp/@playlist.VideoIds.FirstOrDefault()/maxresdefault.webp')">
</a>
<div class="info">
<a href="/playlist?list=@playlist.Id&add=@Model.Id" class="title max-lines-2">
@playlist.Name
</a>
<div>
<span>@playlist.VideoIds.Count videos</span>
</div>
</div>
</div>
}
</div>
</div>

View File

@@ -0,0 +1,25 @@
@model LightTube.Contexts.BaseContext
@{
ViewBag.Title = "Create Playlist";
Layout = "_Layout";
}
<div class="login-container">
<div>
<div>
<form asp-action="CreatePlaylist" method="POST" class="playlist-form">
<h1>Create Playlist</h1>
<input name="name" type="text" placeholder="Playlist Name">
<input name="description" type="text" placeholder="Description">
<select name="visibility">
<option value="UNLISTED">Anyone with the link can view</option>
<option value="PRIVATE">Only you can view</option>
</select>
<input type="submit" value="Create">
</form>
</div>
</div>
<div>
</div>
</div>

View File

@@ -0,0 +1,46 @@
@using LightTube.Database
@model LightTube.Contexts.MessageContext
@{
ViewData["Title"] = "Delete Account";
Layout = "_Layout";
}
@if (!string.IsNullOrWhiteSpace(Model.Message))
{
<div class="login-message">
@Model.Message
</div>
}
<div class="login-container">
<div>
<div>
@if (Context.Request.Cookies.TryGetValue("account_data", out string _))
{
Context.TryGetUser(out LTUser user, "web");
<form asp-action="Delete" method="POST" class="login-form">
<h1>Delete Account</h1>
<p>Deleting a local account</p>
<input name="email" type="hidden" value="@user.UserID">
<input name="password" type="hidden" value="@user.PasswordHash">
<input type="submit" value="Delete Account" class="login-button danger">
</form>
}
else
{
<form asp-action="Delete" method="POST" class="login-form">
<h1>Delete Account</h1>
<input name="userid" type="text" placeholder="UserID">
<input name="password" type="password" placeholder="Password">
<input type="submit" value="Delete Account" class="login-button danger">
</form>
}
</div>
</div>
<div>
<div>
<h1>Warning!</h1>
<p>You cannot undo this operation! After you enter your username and password, your account will get deleted forever.</p>
</div>
</div>
</div>

View File

@@ -0,0 +1,29 @@
@model LightTube.Contexts.MessageContext
@{
ViewData["Title"] = "Login";
Layout = "_Layout";
}
@if (!string.IsNullOrWhiteSpace(Model.Message))
{
<div class="login-message">
@Model.Message
</div>
}
<div class="login-container">
<div>
<div>
<form asp-action="Login" method="POST" class="login-form">
<h1>Log in</h1>
<input name="userid" type="text" placeholder="UserID">
<input name="password" type="password" placeholder="Password">
<input type="submit" value="Login">
</form>
</div>
</div>
<div>
<h2>Don't have an account?</h2>
<a href="/Account/Register" class="login-button">Create an account</a>
</div>
</div>

View File

@@ -0,0 +1,18 @@
@using LightTube.Database
@model LightTube.Contexts.LoginsContext
@{
ViewData["Title"] = "Active Logins";
Layout = "_Layout";
}
<h1 style="text-align:center;">Active Logins</h1>
<div class="logins-container">
@foreach (LTLogin login in Model.Logins)
{
<div class="login">
<h2 class="max-lines-1">@(login.Identifier == Model.CurrentLogin ? "(This window) " : "")@login.GetTitle()</h2>
<p>@Html.Raw(login.GetDescription().Replace("\n", "<br>"))</p>
<a href="/Account/DisableLogin?id=@login.Identifier" class="login-button" style="color:red;">Disable</a>
</div>
}
</div>

View File

@@ -0,0 +1,42 @@
@model LightTube.Contexts.MessageContext
@{
ViewData["Title"] = "Register";
Layout = "_Layout";
}
@if (!string.IsNullOrWhiteSpace(Model.Message))
{
<div class="login-message">
@Model.Message
</div>
}
<div class="login-container">
<div>
<div>
<form asp-action="Register" method="POST" class="login-form">
<h1>Register</h1>
<input name="userid" type="text" placeholder="UserID">
<input name="password" type="password" placeholder="Password">
<input type="submit" value="Register">
</form>
</div>
</div>
<div>
<div>
<h1>...or register with a local account</h1>
<h2>What is the difference?</h2>
<ul>
<li>Remote account data is saved in this lighttube instance, while local account data is stored in
your browser's cookies
<ul>
<li>This means that the author of this lighttube instance cannot see your account data</li>
<li>It also means that, if you clear your cookies a lot, your account data will also get
lost with the cookies</li>
</ul>
</li>
</ul>
<a href="/Account/RegisterLocal" class="login-button">Create local account</a>
</div>
</div>
</div>

View File

@@ -0,0 +1,63 @@
@model LightTube.Contexts.SettingsContext
@{
ViewBag.Title = "Settings";
Layout = "_Layout";
}
<form method="post">
<div class="settings-content">
<h1 style="text-align:center">Settings</h1>
<div>
<label for="settings-theme">Theme</label>
<select id="settings-theme" name="theme">
@Html.Raw($"<option value='light' {(Model.Theme == "light" ? "selected" : "")}>Light</option>")
@Html.Raw($"<option value='dark' {(Model.Theme == "dark" ? "selected" : "")}>Dark</option>")
</select>
<p>This is the visual theme the website will use.</p>
</div>
<div>
<label for="settings-yhl">Content Language</label>
<select id="settings-yhl" name="hl">
@foreach (KeyValuePair<string, string> o in Model.Languages)
{
@Html.Raw($"<option value='{o.Key}' {(o.Key == Model.CurrentLanguage ? "selected" : "")}>{o.Value}</option>")
}
</select>
<p>The language YouTube will deliver the content in. This will not affect LightTube's UI language.</p>
</div>
<div>
<label for="settings-ygl">Content Region</label>
<select id="settings-ygl" name="gl">
@foreach (KeyValuePair<string, string> o in Model.Regions)
{
@Html.Raw($"<option value='{o.Key}' {(o.Key == Model.CurrentRegion ? "selected" : "")}>{o.Value}</option>")
}
</select>
<p>The language YouTube will deliver the content for. It is used for the explore page and the recommendations.</p>
</div>
<div>
<label for="settings-player">Player</label>
<select id="settings-player" name="compatibility">
@Html.Raw($"<option value=\"false\" {(Model.CompatibilityMode ? "" : "selected")}>DASH playback with muxed fallback (recommended)</option>")
@Html.Raw($"<option value=\"true\" {(Model.CompatibilityMode ? "selected" : "")}>Muxed formats only (only supports 360p & 720p)</option>")
</select>
<p>Player behaviour. DASH playback allows for resolutions over 720p, but it is not compatible in all browsers. (e.g: Firefox Mobile)</p>
</div>
<div>
<label for="settings-api">API Access</label>
<select id="settings-api" name="api-access">
@Html.Raw($"<option value=\"true\" {(Model.ApiAccess ? "selected" : "")}>Enabled</option>")
@Html.Raw($"<option value=\"false\" {(Model.ApiAccess ? "" : "selected")}>Disabled</option>")
</select>
<p>This will allow apps to log in using your username and password</p>
</div>
<div style="display:flex;flex-direction:row">
<a href="/Account/Logins" class="login-button">Active Logins</a>
<a href="/Account/Delete" class="login-button" style="color:red">Delete Account</a>
</div>
</div>
<br>
<input type="submit" class="login-button" value="Save"/>
</form>