commit ed2b4aa5f4988b9fec9da7124ab5286a0844ec1a Author: ChiaraBm Date: Fri Feb 20 22:54:01 2026 +0100 First iteration of the plugin template diff --git a/.gitea/workflows/publish.yml b/.gitea/workflows/publish.yml new file mode 100644 index 0000000..e059af6 --- /dev/null +++ b/.gitea/workflows/publish.yml @@ -0,0 +1,29 @@ +name: "Nuget: publish" + +on: + workflow_dispatch: + push: + paths: + - "Moonlight.PluginTemplate.csproj" + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + # Checkout code + - name: Checkout code + uses: actions/checkout@v4 + + # Build project + - name: Build project + run: dotnet build Moonlight.PluginTemplate --configuration Release + + # Publish project + - name: Publish NuGet package + run: dotnet pack Moonlight.PluginTemplate --configuration Release --output ./artifacts + + - name: Push nuget package + run: dotnet nuget push ./artifacts/*.nupkg --skip-duplicate --source https://git.battlestati.one/api/packages/Moonlight-Panel/nuget/index.json --api-key ${{ secrets.ACCESS_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a14093b --- /dev/null +++ b/.gitignore @@ -0,0 +1,409 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +**/.idea/** + +# Style builds +**/style.min.css +**/package-lock.json +**/bun.lock + +# Secrets +**/.env +**/appsettings.json +**/appsettings.Development.json +**/storage \ No newline at end of file diff --git a/Moonlight.PluginTemplate.csproj b/Moonlight.PluginTemplate.csproj new file mode 100644 index 0000000..61d88d4 --- /dev/null +++ b/Moonlight.PluginTemplate.csproj @@ -0,0 +1,61 @@ + + + + Moonlight.PluginTemplate + 1.0.0 + Moonlight.PluginTemplate + Moonlight-Panel + Template for a plugin for moonlighte + moonlight,plugin,template + https://git.battlestati.one/Moonlight-Panel/PluginTemplate + Template + net10.0 + true + false + content + $(NoWarn);NU5128 + true + README.md + Moonlight.PluginTemplate + + + + false + + + + + + + + + + + + + + + + + + + + + + diff --git a/PluginTemplate.slnx b/PluginTemplate.slnx new file mode 100644 index 0000000..d12dd8d --- /dev/null +++ b/PluginTemplate.slnx @@ -0,0 +1,3 @@ + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..629251f --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Template for a plugin for moonlight diff --git a/content/PluginTemplate/.template.config/template.json b/content/PluginTemplate/.template.config/template.json new file mode 100644 index 0000000..0b7b927 --- /dev/null +++ b/content/PluginTemplate/.template.config/template.json @@ -0,0 +1,54 @@ +{ + "$schema": "http://json.schemastore.org/template", + "author": "Moonlight-Panel", + "classifications": [ + "Moonlight" + ], + "name": "PluginTemplate", + "description": "Template for a plugin for moonlight", + "precedence": "0", + "identity": "Moonlight.PluginTemplate", + "shortName": "moonlight-plugintemplate", + "tags": { + "language": "C#", + "type": "project" + }, + "sourceName": "PluginTemplate", + "sources": [ + { + "source": "./", + "target": "./", + "include": [ + "**/*" + ], + "exclude": [ + "**/[Bb]in/**", + "**/[Oo]bj/**", + "**/.template.config/**", + "**/*.filelist", + "**/*.user", + "**/*.lock.json", + "**/bun.lock", + "**/node_modules/**", + "**/storage/**", + "**/appsettings.Development.json", + "**/appsettings.json", + "**/.idea/**", + "**/.idea/**", + "**/style.min.css" + ] + } + ], + "postActions": [ + { + "actionId": "AC1156F7-BB77-4DB8-B28F-24EEBCCA1E5C", + "condition": "true", + "id": "instructions", + "manualInstructions": [ + { + "text": "Template successfully applied. https://moonlightpa.nl/dev" + } + ] + } + ] +} diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Api.props b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Api.props new file mode 100644 index 0000000..f531296 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Api.props @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/PluginTemplate.Api.Host.csproj b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/PluginTemplate.Api.Host.csproj new file mode 100644 index 0000000..4512290 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/PluginTemplate.Api.Host.csproj @@ -0,0 +1,29 @@ + + + + net10.0 + enable + enable + + + + + + + + all + runtime; build; native; analyzers; buildtransitive + + + + + + + + + + + + + + diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Program.cs b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Program.cs new file mode 100644 index 0000000..6a74836 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Program.cs @@ -0,0 +1,9 @@ +using Moonlight.Api; +using SimplePlugin.Generated; + +var plugins = PluginRegistry + .Modules + .OfType() + .ToArray(); + +await StartupHandler.RunAsync(args, plugins); \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Properties/launchSettings.json b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Properties/launchSettings.json new file mode 100644 index 0000000..f2c4d7a --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://localhost:5031", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7240;http://localhost:5031", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/appsettings.Example.json b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/appsettings.Example.json new file mode 100644 index 0000000..6a31ede --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Api.Host/appsettings.Example.json @@ -0,0 +1,23 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "Moonlight": { + "Database": { + "Host": "your-db.host", + "Username": "change_me", + "Password": "change_me", + "Database": "change_me" + }, + "Oidc": { + "Authority": "http://localhost:8092", + "RequireHttpsMetadata": false, + "ClientId": "clientId", + "ClientSecret": "clientSecret" + } + } +} diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Frontend.props b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Frontend.props new file mode 100644 index 0000000..384e727 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Frontend.props @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/PluginTemplate.Frontend.Host.csproj b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/PluginTemplate.Frontend.Host.csproj new file mode 100644 index 0000000..764a410 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/PluginTemplate.Frontend.Host.csproj @@ -0,0 +1,22 @@ + + + + net10.0 + enable + enable + true + + + + + + + + + + + + + + + diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Program.cs b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Program.cs new file mode 100644 index 0000000..eff3e47 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Program.cs @@ -0,0 +1,9 @@ +using Moonlight.Frontend; +using SimplePlugin.Generated; + +var plugins = PluginRegistry + .Modules + .OfType() + .ToArray(); + +await StartupHandler.RunAsync(args, plugins); \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/extract-classes.mjs b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/extract-classes.mjs new file mode 100644 index 0000000..f27b5a5 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/extract-classes.mjs @@ -0,0 +1,25 @@ +import fs from 'fs'; +import selectorParser from 'postcss-selector-parser'; + +export default function extractTailwindClasses(opts = {}) { + const classSet = new Set(); + + return { + postcssPlugin: 'extract-tailwind-classes', + Rule(rule) { + selectorParser(selectors => { + selectors.walkClasses(node => { + classSet.add(node.value); + }); + }).processSync(rule.selector); + }, + OnceExit() { + const classArray = Array.from(classSet).sort(); + fs.mkdirSync('../../../PluginTemplate.Frontend/Styles', { recursive: true }); + fs.writeFileSync('../../../PluginTemplate.Frontend/Styles/PluginTemplate.Frontend.map', classArray.join('\n')); + console.log(`Extracted classes ${classArray.length}`); + } + }; +} + +extractTailwindClasses.postcss = true; \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/package.json b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/package.json new file mode 100644 index 0000000..f1efab1 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/package.json @@ -0,0 +1,19 @@ +{ + "scripts": { + "dev": "npx postcss styles.css -o ../wwwroot/style.min.css --watch", + "dev-build": "npx postcss styles.css -o ../wwwroot/style.min.css", + "build": "cross-env EXTRACT_CLASSES=true npx postcss styles.css -o ../wwwroot/style.min.css" + }, + "dependencies": { + "@tailwindcss/postcss": "^4.1.18", + "cssnano": "^7.1.2", + "postcss": "^8.5.6", + "postcss-cli": "^11.0.1", + "postcss-selector-parser": "^7.1.1", + "tailwindcss": "^4.1.18", + "tw-animate-css": "^1.4.0" + }, + "devDependencies": { + "cross-env": "^10.1.0" + } +} \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/postcss.config.mjs b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/postcss.config.mjs new file mode 100644 index 0000000..3bc7e1b --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/postcss.config.mjs @@ -0,0 +1,18 @@ +import tailwindcss from '@tailwindcss/postcss'; +import cssnano from 'cssnano'; +import extractTailwindClasses from './extract-classes.mjs'; + +const plugins = [ + tailwindcss, + cssnano({ + preset: 'default' + }) +]; + +if (process.env.EXTRACT_CLASSES === "true") { + plugins.push(extractTailwindClasses()); +} + +export default { + plugins +}; \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/styles.css b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/styles.css new file mode 100644 index 0000000..2074f76 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/styles.css @@ -0,0 +1,31 @@ +@import "tailwindcss"; +@import "tw-animate-css"; + +@import "../bin/ShadcnBlazor/scrollbar.css"; +@import "../bin/ShadcnBlazor/default-theme.css"; +@import "./theme.css"; + +@source "../bin/Moonlight.Frontend/*.map"; + +@source "../../../Moonlight.Api/**/*.razor"; +@source "../../../Moonlight.Api/**/*.cs"; +@source "../../../Moonlight.Api/**/*.html"; + +@source "../../../Moonlight.Frontend/**/*.razor"; +@source "../../../Moonlight.Frontend/**/*.cs"; +@source "../../../Moonlight.Frontend/**/*.html"; + +@custom-variant dark (&:is(.dark *)); + +#blazor-error-ui { + display: none; +} + +@layer base { + * { + @apply border-border outline-ring/50; + } + body { + @apply bg-background text-foreground; + } +} \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/theme.css b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/theme.css new file mode 100644 index 0000000..510373c --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/Styles/theme.css @@ -0,0 +1,132 @@ +:root { + --radius: 0.625rem; + --background: oklch(1 0 0); + --foreground: oklch(0.129 0.042 264.695); + --card: oklch(1 0 0); + --card-foreground: oklch(0.129 0.042 264.695); + --popover: oklch(1 0 0); + --popover-foreground: oklch(0.129 0.042 264.695); + --primary: oklch(0.208 0.042 265.755); + --primary-foreground: oklch(0.984 0.003 247.858); + --secondary: oklch(0.968 0.007 247.896); + --secondary-foreground: oklch(0.208 0.042 265.755); + --muted: oklch(0.968 0.007 247.896); + --muted-foreground: oklch(0.554 0.046 257.417); + --accent: oklch(0.968 0.007 247.896); + --accent-foreground: oklch(0.208 0.042 265.755); + --destructive: oklch(0.577 0.245 27.325); + --border: oklch(0.929 0.013 255.508); + --input: oklch(0.929 0.013 255.508); + --ring: oklch(0.704 0.04 256.788); + --chart-1: oklch(0.646 0.222 41.116); + --chart-2: oklch(0.6 0.118 184.704); + --chart-3: oklch(0.398 0.07 227.392); + --chart-4: oklch(0.828 0.189 84.429); + --chart-5: oklch(0.769 0.188 70.08); + + --sidebar: var(--background); + --sidebar-foreground: var(--foreground); + --sidebar-primary: var(--primary); + --sidebar-primary-foreground: var(--primary-foreground); + --sidebar-accent: var(--accent); + --sidebar-accent-foreground: var(--accent-foreground); + --sidebar-border: var(--border); + --sidebar-ring: var(--ring); + + --font-sans: Inter, sans-serif; + --font-serif: Georgia, serif; +} + +.dark { + /* Deep blue-slate background with purple undertones */ + --background: oklch(0.16 0.028 260); + --foreground: oklch(0.98 0.008 260); + + /* Cards with slightly lighter blue-slate */ + --card: oklch(0.21 0.032 260); + --card-foreground: oklch(0.98 0.008 260); + + /* Popovers with medium depth */ + --popover: oklch(0.24 0.035 260); + --popover-foreground: oklch(0.98 0.008 260); + + /* Vibrant blue-purple primary */ + --primary: oklch(0.62 0.18 270); + --primary-foreground: oklch(0.99 0.005 260); + + /* Secondary with blue-slate tone */ + --secondary: oklch(0.27 0.038 260); + --secondary-foreground: oklch(0.98 0.008 260); + + /* Muted elements */ + --muted: oklch(0.25 0.035 260); + --muted-foreground: oklch(0.66 0.025 260); + + /* Accent with purple-blue blend */ + --accent: oklch(0.36 0.065 268); + --accent-foreground: oklch(0.98 0.008 260); + + /* Destructive red with good contrast */ + --destructive: oklch(0.62 0.22 25); + --destructive-foreground: oklch(0.99 0.005 260); + + /* Subtle borders and inputs */ + --border: oklch(0.32 0.025 260); + --input: oklch(0.30 0.030 260); + --ring: oklch(0.62 0.18 270); + + /* Chart colors with blue-purple harmony */ + --chart-1: oklch(0.58 0.18 270); + --chart-2: oklch(0.62 0.16 245); + --chart-3: oklch(0.68 0.15 290); + --chart-4: oklch(0.60 0.20 260); + --chart-5: oklch(0.65 0.14 280); + + /* Sidebar with slightly different depth */ + --sidebar: oklch(0.18 0.030 260); + --sidebar-foreground: oklch(0.97 0.008 260); + --sidebar-primary: oklch(0.60 0.17 270); + --sidebar-primary-foreground: oklch(0.99 0.005 260); + --sidebar-accent: oklch(0.26 0.038 260); + --sidebar-accent-foreground: oklch(0.98 0.008 260); + --sidebar-border: oklch(0.30 0.025 260); + --sidebar-ring: oklch(0.58 0.17 270); +} + +@theme inline { + --radius-sm: calc(var(--radius) - 4px); + --radius-md: calc(var(--radius) - 2px); + --radius-lg: var(--radius); + --radius-xl: calc(var(--radius) + 4px); + --color-background: var(--background); + --color-foreground: var(--foreground); + --color-card: var(--card); + --color-card-foreground: var(--card-foreground); + --color-popover: var(--popover); + --color-popover-foreground: var(--popover-foreground); + --color-primary: var(--primary); + --color-primary-foreground: var(--primary-foreground); + --color-secondary: var(--secondary); + --color-secondary-foreground: var(--secondary-foreground); + --color-muted: var(--muted); + --color-muted-foreground: var(--muted-foreground); + --color-accent: var(--accent); + --color-accent-foreground: var(--accent-foreground); + --color-destructive: var(--destructive); + --color-border: var(--border); + --color-input: var(--input); + --color-ring: var(--ring); + --color-chart-1: var(--chart-1); + --color-chart-2: var(--chart-2); + --color-chart-3: var(--chart-3); + --color-chart-4: var(--chart-4); + --color-chart-5: var(--chart-5); + --color-sidebar: var(--sidebar); + --color-sidebar-foreground: var(--sidebar-foreground); + --color-sidebar-primary: var(--sidebar-primary); + --color-sidebar-primary-foreground: var(--sidebar-primary-foreground); + --color-sidebar-accent: var(--sidebar-accent); + --color-sidebar-accent-foreground: var(--sidebar-accent-foreground); + --color-sidebar-border: var(--sidebar-border); + --color-sidebar-ring: var(--sidebar-ring); +} \ No newline at end of file diff --git a/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/wwwroot/index.html b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/wwwroot/index.html new file mode 100644 index 0000000..dfb9733 --- /dev/null +++ b/content/PluginTemplate/Hosts/PluginTemplate.Frontend.Host/wwwroot/index.html @@ -0,0 +1,108 @@ + + + + + + + Moonlight + + + + + + + + + + +
+
+ +
+
+
+ + + + + +
+
+
+ Loading application +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ An unhandled error has occurred. + Reload + 🗙 +
+ + + + + + + + diff --git a/content/PluginTemplate/PluginTemplate.Api/Http/Controllers/FormController.cs b/content/PluginTemplate/PluginTemplate.Api/Http/Controllers/FormController.cs new file mode 100644 index 0000000..0bbc36b --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Api/Http/Controllers/FormController.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using PluginTemplate.Shared.Http.Requests; +using PluginTemplate.Shared.Http.Responses; + +namespace PluginTemplate.Api.Http.Controllers; + +[Authorize] +[ApiController] +[Route("api/form")] +public class FormController : Controller +{ + [HttpPost] + public async Task> PostAsync([FromBody] FormSubmitDto dto) + { + return new FormResultDto() + { + Result = dto.TextField.Replace(" ", string.Empty) + }; + } +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Api/PluginTemplate.Api.csproj b/content/PluginTemplate/PluginTemplate.Api/PluginTemplate.Api.csproj new file mode 100644 index 0000000..73ec4c4 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Api/PluginTemplate.Api.csproj @@ -0,0 +1,36 @@ + + + + net10.0 + enable + enable + + + + + + + + + + content;contentfiles + + + + + + + + + + + + + + + + + + + + diff --git a/content/PluginTemplate/PluginTemplate.Api/Startup.cs b/content/PluginTemplate/PluginTemplate.Api/Startup.cs new file mode 100644 index 0000000..e29d83e --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Api/Startup.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Moonlight.Api; +using SimplePlugin.Abstractions; +using SerializationContext = PluginTemplate.Shared.SerializationContext; + +namespace PluginTemplate.Api; + +[PluginModule] +public class Startup : MoonlightPlugin +{ + public override void PreBuild(WebApplicationBuilder builder) + { + builder.Services.AddControllers() + .AddApplicationPart(typeof(Startup).Assembly) + .AddJsonOptions(options => + { + options.JsonSerializerOptions.TypeInfoResolverChain.Add(SerializationContext.Default); + }); + } +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Frontend/Implementations/PermissionProvider.cs b/content/PluginTemplate/PluginTemplate.Frontend/Implementations/PermissionProvider.cs new file mode 100644 index 0000000..95fa932 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/Implementations/PermissionProvider.cs @@ -0,0 +1,17 @@ +using LucideBlazor; +using Moonlight.Frontend.Interfaces; +using Moonlight.Frontend.Models; + +namespace PluginTemplate.Frontend.Implementations; + +public class PermissionProvider : IPermissionProvider +{ + public Task GetPermissionsAsync() + { + return Task.FromResult([ + new PermissionCategory("Demo", typeof(SparklesIcon), [ + new Permission("Permissions:Demo", "Demo", "Access to demo page") + ]) + ]); + } +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Frontend/Implementations/SidebarProvider.cs b/content/PluginTemplate/PluginTemplate.Frontend/Implementations/SidebarProvider.cs new file mode 100644 index 0000000..d20d7ca --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/Implementations/SidebarProvider.cs @@ -0,0 +1,21 @@ +using LucideBlazor; +using Moonlight.Frontend.Interfaces; +using Moonlight.Frontend.Models; + +namespace PluginTemplate.Frontend.Implementations; + +public sealed class SidebarProvider : ISidebarProvider +{ + public Task GetItemsAsync() + { + return Task.FromResult([ + new SidebarItem() + { + Group = "Demo", + Name = "Demo", + IconType = typeof(SparklesIcon), + Path = "/demo" + } + ]); + } +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Frontend/PluginTemplate.Frontend.csproj b/content/PluginTemplate/PluginTemplate.Frontend/PluginTemplate.Frontend.csproj new file mode 100644 index 0000000..6e803bf --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/PluginTemplate.Frontend.csproj @@ -0,0 +1,32 @@ + + + + net10.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/content/PluginTemplate/PluginTemplate.Frontend/PluginTemplate.Frontend.targets b/content/PluginTemplate/PluginTemplate.Frontend/PluginTemplate.Frontend.targets new file mode 100644 index 0000000..ade13a9 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/PluginTemplate.Frontend.targets @@ -0,0 +1,15 @@ + + + + $(MSBuildProjectDirectory)\bin\PluginTemplate + + + + + + + + + + + \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Frontend/Startup.cs b/content/PluginTemplate/PluginTemplate.Frontend/Startup.cs new file mode 100644 index 0000000..0324fc0 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/Startup.cs @@ -0,0 +1,29 @@ +using Microsoft.AspNetCore.Components.WebAssembly.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Moonlight.Frontend; +using Moonlight.Frontend.Configuration; +using Moonlight.Frontend.Interfaces; +using PluginTemplate.Frontend.Implementations; +using SimplePlugin.Abstractions; + +namespace PluginTemplate.Frontend; + +[PluginModule] +public sealed class Startup : MoonlightPlugin +{ + public override void PreBuild(WebAssemblyHostBuilder builder) + { + builder.Services.AddSingleton(); + builder.Services.AddSingleton(); + + builder.Services.Configure(options => + { + options.Assemblies.Add(typeof(Startup).Assembly); + }); + } + + public override void PostBuild(WebAssemblyHost application) + { + + } +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Frontend/UI/Components/FormDialog.razor b/content/PluginTemplate/PluginTemplate.Frontend/UI/Components/FormDialog.razor new file mode 100644 index 0000000..0dab42a --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/UI/Components/FormDialog.razor @@ -0,0 +1,74 @@ +@using Moonlight.Frontend.Helpers +@using PluginTemplate.Shared +@using PluginTemplate.Shared.Http.Requests +@using PluginTemplate.Shared.Http.Responses +@using ShadcnBlazor.Buttons +@using ShadcnBlazor.Dialogs +@using ShadcnBlazor.Extras.AlertDialogs +@using ShadcnBlazor.Extras.Forms +@using ShadcnBlazor.Fields +@using ShadcnBlazor.Inputs + +@inherits ShadcnBlazor.Extras.Dialogs.DialogBase + +@inject HttpClient HttpClient +@inject AlertDialogService AlertDialogService + + + Example Form + This forms removes all spaces from the input + + + + + +
+ + + + + Form Input + + Input you want to remove the spaces from + + +
+
+ + + + + + +@code +{ + private FormSubmitDto Dto = new(); + private EnhancedEditForm Form; + + private async Task OnSubmit(EditContext editContext, ValidationMessageStore validationMessageStore) + { + var response = await HttpClient.PostAsJsonAsync( + "api/form", + Dto, + SerializationContext.Default.Options + ); + + if (response.IsSuccessStatusCode) + { + var data = await response.Content.ReadFromJsonAsync( + SerializationContext.Default.Options + ); + + if (data == null) + return true; + + await AlertDialogService.InfoAsync("Result", data.Result); + + await CloseAsync(); + return true; + } + + await ProblemDetailsHelper.HandleProblemDetailsAsync(response, Dto, validationMessageStore); + return false; + } +} diff --git a/content/PluginTemplate/PluginTemplate.Frontend/UI/Views/Demo.razor b/content/PluginTemplate/PluginTemplate.Frontend/UI/Views/Demo.razor new file mode 100644 index 0000000..94d8a10 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/UI/Views/Demo.razor @@ -0,0 +1,44 @@ +@page "/demo" +@using LucideBlazor +@using PluginTemplate.Frontend.UI.Components +@using ShadcnBlazor.Buttons +@using ShadcnBlazor.Cards +@using ShadcnBlazor.Extras.Dialogs + +@inject DialogService DialogService + +
+ + + Demo + A cool demo page + + + You successfully used the plugin template to create your moonlight plugin :) + + + + + + + + + + +
+ +@code +{ + private async Task LaunchFormAsync() + => await DialogService.LaunchAsync(); +} diff --git a/content/PluginTemplate/PluginTemplate.Frontend/UI/_Imports.razor b/content/PluginTemplate/PluginTemplate.Frontend/UI/_Imports.razor new file mode 100644 index 0000000..3516d7e --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Frontend/UI/_Imports.razor @@ -0,0 +1,6 @@ +@using System.Net.Http +@using System.Net.Http.Json +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Shared/Http/Requests/FormSubmitDto.cs b/content/PluginTemplate/PluginTemplate.Shared/Http/Requests/FormSubmitDto.cs new file mode 100644 index 0000000..673f91e --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Shared/Http/Requests/FormSubmitDto.cs @@ -0,0 +1,10 @@ +using System.ComponentModel.DataAnnotations; + +namespace PluginTemplate.Shared.Http.Requests; + +public class FormSubmitDto +{ + [Required] + [MaxLength(32)] + public string TextField { get; set; } +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Shared/Http/Responses/FormResultDto.cs b/content/PluginTemplate/PluginTemplate.Shared/Http/Responses/FormResultDto.cs new file mode 100644 index 0000000..c554db1 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Shared/Http/Responses/FormResultDto.cs @@ -0,0 +1,6 @@ +namespace PluginTemplate.Shared.Http.Responses; + +public class FormResultDto +{ + public string Result { get; set; } +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.Shared/PluginTemplate.Shared.csproj b/content/PluginTemplate/PluginTemplate.Shared/PluginTemplate.Shared.csproj new file mode 100644 index 0000000..237d661 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Shared/PluginTemplate.Shared.csproj @@ -0,0 +1,9 @@ + + + + net10.0 + enable + enable + + + diff --git a/content/PluginTemplate/PluginTemplate.Shared/SerializationContext.cs b/content/PluginTemplate/PluginTemplate.Shared/SerializationContext.cs new file mode 100644 index 0000000..6ba3345 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.Shared/SerializationContext.cs @@ -0,0 +1,15 @@ +using System.Text.Json; +using System.Text.Json.Serialization; +using PluginTemplate.Shared.Http.Requests; +using PluginTemplate.Shared.Http.Responses; + +namespace PluginTemplate.Shared; + +[JsonSerializable(typeof(FormSubmitDto))] +[JsonSerializable(typeof(FormResultDto))] + +[JsonSourceGenerationOptions(JsonSerializerDefaults.Web)] +public partial class SerializationContext : JsonSerializerContext +{ + +} \ No newline at end of file diff --git a/content/PluginTemplate/PluginTemplate.slnx b/content/PluginTemplate/PluginTemplate.slnx new file mode 100644 index 0000000..4454666 --- /dev/null +++ b/content/PluginTemplate/PluginTemplate.slnx @@ -0,0 +1,9 @@ + + + + + + + + +