diff --git a/.env.example b/.env.example index baa51c44..14c4bcbf 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ TVDB__APIKEY= THEMOVIEDB__APIKEY= AUTHENTICATION_SECRET= +POSTGRES_USERNAME= +POSTGRES_PASSWORD= diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 880c64d3..d7d0206d 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -5,3 +5,7 @@ body: - type: input attributes: label: "Kyoo's version" + - type: textarea + attributes: + label: What happened? + description: Also tell us, what did you expect to happen? diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index 8f7866ec..115d47a0 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,3 +1,7 @@ name: Feature Request description: Suggest a new feature for Kyoo (don't forget to check projects first) labels: [enhancement] +body: + - type: textarea + attributes: + label: Feature description diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index a2dbbf99..00000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,184 +0,0 @@ -name: Build -on: [push, pull_request, workflow_dispatch] - -jobs: - build: - name: "${{matrix.artifact}}'s Build" - runs-on: ${{matrix.os}} - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - strategy: - fail-fast: false - matrix: - include: - - os: ubuntu-latest - runtime: linux-x64 - artifact: linux - - os: windows-latest - runtime: win-x64 - artifact: windows - - os: macOS-latest - runtime: osx-x64 - artifact: macos - outputs: - version: ${{ steps.gitversion.outputs.majorMinorPatch }} - steps: - - uses: actions/checkout@v1 - with: - submodules: recursive - fetch-depth: 0 - - name: Setup .NET - uses: actions/setup-dotnet@v1 - with: - dotnet-version: 6.0.x - - name: Install ffmpeg - shell: bash - run: | - if [[ "${{runner.os}}" == "Windows" ]]; then - choco install ffmpeg-shared - elif [[ "${{runner.os}}" == "macOS" ]]; then - brew install ffmpeg - else - sudo apt-get update - sudo apt-get install -y libavutil-dev libavcodec-dev libavformat-dev - fi - - name: Enabling windows compilations tools - if: matrix.artifact == 'windows' - uses: ilammy/msvc-dev-cmd@v1 - - name: Select the project to build - shell: bash - run: | - echo "PROJECT=$([ "${{runner.os}}" == "Windows" ] \ - && echo " -p:IncludeConsole=true -p:CheckCodingStyle=false src/Kyoo.Host.WindowsTrait" \ - || echo " -p:CheckCodingStyle=false src/Kyoo.Host.Console")" >> $GITHUB_ENV - - name: Build the app - env: - INCLUDE: ${{env.INCLUDE}};C:\Program Files\FFmpeg\include - LIB: ${{env.LIB}};C:\Program Files\FFmpeg\lib - LIBPATH: ${{env.LIBPATH}};C:\Program Files\FFmpeg\lib - CFLAGS: -I/usr/local/include - LDFLAGS: -L/usr/local/lib - run: dotnet publish -r ${{matrix.runtime}} --self-contained -c Release -o dist ${{env.PROJECT}} - - name: Compression output - shell: bash - run: | - assets=kyoo_${{matrix.artifact}} - if [[ "${{runner.os}}" == "Windows" ]]; then - cd dist - cp -r "/C/Program Files/FFmpeg/bin/." . - 7z a "../$assets.zip" - else - rootgrp=$([ "${{runner.os}}" == "macOS" ] && echo wheel || echo root) - sudo chown -R root:$rootgrp dist - tar -C dist -czf "$assets.tar.gz" . - fi - - uses: actions/upload-artifact@v2 - with: - name: kyoo_${{matrix.artifact}} - path: | - *.zip - *.tar.gz - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.13 - with: - versionSpec: '5.x' - - name: Determine Version - id: gitversion - uses: gittools/actions/gitversion/execute@v0.9.13 - with: - useConfigFile: true - - windows_release: - name: Create windows release - runs-on: windows-latest - needs: build - if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'tags') }} - env: - version: ${{ needs.build.outputs.version }} - steps: - - uses: actions/checkout@v1 - - name: Download windows build - uses: actions/download-artifact@v2 - with: - name: kyoo_windows - path: artifact - - name: Unzip windows files - run: mkdir dist_win && 7z x artifact/kyoo_windows.zip -odist_win - - name: Install Inno Setup - shell: cmd - run: | - curl -L https://jrsoftware.org/download.php/is.exe > innosetup.exe - innosetup.exe /VERYSILENT /SUPPRESSMSGBOXES /Log=log.txt || (cat log.txt && exit 1) - - name: Create windows installer - shell: bash - run: iscc -Dkyoo=$(realpath dist_win) -Dversion=${version} -O./ -Fkyoo-windows deployment/kyoo-windows.iss - - uses: actions/upload-artifact@v2 - with: - name: kyoo_windows_installer - path: ./kyoo-windows.exe - - release: - name: Create debian, rpm & arch releases - runs-on: ubuntu-latest - needs: build - if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'tags') }} - env: - description: "A portable and vast media library solution." - version: ${{ needs.build.outputs.version }} - steps: - - uses: actions/checkout@v1 - - name: Download linux build - uses: actions/download-artifact@v2 - with: - name: kyoo_linux - path: artifact - - name: Unzip the published files. - run: mkdir dist && tar -C dist -xzf artifact/kyoo_linux.tar.gz - - - name: Create the package structure - run: | - sudo mkdir -p pkg/usr/lib/ - sudo cp -r --no-preserve ownership dist pkg/usr/lib/kyoo - sudo install -Dm 644 deployment/kyoo.service -t pkg/usr/lib/systemd/system/ - sudo install -Dm 644 deployment/kyoo.sysusers pkg/usr/lib/sysusers.d/kyoo.conf - sudo install -Dm 644 deployment/kyoo.tmpfiles pkg/usr/lib/tmpfiles.d/kyoo.conf - - name: Build debian package - uses: jiro4989/build-deb-action@v2 - with: - package: kyoo - package_root: pkg - maintainer: Zoe Roux - version: ${{env.version}} - depends: "libavutil-dev, libavcodec-dev, libavformat-dev" - arch: amd64 - desc: ${{env.description}} - - name: Build rpm package - run: | - mkdir out - sudo rm -rf pkg/DEBIAN - rpmbuild -bb --buildroot $(pwd)/out --build-in-place --define "_rpmdir $(pwd)/rpm" --define "version_ ${version}" deployment/kyoo.spec - - - name: Prepare arch package - run: | - mkdir deployment/output - sed -i s/\$version/${version}/ deployment/PKGBUILD #doing the substitution here since the pkgbuild is run in a docker without env - cp -a pkg/usr deployment/output/usr - - uses: edlanglois/pkgbuild-action@v1 - id: makepkg - with: - pkgdir: deployment - namcapDisable: true - - - uses: actions/upload-artifact@v2 - with: - name: kyoo_rpm - path: ./rpm/x86_64/*.rpm - - uses: actions/upload-artifact@v2 - with: - name: kyoo_debian - path: ./*.deb - - uses: actions/upload-artifact@v2 - with: - name: kyoo_arch - path: ${{steps.makepkg.outputs.pkgfile0}} - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d571ffa..c0a355bb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,13 +20,6 @@ jobs: repo-token: ${{secrets.GITHUB_TOKEN}} running-workflow-name: release allowed-conclusions: success,skipped,cancelled,neutral - - name: Download artifacts - uses: dawidd6/action-download-artifact@v2 - with: - commit: ${{env.COMMIT_SHA}} - workflow: build.yml - path: ./artifacts - github_token: ${{secrets.GITHUB_TOKEN}} # - name: Public the abstractions to nuget # id: publish_nuget # uses: rohith/publish-nuget@v2 @@ -40,5 +33,4 @@ jobs: uses: ncipollo/release-action@v1 with: generateReleaseNotes: true - artifacts: ./artifacts/**/* token: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/robot.yml b/.github/workflows/robot.yml index ad34a02b..14d48199 100644 --- a/.github/workflows/robot.yml +++ b/.github/workflows/robot.yml @@ -20,7 +20,7 @@ jobs: - name: Perform healthchecks run: | docker-compose ps -a - wget --retry-connrefused http://localhost:5000 # /healthcheck + wget --retry-connrefused http://localhost:8901 # /healthcheck - name: Run robot tests run: | diff --git a/deployment/.gitignore b/deployment/.gitignore deleted file mode 100644 index 936548d0..00000000 --- a/deployment/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -Kyoo/ -src/ -pkg/ -kyoo-1.0.0-1-x86_64.pkg.tar.zst - diff --git a/deployment/PKGBUILD b/deployment/PKGBUILD deleted file mode 100644 index 7cef4c58..00000000 --- a/deployment/PKGBUILD +++ /dev/null @@ -1,28 +0,0 @@ -# Maintainer: Zoe Roux -pkgname=kyoo-bin -pkgver=1.0.0 -pkgrel=1 -epoch= -pkgdesc="A portable and vast media library solution." -arch=("i686" "x86_64" "armv6h") -url="https://github.com/AnonymusRaccoon/Kyoo" -license=("GPLv3") -groups=() -depends=("ffmpeg") -makedepends=() -# The output folder is needed but we can't use directory in the source array. -source=() -sha256sums=() -options=('staticlibs') - -pkgver() { - echo $version # The version is available as an environment variable. -} - -build() { - cp -a "$srcdir/../output" "$srcdir" -} - -package() { - cp -a "$srcdir/output/." "$pkgdir" -} diff --git a/deployment/kyoo-windows.iss b/deployment/kyoo-windows.iss deleted file mode 100644 index 87bbb976..00000000 --- a/deployment/kyoo-windows.iss +++ /dev/null @@ -1,67 +0,0 @@ -[Setup] -AppId={{31A61284-7939-46BC-B584-D2279A6EEEE8} -AppName=Kyoo -AppVersion={#version} -AppPublisher=SDG -AppPublisherURL=https://github.com/AnonymusRaccoon/Kyoo -AppSupportURL=https://github.com/AnonymusRaccoon/Kyoo -AppUpdatesURL=https://github.com/AnonymusRaccoon/Kyoo -DefaultDirName={commonpf}\Kyoo -DisableProgramGroupPage=yes -LicenseFile={#kyoo}\LICENSE -SetupIconFile={#kyoo}\wwwroot\icon-256x256.ico -Compression=lzma -SolidCompression=yes -WizardStyle=modern -AppCopyright=GPL-3.0 -ArchitecturesInstallIn64BitMode=x64 arm64 ia64 - -[Languages] -Name: "english"; MessagesFile: "compiler:Default.isl" - -[Tasks] -Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked -Name: "startupShortcut"; Description: "Create shortcut in Startup folder (Starts when you log into Windows)"; GroupDescription: "Start automatically"; Flags: exclusive -Name: "none"; Description: "Do not start automatically"; GroupDescription: "Start automatically"; Flags: exclusive unchecked - -[Files] -Source: "{#kyoo}\Kyoo.Host.Console.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#kyoo}\Kyoo.Host.WindowsTrait.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#kyoo}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs - -[Registry] -Root: HKA; Subkey: "Software\SDG"; Flags: uninsdeletekeyifempty -Root: HKA; Subkey: "Software\SDG\Kyoo"; Flags: uninsdeletekey -Root: HKA; Subkey: "Software\SDG\Kyoo\Settings"; ValueType: string; ValueName: "DataDir"; ValueData: "{code:GetDataDir}" - -[UninstallDelete] -Type: filesandordirs; Name: "{code:GetDataDir}" - -[Icons] -Name: "{autoprograms}\Kyoo"; Filename: "{app}\Kyoo.Host.WindowsTrait.exe" -Name: "{autoprograms}\Kyoo (Console)"; Filename: "{app}\Kyoo.Host.Console.exe" -Name: "{autodesktop}\Kyoo"; Filename: "{app}\Kyoo.Host.WindowsTrait.exe"; Tasks: desktopicon -Name: "{autostartup}\Kyoo"; Filename: "{app}\Kyoo.Host.WindowsTrait.exe"; Tasks: startupShortcut - -[Run] -Filename: "{app}\Kyoo.Host.WindowsTrait.exe"; Description: "{cm:LaunchProgram,Kyoo}"; Flags: nowait postinstall skipifsilent - -[Code] -var - DataDirPage: TInputDirWizardPage; - -procedure InitializeWizard; -begin - DataDirPage := CreateInputDirPage(wpSelectDir, - 'Choose Data Location', 'Choose the folder in which to install the Kyoo data', - 'The installer will set the following folder for Kyoo. To install in a different folder, click Browse and select another folder.' + - 'Please make sure the folder exists and is accessible. Do not choose the server install folder. Click Next to continue.', - False, ''); - DataDirPage.Add(''); - DataDirPage.Values[0] := GetPreviousData('DataDir', 'C:\ProgramData\Kyoo'); -end; - -function GetDataDir(Param: String): String; -begin - Result := DataDirPage.Values[0]; -end; diff --git a/deployment/kyoo.service b/deployment/kyoo.service deleted file mode 100644 index b9cdcf0c..00000000 --- a/deployment/kyoo.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Kyoo Media Server -After=network.target - -[Service] -User=kyoo -Environment=KYOO_DATADIR=/var/lib/kyoo -ExecStart=/usr/lib/kyoo/Kyoo.Host.Console -Restart=on-abort -TimeoutSec=20 -StandardOutput=null -StandardError=null - -[Install] -WantedBy=multi-user.target diff --git a/deployment/kyoo.spec b/deployment/kyoo.spec deleted file mode 100644 index 9c6d2c70..00000000 --- a/deployment/kyoo.spec +++ /dev/null @@ -1,26 +0,0 @@ -%define _build_id_links none - -Name: kyoo -Version: %{version_} -Release: 1%{?dist} -Summary: A portable and vast media library solution. -URL: https://github.com/AnonymusRaccoon/Kyoo -License: GPL-3.0 -BuildArch: x86_64 -Requires: ffmpeg-devel -AutoReqProv: no - -%description -A media browser - -%install -cp -a pkg/. %{buildroot} - -%clean -rm -rf %{buildroot} - -%files -/usr/lib/kyoo -/usr/lib/systemd/system/* -/usr/lib/sysusers.d/kyoo.conf -/usr/lib/tmpfiles.d/kyoo.conf diff --git a/deployment/kyoo.sysusers b/deployment/kyoo.sysusers deleted file mode 100644 index 35918eea..00000000 --- a/deployment/kyoo.sysusers +++ /dev/null @@ -1 +0,0 @@ -u kyoo - "Kyoo Media Server" /var/lib/kyoo diff --git a/deployment/kyoo.tmpfiles b/deployment/kyoo.tmpfiles deleted file mode 100644 index c8772471..00000000 --- a/deployment/kyoo.tmpfiles +++ /dev/null @@ -1 +0,0 @@ -d /var/lib/kyoo 0755 kyoo kyoo diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 00000000..50a1b9e5 --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,55 @@ +version: "3.8" + +services: + kyoo: + build: + context: ./back + dockerfile: Dockerfile.dev + restart: on-failure + environment: + - KYOO_DATADIR=/var/lib/kyoo + - DATABASE__ENABLED=postgres + - DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres + - DATABASE__CONFIGURATIONS__POSTGRES__USER=kyoo + - DATABASE__CONFIGURATIONS__POSTGRES__PASSWORD=kyooPassword + - TVDB__APIKEY=${TVDB__APIKEY} + - THEMOVIEDB__APIKEY=${THEMOVIEDB__APIKEY} + depends_on: + - postgres + volumes: + - kyoo:/var/lib/kyoo + - ./video:/video + front: + build: + context: ./front + dockerfile: Dockerfile.dev + restart: on-failure + environment: + - KYOO_URL=http://kyoo:5000 + ingress: + image: nginx + restart: on-failure + environment: + - PORT=8901 + - FRONT_URL=http://front:8901 + - BACK_URL=http://kyoo:5000 + volumes: + - ./nginx.conf.template:/etc/nginx/templates/kyoo.conf.template:ro + depends_on: + - kyoo + - front + ports: + - "8901:8901" + postgres: + image: "postgres" + restart: on-failure + environment: + - POSTGRES_USER=kyoo + - POSTGRES_PASSWORD=kyooPassword + volumes: + - db:/var/lib/postgresql/data + +volumes: + kyoo: + db: + diff --git a/docker-compose.yml b/docker-compose.yml index 53c0e126..2bbbc72d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,14 +2,14 @@ version: "3.8" services: kyoo: - build: . + build: ./back restart: on-failure environment: - KYOO_DATADIR=/var/lib/kyoo - DATABASE__ENABLED=postgres - DATABASE__CONFIGURATIONS__POSTGRES__SERVER=postgres - - DATABASE__CONFIGURATIONS__POSTGRES__USER=kyoo - - DATABASE__CONFIGURATIONS__POSTGRES__PASSWORD=kyooPassword + - DATABASE__CONFIGURATIONS__POSTGRES__USER=${POSTGRES_USER} + - DATABASE__CONFIGURATIONS__POSTGRES__PASSWORD=${POSTGRES_PASSWORD} - TVDB__APIKEY=${TVDB__APIKEY} - THEMOVIEDB__APIKEY=${THEMOVIEDB__APIKEY} depends_on: @@ -40,8 +40,8 @@ services: image: "postgres" restart: on-failure environment: - - POSTGRES_USER=kyoo - - POSTGRES_PASSWORD=kyooPassword + - POSTGRES_USER=${POSTGRES_USER} + - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} volumes: - db:/var/lib/postgresql/data diff --git a/src/Kyoo.Host.Generic/PluginsStartup.cs b/src/Kyoo.Host.Generic/PluginsStartup.cs index a753284f..a5707773 100644 --- a/src/Kyoo.Host.Generic/PluginsStartup.cs +++ b/src/Kyoo.Host.Generic/PluginsStartup.cs @@ -32,7 +32,6 @@ using Kyoo.Swagger; using Kyoo.TheMovieDb; using Kyoo.TheTvdb; using Kyoo.Utils; -using Kyoo.WebApp; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; @@ -77,7 +76,6 @@ namespace Kyoo.Host.Generic _hostModule = new HostModule(_plugins); _plugins.LoadPlugins( typeof(CoreModule), - typeof(WebAppModule), typeof(AuthenticationModule), typeof(PostgresModule), typeof(SqLiteModule), diff --git a/src/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.Skipped.target b/src/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.Skipped.target deleted file mode 100644 index 62ab4d53..00000000 --- a/src/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.Skipped.target +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.csproj b/src/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.csproj deleted file mode 100644 index b76edf01..00000000 --- a/src/Kyoo.Host.WindowsTrait/Kyoo.Host.WindowsTrait.csproj +++ /dev/null @@ -1,33 +0,0 @@ - - - - - WinExe - net6.0-windows - default - true - Kyoo.Host.WindowsTrait - Kyoo.Host.WindowsTrait - - - - - - - - PreserveNewest - - - - - net6.0 - NU1503 - - - - - - - - - diff --git a/src/Kyoo.Host.WindowsTrait/Program.cs b/src/Kyoo.Host.WindowsTrait/Program.cs deleted file mode 100644 index 15b2ec10..00000000 --- a/src/Kyoo.Host.WindowsTrait/Program.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Kyoo - A portable and vast media library solution. -// Copyright (c) Kyoo. -// -// See AUTHORS.md and LICENSE file in the project root for full license information. -// -// Kyoo is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// any later version. -// -// Kyoo is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Kyoo. If not, see . - -using System.Threading.Tasks; -using Autofac; -using Kyoo.Host.Generic; - -namespace Kyoo.Host.WindowsTrait -{ - /// - /// Windows's program entrypoint. - /// - public static class Program - { - /// - /// The string representation of the environment used in IWebHostEnvironment. - /// -#if DEBUG - private const string Environment = "Development"; -#else - private const string Environment = "Production"; -#endif - - /// - /// The main entry point for the application that overrides the default host. - /// It adds a system trait for windows and since the host is build as a windows executable instead of a console - /// app, the console is not showed. - /// - /// Command line arguments - /// A representing the lifetime of the program. - public static Task Main(string[] args) - { - Application application = new(Environment); - return application.Start(args, builder => - { - builder.RegisterType().As().SingleInstance(); - }); - } - } -} diff --git a/src/Kyoo.Host.WindowsTrait/SystemTrait.cs b/src/Kyoo.Host.WindowsTrait/SystemTrait.cs deleted file mode 100644 index 8c8ca8fe..00000000 --- a/src/Kyoo.Host.WindowsTrait/SystemTrait.cs +++ /dev/null @@ -1,182 +0,0 @@ -// Kyoo - A portable and vast media library solution. -// Copyright (c) Kyoo. -// -// See AUTHORS.md and LICENSE file in the project root for full license information. -// -// Kyoo is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// any later version. -// -// Kyoo is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Kyoo. If not, see . - -using System; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Threading; -using System.Windows.Forms; -using Autofac; -using Kyoo.Abstractions.Controllers; -using Kyoo.Core.Models.Options; -using Microsoft.Extensions.Options; - -namespace Kyoo.Host.WindowsTrait -{ - /// - /// A singleton that add an notification icon on the window's toolbar. - /// - public sealed class SystemTrait : IStartable, IDisposable - { - /// - /// The application running Kyoo. - /// - private readonly IApplication _application; - - /// - /// The options containing the . - /// - private readonly IOptions _options; - - /// - /// The thread where the trait is running. - /// - private Thread _thread; - - /// - /// Create a new . - /// - /// The application running Kyoo. - /// The options to use. - public SystemTrait(IApplication application, IOptions options) - { - _application = application; - _options = options; - } - - /// - public void Start() - { - _thread = new Thread(() => InternalSystemTrait.Run(_application, _options)) - { - IsBackground = true - }; - _thread.Start(); - } - - /// - public void Dispose() - { - Application.Exit(); - _thread?.Join(); - _thread = null; - } - - /// - /// The internal class for . It should be invoked via - /// . - /// - private class InternalSystemTrait : ApplicationContext - { - /// - /// The application running Kyoo. - /// - private readonly IApplication _application; - - /// - /// The options containing the . - /// - private readonly IOptions _options; - - /// - /// The Icon that is displayed in the window's bar. - /// - private readonly NotifyIcon _icon; - - /// - /// Create a new . Used only by . - /// - /// The application running Kyoo. - /// The option containing the public url. - private InternalSystemTrait(IApplication application, IOptions options) - { - _application = application; - _options = options; - - AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose(); - Application.ApplicationExit += (_, _) => Dispose(); - - _icon = new NotifyIcon - { - Text = "Kyoo", - Icon = new Icon(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "kyoo.ico")), - Visible = true - }; - _icon.MouseClick += (_, e) => - { - if (e.Button != MouseButtons.Left) - return; - _StartBrowser(); - }; - - _icon.ContextMenuStrip = new ContextMenuStrip(); - _icon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] - { - new ToolStripMenuItem("Open browser", null, (_, _) => { _StartBrowser(); }), - new ToolStripMenuItem("Open logs", null, (_, _) => { _OpenLogs(); }), - new ToolStripSeparator(), - new ToolStripMenuItem("Exit", null, (_, _) => { _application.Shutdown(); }) - }); - } - - /// - /// Run the trait in the current thread, this method does not return while the trait is running. - /// - /// The application running Kyoo. - /// The options to pass to . - public static void Run(IApplication application, IOptions options) - { - using InternalSystemTrait trait = new(application, options); - Application.Run(trait); - } - - /// - protected override void Dispose(bool disposing) - { - _icon.Visible = false; - base.Dispose(disposing); - _icon.Dispose(); - } - - /// - /// Open kyoo's page in the user's default browser. - /// - private void _StartBrowser() - { - Process browser = new() - { - StartInfo = new ProcessStartInfo(_options.Value.Url.ToString().Replace("//*:", "//localhost:")) - { - UseShellExecute = true - } - }; - browser.Start(); - } - - /// - /// Open the log directory in windows's explorer. - /// - private void _OpenLogs() - { - string logDir = Path.Combine(_application.GetDataDirectory(), "logs"); - Process.Start("explorer.exe", logDir); - } - } - } -} diff --git a/src/Kyoo.Host.WindowsTrait/kyoo.ico b/src/Kyoo.Host.WindowsTrait/kyoo.ico deleted file mode 100644 index 8bfcd8c3..00000000 Binary files a/src/Kyoo.Host.WindowsTrait/kyoo.ico and /dev/null differ diff --git a/src/Kyoo.WebApp/Kyoo.WebApp.csproj b/src/Kyoo.WebApp/Kyoo.WebApp.csproj deleted file mode 100644 index f4a4e8a7..00000000 --- a/src/Kyoo.WebApp/Kyoo.WebApp.csproj +++ /dev/null @@ -1,78 +0,0 @@ - - - - - Kyoo.WebApp - Kyoo.WebApp - - true - Latest - false - $(DefaultItemExcludes);$(SpaRoot)node_modules/** - ../../front/ - ../../icons/ - $(SpaRoot)node_modules/.install-stamp - - - false - - - - - - - - - - - - - - - wwwroot/%(RecursiveDir)%(Filename)%(Extension) - Always - - - - wwwroot/%(RecursiveDir)%(Filename)%(Extension) - Always - - - - - - - - - - - - - - - - - - - - - - - - - wwwroot/%(NewContent.RecursiveDir)%(NewContent.Filename)%(NewContent.Extension) - Always - - - - - - - - - NpmInstall; - RunWebpack; - $(BuildDependsOn) - - - diff --git a/src/Kyoo.WebApp/WebAppModule.cs b/src/Kyoo.WebApp/WebAppModule.cs deleted file mode 100644 index 349f6f48..00000000 --- a/src/Kyoo.WebApp/WebAppModule.cs +++ /dev/null @@ -1,135 +0,0 @@ -// Kyoo - A portable and vast media library solution. -// Copyright (c) Kyoo. -// -// See AUTHORS.md and LICENSE file in the project root for full license information. -// -// Kyoo is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// any later version. -// -// Kyoo is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Kyoo. If not, see . - -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.CompilerServices; -using Kyoo.Abstractions.Controllers; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.SpaServices.AngularCli; -using Microsoft.AspNetCore.StaticFiles; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; - -namespace Kyoo.WebApp -{ - /// - /// A module to enable the web-app (the front-end of kyoo). - /// - public class WebAppModule : IPlugin - { - /// - public string Slug => "webapp"; - - /// - public string Name => "WebApp"; - - /// - public string Description => "A module to enable the web-app (the front-end of kyoo)."; - - /// - public Dictionary Configuration => new(); - - /// - public bool Enabled => false; // Directory.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "wwwroot")); - - /// - /// Create a new . - /// - /// A logger only used to inform the user if the webapp could not be enabled. - public WebAppModule(ILogger logger) - { - if (!Enabled) - logger.LogError("The web app files could not be found, it will be disabled"); - } - - /// - public void Configure(IServiceCollection services) - { - services.AddSpaStaticFiles(x => - { - x.RootPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "wwwroot"); - }); - } - - /// - public IEnumerable ConfigureSteps => new IStartupAction[] - { - SA.New((app, env) => - { - if (!env.IsDevelopment()) - app.UseSpaStaticFiles(); - }, SA.StaticFiles), - SA.New((app, contentTypeProvider) => - { - app.UseStaticFiles(new StaticFileOptions - { - ContentTypeProvider = contentTypeProvider, - FileProvider = new PhysicalFileProvider(Path.Join(AppDomain.CurrentDomain.BaseDirectory, "wwwroot")) - }); - }, SA.StaticFiles), - SA.New(app => - { - app.Use((ctx, next) => - { - ctx.Response.Headers.Remove("X-Powered-By"); - ctx.Response.Headers.Remove("Server"); - ctx.Response.Headers.Add("Feature-Policy", "autoplay 'self'; fullscreen"); - ctx.Response.Headers.Add("Content-Security-Policy", "default-src 'self' blob:; script-src 'self' blob: 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src 'self'"); - ctx.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); - ctx.Response.Headers.Add("Referrer-Policy", "no-referrer"); - ctx.Response.Headers.Add("Access-Control-Allow-Origin", "null"); - ctx.Response.Headers.Add("X-Content-Type-Options", "nosniff"); - return next(); - }); - }, SA.Endpoint - 499), - SA.New((app, env) => - { - app.UseSpa(spa => - { - spa.Options.SourcePath = _GetSpaSourcePath(); - - if (env.IsDevelopment()) - spa.UseAngularCliServer("start"); - }); - }, SA.Endpoint - 500) - }; - - /// - /// Get the root directory of the web app - /// - /// The path of the source code of the web app or null if the directory has been deleted. - private static string _GetSpaSourcePath() - { - static string GetRepoRootPath([CallerFilePath] string path = null) - { - // path is {RepoRoot}/src/Kyoo.WebApp/WebAppModules.cs - for (int i = 0; i < 3; i++) - path = Path.GetDirectoryName(path); - return path; - } - - string path = Path.Join(GetRepoRootPath(), "front"); - return Directory.Exists(path) ? path : null; - } - } -}