More product setup
This commit is contained in:
18
AobaCore/AobaCore.csproj
Normal file
18
AobaCore/AobaCore.csproj
Normal file
@@ -0,0 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.3" />
|
||||
<PackageReference Include="MongoDB.Bson" Version="3.3.0" />
|
||||
<PackageReference Include="MaybeError" Version="1.0.5" />
|
||||
<PackageReference Include="MongoDB.Analyzer" Version="1.5.0" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="2.30.0" />
|
||||
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.30.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
19
AobaCore/AobaService.cs
Normal file
19
AobaCore/AobaService.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using AobaV2.Models;
|
||||
|
||||
using MaybeError;
|
||||
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace AobaCore;
|
||||
|
||||
public class AobaService(IMongoDatabase db)
|
||||
{
|
||||
private readonly IMongoCollection<Media> _media = db.GetCollection<Media>("media");
|
||||
|
||||
|
||||
public async Task<Media?> GetMediaAsync(ObjectId id)
|
||||
{
|
||||
return await _media.Find(m => m.Id == id).FirstOrDefaultAsync();
|
||||
}
|
||||
}
|
||||
17
AobaCore/Extensions.cs
Normal file
17
AobaCore/Extensions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AobaCore;
|
||||
public static class Extensions
|
||||
{
|
||||
public static IServiceCollection AddAoba(this IServiceCollection services)
|
||||
{
|
||||
services.AddSingleton<AobaService>();
|
||||
return services;
|
||||
}
|
||||
}
|
||||
79
AobaCore/Models/Media.cs
Normal file
79
AobaCore/Models/Media.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
|
||||
namespace AobaV2.Models;
|
||||
|
||||
[BsonIgnoreExtraElements]
|
||||
public class Media
|
||||
{
|
||||
[BsonId]
|
||||
public ObjectId Id { get; set; }
|
||||
public ObjectId MediaId { get; set; }
|
||||
public required string Filename { get; set; }
|
||||
public MediaType MediaType { get; set; }
|
||||
public required string Ext { get; set; }
|
||||
public int ViewCount { get; set; }
|
||||
public ObjectId Owner { get; set; }
|
||||
|
||||
|
||||
public static readonly Dictionary<string, MediaType> KnownTypes = new()
|
||||
{
|
||||
{ ".jpg", MediaType.Image },
|
||||
{ ".avif", MediaType.Image },
|
||||
{ ".jpeg", MediaType.Image },
|
||||
{ ".png", MediaType.Image },
|
||||
{ ".apng", MediaType.Image },
|
||||
{ ".webp", MediaType.Image },
|
||||
{ ".ico", MediaType.Image },
|
||||
{ ".gif", MediaType.Image },
|
||||
{ ".mp3", MediaType.Audio },
|
||||
{ ".flac", MediaType.Audio },
|
||||
{ ".alac", MediaType.Audio },
|
||||
{ ".mp4", MediaType.Video },
|
||||
{ ".webm", MediaType.Video },
|
||||
{ ".mov", MediaType.Video },
|
||||
{ ".avi", MediaType.Video },
|
||||
{ ".mkv", MediaType.Video },
|
||||
{ ".txt", MediaType.Text },
|
||||
{ ".log", MediaType.Text },
|
||||
{ ".css", MediaType.Code },
|
||||
{ ".cs", MediaType.Code },
|
||||
{ ".cpp", MediaType.Code },
|
||||
{ ".lua", MediaType.Code },
|
||||
{ ".js", MediaType.Code },
|
||||
{ ".htm", MediaType.Code },
|
||||
{ ".html", MediaType.Code },
|
||||
{ ".cshtml", MediaType.Code },
|
||||
{ ".xml", MediaType.Code },
|
||||
{ ".json", MediaType.Code },
|
||||
{ ".py", MediaType.Code },
|
||||
};
|
||||
|
||||
public string GetMediaUrl()
|
||||
{
|
||||
return this switch
|
||||
{
|
||||
Media { MediaType: MediaType.Raw or MediaType.Text or MediaType.Code} => $"/i/dl/{Id}/{Filename}",
|
||||
_ => $"/i/{Id}"
|
||||
};
|
||||
}
|
||||
|
||||
public static MediaType GetMediaType(string filename)
|
||||
{
|
||||
string ext = Path.GetExtension(filename);
|
||||
if (KnownTypes.TryGetValue(ext, out MediaType mType))
|
||||
return mType;
|
||||
else
|
||||
return MediaType.Raw;
|
||||
}
|
||||
}
|
||||
|
||||
public enum MediaType
|
||||
{
|
||||
Image,
|
||||
Audio,
|
||||
Video,
|
||||
Text,
|
||||
Code,
|
||||
Raw
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.13.35919.96 d17.13
|
||||
VisualStudioVersion = 17.13.35919.96
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AobaV2", "AobaV2\AobaV2.csproj", "{A97400AB-4B57-4074-9A31-8D46A305E633}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AobaCore", "AobaCore\AobaCore.csproj", "{65EEC037-E845-471D-A838-BEEADF781C17}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -15,6 +17,10 @@ Global
|
||||
{A97400AB-4B57-4074-9A31-8D46A305E633}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A97400AB-4B57-4074-9A31-8D46A305E633}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A97400AB-4B57-4074-9A31-8D46A305E633}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{65EEC037-E845-471D-A838-BEEADF781C17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{65EEC037-E845-471D-A838-BEEADF781C17}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{65EEC037-E845-471D-A838-BEEADF781C17}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{65EEC037-E845-471D-A838-BEEADF781C17}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -10,11 +10,14 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Styles\main.scss" />
|
||||
<Content Include="Styles\mixins.scss" />
|
||||
<Content Include="Styles\UI\Inputs.scss" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.SassCompiler" Version="1.86.0" />
|
||||
<PackageReference Include="Isopoh.Cryptography.Argon2" Version="2.0.0" />
|
||||
<PackageReference Include="MaybeError" Version="1.0.5" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.7.0" />
|
||||
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="5.8.1">
|
||||
@@ -25,7 +28,10 @@
|
||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="3.0.71" />
|
||||
<PackageReference Include="MongoDB.Analyzer" Version="1.5.0" />
|
||||
<PackageReference Include="MongoDB.Bson" Version="3.3.0" />
|
||||
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.30.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AobaCore\AobaCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
10
AobaV2/Controllers/MediaController.cs
Normal file
10
AobaV2/Controllers/MediaController.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace AobaV2.Controllers;
|
||||
public class MediaController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
using AobaCore;
|
||||
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -10,6 +12,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllersWithViews();
|
||||
#endif
|
||||
|
||||
builder.Services.AddAoba();
|
||||
builder.Services.Configure<FormOptions>(opt =>
|
||||
{
|
||||
opt.ValueLengthLimit = int.MaxValue;
|
||||
@@ -21,9 +24,9 @@ var app = builder.Build();
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
//Javascript frameworks were a mistake
|
||||
@@ -49,9 +52,9 @@ app.UseAuthorization();
|
||||
app.MapStaticAssets();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}")
|
||||
.WithStaticAssets();
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}")
|
||||
.WithStaticAssets();
|
||||
|
||||
|
||||
app.Run();
|
||||
|
||||
10
AobaV2/Styles/UI/Common.scss
Normal file
10
AobaV2/Styles/UI/Common.scss
Normal file
@@ -0,0 +1,10 @@
|
||||
@import '../mixins';
|
||||
@import '../vars';
|
||||
|
||||
a{
|
||||
color:$featureColor;
|
||||
|
||||
&:hover{
|
||||
color:$accentColor;
|
||||
}
|
||||
}
|
||||
2
AobaV2/Styles/UI/Inputs.scss
Normal file
2
AobaV2/Styles/UI/Inputs.scss
Normal file
@@ -0,0 +1,2 @@
|
||||
@import '../mixins';
|
||||
@import '../vars';
|
||||
@@ -1,3 +1,34 @@
|
||||
h1{
|
||||
color:red;
|
||||
@import 'mixins';
|
||||
@import 'vars';
|
||||
@import 'UI/Inputs.scss';
|
||||
@import 'UI/Common.scss';
|
||||
|
||||
|
||||
:root {
|
||||
background-color: $mainBGColor;
|
||||
color: $mainTextColor;
|
||||
box-sizing: border-box;
|
||||
font-family: "Noto Sans", sans-serif;
|
||||
font-optical-sizing: auto;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
font-variation-settings: "wdth" 100;
|
||||
}
|
||||
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
nav{
|
||||
position:sticky;
|
||||
top:0;
|
||||
background-color:$featureColor;
|
||||
height:$navBarSize;
|
||||
|
||||
.branding{
|
||||
img{
|
||||
height:$navBarSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
AobaV2/Styles/mixins.scss
Normal file
43
AobaV2/Styles/mixins.scss
Normal file
@@ -0,0 +1,43 @@
|
||||
$navBarSize: 40px;
|
||||
|
||||
@mixin mobile {
|
||||
@media (max-width: 700px) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin max-screen($size) {
|
||||
@media (max-width: #{$size}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin max-container($size) {
|
||||
@container (max-width: #{$size}) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin small-container {
|
||||
@container (max-width: 500px) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin medium-container {
|
||||
@container (max-width: 800px) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin large-container {
|
||||
@container (max-width: 1000px) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
@mixin xlarge-container {
|
||||
@container (max-width: 1200px) {
|
||||
@content;
|
||||
}
|
||||
}
|
||||
11
AobaV2/Styles/vars.scss
Normal file
11
AobaV2/Styles/vars.scss
Normal file
@@ -0,0 +1,11 @@
|
||||
$mainBGColor: #584577;
|
||||
$featureColor: #CE2D4F;
|
||||
$accentColor: #f0eaf8;
|
||||
|
||||
$mainTextColor: #eee;
|
||||
$brightTextColor: #fff;
|
||||
$invertTextColor: #222;
|
||||
$invertBrightTextColor: #000;
|
||||
|
||||
|
||||
$navBarSize: 50px;
|
||||
@@ -1,8 +1,4 @@
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Welcome</h1>
|
||||
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
|
||||
</div>
|
||||
<partial name="ImageGrid" />
|
||||
3
AobaV2/Views/Shared/ImageGrid.cshtml
Normal file
3
AobaV2/Views/Shared/ImageGrid.cshtml
Normal file
@@ -0,0 +1,3 @@
|
||||
@{
|
||||
}
|
||||
<div>Image Grid</div>
|
||||
14
AobaV2/Views/Shared/Navigation.cshtml
Normal file
14
AobaV2/Views/Shared/Navigation.cshtml
Normal file
@@ -0,0 +1,14 @@
|
||||
@*
|
||||
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
}
|
||||
<nav>
|
||||
<div class="branding">
|
||||
<img src="favicon.ico"/>
|
||||
</div>
|
||||
<div class="search">
|
||||
|
||||
</div>
|
||||
<div class="controls"></div>
|
||||
</nav>
|
||||
@@ -1,40 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - AobaV2</title>
|
||||
<link rel="stylesheet" href="~/css/main.css" asp-append-version="true" />
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - AobaV2</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com"/>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap" />
|
||||
<link rel="stylesheet" href="~/css/main.css" asp-append-version="true" />
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">AobaV2</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<main role="main" class="pb-3">
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
<partial name="Navigation"/>
|
||||
@RenderBody()
|
||||
|
||||
<script src="~/lib/jquery/jquery.min.js"></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
<script src="~/lib/jquery/jquery.min.js" defer></script>
|
||||
@await RenderSectionAsync("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
Layout = "_Layout";
|
||||
}
|
||||
|
||||
BIN
AobaV2/wwwroot/Aobax32.ico
Normal file
BIN
AobaV2/wwwroot/Aobax32.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 66 KiB |
Reference in New Issue
Block a user