inputs.scss refactor

Added upload date to media + sort by date
This commit is contained in:
2025-05-18 19:58:56 -04:00
parent 541cdd0b57
commit 3d4e269c21
14 changed files with 53 additions and 71 deletions

View File

@@ -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" ]

View File

@@ -1,9 +1,23 @@
.searchBar {
display: grid;
width: 100%;
}
label { label {
display: flex; display: flex;
flex-direction: column; 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;
}
}

View File

@@ -1,6 +1,5 @@
@import "mixins"; @import "mixins";
@import "colors"; @import "colors";
@import "inputs";
:root { :root {
background-color: $mainBGColor; background-color: $mainBGColor;
@@ -13,6 +12,11 @@
font-variation-settings: "wdth" 100; font-variation-settings: "wdth" 100;
} }
.stickyTop {
top: 0;
position: sticky;
}
body { body {
padding: 0; padding: 0;
margin: 0; margin: 0;

View File

@@ -4,7 +4,7 @@ use dioxus::prelude::*;
pub fn Search(query: Signal<String>) -> Element { pub fn Search(query: Signal<String>) -> Element {
rsx! { rsx! {
div{ div{
class: "searchBar", class: "searchBar stickyTop",
input { input {
type: "search", type: "search",
placeholder: "Search Files", placeholder: "Search Files",

View File

@@ -17,6 +17,7 @@ pub const HOST: &'static str = "https://aoba.app";
const FAVICON: Asset = asset!("/assets/favicon.ico"); const FAVICON: Asset = asset!("/assets/favicon.ico");
const MAIN_CSS: Asset = asset!("/assets/style/main.scss"); const MAIN_CSS: Asset = asset!("/assets/style/main.scss");
const INPUT_CSS: Asset = asset!("/assets/style/inputs.scss");
fn main() { fn main() {
dioxus::launch(App); 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.googleapis.com" }
document::Link { rel: "preconnect", href: "https://fonts.gstatic.com" } document::Link { rel: "preconnect", href: "https://fonts.gstatic.com" }
document::Link { rel: "stylesheet", href: MAIN_CSS } document::Link { rel: "stylesheet", href: MAIN_CSS }
document::Link { rel: "stylesheet", href: INPUT_CSS }
document::Link { document::Link {
rel: "stylesheet", rel: "stylesheet",
href: "https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap", href: "https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap",

View File

@@ -11,7 +11,6 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.5" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.5" />
<PackageReference Include="MaybeError" Version="1.1.0" /> <PackageReference Include="MaybeError" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" /> <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.5" />
<PackageReference Include="MongoDB.Analyzer" Version="2.0.0" />
<PackageReference Include="MongoDB.Driver" Version="3.4.0" /> <PackageReference Include="MongoDB.Driver" Version="3.4.0" />
<PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="2.0.0" /> <PackageReference Include="MongoDB.Driver.Core.Extensions.DiagnosticSources" Version="2.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.10.0" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.10.0" />

View File

@@ -21,11 +21,12 @@ public class AobaService(IMongoDatabase db)
public async Task<PagedResult<Media>> FindMediaAsync(string? query, int page = 1, int pageSize = 100) public async Task<PagedResult<Media>> FindMediaAsync(string? query, int page = 1, int pageSize = 100)
{ {
var filter = string.IsNullOrWhiteSpace(query) ? "{}" : Builders<Media>.Filter.Text(query); var filter = string.IsNullOrWhiteSpace(query) ? "{}" : Builders<Media>.Filter.Text(query);
var sort = Builders<Media>.Sort.Descending(m => m.UploadDate);
var find = _media.Find(filter); var find = _media.Find(filter);
var total = await find.CountDocumentsAsync(); var total = await find.CountDocumentsAsync();
page -= 1; 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<Media>(items, page, pageSize, total); return new PagedResult<Media>(items, page, pageSize, total);
} }

View File

@@ -1,4 +1,4 @@
global using MaybeError; global using MaybeError;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using MongoDB.Driver; using MongoDB.Driver;
@@ -13,9 +13,9 @@ using System.Threading.Tasks;
namespace AobaCore; namespace AobaCore;
public static class Extensions 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()); settings.ClusterConfigurator = cb => cb.Subscribe(new DiagnosticsActivityEventSubscriber());
var dbClient = new MongoClient(settings); var dbClient = new MongoClient(settings);
var db = dbClient.GetDatabase("Aoba"); var db = dbClient.GetDatabase("Aoba");

View File

@@ -14,6 +14,7 @@ public class Media
public string Ext { get; set; } public string Ext { get; set; }
public int ViewCount { get; set; } public int ViewCount { get; set; }
public ObjectId Owner { get; set; } public ObjectId Owner { get; set; }
public DateTime UploadDate { get; set; }
public static readonly Dictionary<string, MediaType> KnownTypes = new() public static readonly Dictionary<string, MediaType> KnownTypes = new()

View File

@@ -36,7 +36,7 @@
<Protobuf Include="Proto\Auth.proto"></Protobuf> <Protobuf Include="Proto\Auth.proto"></Protobuf>
</ItemGroup> </ItemGroup>
<Target Name="BuildDioxusClientDebug" BeforeTargets="Build" Condition="'$(Configuration)'=='DEBUG'"> <Target Name="BuildDioxusClientDebug" BeforeTargets="Build" Condition="'$(Configuration)'=='B'">
<Exec Command="dx build --platform web" WorkingDirectory="..\AobaClient" /> <Exec Command="dx build --platform web" WorkingDirectory="..\AobaClient" />
<Exec Command="rm -rf wwwroot/*" /> <Exec Command="rm -rf wwwroot/*" />
<Exec Command="cp -r target\dx\aoba-client\debug\web\public\* ../AobaServer/wwwroot/" WorkingDirectory="..\AobaClient" /> <Exec Command="cp -r target\dx\aoba-client\debug\web\public\* ../AobaServer/wwwroot/" WorkingDirectory="..\AobaClient" />

View File

@@ -42,4 +42,11 @@ public class MediaController(AobaService aobaService, ILogger<MediaController> l
return NotFound(); return NotFound();
return LocalRedirectPermanent($"/m/{media.MediaId}/{rest}"); return LocalRedirectPermanent($"/m/{media.MediaId}/{rest}");
} }
[HttpGet("thumb/{id}")]
public async Task<IActionResult> ThumbAsync(ObjectId id)
{
return NoContent();
}
} }

View File

@@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Http.Features;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
// Add services to the container. // Add services to the container.
builder.Services.AddControllers(opt => opt.ModelBinderProviders.Add(new BsonIdModelBinderProvider())); 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 ", ""); ctx.Token = ctx.Request.Headers.Authorization.FirstOrDefault()?.Replace("Bearer ", "");
#if DEBUG //allow cookie based auth when in debug mode #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; ctx.Token = ctx.Request.Cookies.FirstOrDefault(c => c.Key == "token").Value;
#endif #endif
@@ -90,7 +90,8 @@ builder.Services.AddAuthentication(options =>
}; };
}).AddScheme<AuthenticationSchemeOptions, AobaAuthenticationHandler>("Aoba", null); }).AddScheme<AuthenticationSchemeOptions, AobaAuthenticationHandler>("Aoba", null);
builder.Services.AddAoba(); var dbString = config["DB_STRING"];
builder.Services.AddAoba(dbString ?? "mongodb://localhost:27017");
builder.Services.Configure<FormOptions>(opt => builder.Services.Configure<FormOptions>(opt =>
{ {
opt.ValueLengthLimit = int.MaxValue; opt.ValueLengthLimit = int.MaxValue;

View File

@@ -1,8 +1,9 @@
{ {
"Logging": { "Logging": {
"LogLevel": { "LogLevel": {
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
} },
"DB_STRING": "mongodb://NinoIna:27017"
} }

View File

@@ -1,9 +1,5 @@
services: services:
# client: aoba:
# build:
# context: .
# dockerfile: AobaClient/Dockerfile
server:
build: build:
context: . context: .
dockerfile: AobaServer/Dockerfile dockerfile: AobaServer/Dockerfile