From 3d4e269c21a73a1091790a52766b8baff5e657a9 Mon Sep 17 00:00:00 2001 From: Amatsugu Date: Sun, 18 May 2025 19:58:56 -0400 Subject: [PATCH] inputs.scss refactor Added upload date to media + sort by date --- AobaClient/Dockerfile | 44 ----------------------- AobaClient/assets/style/inputs.scss | 24 ++++++++++--- AobaClient/assets/style/main.scss | 6 +++- AobaClient/src/components/search.rs | 2 +- AobaClient/src/main.rs | 2 ++ AobaCore/AobaCore.csproj | 1 - AobaCore/AobaService.cs | 3 +- AobaCore/Extensions.cs | 6 ++-- AobaCore/Models/Media.cs | 1 + AobaServer/AobaServer.csproj | 2 +- AobaServer/Controllers/MediaController.cs | 7 ++++ AobaServer/Program.cs | 7 ++-- AobaServer/appsettings.Development.json | 13 +++---- docker-compose.yml | 6 +--- 14 files changed, 53 insertions(+), 71 deletions(-) delete mode 100644 AobaClient/Dockerfile diff --git a/AobaClient/Dockerfile b/AobaClient/Dockerfile deleted file mode 100644 index f2efd26..0000000 --- a/AobaClient/Dockerfile +++ /dev/null @@ -1,44 +0,0 @@ -FROM rust:1 AS chef -RUN rustup target add wasm32-unknown-unknown -RUN cargo install cargo-chef -WORKDIR /app - -FROM chef AS planner -COPY . . -WORKDIR /app/AobaClient -RUN cargo chef prepare --recipe-path recipe.json - -FROM chef AS builder -WORKDIR /app/AobaClient -COPY --from=planner /app/AobaClient/recipe.json recipe.json -RUN cargo chef cook --release --recipe-path recipe.json -COPY /AobaClient /app/AobaClient -COPY /AobaServer/Proto /app/AobaServer/Proto - -# Install Protobuf -RUN apt update -RUN apt install -y protobuf-compiler libprotobuf-dev - -# Install `dx` -RUN curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash -RUN cargo binstall dioxus-cli --root /.cargo -y --force -ENV PATH="/.cargo/bin:$PATH" - -# Create the final bundle folder. Bundle always executes in release mode with optimizations enabled -RUN dx bundle --platform web -ENTRYPOINT [ "sleep", "infinity" ] - - -# FROM chef AS runtime -# COPY --from=builder /app/AobaClient/target/dx/aoba-client/release/web/ /usr/local/app - -# # set our port and make sure to listen for all connections -# ENV PORT=8616 -# ENV IP=0.0.0.0 - -# # expose the port 8080 -# EXPOSE 8616 - -# WORKDIR /usr/local/app -# ENTRYPOINT [ "/usr/local/app/server" ] - diff --git a/AobaClient/assets/style/inputs.scss b/AobaClient/assets/style/inputs.scss index a25384c..92211a1 100644 --- a/AobaClient/assets/style/inputs.scss +++ b/AobaClient/assets/style/inputs.scss @@ -1,9 +1,23 @@ -.searchBar { - display: grid; - width: 100%; -} - label { display: flex; flex-direction: column; } + +textarea, +input[type="url"], +input[type="email"], +input[type="number"], +input[type="tel"], +input[type="text"] { +} + +.searchBar { + display: grid; + width: 100%; + + input { + padding: 10px; + font-size: 1.5rem; + border-radius: 20px; + } +} diff --git a/AobaClient/assets/style/main.scss b/AobaClient/assets/style/main.scss index 52c5388..7390af7 100644 --- a/AobaClient/assets/style/main.scss +++ b/AobaClient/assets/style/main.scss @@ -1,6 +1,5 @@ @import "mixins"; @import "colors"; -@import "inputs"; :root { background-color: $mainBGColor; @@ -13,6 +12,11 @@ font-variation-settings: "wdth" 100; } +.stickyTop { + top: 0; + position: sticky; +} + body { padding: 0; margin: 0; diff --git a/AobaClient/src/components/search.rs b/AobaClient/src/components/search.rs index c8d9b06..8545343 100644 --- a/AobaClient/src/components/search.rs +++ b/AobaClient/src/components/search.rs @@ -4,7 +4,7 @@ use dioxus::prelude::*; pub fn Search(query: Signal) -> Element { rsx! { div{ - class: "searchBar", + class: "searchBar stickyTop", input { type: "search", placeholder: "Search Files", diff --git a/AobaClient/src/main.rs b/AobaClient/src/main.rs index 50ad648..75b421a 100644 --- a/AobaClient/src/main.rs +++ b/AobaClient/src/main.rs @@ -17,6 +17,7 @@ pub const HOST: &'static str = "https://aoba.app"; const FAVICON: Asset = asset!("/assets/favicon.ico"); const MAIN_CSS: Asset = asset!("/assets/style/main.scss"); +const INPUT_CSS: Asset = asset!("/assets/style/inputs.scss"); fn main() { dioxus::launch(App); @@ -30,6 +31,7 @@ fn App() -> Element { document::Link { rel: "preconnect", href: "https://fonts.googleapis.com" } document::Link { rel: "preconnect", href: "https://fonts.gstatic.com" } document::Link { rel: "stylesheet", href: MAIN_CSS } + document::Link { rel: "stylesheet", href: INPUT_CSS } document::Link { rel: "stylesheet", href: "https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap", diff --git a/AobaCore/AobaCore.csproj b/AobaCore/AobaCore.csproj index 3a18181..7eb3c32 100644 --- a/AobaCore/AobaCore.csproj +++ b/AobaCore/AobaCore.csproj @@ -11,7 +11,6 @@ - diff --git a/AobaCore/AobaService.cs b/AobaCore/AobaService.cs index ffe820f..e7869ea 100644 --- a/AobaCore/AobaService.cs +++ b/AobaCore/AobaService.cs @@ -21,11 +21,12 @@ public class AobaService(IMongoDatabase db) public async Task> FindMediaAsync(string? query, int page = 1, int pageSize = 100) { var filter = string.IsNullOrWhiteSpace(query) ? "{}" : Builders.Filter.Text(query); + var sort = Builders.Sort.Descending(m => m.UploadDate); var find = _media.Find(filter); var total = await find.CountDocumentsAsync(); page -= 1; - var items = await find.Skip(page * pageSize).Limit(pageSize).ToListAsync(); + var items = await find.Sort(sort).Skip(page * pageSize).Limit(pageSize).ToListAsync(); return new PagedResult(items, page, pageSize, total); } diff --git a/AobaCore/Extensions.cs b/AobaCore/Extensions.cs index a2cd903..691cb35 100644 --- a/AobaCore/Extensions.cs +++ b/AobaCore/Extensions.cs @@ -1,4 +1,4 @@ -global using MaybeError; +global using MaybeError; using Microsoft.Extensions.DependencyInjection; using MongoDB.Driver; @@ -13,9 +13,9 @@ using System.Threading.Tasks; namespace AobaCore; public static class Extensions { - public static IServiceCollection AddAoba(this IServiceCollection services) + public static IServiceCollection AddAoba(this IServiceCollection services, string dbString) { - var settings = MongoClientSettings.FromConnectionString("mongodb://NinoIna:27017"); + var settings = MongoClientSettings.FromConnectionString(dbString); settings.ClusterConfigurator = cb => cb.Subscribe(new DiagnosticsActivityEventSubscriber()); var dbClient = new MongoClient(settings); var db = dbClient.GetDatabase("Aoba"); diff --git a/AobaCore/Models/Media.cs b/AobaCore/Models/Media.cs index 5d178b5..3e0ab51 100644 --- a/AobaCore/Models/Media.cs +++ b/AobaCore/Models/Media.cs @@ -14,6 +14,7 @@ public class Media public string Ext { get; set; } public int ViewCount { get; set; } public ObjectId Owner { get; set; } + public DateTime UploadDate { get; set; } public static readonly Dictionary KnownTypes = new() diff --git a/AobaServer/AobaServer.csproj b/AobaServer/AobaServer.csproj index 2de3dd8..d3976c5 100644 --- a/AobaServer/AobaServer.csproj +++ b/AobaServer/AobaServer.csproj @@ -36,7 +36,7 @@ - + diff --git a/AobaServer/Controllers/MediaController.cs b/AobaServer/Controllers/MediaController.cs index e759c8c..4878bb1 100644 --- a/AobaServer/Controllers/MediaController.cs +++ b/AobaServer/Controllers/MediaController.cs @@ -42,4 +42,11 @@ public class MediaController(AobaService aobaService, ILogger l return NotFound(); return LocalRedirectPermanent($"/m/{media.MediaId}/{rest}"); } + + [HttpGet("thumb/{id}")] + public async Task ThumbAsync(ObjectId id) + { + + return NoContent(); + } } diff --git a/AobaServer/Program.cs b/AobaServer/Program.cs index 3241517..477f2b5 100644 --- a/AobaServer/Program.cs +++ b/AobaServer/Program.cs @@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Http.Features; using Microsoft.IdentityModel.Tokens; var builder = WebApplication.CreateBuilder(args); - +var config = builder.Configuration; // Add services to the container. builder.Services.AddControllers(opt => opt.ModelBinderProviders.Add(new BsonIdModelBinderProvider())); @@ -70,7 +70,7 @@ builder.Services.AddAuthentication(options => ctx.Token = ctx.Request.Headers.Authorization.FirstOrDefault()?.Replace("Bearer ", ""); #if DEBUG //allow cookie based auth when in debug mode - if(string.IsNullOrWhiteSpace(ctx.Token)) + if (string.IsNullOrWhiteSpace(ctx.Token)) ctx.Token = ctx.Request.Cookies.FirstOrDefault(c => c.Key == "token").Value; #endif @@ -90,7 +90,8 @@ builder.Services.AddAuthentication(options => }; }).AddScheme("Aoba", null); -builder.Services.AddAoba(); +var dbString = config["DB_STRING"]; +builder.Services.AddAoba(dbString ?? "mongodb://localhost:27017"); builder.Services.Configure(opt => { opt.ValueLengthLimit = int.MaxValue; diff --git a/AobaServer/appsettings.Development.json b/AobaServer/appsettings.Development.json index 0c208ae..2dc7cb1 100644 --- a/AobaServer/appsettings.Development.json +++ b/AobaServer/appsettings.Development.json @@ -1,8 +1,9 @@ { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - } + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "DB_STRING": "mongodb://NinoIna:27017" } diff --git a/docker-compose.yml b/docker-compose.yml index 321bd62..fc7220e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,5 @@ services: - # client: - # build: - # context: . - # dockerfile: AobaClient/Dockerfile - server: + aoba: build: context: . dockerfile: AobaServer/Dockerfile