First commit
This commit is contained in:
commit
52a0ba1f04
|
@ -0,0 +1,484 @@
|
||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from `dotnet new gitignore`
|
||||||
|
|
||||||
|
# dotenv files
|
||||||
|
.env
|
||||||
|
|
||||||
|
# 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/
|
||||||
|
[Dd]ata
|
||||||
|
# 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
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
|
||||||
|
# Tye
|
||||||
|
.tye/
|
||||||
|
|
||||||
|
# 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
|
||||||
|
*.sln.iml
|
||||||
|
.idea
|
||||||
|
|
||||||
|
##
|
||||||
|
## Visual studio for Mac
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
# globs
|
||||||
|
Makefile.in
|
||||||
|
*.userprefs
|
||||||
|
*.usertasks
|
||||||
|
config.make
|
||||||
|
config.status
|
||||||
|
aclocal.m4
|
||||||
|
install-sh
|
||||||
|
autom4te.cache/
|
||||||
|
*.tar.gz
|
||||||
|
tarballs/
|
||||||
|
test-results/
|
||||||
|
|
||||||
|
# Mac bundle stuff
|
||||||
|
*.dmg
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# Vim temporary swap files
|
||||||
|
*.swp
|
|
@ -0,0 +1,675 @@
|
||||||
|
# GNU GENERAL PUBLIC LICENSE
|
||||||
|
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||||
|
<https://fsf.org/>
|
||||||
|
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies of this
|
||||||
|
license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
## Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom
|
||||||
|
to share and change all versions of a program--to make sure it remains
|
||||||
|
free software for all its users. We, the Free Software Foundation, use
|
||||||
|
the GNU General Public License for most of our software; it applies
|
||||||
|
also to any other work released this way by its authors. You can apply
|
||||||
|
it to your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you
|
||||||
|
have certain responsibilities if you distribute copies of the
|
||||||
|
software, or if you modify it: responsibilities to respect the freedom
|
||||||
|
of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the
|
||||||
|
manufacturer can do so. This is fundamentally incompatible with the
|
||||||
|
aim of protecting users' freedom to change the software. The
|
||||||
|
systematic pattern of such abuse occurs in the area of products for
|
||||||
|
individuals to use, which is precisely where it is most unacceptable.
|
||||||
|
Therefore, we have designed this version of the GPL to prohibit the
|
||||||
|
practice for those products. If such problems arise substantially in
|
||||||
|
other domains, we stand ready to extend this provision to those
|
||||||
|
domains in future versions of the GPL, as needed to protect the
|
||||||
|
freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish
|
||||||
|
to avoid the special danger that patents applied to a free program
|
||||||
|
could make it effectively proprietary. To prevent this, the GPL
|
||||||
|
assures that patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
## TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
### 0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds
|
||||||
|
of works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of
|
||||||
|
an exact copy. The resulting work is called a "modified version" of
|
||||||
|
the earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user
|
||||||
|
through a computer network, with no transfer of a copy, is not
|
||||||
|
conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices" to
|
||||||
|
the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
### 1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work for
|
||||||
|
making modifications to it. "Object code" means any non-source form of
|
||||||
|
a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users can
|
||||||
|
regenerate automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that same
|
||||||
|
work.
|
||||||
|
|
||||||
|
### 2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not convey,
|
||||||
|
without conditions so long as your license otherwise remains in force.
|
||||||
|
You may convey covered works to others for the sole purpose of having
|
||||||
|
them make modifications exclusively for you, or provide you with
|
||||||
|
facilities for running those works, provided that you comply with the
|
||||||
|
terms of this License in conveying all material for which you do not
|
||||||
|
control copyright. Those thus making or running the covered works for
|
||||||
|
you must do so exclusively on your behalf, under your direction and
|
||||||
|
control, on terms that prohibit them from making any copies of your
|
||||||
|
copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under the
|
||||||
|
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||||
|
it unnecessary.
|
||||||
|
|
||||||
|
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such
|
||||||
|
circumvention is effected by exercising rights under this License with
|
||||||
|
respect to the covered work, and you disclaim any intention to limit
|
||||||
|
operation or modification of the work as a means of enforcing, against
|
||||||
|
the work's users, your or third parties' legal rights to forbid
|
||||||
|
circumvention of technological measures.
|
||||||
|
|
||||||
|
### 4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
### 5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
- a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
- b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under
|
||||||
|
section 7. This requirement modifies the requirement in section 4
|
||||||
|
to "keep intact all notices".
|
||||||
|
- c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
- d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
### 6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms of
|
||||||
|
sections 4 and 5, provided that you also convey the machine-readable
|
||||||
|
Corresponding Source under the terms of this License, in one of these
|
||||||
|
ways:
|
||||||
|
|
||||||
|
- a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
- b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the Corresponding
|
||||||
|
Source from a network server at no charge.
|
||||||
|
- c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
- d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
- e) Convey the object code using peer-to-peer transmission,
|
||||||
|
provided you inform other peers where the object code and
|
||||||
|
Corresponding Source of the work are being offered to the general
|
||||||
|
public at no charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal,
|
||||||
|
family, or household purposes, or (2) anything designed or sold for
|
||||||
|
incorporation into a dwelling. In determining whether a product is a
|
||||||
|
consumer product, doubtful cases shall be resolved in favor of
|
||||||
|
coverage. For a particular product received by a particular user,
|
||||||
|
"normally used" refers to a typical or common use of that class of
|
||||||
|
product, regardless of the status of the particular user or of the way
|
||||||
|
in which the particular user actually uses, or expects or is expected
|
||||||
|
to use, the product. A product is a consumer product regardless of
|
||||||
|
whether the product has substantial commercial, industrial or
|
||||||
|
non-consumer uses, unless such uses represent the only significant
|
||||||
|
mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to
|
||||||
|
install and execute modified versions of a covered work in that User
|
||||||
|
Product from a modified version of its Corresponding Source. The
|
||||||
|
information must suffice to ensure that the continued functioning of
|
||||||
|
the modified object code is in no case prevented or interfered with
|
||||||
|
solely because modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or
|
||||||
|
updates for a work that has been modified or installed by the
|
||||||
|
recipient, or for the User Product in which it has been modified or
|
||||||
|
installed. Access to a network may be denied when the modification
|
||||||
|
itself materially and adversely affects the operation of the network
|
||||||
|
or violates the rules and protocols for communication across the
|
||||||
|
network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
### 7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders
|
||||||
|
of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
- a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
- b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
- c) Prohibiting misrepresentation of the origin of that material,
|
||||||
|
or requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
- d) Limiting the use for publicity purposes of names of licensors
|
||||||
|
or authors of the material; or
|
||||||
|
- e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
- f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions
|
||||||
|
of it) with contractual assumptions of liability to the recipient,
|
||||||
|
for any liability that these contractual assumptions directly
|
||||||
|
impose on those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions; the
|
||||||
|
above requirements apply either way.
|
||||||
|
|
||||||
|
### 8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your license
|
||||||
|
from a particular copyright holder is reinstated (a) provisionally,
|
||||||
|
unless and until the copyright holder explicitly and finally
|
||||||
|
terminates your license, and (b) permanently, if the copyright holder
|
||||||
|
fails to notify you of the violation by some reasonable means prior to
|
||||||
|
60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
### 9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or run
|
||||||
|
a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
### 10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
### 11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims owned
|
||||||
|
or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within the
|
||||||
|
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||||
|
the non-exercise of one or more of the rights that are specifically
|
||||||
|
granted under this License. You may not convey a covered work if you
|
||||||
|
are a party to an arrangement with a third party that is in the
|
||||||
|
business of distributing software, under which you make payment to the
|
||||||
|
third party based on the extent of your activity of conveying the
|
||||||
|
work, and under which the third party grants, to any of the parties
|
||||||
|
who would receive the covered work from you, a discriminatory patent
|
||||||
|
license (a) in connection with copies of the covered work conveyed by
|
||||||
|
you (or copies made from those copies), or (b) primarily for and in
|
||||||
|
connection with specific products or compilations that contain the
|
||||||
|
covered work, unless you entered into that arrangement, or that patent
|
||||||
|
license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
### 12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under
|
||||||
|
this License and any other pertinent obligations, then as a
|
||||||
|
consequence you may not convey it at all. For example, if you agree to
|
||||||
|
terms that obligate you to collect a royalty for further conveying
|
||||||
|
from those to whom you convey the Program, the only way you could
|
||||||
|
satisfy both those terms and this License would be to refrain entirely
|
||||||
|
from conveying the Program.
|
||||||
|
|
||||||
|
### 13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
### 14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions
|
||||||
|
of the GNU General Public License from time to time. Such new versions
|
||||||
|
will be similar in spirit to the present version, but may differ in
|
||||||
|
detail to address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the Program
|
||||||
|
specifies that a certain numbered version of the GNU General Public
|
||||||
|
License "or any later version" applies to it, you have the option of
|
||||||
|
following the terms and conditions either of that numbered version or
|
||||||
|
of any later version published by the Free Software Foundation. If the
|
||||||
|
Program does not specify a version number of the GNU General Public
|
||||||
|
License, you may choose any version ever published by the Free
|
||||||
|
Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future versions
|
||||||
|
of the GNU General Public License can be used, that proxy's public
|
||||||
|
statement of acceptance of a version permanently authorizes you to
|
||||||
|
choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
### 15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||||
|
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||||
|
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||||
|
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||||
|
CORRECTION.
|
||||||
|
|
||||||
|
### 16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||||
|
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||||
|
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||||
|
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||||
|
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||||
|
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||||
|
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
|
### 17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
## How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these
|
||||||
|
terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest to
|
||||||
|
attach them to the start of each source file to most effectively state
|
||||||
|
the exclusion of warranty; and each file should have at least the
|
||||||
|
"copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program 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
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper
|
||||||
|
mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands \`show w' and \`show c' should show the
|
||||||
|
appropriate parts of the General Public License. Of course, your
|
||||||
|
program's commands might be different; for a GUI interface, you would
|
||||||
|
use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or
|
||||||
|
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||||
|
necessary. For more information on this, and how to apply and follow
|
||||||
|
the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your
|
||||||
|
program into proprietary programs. If your program is a subroutine
|
||||||
|
library, you may consider it more useful to permit linking proprietary
|
||||||
|
applications with the library. If this is what you want to do, use the
|
||||||
|
GNU Lesser General Public License instead of this License. But first,
|
||||||
|
please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
@ -0,0 +1,18 @@
|
||||||
|
using Tesses.CMS.Client;
|
||||||
|
|
||||||
|
TessesCMSClient client = new TessesCMSClient("http://192.168.0.155:62444/");
|
||||||
|
|
||||||
|
await foreach(var item in client.Movies.GetMoviesAsync("Blender"))
|
||||||
|
{
|
||||||
|
Console.WriteLine(item.ProperName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool success=await client.Users.LoginAsync("johndoe@example.com","Se7enMovie");
|
||||||
|
if(success)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Logged in successfully");
|
||||||
|
}
|
||||||
|
//await client.Movies.CreateAsync("HolyLoop","Holy Loop");
|
||||||
|
|
||||||
|
|
||||||
|
await client.Users.LogoutAsync();
|
|
@ -0,0 +1,14 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Tesses.CMS.Client\Tesses.CMS.Client.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,85 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Tesses.CMS.Client
|
||||||
|
{
|
||||||
|
public class TessesCMSClient
|
||||||
|
{
|
||||||
|
private static HttpClient CreateHttpClient()
|
||||||
|
{
|
||||||
|
HttpClientHandler httpClientHandler=new HttpClientHandler();
|
||||||
|
httpClientHandler.AllowAutoRedirect=true;
|
||||||
|
httpClientHandler.UseCookies=true;
|
||||||
|
HttpClient client=new HttpClient(httpClientHandler);
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
internal HttpClient client;
|
||||||
|
internal string rooturl;
|
||||||
|
public HttpClient Client => client;
|
||||||
|
public string RootUrl => $"{rooturl}/";
|
||||||
|
public TessesCMSClient(string url,HttpClient client)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
rooturl = url.TrimEnd('/');
|
||||||
|
}
|
||||||
|
public TessesCMSClient(HttpClient client) : this("https://tessesstudios.com/",client)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TessesCMSClient(string url) : this(url,CreateHttpClient())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public TessesCMSClient() : this(CreateHttpClient())
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovieClient Movies => new MovieClient(this);
|
||||||
|
|
||||||
|
public UserClient Users => new UserClient(this);
|
||||||
|
}
|
||||||
|
public class UserClient
|
||||||
|
{
|
||||||
|
TessesCMSClient client;
|
||||||
|
internal UserClient(TessesCMSClient client)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
public async Task LogoutAsync()
|
||||||
|
{
|
||||||
|
await client.client.GetStringAsync($"{client.rooturl}/logout");
|
||||||
|
}
|
||||||
|
public async Task<bool> LoginAsync(string email,string password)
|
||||||
|
{
|
||||||
|
Dictionary<string,string> us=new Dictionary<string, string>();
|
||||||
|
us.Add("email",email);
|
||||||
|
us.Add("password",password);
|
||||||
|
using(var res=await client.client.PostAsync($"{client.rooturl}/login", new FormUrlEncodedContent(us)))
|
||||||
|
return res.StatusCode != System.Net.HttpStatusCode.Unauthorized;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MovieClient
|
||||||
|
{
|
||||||
|
TessesCMSClient client;
|
||||||
|
internal MovieClient(TessesCMSClient client)
|
||||||
|
{
|
||||||
|
this.client = client;
|
||||||
|
}
|
||||||
|
public async IAsyncEnumerable<Movie> GetMoviesAsync(string user)
|
||||||
|
{
|
||||||
|
foreach(var item in JsonConvert.DeserializeObject<List<Movie>>(await client.client.GetStringAsync($"{client.rooturl}/api/v1/GetMovies?user={HttpUtility.UrlDecode(user)}")))
|
||||||
|
{
|
||||||
|
yield return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Tesses.CMS.Client
|
||||||
|
{
|
||||||
|
public class Movie
|
||||||
|
{
|
||||||
|
public string ProperName {get;set;}
|
||||||
|
|
||||||
|
public string Name {get;set;}
|
||||||
|
|
||||||
|
public DateTime CreationTime {get;set;}
|
||||||
|
|
||||||
|
public DateTime LastUpdated {get;set;}
|
||||||
|
|
||||||
|
public string Description {get;set;}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<LangVersion>8.0</LangVersion>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,5 @@
|
||||||
|
using Tesses.WebServer;
|
||||||
|
using Tesses.CMS;
|
||||||
|
string path = args.Length > 0 ? args[0] : "data";
|
||||||
|
CMSServer server=new CMSServer(path,new LiteDBContentProvider(path));
|
||||||
|
server.Server.StartServer(server.Configuration.Port);
|
|
@ -0,0 +1,20 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
|
||||||
|
<PackageReference Include="PlaylistsNET" Version="1.4.0" />
|
||||||
|
<PackageReference Include="Tesses.WebServer.EasyServer" Version="1.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Tesses.CMS\Tesses.CMS.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Tesses.WebServer;
|
||||||
|
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class AssetProvider : Server
|
||||||
|
{
|
||||||
|
static Assembly asm=typeof(AssetProvider).Assembly;
|
||||||
|
public AssetProvider()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Stream OpenRead(string path)
|
||||||
|
{
|
||||||
|
return asm.GetManifestResourceStream($"Tesses.CMS.Assets{path.Replace("/",".")}");
|
||||||
|
|
||||||
|
}
|
||||||
|
public override async Task GetAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
await ctx.SendTextAsync(await ReadAllTextAsync(ctx.UrlPath),HeyRed.Mime.MimeTypesMap.GetMimeType(ctx.UrlPath));
|
||||||
|
}catch(ArgumentNullException ex)
|
||||||
|
{
|
||||||
|
_=ex;
|
||||||
|
await NotFoundServer.ServerNull.GetAsync(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static async Task<string> ReadAllTextAsync(string path)
|
||||||
|
{
|
||||||
|
using(var s = OpenRead(path))
|
||||||
|
using(var ms = new StreamReader(s))
|
||||||
|
{
|
||||||
|
return await ms.ReadToEndAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ReadAllText(string path)
|
||||||
|
{
|
||||||
|
using(var s = OpenRead(path))
|
||||||
|
using(var ms = new StreamReader(s))
|
||||||
|
return ms.ReadToEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
<div class="container">
|
||||||
|
<h1>Devcenter</h1>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><a href="{{rooturl}}api/v1/">Api</a></li>
|
||||||
|
<li><a href="{{rooturl}}devcenter/webhooks">Webhooks</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<h1>Change movie metadata</h1>
|
||||||
|
<form action="./edit" method="post" enctype="application/x-www-form-urlencoded">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="proper-name" class="form-label">Proper Name</label>
|
||||||
|
<input type="text" class="form-control" id="proper-name" name="proper_name" value="{{propername}}">
|
||||||
|
</div>
|
||||||
|
<div class="form-floating">
|
||||||
|
<textarea class="form-control" placeholder="Description" name="description" id="floatingTextarea">{{description}}</textarea>
|
||||||
|
<label for="floatingTextarea">Description</label>
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Change Metadata" class="btn btn-primary">
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<h1>Upload movie files</h1>
|
||||||
|
<form action="./upload" method="post" enctype="multipart/form-data">
|
||||||
|
<h1>You should do these in order (not required but recomended because you can only upload one at a time, that is in one tab at least)</h1>
|
||||||
|
<select class="form-select" name="type" aria-label="Select resource">
|
||||||
|
<option value="thumbnail" selected>Thumbnail (should be 120x214, the coverart for the movie)</option>
|
||||||
|
<option value="poster">Poster (same resoultion as movie, what you see on video player before pressing play)</option>
|
||||||
|
<option value="movie">Movie (should be mp4, this file will be downloaded when someone clicks download and will be converted to a browser version)</option>
|
||||||
|
</select>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="formFileSm" class="form-label">File to upload</label>
|
||||||
|
<input class="form-control form-control-sm" id="formFileSm" name="file" type="file">
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Submit" class="btn btn-primary">
|
||||||
|
|
||||||
|
</form>
|
||||||
|
<a href="./extras/" target="_blank" class="btn btn-primary">View/Edit extras</a>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<div class="container">
|
||||||
|
<h1>Welcome to {{title}}</h1>
|
||||||
|
<a href="./users">View users</a>
|
||||||
|
<div class="alert alert-info" role="alert">
|
||||||
|
|
||||||
|
TessesCMS Copyright (C) 2023 Michael Nolan<br>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY<br>
|
||||||
|
This is free software, and you are welcome to redistribute it<br>
|
||||||
|
under certain conditions; click <a href="https://www.gnu.org/licenses/gpl-3.0.html">here</a> for details.<br>
|
||||||
|
<a href="https://gitlab.tesses.net/tesses50/tesses-cms" class="btn btn-outline-info">View Source</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<form method="post" action="./login">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="exampleFormControlInput1" class="form-label">Email address</label>
|
||||||
|
<input type="email" name="email" class="form-control" id="exampleFormControlInput1" placeholder="name@example.com">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="exampleFormControlInput2" class="form-label">Password</label>
|
||||||
|
<input type="password" name="password" class="form-control" id="exampleFormControlInput2">
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Login" class="btn btn-primary">
|
||||||
|
<a href="./signup">Signup</a>
|
||||||
|
</form>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<form action="./mailinglist" method="post">
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="enablemovies" {{if enablemovies}} checked {{end}} id="flexCheckMovies">
|
||||||
|
<label class="form-check-label" for="flexCheckMovies">
|
||||||
|
Movies
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="enableshows" {{if enableshows}} checked {{end}} id="flexCheckShows">
|
||||||
|
<label class="form-check-label" for="flexCheckShows">
|
||||||
|
Shows
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="enablesingles" {{if enablesingles}} checked {{end}} id="flexCheckSingle">
|
||||||
|
<label class="form-check-label" for="flexCheckSingle">
|
||||||
|
Music - Single
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="enablealbums" {{if enablealbums}} checked {{end}} id="flexCheckAlbum">
|
||||||
|
<label class="form-check-label" for="flexCheckAlbum">
|
||||||
|
Music - Album
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="enablesoftware" {{if enablesoftware}} checked {{end}} id="flexCheckSoftware">
|
||||||
|
<label class="form-check-label" for="flexCheckSoftware">
|
||||||
|
Software
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="enableother" {{if enableother}} checked {{end}} id="flexCheckOther">
|
||||||
|
<label class="form-check-label" for="flexCheckOther">
|
||||||
|
Other
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Update" class="btn btn-primary">
|
||||||
|
</form>
|
|
@ -0,0 +1,35 @@
|
||||||
|
<br>
|
||||||
|
<div class="container">
|
||||||
|
<img src="{{moviethumbnail}}" alt="{{movieproper}}" width="120" height="214">
|
||||||
|
<h1>{{movieproper}}</h1>
|
||||||
|
<h2>{{userproper}}</h2>
|
||||||
|
<hr>
|
||||||
|
<a class="btn btn-primary" href="./play">Watch Online</a>
|
||||||
|
<a class="btn btn-primary" href="{{downloadurl}}" download="{{movieproperattr}}.mp4">Download</a>
|
||||||
|
{{if editable}}
|
||||||
|
<a class="btn btn-primary" href="./edit">Edit</a>
|
||||||
|
{{end}}
|
||||||
|
{{if torrentexists}}
|
||||||
|
<a class="btn btn-primary" href="{{torrent}}">Torrent</a>
|
||||||
|
{{end}}
|
||||||
|
{{if torrentwextraexists}}
|
||||||
|
<a class="btn btn-primary" href="{{torrentwextra}}">Torrent With Extras</a>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<div class="accordion" id="accordionExample">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
|
||||||
|
Description
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="collapseOne" class="accordion-collapse collapse" data-bs-parent="#accordionExample">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<p>{{moviedescription}}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<div class="container-fluid">
|
||||||
|
<!--thanks to https://stackoverflow.com/a/21678797-->
|
||||||
|
<style>
|
||||||
|
ul {
|
||||||
|
|
||||||
|
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<ul>
|
||||||
|
|
||||||
|
|
||||||
|
{{for movie in movies}}
|
||||||
|
<li>
|
||||||
|
<img src="{{movie.thumbnail}}" width="120" height="214"><br><a href="../movie/{{movie.name}}/">{{movie.proper}}</a>
|
||||||
|
</li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -0,0 +1,39 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{{title}}</title>
|
||||||
|
<link rel="stylesheet" href="{{rooturl}}video-js.css">
|
||||||
|
<link rel="stylesheet" href="{{rooturl}}bootstrap.min.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" href="{{rooturl}}">{{title}}</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
|
<ul class="navbar-nav">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link {{ if ishome }} active {{ end }}" {{ if ishome }} aria-current="page" {{ end }} href="{{rooturl}}">Home</a>
|
||||||
|
</li>
|
||||||
|
{{for url in urls}}
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link {{ if url.active }} active {{ end }}" {{ if url.active }} aria-current="page" {{ end }} href="{{url.url}}">{{url.text}}</a>
|
||||||
|
</li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<main>
|
||||||
|
{{body}}
|
||||||
|
</main>
|
||||||
|
<script src="{{rooturl}}bootstrap.min.js"></script>
|
||||||
|
<script src="{{rooturl}}video.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,25 @@
|
||||||
|
<form method="post" action="./signup">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="exampleFormControlInput1" class="form-label">Name</label>
|
||||||
|
<input type="text" name="name" class="form-control" id="exampleFormControlInput1" placeholder="">
|
||||||
|
<div id="message" class="form-text">This is the name that is used in URL, no spaces or /\"&,?|:;*@!#</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="exampleFormControlInput2" class="form-label">Proper Name</label>
|
||||||
|
<input type="text" name="proper_name" class="form-control" id="exampleFormControlInput2" placeholder="">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="exampleFormControlInput3" class="form-label">Email address</label>
|
||||||
|
<input type="email" name="email" class="form-control" id="exampleFormControlInput3" placeholder="name@example.com">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="exampleFormControlInput4" class="form-label">Password</label>
|
||||||
|
<input type="password" name="password" class="form-control" id="exampleFormControlInput4">
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="exampleFormControlInput5" class="form-label">Confirm Password</label>
|
||||||
|
<input type="password" name="confirm_password" class="form-control" id="exampleFormControlInput5">
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Create Account" class="btn btn-primary">
|
||||||
|
</form>
|
|
@ -0,0 +1,49 @@
|
||||||
|
<div class="container">
|
||||||
|
<form action="/upload" method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="name" class="form-label">Name</label>
|
||||||
|
<input type="text" class="form-control" id="name" name="name" aria-describedby="message">
|
||||||
|
<div id="message" class="form-text">This is the name that is used in URL, no spaces or /\"&,?|:;*@!#</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="proper-name" class="form-label">Proper Name</label>
|
||||||
|
<input type="text" class="form-control" id="proper-name" name="proper_name">
|
||||||
|
</div>
|
||||||
|
<div class="form-floating">
|
||||||
|
<textarea class="form-control" placeholder="Description" name="description" id="floatingTextarea"></textarea>
|
||||||
|
<label for="floatingTextarea">Description</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" checked type="radio" name="type" value="movie" id="movie">
|
||||||
|
<label class="form-check-label" for="movie">
|
||||||
|
Movie
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="type" value="show" id="show">
|
||||||
|
<label class="form-check-label" for="show">
|
||||||
|
Show
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="type" value="music-single" id="music-single">
|
||||||
|
<label class="form-check-label" for="music-single">
|
||||||
|
Music - Single
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="type" value="music-album" id="music-album">
|
||||||
|
<label class="form-check-label" for="music-album">
|
||||||
|
Music - Album
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="type" value="software" id="software">
|
||||||
|
<label class="form-check-label" for="software">
|
||||||
|
Software
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Next" class="btn btn-primary">
|
||||||
|
</form>
|
||||||
|
</div>
|
|
@ -0,0 +1,25 @@
|
||||||
|
<div class="container">
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="./movies/">Movies</a>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="./shows/">Shows</a>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="./singles/">Music Singles</a>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="./albums/">Music Albums</a>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="./software/">Software</a>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="./other/">Other</a>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<a href="./about">About</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<ul class="list-group">
|
||||||
|
{{for user in users}}
|
||||||
|
<li class="list-group-item"><a href="{{rooturl}}user/{{user.username}}/">{{user.proper}}</a></li>
|
||||||
|
{{end}}
|
||||||
|
</ul>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{{moviename}}</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
padding: 0px;
|
||||||
|
border: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
/*body {
|
||||||
|
overflow:hidden;}*/
|
||||||
|
video {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<video src="{{moviebrowserurl}}" poster="{{movieposter}}" controls>
|
||||||
|
|
||||||
|
</video>
|
||||||
|
</body>
|
||||||
|
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,757 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using LiteDB;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Tesses.VirtualFilesystem;
|
||||||
|
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class Torrent
|
||||||
|
{
|
||||||
|
public string UrlList {get;set;}="";
|
||||||
|
private BencodedDictionary torrent=null;
|
||||||
|
public BencodedDictionary ToTorrentFile()
|
||||||
|
{
|
||||||
|
if(torrent != null) return torrent;
|
||||||
|
BencodedDictionary dict=new BencodedDictionary();
|
||||||
|
if(this.AnnounceList.Count> 0)
|
||||||
|
{
|
||||||
|
dict["announce"] = (BencodedString)AnnounceList[0];
|
||||||
|
var al = new BencodedList();
|
||||||
|
foreach(var item in AnnounceList)
|
||||||
|
{
|
||||||
|
BencodedList ls2=new BencodedList();
|
||||||
|
ls2.Add((BencodedString)item);
|
||||||
|
al.Add(ls2);
|
||||||
|
}
|
||||||
|
dict["announce-list"] = al;
|
||||||
|
}
|
||||||
|
if(!string.IsNullOrWhiteSpace(UrlList))
|
||||||
|
{
|
||||||
|
dict["url-list"] = (BencodedString)UrlList;
|
||||||
|
}
|
||||||
|
dict["created by"] = (BencodedString)CreatedBy;
|
||||||
|
dict["creation date"] = new BencodedNumber(CreationDate.ToUnixTimeSeconds());
|
||||||
|
var info = new BencodedDictionary();
|
||||||
|
|
||||||
|
|
||||||
|
byte[] pieces = new byte[Info.Pieces.Count * 20];
|
||||||
|
for(int i = 0;i< Info.Pieces.Count;i++)
|
||||||
|
{
|
||||||
|
Array.Copy(Info.Pieces[i],0,pieces,i*20,20);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Info.Files.Count > 0)
|
||||||
|
{
|
||||||
|
BencodedList ls=new BencodedList();
|
||||||
|
foreach(var item in Info.Files)
|
||||||
|
{
|
||||||
|
BencodedDictionary file=new BencodedDictionary();
|
||||||
|
file["length"] = new BencodedNumber(item.Length);
|
||||||
|
BencodedList paths = new BencodedList();
|
||||||
|
foreach(var path in item.Path)
|
||||||
|
{
|
||||||
|
paths.Add((BencodedString)path);
|
||||||
|
}
|
||||||
|
file["path"] = paths;
|
||||||
|
|
||||||
|
ls.Add(file);
|
||||||
|
}
|
||||||
|
info["files"] = ls;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info["length"] = new BencodedNumber(Info.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
info["name"] = (BencodedString)Info.Name;
|
||||||
|
info["piece length"] = new BencodedNumber(Info.PieceLength);
|
||||||
|
|
||||||
|
info["pieces"] = new BencodedString(pieces);
|
||||||
|
|
||||||
|
dict["info"] = info;
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
public static Torrent FromTorrentFile(BencodedData file)
|
||||||
|
{
|
||||||
|
var torrent = file as BencodedDictionary;
|
||||||
|
if(torrent == null) return new Torrent();
|
||||||
|
Torrent torrentObj= new Torrent();
|
||||||
|
torrentObj.torrent = torrent;
|
||||||
|
if(torrent.TryGetValue("url-list",out var urlList))
|
||||||
|
{
|
||||||
|
torrentObj.UrlList = urlList.ToString();
|
||||||
|
}
|
||||||
|
if(torrent.TryGetValue("created by", out var created_by))
|
||||||
|
{
|
||||||
|
torrentObj.CreatedBy = created_by.ToString();
|
||||||
|
}
|
||||||
|
if(torrent.TryGetValue("creation date", out var creation_date))
|
||||||
|
{
|
||||||
|
var creationdate = creation_date as BencodedNumber;
|
||||||
|
if(creationdate != null)
|
||||||
|
{
|
||||||
|
torrentObj.CreationDate = DateTimeOffset.FromUnixTimeSeconds(creationdate.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(torrent.TryGetValue("announce-list", out var announce_list))
|
||||||
|
{
|
||||||
|
var announcelist = announce_list as BencodedList;
|
||||||
|
if(announcelist != null)
|
||||||
|
foreach(var item in announcelist)
|
||||||
|
{
|
||||||
|
var ls0 = item as BencodedList;
|
||||||
|
if(ls0 != null)
|
||||||
|
foreach(var item0 in ls0)
|
||||||
|
torrentObj.AnnounceList.Add(item0.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(torrent.TryGetValue("announce", out var announce))
|
||||||
|
{
|
||||||
|
if(torrentObj.AnnounceList.Count == 0)
|
||||||
|
torrentObj.AnnounceList.Add(announce.ToString());
|
||||||
|
}
|
||||||
|
if(torrent.TryGetValue("info", out var info))
|
||||||
|
{
|
||||||
|
var info_dict = info as BencodedDictionary;
|
||||||
|
if(info_dict != null)
|
||||||
|
{
|
||||||
|
torrentObj.InfoHash = torrentObj.GetInfoHash(info_dict);
|
||||||
|
if(info_dict.TryGetValue("name",out var name))
|
||||||
|
{
|
||||||
|
torrentObj.Info.Name = name.ToString();
|
||||||
|
}
|
||||||
|
if(info_dict.TryGetValue("piece length",out var piece_length))
|
||||||
|
{
|
||||||
|
var piecelength = piece_length as BencodedNumber;
|
||||||
|
if(piecelength != null)
|
||||||
|
{
|
||||||
|
torrentObj.Info.PieceLength = (int)piecelength.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info_dict.TryGetValue("files",out var files_list))
|
||||||
|
{
|
||||||
|
var files = files_list as BencodedList;
|
||||||
|
if(files != null)
|
||||||
|
{
|
||||||
|
long offset = 0;
|
||||||
|
foreach(var _file in files)
|
||||||
|
{
|
||||||
|
var _file_dict = _file as BencodedDictionary;
|
||||||
|
if(_file_dict != null)
|
||||||
|
{
|
||||||
|
TorrentInfoFile torrfile=new TorrentInfoFile();
|
||||||
|
torrfile.Offset = offset;
|
||||||
|
|
||||||
|
if(_file_dict.TryGetValue("length", out var length2))
|
||||||
|
{
|
||||||
|
var l = length2 as BencodedNumber;
|
||||||
|
if(l != null)
|
||||||
|
offset += torrfile.Length = l.Value;
|
||||||
|
}
|
||||||
|
if(_file_dict.TryGetValue("path", out var path))
|
||||||
|
{
|
||||||
|
var pathlist = path as BencodedList;
|
||||||
|
if(pathlist != null)
|
||||||
|
torrfile.Path = pathlist.Select<BencodedData,string>(e=>e.ToString()).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
torrentObj.Info.Files.Add(torrfile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
torrentObj.Info.Length = offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(info_dict.TryGetValue("length", out var _length))
|
||||||
|
{
|
||||||
|
var length = _length as BencodedNumber;
|
||||||
|
if(length != null)
|
||||||
|
torrentObj.Info.Length = length.Value;
|
||||||
|
}
|
||||||
|
if(info_dict.TryGetValue("pieces",out var _pieces))
|
||||||
|
{
|
||||||
|
var pieces = _pieces as BencodedString;
|
||||||
|
if(pieces !=null)
|
||||||
|
{
|
||||||
|
byte[] array=(byte[])pieces;
|
||||||
|
int noPieces=pieces.Length / 20;
|
||||||
|
for(int i = 0;i<noPieces;i++)
|
||||||
|
{
|
||||||
|
byte[] piece = new byte[20];
|
||||||
|
Array.Copy(array, i*20, piece,0,20);
|
||||||
|
torrentObj.Info.Pieces.Add(piece);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return torrentObj;
|
||||||
|
}
|
||||||
|
public DateTimeOffset CreationDate {get;set;}=DateTimeOffset.Now;
|
||||||
|
public List<string> AnnounceList {get;set;}=new List<string>();
|
||||||
|
public string CreatedBy {get;set;}="TessesCMS";
|
||||||
|
public byte[] InfoHash {get;set;}=null;
|
||||||
|
public async Task<byte[]> GetInfoHashAsync()
|
||||||
|
{
|
||||||
|
if(InfoHash != null) return InfoHash;
|
||||||
|
using(MemoryStream memoryStream=new MemoryStream())
|
||||||
|
{
|
||||||
|
await ToTorrentFile()["info"].WriteToStreamAsync(memoryStream);
|
||||||
|
using(var sha1=SHA1Managed.Create())
|
||||||
|
return sha1.ComputeHash(memoryStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public byte[] GetInfoHash()
|
||||||
|
{
|
||||||
|
if(InfoHash != null) return InfoHash;
|
||||||
|
return GetInfoHash(ToTorrentFile()["info"]);
|
||||||
|
}
|
||||||
|
internal byte[] GetInfoHash(BencodedData data)
|
||||||
|
{
|
||||||
|
|
||||||
|
using(MemoryStream memoryStream=new MemoryStream())
|
||||||
|
{
|
||||||
|
data.WriteToStream(memoryStream);
|
||||||
|
using(var sha1=SHA1Managed.Create())
|
||||||
|
return sha1.ComputeHash(memoryStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public TorrentInfo Info {get;set;}=new TorrentInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TorrentInfo
|
||||||
|
{
|
||||||
|
public List<TorrentInfoFile> Files {get;set;}=new List<TorrentInfoFile>();
|
||||||
|
public string Name {get;set;}
|
||||||
|
|
||||||
|
public long Length {get;set;}
|
||||||
|
|
||||||
|
public int PieceLength {get;set;}
|
||||||
|
|
||||||
|
|
||||||
|
public List<byte[]> Pieces {get;set;}=new List<byte[]>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class TorrentInfoFile
|
||||||
|
{
|
||||||
|
public long Offset {get;set;}
|
||||||
|
|
||||||
|
public long Length {get;set;}
|
||||||
|
|
||||||
|
public string[] Path {get;set;}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return System.IO.Path.Combine(Path);
|
||||||
|
}
|
||||||
|
public UnixPath ToUnixPath()
|
||||||
|
{
|
||||||
|
return new UnixPath(Path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public abstract class BencodedData
|
||||||
|
{
|
||||||
|
internal static async Task<int> ReadByteAsync(Stream strm)
|
||||||
|
{
|
||||||
|
byte[] buffer=new byte[1];
|
||||||
|
if(await strm.ReadAsync(buffer,0,1) == 0) return -1;
|
||||||
|
return buffer[0];
|
||||||
|
}
|
||||||
|
public static BencodedData ReadFromStream(Stream strm)
|
||||||
|
{
|
||||||
|
int b=strm.ReadByte();
|
||||||
|
switch(b)
|
||||||
|
{
|
||||||
|
case 'e':
|
||||||
|
return null;
|
||||||
|
case 'i':
|
||||||
|
return BencodedNumber.ReadIntFromStream(strm);
|
||||||
|
case 'l':
|
||||||
|
return BencodedList.ReadListFromStream(strm);
|
||||||
|
case 'd':
|
||||||
|
return BencodedDictionary.ReadDictionaryFromStream(strm);
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
StringBuilder sb= new StringBuilder();
|
||||||
|
sb.Append((char)b);
|
||||||
|
b = strm.ReadByte();
|
||||||
|
while(b != ':' && b !=-1)
|
||||||
|
{
|
||||||
|
sb.Append((char)b);
|
||||||
|
b = strm.ReadByte();
|
||||||
|
}
|
||||||
|
if(int.TryParse(sb.ToString(), out var number))
|
||||||
|
{
|
||||||
|
byte[] str = new byte[number];
|
||||||
|
if(strm.Read(str,0,str.Length) != str.Length)
|
||||||
|
{
|
||||||
|
return (BencodedString)"";
|
||||||
|
}
|
||||||
|
return new BencodedString(str);
|
||||||
|
}
|
||||||
|
return (BencodedString)"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static async Task<BencodedData> ReadFromStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
int b=await ReadByteAsync(strm);
|
||||||
|
switch(b)
|
||||||
|
{
|
||||||
|
case 'e':
|
||||||
|
return null;
|
||||||
|
case 'i':
|
||||||
|
return await BencodedNumber.ReadIntFromStreamAsync(strm);
|
||||||
|
case 'l':
|
||||||
|
return await BencodedList.ReadListFromStreamAsync(strm);
|
||||||
|
case 'd':
|
||||||
|
return await BencodedDictionary.ReadDictionaryFromStreamAsync(strm);
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
StringBuilder sb= new StringBuilder();
|
||||||
|
sb.Append((char)b);
|
||||||
|
b = await ReadByteAsync(strm);
|
||||||
|
while(b != ':' && b !=-1)
|
||||||
|
{
|
||||||
|
sb.Append((char)b);
|
||||||
|
b = await ReadByteAsync(strm);
|
||||||
|
}
|
||||||
|
if(int.TryParse(sb.ToString(), out var number))
|
||||||
|
{
|
||||||
|
byte[] str = new byte[number];
|
||||||
|
if(await strm.ReadAsync(str,0,str.Length) != str.Length)
|
||||||
|
{
|
||||||
|
return (BencodedString)"";
|
||||||
|
}
|
||||||
|
return new BencodedString(str);
|
||||||
|
}
|
||||||
|
return (BencodedString)"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public abstract Task WriteToStreamAsync(Stream strm);
|
||||||
|
|
||||||
|
public abstract void WriteToStream(Stream strm);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BencodedDictionary : BencodedData, IDictionary<string,BencodedData>
|
||||||
|
{
|
||||||
|
|
||||||
|
List<KeyValuePair<string,BencodedData>> _dict=new List<KeyValuePair<string, BencodedData>>();
|
||||||
|
public BencodedData this[string key]
|
||||||
|
{
|
||||||
|
get{
|
||||||
|
foreach(var item in _dict)
|
||||||
|
{
|
||||||
|
if(item.Key == key) return item.Value;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
var val= new KeyValuePair<string, BencodedData>(key,value);
|
||||||
|
for(int i = 0;i<_dict.Count;i++)
|
||||||
|
{
|
||||||
|
if(_dict[i].Key == key)
|
||||||
|
{
|
||||||
|
_dict[i] = val;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_dict.Add(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICollection<string> Keys => _dict.Select(e=>e.Key).ToList();
|
||||||
|
|
||||||
|
public ICollection<BencodedData> Values => _dict.Select(e=>e.Value).ToList();
|
||||||
|
|
||||||
|
public int Count => _dict.Count;
|
||||||
|
|
||||||
|
public bool IsReadOnly => false;
|
||||||
|
|
||||||
|
internal static async Task<BencodedData> ReadDictionaryFromStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
BencodedDictionary dict=new BencodedDictionary();
|
||||||
|
BencodedData data;
|
||||||
|
while((data=await ReadFromStreamAsync(strm)) != null)
|
||||||
|
{
|
||||||
|
var res=await ReadFromStreamAsync(strm);
|
||||||
|
if(res == null) break;
|
||||||
|
dict.Add(data.ToString(), res);
|
||||||
|
}
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static BencodedData ReadDictionaryFromStream(Stream strm)
|
||||||
|
{
|
||||||
|
BencodedDictionary dict=new BencodedDictionary();
|
||||||
|
BencodedData data;
|
||||||
|
while((data=ReadFromStream(strm)) != null)
|
||||||
|
{
|
||||||
|
var res=ReadFromStream(strm);
|
||||||
|
if(res == null) break;
|
||||||
|
dict.Add(data.ToString(), res);
|
||||||
|
}
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
public void Add(string key, BencodedData value)
|
||||||
|
{
|
||||||
|
_dict.Add(new KeyValuePair<string, BencodedData>(key,value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(KeyValuePair<string, BencodedData> item)
|
||||||
|
{
|
||||||
|
|
||||||
|
_dict.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
_dict.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(KeyValuePair<string, BencodedData> item)
|
||||||
|
{
|
||||||
|
return _dict.Contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsKey(string key)
|
||||||
|
{
|
||||||
|
foreach(var item in _dict)
|
||||||
|
{
|
||||||
|
if(item.Key == key) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(KeyValuePair<string, BencodedData>[] array, int arrayIndex)
|
||||||
|
{
|
||||||
|
_dict.CopyTo(array,arrayIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<KeyValuePair<string, BencodedData>> GetEnumerator()
|
||||||
|
{
|
||||||
|
return _dict.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(string key)
|
||||||
|
{
|
||||||
|
for(int i = 0;i<_dict.Count;i++)
|
||||||
|
{
|
||||||
|
if(_dict[i].Key == key)
|
||||||
|
{
|
||||||
|
_dict.RemoveAt(i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(KeyValuePair<string, BencodedData> item)
|
||||||
|
{
|
||||||
|
return _dict.Remove(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TryGetValue(string key, out BencodedData value)
|
||||||
|
{
|
||||||
|
value = null;
|
||||||
|
foreach(var item in _dict)
|
||||||
|
{
|
||||||
|
if(item.Key == key) {value = item.Value; return true;}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteToStream(Stream strm)
|
||||||
|
{
|
||||||
|
strm.WriteByte((byte)'d');
|
||||||
|
foreach(var item in this)
|
||||||
|
{
|
||||||
|
BencodedString str = item.Key;
|
||||||
|
str.WriteToStream(strm);
|
||||||
|
item.Value.WriteToStream(strm);
|
||||||
|
}
|
||||||
|
strm.WriteByte((byte)'e');
|
||||||
|
}
|
||||||
|
|
||||||
|
public override async Task WriteToStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
await strm.WriteAsync(new byte[]{(byte)'d'},0,1);
|
||||||
|
|
||||||
|
foreach(var item in this)
|
||||||
|
{
|
||||||
|
BencodedString str = item.Key;
|
||||||
|
await str.WriteToStreamAsync(strm);
|
||||||
|
await item.Value.WriteToStreamAsync(strm);
|
||||||
|
}
|
||||||
|
await strm.WriteAsync(new byte[]{(byte)'e'},0,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return _dict.GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public sealed class BencodedList : BencodedData, IList<BencodedData>
|
||||||
|
{
|
||||||
|
List<BencodedData> bencodedDatas=new List<BencodedData>();
|
||||||
|
public BencodedList()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public BencodedData this[int index] { get => bencodedDatas[index]; set => bencodedDatas[index]=value; }
|
||||||
|
|
||||||
|
public int Count => bencodedDatas.Count;
|
||||||
|
|
||||||
|
public bool IsReadOnly => false;
|
||||||
|
|
||||||
|
internal static BencodedData ReadListFromStream(Stream strm)
|
||||||
|
{
|
||||||
|
BencodedList list=new BencodedList();
|
||||||
|
BencodedData data;
|
||||||
|
while((data = ReadFromStream(strm)) != null)
|
||||||
|
{
|
||||||
|
list.Add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static async Task<BencodedData> ReadListFromStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
BencodedList list=new BencodedList();
|
||||||
|
BencodedData data;
|
||||||
|
while((data = await ReadFromStreamAsync(strm)) != null)
|
||||||
|
{
|
||||||
|
list.Add(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(BencodedData item)
|
||||||
|
{
|
||||||
|
bencodedDatas.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddRange(IEnumerable<BencodedData> items)
|
||||||
|
{
|
||||||
|
bencodedDatas.AddRange(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
bencodedDatas.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Contains(BencodedData item)
|
||||||
|
{
|
||||||
|
return bencodedDatas.Contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CopyTo(BencodedData[] array, int arrayIndex)
|
||||||
|
{
|
||||||
|
bencodedDatas.CopyTo(array,arrayIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerator<BencodedData> GetEnumerator()
|
||||||
|
{
|
||||||
|
return bencodedDatas.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int IndexOf(BencodedData item)
|
||||||
|
{
|
||||||
|
return bencodedDatas.IndexOf(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert(int index, BencodedData item)
|
||||||
|
{
|
||||||
|
bencodedDatas.Insert(index,item);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Remove(BencodedData item)
|
||||||
|
{
|
||||||
|
return bencodedDatas.Remove(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveAt(int index)
|
||||||
|
{
|
||||||
|
bencodedDatas.RemoveAt(index);
|
||||||
|
}
|
||||||
|
public override void WriteToStream(Stream strm)
|
||||||
|
{
|
||||||
|
strm.WriteByte((byte)'l');
|
||||||
|
foreach(var item in this)
|
||||||
|
{
|
||||||
|
item.WriteToStream(strm);
|
||||||
|
}
|
||||||
|
strm.WriteByte((byte)'e');
|
||||||
|
}
|
||||||
|
public override async Task WriteToStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
await strm.WriteAsync(new byte[]{(byte)'l'},0,1);
|
||||||
|
|
||||||
|
foreach(var item in this)
|
||||||
|
{
|
||||||
|
await item.WriteToStreamAsync(strm);
|
||||||
|
}
|
||||||
|
await strm.WriteAsync(new byte[]{(byte)'e'},0,1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return bencodedDatas.GetEnumerator();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public sealed class BencodedNumber : BencodedData
|
||||||
|
{
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Value.ToString();
|
||||||
|
}
|
||||||
|
public BencodedNumber(long value)
|
||||||
|
{
|
||||||
|
Value = value;
|
||||||
|
}
|
||||||
|
public static implicit operator BencodedNumber(long number)
|
||||||
|
{
|
||||||
|
return new BencodedNumber(number);
|
||||||
|
}
|
||||||
|
public static explicit operator long(BencodedNumber number)
|
||||||
|
{
|
||||||
|
return number.Value;
|
||||||
|
}
|
||||||
|
public long Value {get;private set;}
|
||||||
|
public override async Task WriteToStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
var bytes=Encoding.UTF8.GetBytes($"i{Value}e");
|
||||||
|
await strm.WriteAsync(bytes,0,bytes.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static async Task<BencodedData> ReadIntFromStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
|
||||||
|
StringBuilder b=new StringBuilder();
|
||||||
|
int read = await ReadByteAsync(strm);
|
||||||
|
while(read != 'e' && read != -1)
|
||||||
|
{
|
||||||
|
b.Append((char)read);
|
||||||
|
read = await ReadByteAsync(strm);
|
||||||
|
}
|
||||||
|
if(long.TryParse(b.ToString(),out var number))
|
||||||
|
{
|
||||||
|
return new BencodedNumber(number);
|
||||||
|
}
|
||||||
|
return new BencodedNumber(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteToStream(Stream strm)
|
||||||
|
{
|
||||||
|
var bytes=Encoding.UTF8.GetBytes($"i{Value}e");
|
||||||
|
strm.Write(bytes,0,bytes.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static BencodedData ReadIntFromStream(Stream strm)
|
||||||
|
{
|
||||||
|
StringBuilder b=new StringBuilder();
|
||||||
|
int read = strm.ReadByte();
|
||||||
|
while(read != 'e' && read != -1)
|
||||||
|
{
|
||||||
|
b.Append((char)read);
|
||||||
|
read = strm.ReadByte();
|
||||||
|
}
|
||||||
|
if(long.TryParse(b.ToString(),out var number))
|
||||||
|
{
|
||||||
|
return new BencodedNumber(number);
|
||||||
|
}
|
||||||
|
return new BencodedNumber(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public sealed class BencodedString : BencodedData, IEnumerable<byte>
|
||||||
|
{
|
||||||
|
public static implicit operator BencodedString(byte[] data)
|
||||||
|
{
|
||||||
|
return new BencodedString(data);
|
||||||
|
}
|
||||||
|
public static implicit operator BencodedString(string text)
|
||||||
|
{
|
||||||
|
return new BencodedString(Encoding.UTF8.GetBytes(text));
|
||||||
|
}
|
||||||
|
public static explicit operator string(BencodedString str)
|
||||||
|
{
|
||||||
|
return str.ToString();
|
||||||
|
}
|
||||||
|
public static explicit operator byte[](BencodedString str)
|
||||||
|
{
|
||||||
|
byte[] myL=new byte[str.data.Length];
|
||||||
|
Array.Copy(str.data,myL,myL.Length);
|
||||||
|
return myL;
|
||||||
|
}
|
||||||
|
public BencodedString(byte[] array)
|
||||||
|
{
|
||||||
|
data = array;
|
||||||
|
}
|
||||||
|
public byte this[int index]
|
||||||
|
{
|
||||||
|
get=>data[index];
|
||||||
|
}
|
||||||
|
byte[] data;
|
||||||
|
|
||||||
|
public int Count => data.Length;
|
||||||
|
public int Length => data.Length;
|
||||||
|
|
||||||
|
public override async Task WriteToStreamAsync(Stream strm)
|
||||||
|
{
|
||||||
|
byte[] utf8 = Encoding.UTF8.GetBytes($"{data.Length}:");
|
||||||
|
await strm.WriteAsync(utf8,0,utf8.Length);
|
||||||
|
await strm.WriteAsync(data,0,data.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IEnumerable<byte> _E()
|
||||||
|
{
|
||||||
|
foreach(var c in data) yield return c;
|
||||||
|
}
|
||||||
|
public IEnumerator<byte> GetEnumerator()
|
||||||
|
{
|
||||||
|
return _E().GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return data.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Encoding.UTF8.GetString(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void WriteToStream(Stream strm)
|
||||||
|
{
|
||||||
|
byte[] utf8 = Encoding.UTF8.GetBytes($"{data.Length}:");
|
||||||
|
strm.Write(utf8,0,utf8.Length);
|
||||||
|
strm.Write(data,0,data.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
|
using Tesses.WebServer;
|
||||||
|
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class CMSConfiguration
|
||||||
|
{
|
||||||
|
|
||||||
|
public ushort Port {get;set;}=62444;
|
||||||
|
|
||||||
|
public string Title {get;set;}="TessesCMS";
|
||||||
|
|
||||||
|
public string Root {get;set;}="/";
|
||||||
|
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
|
||||||
|
public CMSPublish Publish {get;set;}=CMSPublish.NoRestriction;
|
||||||
|
public List<CMSNavUrl> Urls { get; set; }=new List<CMSNavUrl>();
|
||||||
|
public string BrowserTranscode {get;set;}="-vf scale=640:480 -crf 28";
|
||||||
|
public List<string> BittorrentTrackers {get;set;}=new List<string>();
|
||||||
|
public CMSNavUrl RelativeNavUrl(string text,string url)
|
||||||
|
{
|
||||||
|
return RelativeNavUrl(new CMSNavUrl(text,url));
|
||||||
|
}
|
||||||
|
public CMSNavUrl RelativeNavUrl(CMSNavUrl url)
|
||||||
|
{
|
||||||
|
return new CMSNavUrl(url.Text,$"{Root.TrimEnd('/')}/{url.Url.TrimStart('/')}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CMSNavUrl
|
||||||
|
{
|
||||||
|
public CMSNavUrl() : this("","")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public CMSNavUrl(string text,string url)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
Url = url;
|
||||||
|
}
|
||||||
|
public string Text {get;set;}
|
||||||
|
|
||||||
|
public string Url {get;set;}
|
||||||
|
|
||||||
|
public bool Active {get;set;}=false;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum CMSPublish
|
||||||
|
{
|
||||||
|
NoRestriction = 0,
|
||||||
|
RequireInvite = 1,
|
||||||
|
|
||||||
|
Admin = 2
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,934 @@
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Tesses.WebServer;
|
||||||
|
using Scriban;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Tesses.WebServer.Swagme;
|
||||||
|
using System.Net;
|
||||||
|
using System.Web;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using Microsoft.SyndicationFeed.Rss;
|
||||||
|
using Microsoft.SyndicationFeed.Atom;
|
||||||
|
using Microsoft.SyndicationFeed;
|
||||||
|
using PlaylistsNET.Models;
|
||||||
|
using PlaylistsNET.Content;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class CMSServer
|
||||||
|
{
|
||||||
|
public Dictionary<string,UserAccount> Sessions {get;set;}=new Dictionary<string, UserAccount>();
|
||||||
|
Template pageShell;
|
||||||
|
Template pageIndex;
|
||||||
|
Template pageDevcenter;
|
||||||
|
|
||||||
|
Template pageMovie;
|
||||||
|
Template pageMovies;
|
||||||
|
Template pageWatchMovie;
|
||||||
|
|
||||||
|
Template pageUpload;
|
||||||
|
|
||||||
|
Template pageUsers;
|
||||||
|
Template pageEditMovieDetails;
|
||||||
|
|
||||||
|
|
||||||
|
RouteServer routeServer;
|
||||||
|
|
||||||
|
PathValueServer usersPathValueServer;
|
||||||
|
|
||||||
|
PathValueServer moviePathValueServer;
|
||||||
|
MountableServer usersMountableServer;
|
||||||
|
|
||||||
|
RouteServer movieRouteServer;
|
||||||
|
|
||||||
|
IContentProvider provider;
|
||||||
|
string path;
|
||||||
|
public CMSServer(string configpath,IContentProvider provider)
|
||||||
|
{
|
||||||
|
this.provider=provider;
|
||||||
|
usersMountableServer=new MountableServer();
|
||||||
|
usersPathValueServer = new PathValueServer(usersMountableServer);
|
||||||
|
movieRouteServer=new RouteServer();
|
||||||
|
moviePathValueServer = new PathValueServer(movieRouteServer);
|
||||||
|
string configJson = Path.Combine(configpath,"config.json");
|
||||||
|
if(File.Exists(configJson))
|
||||||
|
{
|
||||||
|
Configuration = JsonConvert.DeserializeObject<CMSConfiguration>(File.ReadAllText(configJson));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Configuration.BittorrentTrackers.Count == 0)
|
||||||
|
{
|
||||||
|
Configuration.BittorrentTrackers.AddRange( new string[]{
|
||||||
|
"https://t1.hloli.org:443/announce",
|
||||||
|
"http://1337.abcvg.info:80/announce",
|
||||||
|
"http://tracker.renfei.net:8080/announce",
|
||||||
|
"http://tracker.gbitt.info:80/announce",
|
||||||
|
"http://p2p.0g.cx:6969/announce",
|
||||||
|
"https://tracker.foreverpirates.co:443/announce"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pageShell=Template.Parse(AssetProvider.ReadAllText("/PageShell.html"));
|
||||||
|
|
||||||
|
pageIndex = Template.Parse(AssetProvider.ReadAllText("/Index.html"));
|
||||||
|
pageDevcenter = Template.Parse(AssetProvider.ReadAllText("/Devcenter.html"));
|
||||||
|
pageMovie = Template.Parse(AssetProvider.ReadAllText("/MoviePage.html"));
|
||||||
|
pageMovies = Template.Parse(AssetProvider.ReadAllText("/MoviesPage.html"));
|
||||||
|
pageUsers = Template.Parse(AssetProvider.ReadAllText("/UsersPage.html"));
|
||||||
|
pageWatchMovie = Template.Parse(AssetProvider.ReadAllText("/WatchMovie.html"));
|
||||||
|
pageUpload = Template.Parse(AssetProvider.ReadAllText("/Upload.html"));
|
||||||
|
pageEditMovieDetails = Template.Parse(AssetProvider.ReadAllText("/EditMovieDetails.html"));
|
||||||
|
MountableServer mountableServer = new MountableServer(new AssetProvider());
|
||||||
|
path=Path.Combine(configpath,"content");
|
||||||
|
|
||||||
|
mountableServer.Mount("/content/",new StaticServer(path){AllowListingDirectories=true});
|
||||||
|
mountableServer.Mount("/api/v1/",CreateSwagme());
|
||||||
|
mountableServer.Mount("/user/",usersPathValueServer);
|
||||||
|
|
||||||
|
routeServer = new RouteServer(mountableServer);
|
||||||
|
routeServer.Add("/",Index,"GET");
|
||||||
|
routeServer.Add("/devcenter",Devcenter,"GET");
|
||||||
|
routeServer.Add("/upload",UploadPage1,"GET");
|
||||||
|
routeServer.Add("/upload",Upload,"POST");
|
||||||
|
routeServer.Add("/users",UsersAsync,"GET");
|
||||||
|
routeServer.Add("/login",LoginAsync);
|
||||||
|
routeServer.Add("/login",LoginPostAsync,"POST");
|
||||||
|
routeServer.Add("/signup",SignupAsync);
|
||||||
|
routeServer.Add("/signup",SignupPostAsync,"POST");
|
||||||
|
RegisterUsersPath();
|
||||||
|
Task.Factory.StartNew(async()=>{
|
||||||
|
while(Running)
|
||||||
|
{
|
||||||
|
if(tasks.TryDequeue(out var item))
|
||||||
|
{
|
||||||
|
await item();
|
||||||
|
}
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(0.125));
|
||||||
|
}
|
||||||
|
}).Wait(0);
|
||||||
|
}
|
||||||
|
public bool Running =true;
|
||||||
|
public async Task LoginAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await AssetProvider.ReadAllTextAsync("/LoginPage.html")));
|
||||||
|
|
||||||
|
}
|
||||||
|
public async Task SignupAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await AssetProvider.ReadAllTextAsync("/SignupPage.html")));
|
||||||
|
|
||||||
|
}
|
||||||
|
public async Task SignupPostAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
ctx.ParseBody();
|
||||||
|
if(ctx.QueryParams.TryGetFirst("email", out var email) && ctx.QueryParams.TryGetFirst("name", out var name) && ctx.QueryParams.TryGetFirst("proper_name",out var proper_name) && ctx.QueryParams.TryGetFirst("password",out var password) && ctx.QueryParams.TryGetFirst("confirm_password",out var confirm_password))
|
||||||
|
{
|
||||||
|
bool error = false,emailTaken=false, nameTaken=false, properNameTaken=false, passwordDontMatch=false, passwordNotGoodEnough=false;
|
||||||
|
foreach(var user in provider.GetUsers())
|
||||||
|
{
|
||||||
|
if(user.Username == name)
|
||||||
|
{
|
||||||
|
nameTaken=true;
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
if(user.Email == email)
|
||||||
|
{
|
||||||
|
emailTaken=true;
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
if(user.ProperName == proper_name)
|
||||||
|
{
|
||||||
|
properNameTaken=true;
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(password != confirm_password)
|
||||||
|
{
|
||||||
|
error=true;
|
||||||
|
passwordDontMatch=true;
|
||||||
|
}
|
||||||
|
if(password.Length < 10)
|
||||||
|
{
|
||||||
|
error=true;
|
||||||
|
passwordNotGoodEnough=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(error)
|
||||||
|
{
|
||||||
|
StringBuilder b=new StringBuilder();
|
||||||
|
|
||||||
|
if(emailTaken)
|
||||||
|
{
|
||||||
|
b.AppendLine("<h1>Email is taken</h1>");
|
||||||
|
}
|
||||||
|
if(nameTaken)
|
||||||
|
{
|
||||||
|
b.AppendLine("<h1>Name is taken</h1>");
|
||||||
|
}
|
||||||
|
if(properNameTaken)
|
||||||
|
{
|
||||||
|
b.AppendLine("<h1>Proper Name is taken");
|
||||||
|
}
|
||||||
|
if(passwordNotGoodEnough)
|
||||||
|
{
|
||||||
|
b.AppendLine("<h1>Password not good enough</h1>");
|
||||||
|
}
|
||||||
|
if(passwordDontMatch)
|
||||||
|
{
|
||||||
|
b.AppendLine("<h1>Passwords don't match</h1>");
|
||||||
|
}
|
||||||
|
await ctx.SendTextAsync(b.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
provider.CreateUser(Configuration,name,proper_name,email,password);
|
||||||
|
await ctx.SendRedirectAsync($"{Configuration.Root.TrimEnd('/')}/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public async Task LoginPostAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
ctx.ParseBody();
|
||||||
|
if(ctx.QueryParams.TryGetFirst("email",out var email) && ctx.QueryParams.TryGetFirst("password",out var password))
|
||||||
|
{
|
||||||
|
foreach(var a in provider.GetUsers())
|
||||||
|
{
|
||||||
|
if(a.Email != email) continue;
|
||||||
|
if(a.Email == email && a.PasswordCorrect(password))
|
||||||
|
{
|
||||||
|
//we got it
|
||||||
|
byte[] bytes=new byte[32];
|
||||||
|
string cookie;
|
||||||
|
using(var rng = RandomNumberGenerator.Create())
|
||||||
|
do {
|
||||||
|
|
||||||
|
rng.GetBytes(bytes);
|
||||||
|
cookie=Convert.ToBase64String(bytes);
|
||||||
|
} while(Sessions.ContainsKey(cookie));
|
||||||
|
|
||||||
|
Sessions.Add(cookie,a);
|
||||||
|
ctx.ResponseHeaders.Add("Set-Cookie",$"Session={cookie}; Path=/");
|
||||||
|
await ctx.SendRedirectAsync($"{Configuration.Root.TrimEnd('/')}/");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
ctx.StatusCode=401;
|
||||||
|
await ctx.SendTextAsync("<h1>Incorrect</h1><a href=\"./\">Home</a> | <a href=\"./login\">Login</a>");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private UserAccount GetAccount(ServerContext ctx)
|
||||||
|
{
|
||||||
|
if(ctx.RequestHeaders.TryGetValue("Cookie",out var cookies))
|
||||||
|
{
|
||||||
|
foreach(var c in cookies)
|
||||||
|
{
|
||||||
|
var co = c.Split(new char[]{'='},2);
|
||||||
|
if(co.Length == 2 && co[0] == "Session")
|
||||||
|
{
|
||||||
|
if(Sessions.TryGetValue(co[1],out var account))
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private async Task UsersAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
List<object> users=new List<object>();
|
||||||
|
foreach(var user in provider.GetUsers())
|
||||||
|
{
|
||||||
|
users.Add(user.Scriban());
|
||||||
|
}
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await pageUsers.RenderAsync(new {
|
||||||
|
Users=users,
|
||||||
|
rooturl=$"{Configuration.Root.TrimEnd('/')}/"
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
const string badC="/\\\"&,?|:;*@!# ";
|
||||||
|
private string FixString(string str)
|
||||||
|
{
|
||||||
|
StringBuilder b=new StringBuilder();
|
||||||
|
foreach(var item in str)
|
||||||
|
{
|
||||||
|
if(char.IsControl(item))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(item >= 127) continue;
|
||||||
|
if(badC.Contains(item.ToString())) continue;
|
||||||
|
b.Append(item.ToString());
|
||||||
|
}
|
||||||
|
return b.ToString();
|
||||||
|
}
|
||||||
|
private async Task Upload(ServerContext ctx)
|
||||||
|
{
|
||||||
|
ctx.ParseBody();
|
||||||
|
if(ctx.QueryParams.TryGetFirst("name",out var name) && ctx.QueryParams.TryGetFirst("proper_name",out var proper_name) && ctx.QueryParams.TryGetFirst("type", out var type) && ctx.QueryParams.TryGetFirst("description",out var description))
|
||||||
|
{
|
||||||
|
var account=GetAccount(ctx);
|
||||||
|
if(account != null)
|
||||||
|
{
|
||||||
|
if(!account.IsAdmin && Configuration.Publish == CMSPublish.Admin)
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>You can't upload content</h1>"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!(account.IsAdmin || account.IsInvited) && Configuration.Publish == CMSPublish.RequireInvite)
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>You can't upload content</h1>"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!(account.IsAdmin || account.IsInvited || account.IsVerified))
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>You can't upload content</h1>"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
name = FixString(name);
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case "movie":
|
||||||
|
provider.CreateMovie(account.Username,name,proper_name,description);
|
||||||
|
await ctx.SendRedirectAsync($"{Configuration.Root.TrimEnd('/')}/user/{account.Username}/movie/{name}/edit");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ctx.SendRedirectAsync($"{Configuration.Root.TrimEnd('/')}/login");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ctx.SendRedirectAsync($"{Configuration.Root.TrimEnd('/')}/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UploadPage1(ServerContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await RenderUpload1Async(),Configuration.RelativeNavUrl("Devcenter","devcenter")));
|
||||||
|
|
||||||
|
}
|
||||||
|
public IServer Movies()
|
||||||
|
{
|
||||||
|
RouteServer routeServer=new RouteServer();
|
||||||
|
routeServer.Add("/",MoviesAsync);
|
||||||
|
return routeServer;
|
||||||
|
}
|
||||||
|
public async Task MoviesAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string user=usersPathValueServer.GetValue(ctx);
|
||||||
|
List<object> movies=new List<object>();
|
||||||
|
foreach(var item in provider.GetMovies(user))
|
||||||
|
{
|
||||||
|
var data = provider.GetMovieContentMetaData(Configuration,user,item.Name);
|
||||||
|
movies.Add(item.Scriban(data.ThumbnailUrl));
|
||||||
|
}
|
||||||
|
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await pageMovies.RenderAsync(new{Movies=movies})));
|
||||||
|
}
|
||||||
|
private void RegisterUsersPath()
|
||||||
|
{
|
||||||
|
RouteServer routeServer=new RouteServer();
|
||||||
|
routeServer.Add("/",UserPageAsync);
|
||||||
|
usersMountableServer.Mount("/",routeServer);
|
||||||
|
usersMountableServer.Mount("/movies/",Movies());
|
||||||
|
usersMountableServer.Mount("/movie/",moviePathValueServer);
|
||||||
|
RegisterMoviePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UserPageAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await AssetProvider.ReadAllTextAsync("/UserPage.html")));
|
||||||
|
}
|
||||||
|
|
||||||
|
ConcurrentQueue<Func<Task>> tasks=new ConcurrentQueue<Func<Task>>();
|
||||||
|
|
||||||
|
private void RegisterMoviePath()
|
||||||
|
{
|
||||||
|
movieRouteServer.Add("/",MoviePageAsync);
|
||||||
|
movieRouteServer.Add("/play",PlayMoviePageAsync);
|
||||||
|
movieRouteServer.Add("/edit",EditPageAsync);
|
||||||
|
movieRouteServer.Add("/edit",EditPagePostAsync,"POST");
|
||||||
|
movieRouteServer.Add("/upload",UploadStreamAsync,"POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class PieceStream : Stream
|
||||||
|
{
|
||||||
|
public const int PieceLength = 16*1024;
|
||||||
|
public int CurpieceOffset {get;private set;} =0;
|
||||||
|
|
||||||
|
public List<byte[]> Pieces {get;private set;}=new List<byte[]>();
|
||||||
|
|
||||||
|
public byte[] CalculateCurPiece()
|
||||||
|
{
|
||||||
|
using(var sha1=SHA1.Create())
|
||||||
|
{
|
||||||
|
return sha1.ComputeHash(Curpiece,0,CurpieceOffset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public byte[] Curpiece = new byte[PieceLength];
|
||||||
|
public override bool CanRead => false;
|
||||||
|
|
||||||
|
public override bool CanSeek => false;
|
||||||
|
|
||||||
|
public override bool CanWrite => true;
|
||||||
|
long len;
|
||||||
|
public override long Length => len;
|
||||||
|
|
||||||
|
public bool HasPiece=>CurpieceOffset>0;
|
||||||
|
|
||||||
|
public override long Position { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||||
|
|
||||||
|
public override void Flush()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override long Seek(long offset, SeekOrigin origin)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void SetLength(long value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
for(int i = 0;i<count;i++)
|
||||||
|
{
|
||||||
|
byte curByte = buffer[i+offset];
|
||||||
|
if(CurpieceOffset < PieceLength)
|
||||||
|
{
|
||||||
|
Curpiece[CurpieceOffset++] = curByte;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Pieces.Add(this.CalculateCurPiece());
|
||||||
|
CurpieceOffset=0;
|
||||||
|
Curpiece[CurpieceOffset++] = curByte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
len+=count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task GenerateBittorentFileMovieAsync(string user,string movie)
|
||||||
|
{
|
||||||
|
|
||||||
|
string movieDir = Path.Combine(this.path,user,"movie",movie);
|
||||||
|
Console.WriteLine($"Starting torrent creation: {movieDir}");
|
||||||
|
Directory.CreateDirectory(movieDir);
|
||||||
|
string extrasDir = Path.Combine(movieDir,"extras");
|
||||||
|
string subtitles = Path.Combine(movieDir,"subtitles");
|
||||||
|
PieceStream strm = new PieceStream();
|
||||||
|
//calculate without extras
|
||||||
|
List<string[]> paths = new List<string[]>();
|
||||||
|
paths.Add(new string[]{$"{movie}.mp4"});
|
||||||
|
paths.Add(new string[]{"thumbnail.jpg"});
|
||||||
|
paths.Add(new string[]{"poster.jpg"});
|
||||||
|
if(Directory.Exists(subtitles))
|
||||||
|
GetExtras(paths,new string[]{"subtitles"},subtitles);
|
||||||
|
List<long> lengths = new List<long>();
|
||||||
|
foreach(var _path in paths.Select<string[],string>(e=>Path.Combine(e)))
|
||||||
|
using(var movieStrm = File.OpenRead(Path.Combine(movieDir,_path)))
|
||||||
|
{
|
||||||
|
lengths.Add(movieStrm.Length);
|
||||||
|
await movieStrm.CopyToAsync(strm);
|
||||||
|
}
|
||||||
|
Torrent torrent =new Torrent();
|
||||||
|
torrent.AnnounceList.AddRange(Configuration.BittorrentTrackers);
|
||||||
|
torrent.CreationDate=DateTime.Now;
|
||||||
|
torrent.UrlList = $"{Configuration.Root.TrimEnd('/')}/content/{user}/movie/";
|
||||||
|
torrent.Info.PieceLength = PieceStream.PieceLength;
|
||||||
|
torrent.Info.Name = movie;
|
||||||
|
foreach(var piece in strm.Pieces)
|
||||||
|
{
|
||||||
|
torrent.Info.Pieces.Add(piece);
|
||||||
|
}
|
||||||
|
if(strm.HasPiece) torrent.Info.Pieces.Add(strm.CalculateCurPiece());
|
||||||
|
for(int i = 0;i<paths.Count;i++)
|
||||||
|
{
|
||||||
|
var _path = paths[i];
|
||||||
|
var len = lengths[i];
|
||||||
|
torrent.Info.Files.Add(new TorrentInfoFile(){Path=_path, Length = len});
|
||||||
|
}
|
||||||
|
string torrentFile = Path.Combine(movieDir,$"{movie}.torrent");
|
||||||
|
Console.WriteLine(torrentFile);
|
||||||
|
using(var file=File.Create(torrentFile))
|
||||||
|
{
|
||||||
|
await torrent.ToTorrentFile().WriteToStreamAsync(file);
|
||||||
|
}
|
||||||
|
Console.WriteLine($"Created Torrent: {torrentFile}");
|
||||||
|
if(Directory.Exists(extrasDir))
|
||||||
|
{
|
||||||
|
List<string[]> paths2 = new List<string[]>();
|
||||||
|
GetExtras(paths2,new string[]{"extras"},extrasDir);
|
||||||
|
foreach(var _path in paths2.Select<string[],string>(e=>Path.Combine(e)))
|
||||||
|
using(var movieStrm = File.OpenRead(Path.Combine(movieDir,_path)))
|
||||||
|
{
|
||||||
|
lengths.Add(movieStrm.Length);
|
||||||
|
await movieStrm.CopyToAsync(strm);
|
||||||
|
}
|
||||||
|
paths.AddRange(paths2);
|
||||||
|
torrent=new Torrent();
|
||||||
|
torrent.AnnounceList.AddRange(Configuration.BittorrentTrackers);
|
||||||
|
torrent.CreationDate=DateTime.Now;
|
||||||
|
torrent.UrlList = $"{Configuration.Root.TrimEnd('/')}/content/{user}/movie/";
|
||||||
|
torrent.Info.PieceLength = PieceStream.PieceLength;
|
||||||
|
torrent.Info.Name = movie;
|
||||||
|
foreach(var piece in strm.Pieces)
|
||||||
|
{
|
||||||
|
torrent.Info.Pieces.Add(piece);
|
||||||
|
}
|
||||||
|
if(strm.HasPiece) torrent.Info.Pieces.Add(strm.CalculateCurPiece());
|
||||||
|
for(int i = 0;i<paths.Count;i++)
|
||||||
|
{
|
||||||
|
var _path = paths[i];
|
||||||
|
var len = lengths[i];
|
||||||
|
torrent.Info.Files.Add(new TorrentInfoFile(){Path=_path, Length = len});
|
||||||
|
}
|
||||||
|
torrentFile = Path.Combine(movieDir,$"{movie}_withextras.torrent");
|
||||||
|
using(var file=File.Create(torrentFile))
|
||||||
|
{
|
||||||
|
await torrent.ToTorrentFile().WriteToStreamAsync(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetExtras(List<string[]> paths2, string[] torrentPath, string extrasDir)
|
||||||
|
{
|
||||||
|
foreach(var dir in Directory.GetDirectories(extrasDir))
|
||||||
|
{
|
||||||
|
string dirname = Path.GetFileName(dir);
|
||||||
|
string[] path = new string[torrentPath.Length+1];
|
||||||
|
Array.Copy(torrentPath,path,torrentPath.Length);
|
||||||
|
path[path.Length-1] = dirname;
|
||||||
|
GetExtras(paths2,path,dir);
|
||||||
|
}
|
||||||
|
foreach(var file in Directory.GetFiles(extrasDir))
|
||||||
|
{
|
||||||
|
string filename = Path.GetFileName(file);
|
||||||
|
string[] path = new string[torrentPath.Length+1];
|
||||||
|
Array.Copy(torrentPath,path,torrentPath.Length);
|
||||||
|
path[path.Length-1] = filename;
|
||||||
|
paths2.Add(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UploadStreamAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
|
||||||
|
string user=usersPathValueServer.GetValue(ctx);
|
||||||
|
string movie=moviePathValueServer.GetValue(ctx);
|
||||||
|
var me = GetAccount(ctx);
|
||||||
|
var _movie = provider.GetMovie(user,movie);
|
||||||
|
|
||||||
|
if(me != null && me.Username != user && !me.IsAdmin)
|
||||||
|
{
|
||||||
|
me=null;
|
||||||
|
}
|
||||||
|
if(me != null)
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path.Combine(path,user,"movie",movie));
|
||||||
|
var tmpFile = Path.Combine(path,user,"movie",movie,$"tmp{DateTime.Now.ToFileTime().ToString()}.bin");
|
||||||
|
foreach(var item in ctx.ParseBody((n,fn,ct)=>File.Create(tmpFile)))
|
||||||
|
item.Value.Dispose();
|
||||||
|
|
||||||
|
if(_movie != null)
|
||||||
|
{
|
||||||
|
if(ctx.QueryParams.TryGetFirst("type",out var type))
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case "thumbnail":
|
||||||
|
File.Move(tmpFile,Path.Combine(path,user,"movie",movie,"thumbnail.jpg"));
|
||||||
|
break;
|
||||||
|
case "poster":
|
||||||
|
File.Move(tmpFile,Path.Combine(path,user,"movie",movie,"poster.jpg"));
|
||||||
|
break;
|
||||||
|
case "movie":
|
||||||
|
File.Move(tmpFile,Path.Combine(path,user,"movie",movie,$"{movie}.mp4"));
|
||||||
|
ScheduleFFmpeg($"-i \"{Path.Combine(path,user,"movie",movie,$"{movie}.mp4")}\" {Configuration.BrowserTranscode} \"{Path.Combine(path,user,"movie",movie,"browser.mp4")}\"");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ScheduleTask(async()=>{
|
||||||
|
await GenerateBittorentFileMovieAsync(user,movie);
|
||||||
|
});
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>Success</h1><a href=\"./edit\"><- Back</a>"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>Failed</h1><a href=\"./edit\"><- Back</a>"));
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ScheduleFFmpeg(string command)
|
||||||
|
{
|
||||||
|
ScheduleTask(async()=>{
|
||||||
|
using(Process process=new Process())
|
||||||
|
{
|
||||||
|
process.StartInfo.Arguments = command;
|
||||||
|
process.StartInfo.FileName = "ffmpeg";
|
||||||
|
if(process.Start())
|
||||||
|
{
|
||||||
|
await Task.Run(process.WaitForExit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ScheduleTask(Func<Task> task)
|
||||||
|
{
|
||||||
|
tasks.Enqueue(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task EditPagePostAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
ctx.ParseBody();
|
||||||
|
string user=usersPathValueServer.GetValue(ctx);
|
||||||
|
string movie=moviePathValueServer.GetValue(ctx);
|
||||||
|
var me = GetAccount(ctx);
|
||||||
|
var _movie = provider.GetMovie(user,movie);
|
||||||
|
|
||||||
|
if(me != null && me.Username != user && !me.IsAdmin)
|
||||||
|
{
|
||||||
|
me=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(me != null)
|
||||||
|
{
|
||||||
|
if(_movie != null)
|
||||||
|
{
|
||||||
|
if(ctx.QueryParams.TryGetFirst("proper_name",out var proper_name) && ctx.QueryParams.TryGetFirst("description",out var description))
|
||||||
|
{
|
||||||
|
_movie.ProperName = proper_name;
|
||||||
|
_movie.Description = description;
|
||||||
|
provider.UpdateMovie(_movie);
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>Success</h1><a href=\"./edit\"><- Back</a>"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>Failed</h1><a href=\"./edit\"><- Back</a>"));
|
||||||
|
}
|
||||||
|
public async Task EditPageAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string user=usersPathValueServer.GetValue(ctx);
|
||||||
|
string movie=moviePathValueServer.GetValue(ctx);
|
||||||
|
var me = GetAccount(ctx);
|
||||||
|
var _movie = provider.GetMovie(user,movie);
|
||||||
|
|
||||||
|
if(me != null && me.Username != user && !me.IsAdmin)
|
||||||
|
{
|
||||||
|
me=null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(me != null)
|
||||||
|
{
|
||||||
|
if(_movie != null)
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await pageEditMovieDetails.RenderAsync(new{Propername=System.Web.HttpUtility.HtmlAttributeEncode( _movie.ProperName),Description=System.Web.HttpUtility.HtmlEncode(_movie.Description)})));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,"<h1>You are unauthorized to edit this</h1>"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private async Task PlayMoviePageAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string user=usersPathValueServer.GetValue(ctx);
|
||||||
|
string movie=moviePathValueServer.GetValue(ctx);
|
||||||
|
|
||||||
|
var _movie= provider.GetMovie(user,movie);
|
||||||
|
object value;
|
||||||
|
if(_movie != null)
|
||||||
|
{
|
||||||
|
var data=provider.GetMovieContentMetaData(Configuration,user,movie);
|
||||||
|
string thumb = data.ThumbnailUrl;
|
||||||
|
value = new{ username=user, rooturl=$"{Configuration.Root.TrimEnd('/')}/",
|
||||||
|
title=Configuration.Title,hasmovie=true,moviethumbnail=thumb,movieurl=movie,moviename=_movie.Name,moviedescription=_movie.Description,movieposter = data.PosterUrl, moviebrowserurl=data.BrowserStream};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = new{ username=user, rooturl=$"{Configuration.Root.TrimEnd('/')}/",
|
||||||
|
title=Configuration.Title,hasmovie=false};
|
||||||
|
}
|
||||||
|
|
||||||
|
await ctx.SendTextAsync(await pageWatchMovie.RenderAsync(value));
|
||||||
|
|
||||||
|
}
|
||||||
|
private async Task MoviePageAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string user=usersPathValueServer.GetValue(ctx);
|
||||||
|
string movie=moviePathValueServer.GetValue(ctx);
|
||||||
|
|
||||||
|
var _movie= provider.GetMovie(user,movie);
|
||||||
|
var _user = provider.GetUserAccount(user);
|
||||||
|
|
||||||
|
var me = GetAccount(ctx);
|
||||||
|
|
||||||
|
if(me != null && me.Username != user && !me.IsAdmin)
|
||||||
|
{
|
||||||
|
me=null;
|
||||||
|
}
|
||||||
|
object value;
|
||||||
|
if(_movie != null && _user != null)
|
||||||
|
{
|
||||||
|
var data=provider.GetMovieContentMetaData(Configuration,user,movie);
|
||||||
|
string movieDir = Path.Combine(this.path,user,"movie",movie);
|
||||||
|
bool torrent= File.Exists(Path.Combine(movieDir,$"{movie}.torrent"));
|
||||||
|
bool torrent_wextra= File.Exists(Path.Combine(movieDir,$"{movie}_withextras.torrent"));
|
||||||
|
|
||||||
|
string thumb = data.ThumbnailUrl;
|
||||||
|
value = new{ downloadurl=data.DownloadStream,torrentexists=torrent, torrentwextraexists=torrent_wextra, torrent=data.MovieTorrentUrl,torrentwextra=data.MovieWithExtrasTorrentUrl , editable=me!=null, userproper=HttpUtility.HtmlEncode(_user.ProperName), username=HttpUtility.HtmlEncode(user), rooturl=$"{Configuration.Root.TrimEnd('/')}/",
|
||||||
|
title=Configuration.Title,hasmovie=true,moviethumbnail=thumb,movieurl=movie,movieproperattr=HttpUtility.HtmlAttributeEncode(_movie.ProperName),movieproper=HttpUtility.HtmlEncode(_movie.ProperName),moviename=HttpUtility.HtmlEncode(_movie.Name),moviedescription=HttpUtility.HtmlEncode(_movie.Description)};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = new{ username=user, rooturl=$"{Configuration.Root.TrimEnd('/')}/",
|
||||||
|
title=Configuration.Title,hasmovie=false};
|
||||||
|
}
|
||||||
|
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await pageMovie.RenderAsync(value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IServer CreateSwagme()
|
||||||
|
{
|
||||||
|
SwagmeServer swagmeServer=new SwagmeServer();
|
||||||
|
swagmeServer.AbsoluteUrl=true;
|
||||||
|
swagmeServer.Add("/MovieFile",ApiMovieFileAsync,new SwagmeDocumentation("Get the movie resource"),"GET","Movies");
|
||||||
|
swagmeServer.Add("/GetMovies",ApiGetMoviesAsync,new SwagmeDocumentation("Get a list of movies","<b>user</b>: the user of the movie<br><b>type</b>: format of list (defaults to json): pls, json, m3u8 or rss"),"GET","Movies");
|
||||||
|
return swagmeServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ApiMovieFileAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
if(ctx.QueryParams.TryGetFirst("user",out var user) && ctx.QueryParams.TryGetFirst("movie", out var movie))
|
||||||
|
{
|
||||||
|
if(!ctx.QueryParams.TryGetFirst("type", out var type))
|
||||||
|
type="download";
|
||||||
|
|
||||||
|
var info = provider.GetMovieContentMetaData(Configuration,user,movie);
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case "download":
|
||||||
|
await ctx.SendRedirectAsync( info.DownloadStream);
|
||||||
|
break;
|
||||||
|
case "browser":
|
||||||
|
await ctx.SendRedirectAsync(info.BrowserStream);
|
||||||
|
break;
|
||||||
|
case "thumbnail":
|
||||||
|
await ctx.SendRedirectAsync(info.ThumbnailUrl);
|
||||||
|
break;
|
||||||
|
case "poster":
|
||||||
|
await ctx.SendRedirectAsync(info.PosterUrl);
|
||||||
|
break;
|
||||||
|
case "torrent":
|
||||||
|
await ctx.SendRedirectAsync(info.MovieTorrentUrl);
|
||||||
|
break;
|
||||||
|
case "torrent_extra":
|
||||||
|
await ctx.SendRedirectAsync(info.MovieWithExtrasTorrentUrl);
|
||||||
|
break;
|
||||||
|
case "json":
|
||||||
|
await ctx.SendJsonAsync(info);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task ApiGetMoviesAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
UserAccount a;
|
||||||
|
if(!ctx.QueryParams.TryGetFirst("type",out var type)) type="json";
|
||||||
|
if(ctx.QueryParams.TryGetFirst("user",out var user))
|
||||||
|
{
|
||||||
|
a = provider.GetUserAccount(user);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a = provider.GetFirstUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Movie> movies=new List<Movie>();
|
||||||
|
|
||||||
|
if(a != null)
|
||||||
|
{
|
||||||
|
movies.AddRange(provider.GetMovies(a.Id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(type=="json")
|
||||||
|
{
|
||||||
|
await ctx.SendJsonAsync(movies);
|
||||||
|
}
|
||||||
|
if(type == "pls")
|
||||||
|
{
|
||||||
|
StringBuilder b=new StringBuilder();
|
||||||
|
b.AppendLine("[Playlist]");
|
||||||
|
int i = 1;
|
||||||
|
foreach(var item in movies)
|
||||||
|
{
|
||||||
|
b.AppendLine($"File{i}={Configuration.Root.TrimEnd('/')}/api/v1/MovieFile?user={HttpUtility.UrlEncode(user)}&movie={HttpUtility.UrlEncode(item.Name)}&type=download");
|
||||||
|
b.AppendLine($"Length{i}=0");
|
||||||
|
b.AppendLine($"Title{i}={IniEscape(item.ProperName)}");
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
await ctx.SendTextAsync(b.ToString(),"audio/x-scpls");
|
||||||
|
}
|
||||||
|
if(type == "m3u8")
|
||||||
|
{
|
||||||
|
M3uPlaylist playlist=new M3uPlaylist();
|
||||||
|
foreach(var item in movies)
|
||||||
|
{
|
||||||
|
M3uPlaylistEntry entry=new M3uPlaylistEntry();
|
||||||
|
entry.Path = $"{Configuration.Root.TrimEnd('/')}/api/v1/MovieFile?user={HttpUtility.UrlEncode(user)}&movie={HttpUtility.UrlEncode(item.Name)}&type=download";
|
||||||
|
entry.Title = item.ProperName;
|
||||||
|
playlist.PlaylistEntries.Add(entry);
|
||||||
|
}
|
||||||
|
M3uContent content = new M3uContent();
|
||||||
|
await ctx.SendTextAsync(content.ToText(playlist),"application/x-mpegurl");
|
||||||
|
}
|
||||||
|
if(type == "rss")
|
||||||
|
{
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
using (XmlWriter xmlWriter = XmlWriter.Create(sw, new XmlWriterSettings() { Async = true, Indent = false,OmitXmlDeclaration=true, Encoding= Encoding.UTF8 }))
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var rss = new RssFeedWriter(xmlWriter);
|
||||||
|
|
||||||
|
await rss.WriteTitle($"{a.ProperName}'s Movies");
|
||||||
|
await rss.WriteGenerator("TessesCMS");
|
||||||
|
await rss.WriteValue("link",$"{Configuration.Root.TrimEnd('/')}/");
|
||||||
|
foreach(var item in movies)
|
||||||
|
{
|
||||||
|
AtomEntry entry=new AtomEntry();
|
||||||
|
entry.Title = item.ProperName;
|
||||||
|
entry.Description = $"View <a href=\"{Configuration.Root.TrimEnd('/')}/user/{user}/movie/{HttpUtility.UrlEncode(item.Name)}/\">here</a><br>{item.Description}";
|
||||||
|
entry.LastUpdated = item.LastUpdated;
|
||||||
|
entry.Published = item.CreationTime;
|
||||||
|
|
||||||
|
await rss.Write(entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await ctx.SendTextAsync(sw.GetStringBuilder().ToString(),"application/rss+xml");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string IniEscape(string properName)
|
||||||
|
{
|
||||||
|
StringBuilder b=new StringBuilder();
|
||||||
|
foreach(var c in properName)
|
||||||
|
{
|
||||||
|
if(c == '\\' || c ==';' || c == '\"' || c == '\'' || c == '#' || c == '=' || c == ':')
|
||||||
|
{
|
||||||
|
b.Append($"\\{c}");
|
||||||
|
}
|
||||||
|
else if(c == '\0')
|
||||||
|
{
|
||||||
|
b.Append("\\0");
|
||||||
|
}
|
||||||
|
else if(c == '\b')
|
||||||
|
{
|
||||||
|
b.Append("\\b");
|
||||||
|
}
|
||||||
|
else if(c == '\a')
|
||||||
|
{
|
||||||
|
b.Append("\\a");
|
||||||
|
}
|
||||||
|
else if(c == '\t')
|
||||||
|
{
|
||||||
|
b.Append("\\t");
|
||||||
|
}
|
||||||
|
else if(c == '\r')
|
||||||
|
{
|
||||||
|
b.Append("\\r");
|
||||||
|
}else if(c == '\n')
|
||||||
|
{
|
||||||
|
b.Append("\\n");
|
||||||
|
}
|
||||||
|
else if(c > sbyte.MaxValue)
|
||||||
|
{
|
||||||
|
b.Append($"\\x{((int)c).ToString("X4")}");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b.Append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<string> RenderHtmlAsync(bool isHome,string body,params CMSNavUrl[] urls)
|
||||||
|
{
|
||||||
|
List<object> _urls = new List<object>();
|
||||||
|
|
||||||
|
foreach(var item in urls)
|
||||||
|
{
|
||||||
|
_urls.Add(new{text=item.Text, url=item.Url,active=item.Active});
|
||||||
|
}
|
||||||
|
foreach(var item in Configuration.Urls)
|
||||||
|
{
|
||||||
|
_urls.Add(new{text=item.Text,url=item.Url,active=item.Active});
|
||||||
|
}
|
||||||
|
return await pageShell.RenderAsync(new{
|
||||||
|
ishome = isHome,
|
||||||
|
body = body,
|
||||||
|
urls=_urls,
|
||||||
|
rooturl=$"{Configuration.Root.TrimEnd('/')}/",
|
||||||
|
title=Configuration.Title
|
||||||
|
});
|
||||||
|
}
|
||||||
|
private async Task Index(ServerContext ctx)
|
||||||
|
{
|
||||||
|
var account=GetAccount(ctx);
|
||||||
|
CMSNavUrl accountLink=account != null ? Configuration.RelativeNavUrl(account.ProperName,"account") : Configuration.RelativeNavUrl("Login","login");
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(true,await RenderIndexAsync(),Configuration.RelativeNavUrl("Devcenter","devcenter"), accountLink));
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Devcenter(ServerContext ctx)
|
||||||
|
{
|
||||||
|
var link = Configuration.RelativeNavUrl("Devcenter","devcenter");
|
||||||
|
link.Active=true;
|
||||||
|
await ctx.SendTextAsync(await RenderHtmlAsync(false,await RenderDevcenterAsync(),link));
|
||||||
|
}
|
||||||
|
private async Task<string> RenderDevcenterAsync()
|
||||||
|
{
|
||||||
|
return await pageDevcenter.RenderAsync(new{title=Configuration.Title,rooturl=$"{Configuration.Root.TrimEnd('/')}/"});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<string> RenderIndexAsync()
|
||||||
|
{
|
||||||
|
return await pageIndex.RenderAsync(new{title=Configuration.Title,rooturl=$"{Configuration.Root.TrimEnd('/')}/"});
|
||||||
|
}
|
||||||
|
public async Task<string> RenderUpload1Async()
|
||||||
|
{
|
||||||
|
return await pageUpload.RenderAsync(new{title=Configuration.Title,rooturl=$"{Configuration.Root.TrimEnd('/')}/"});
|
||||||
|
|
||||||
|
}
|
||||||
|
public CMSConfiguration Configuration {get;set;}=new CMSConfiguration();
|
||||||
|
public IServer Server => routeServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public interface IContentProvider
|
||||||
|
{
|
||||||
|
UserAccount GetFirstUser();
|
||||||
|
IEnumerable<UserAccount> GetUsers();
|
||||||
|
IEnumerable<Movie> GetMovies(string user);
|
||||||
|
|
||||||
|
IEnumerable<Movie> GetMovies(long user);
|
||||||
|
UserAccount GetUserAccount(string user);
|
||||||
|
|
||||||
|
Movie CreateMovie(string user,string movie,string properName,string description);
|
||||||
|
Movie GetMovie(string user,string movie);
|
||||||
|
|
||||||
|
void UpdateMovie(Movie movie);
|
||||||
|
|
||||||
|
MovieContentMetaData GetMovieContentMetaData(CMSConfiguration configuration,string user,string movie);
|
||||||
|
void CreateUser(CMSConfiguration configuration,string user,string properName,string email,string password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MovieContentMetaData
|
||||||
|
{
|
||||||
|
[JsonProperty("movie_torrent_url")]
|
||||||
|
public string MovieTorrentUrl {get;set;}
|
||||||
|
|
||||||
|
[JsonProperty("movie_with_extras_torrent_url")]
|
||||||
|
public string MovieWithExtrasTorrentUrl {get;set;}
|
||||||
|
|
||||||
|
[JsonProperty("browser_stream")]
|
||||||
|
public string BrowserStream {get;set;}
|
||||||
|
|
||||||
|
[JsonProperty("download_stream")]
|
||||||
|
public string DownloadStream {get;set;}
|
||||||
|
|
||||||
|
[JsonProperty("poster_url")]
|
||||||
|
public string PosterUrl {get;set;}
|
||||||
|
|
||||||
|
[JsonProperty("thumbnail_url")]
|
||||||
|
|
||||||
|
public string ThumbnailUrl {get;set;}
|
||||||
|
|
||||||
|
[JsonProperty("subtitle_streams")]
|
||||||
|
public List<SubtitleStream> SubtitlesStreams {get;set;}=new List<SubtitleStream>();
|
||||||
|
|
||||||
|
[JsonProperty("extra_streams")]
|
||||||
|
public List<ExtraDataStream> ExtraStreams {get;set;}=new List<ExtraDataStream>();
|
||||||
|
}
|
||||||
|
public class ExtraDataStream
|
||||||
|
{
|
||||||
|
[JsonProperty("is_dir")]
|
||||||
|
public bool IsDir {get;set;}
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name {get;set;}
|
||||||
|
|
||||||
|
[JsonProperty("items")]
|
||||||
|
|
||||||
|
public List<ExtraDataStream> Items {get;set;}=new List<ExtraDataStream>();
|
||||||
|
[JsonProperty("url")]
|
||||||
|
public string Url {get;set;}
|
||||||
|
}
|
||||||
|
public class SubtitleStream
|
||||||
|
{
|
||||||
|
[JsonProperty("language_code")]
|
||||||
|
public string LanguageCode {get;set;}="";
|
||||||
|
|
||||||
|
[JsonProperty("url")]
|
||||||
|
|
||||||
|
public string SubtitleUrl {get;set;}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,132 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using LiteDB;
|
||||||
|
|
||||||
|
namespace Tesses.CMS {
|
||||||
|
public class LiteDBContentProvider : IContentProvider
|
||||||
|
{
|
||||||
|
string dir;
|
||||||
|
ILiteDatabase db;
|
||||||
|
public LiteDBContentProvider(string dir)
|
||||||
|
{
|
||||||
|
this.dir = dir;
|
||||||
|
db=new LiteDatabase(Path.Combine(dir,"tesses-cms.db"));
|
||||||
|
}
|
||||||
|
public Movie CreateMovie(string user, string movie, string properName, string description)
|
||||||
|
{
|
||||||
|
var userId=GetUserAccount(user).Id;
|
||||||
|
|
||||||
|
Movie _movie = new Movie(){UserId = userId,Name = movie,ProperName=properName,Description = description};
|
||||||
|
_movie.Id=Movies.Insert(_movie);
|
||||||
|
return _movie;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ILiteCollection<UserAccount> UserAccounts => db.GetCollection<UserAccount>("users");
|
||||||
|
private ILiteCollection<Movie> Movies => db.GetCollection<Movie>("movies");
|
||||||
|
|
||||||
|
public UserAccount GetFirstUser()
|
||||||
|
{
|
||||||
|
return GetUsers().First();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Movie GetMovie(string user, string movie)
|
||||||
|
{
|
||||||
|
var userId=GetUserAccount(user).Id;
|
||||||
|
return Movies.FindOne(e=>e.Name == movie && e.UserId == userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MovieContentMetaData GetMovieContentMetaData(CMSConfiguration configuration, string user, string movie)
|
||||||
|
{
|
||||||
|
var _movie= new MovieContentMetaData(){
|
||||||
|
PosterUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/poster.jpg",
|
||||||
|
ThumbnailUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/thumbnail.jpg",
|
||||||
|
BrowserStream = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/browser.mp4",
|
||||||
|
DownloadStream = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/{movie}.mp4",
|
||||||
|
MovieTorrentUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/{movie}.torrent",
|
||||||
|
MovieWithExtrasTorrentUrl=$"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/{movie}_withextras.torrent"
|
||||||
|
};
|
||||||
|
string subDir=Path.Combine(dir,"content", user, "movie",movie,"subtitles");
|
||||||
|
if(Directory.Exists(subDir))
|
||||||
|
foreach(var language in Directory.GetDirectories(subDir))
|
||||||
|
{
|
||||||
|
string languageCode=Path.GetFileName(language); //en-US for english
|
||||||
|
_movie.SubtitlesStreams.Add(new SubtitleStream(){LanguageCode=languageCode, SubtitleUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/subtitles/{languageCode}/{movie}.srt"});
|
||||||
|
}
|
||||||
|
string extrasPath = Path.Combine(dir,"content", user, "movie",movie,"extras");
|
||||||
|
if(Directory.Exists(extrasPath))
|
||||||
|
FindExtras( $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/extras/",extrasPath,_movie.ExtraStreams);
|
||||||
|
return _movie;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FindExtras(string extras,string v, List<ExtraDataStream> extraStreams)
|
||||||
|
{
|
||||||
|
foreach(var d in Directory.GetDirectories(v))
|
||||||
|
{
|
||||||
|
var dirname = Path.GetFileName(d);
|
||||||
|
string url = $"{extras}{dirname}/";
|
||||||
|
|
||||||
|
ExtraDataStream dataStream=new ExtraDataStream();
|
||||||
|
dataStream.IsDir=true;
|
||||||
|
dataStream.Name = dirname;
|
||||||
|
dataStream.Url = url;
|
||||||
|
|
||||||
|
FindExtras(url,d,dataStream.Items);
|
||||||
|
extraStreams.Add(dataStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach(var f in Directory.GetFiles(v))
|
||||||
|
{
|
||||||
|
var filename = Path.GetFileName(f);
|
||||||
|
var url = $"{extras}{filename}";
|
||||||
|
ExtraDataStream dataStream=new ExtraDataStream();
|
||||||
|
dataStream.IsDir=false;
|
||||||
|
dataStream.Name = filename;
|
||||||
|
dataStream.Url = url;
|
||||||
|
|
||||||
|
extraStreams.Add(dataStream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Movie> GetMovies(string user)
|
||||||
|
{
|
||||||
|
var userId = GetUserAccount(user).Id;
|
||||||
|
return GetMovies(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Movie> GetMovies(long user)
|
||||||
|
{
|
||||||
|
return Movies.Find(e=>e.UserId==user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserAccount GetUserAccount(string user)
|
||||||
|
{
|
||||||
|
return UserAccounts.FindOne(e=>e.Username == user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<UserAccount> GetUsers()
|
||||||
|
{
|
||||||
|
return UserAccounts.FindAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateUser(CMSConfiguration configuration,string user,string properName,string email,string password)
|
||||||
|
{
|
||||||
|
bool isOwner = UserAccounts.Count() == 0;
|
||||||
|
UserAccount account=new UserAccount();
|
||||||
|
account.IsAdmin=isOwner;
|
||||||
|
account.IsVerified = isOwner;
|
||||||
|
account.Username = user;
|
||||||
|
account.ProperName= properName;
|
||||||
|
account.NewSalt();
|
||||||
|
account.PasswordHash=account.GetPasswordHash(password);
|
||||||
|
account.Email = email;
|
||||||
|
UserAccounts.Insert(account);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateMovie(Movie movie)
|
||||||
|
{
|
||||||
|
Movies.Update(movie);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class MockProvider : IContentProvider
|
||||||
|
{
|
||||||
|
List<Movie> movies=new List<Movie>();
|
||||||
|
UserAccount account2=new UserAccount();
|
||||||
|
public MockProvider()
|
||||||
|
{
|
||||||
|
Movie movie=new Movie(){Id=1,ProperName="Big Buck Bunny",Name="BigBuckBunny",UserId=1,CreationTime=new System.DateTime(2018,7,24,14,0,0), Description="Blenders Big Buck Bunny" };
|
||||||
|
movie.LastUpdated = movie.CreationTime;
|
||||||
|
movies.Add(movie);
|
||||||
|
account2.IsAdmin=true;
|
||||||
|
account2.Email = "johndoe@example.com";
|
||||||
|
account2.ProperName = "John Doe";
|
||||||
|
account2.Salt = "Jieaifnaienaifeniaienaif";
|
||||||
|
account2.PasswordHash = "0v4LGsBWyB6LMEuFDzU+H9Iy4Z5T4nyt96FBJ+YXHz0=";
|
||||||
|
account2.Username = "johndoe";
|
||||||
|
account2.Id = 2;
|
||||||
|
UserAccount account1=new UserAccount();
|
||||||
|
account1.Email="blender@example.com";
|
||||||
|
account1.PasswordHash="";
|
||||||
|
account1.ProperName = "Blender Studios";
|
||||||
|
account1.Username = "Blender";
|
||||||
|
account1.Salt ="";
|
||||||
|
account1.Id = 1;
|
||||||
|
|
||||||
|
Users.Add(account1);
|
||||||
|
|
||||||
|
Users.Add(account2);
|
||||||
|
}
|
||||||
|
List<UserAccount> Users =new List<UserAccount>();
|
||||||
|
public Movie CreateMovie(string user, string movie,string properName, string description)
|
||||||
|
{
|
||||||
|
Movie _movie = new Movie();
|
||||||
|
_movie.ProperName = properName;
|
||||||
|
_movie.Name = movie;
|
||||||
|
_movie.Id = movies.Count + 1;
|
||||||
|
_movie.UserId = 2;
|
||||||
|
_movie.Description = description;
|
||||||
|
_movie.CreationTime = DateTime.Now;
|
||||||
|
_movie.LastUpdated = _movie.CreationTime;
|
||||||
|
movies.Add(_movie);
|
||||||
|
return _movie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Movie GetMovie(string user, string movie)
|
||||||
|
{
|
||||||
|
if(user == "Blender" && movie=="BigBuckBunny")
|
||||||
|
{
|
||||||
|
return movies[0];
|
||||||
|
}
|
||||||
|
foreach(var item in movies)
|
||||||
|
{
|
||||||
|
if(item.Name == movie)
|
||||||
|
{
|
||||||
|
if(Users[(int)(item.UserId-1)].Username == user)
|
||||||
|
{
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public UserAccount GetUserAccount(string user)
|
||||||
|
{
|
||||||
|
foreach(var _user in Users)
|
||||||
|
{
|
||||||
|
if(_user.Username == user) return _user;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public IEnumerable<Movie> GetMovies(string user)
|
||||||
|
{
|
||||||
|
foreach(var movie in movies)
|
||||||
|
{
|
||||||
|
if(Users[(int)(movie.UserId-1)].Username == user)
|
||||||
|
{
|
||||||
|
yield return movie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<UserAccount> GetUsers()
|
||||||
|
{
|
||||||
|
return Users;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateMovie(Movie movie)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserAccount GetFirstUser()
|
||||||
|
{
|
||||||
|
return Users[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Movie> GetMovies(long user)
|
||||||
|
{
|
||||||
|
foreach(var movie in movies)
|
||||||
|
{
|
||||||
|
if(movie.UserId == user)
|
||||||
|
{
|
||||||
|
yield return movie;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public MovieContentMetaData GetMovieContentMetaData(CMSConfiguration configuration, string user, string movie)
|
||||||
|
{
|
||||||
|
MovieContentMetaData metaData=new MovieContentMetaData();
|
||||||
|
metaData.DownloadStream = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/{movie}.mp4";
|
||||||
|
metaData.ThumbnailUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/thumbnail.jpg";;
|
||||||
|
metaData.PosterUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/poster.jpg";
|
||||||
|
metaData.BrowserStream = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/browser.mp4";
|
||||||
|
metaData.MovieTorrentUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/{movie}.torrent";
|
||||||
|
metaData.MovieWithExtrasTorrentUrl = $"{configuration.Root.TrimEnd('/')}/content/{user}/movie/{movie}/{movie}_withextras.torrent";
|
||||||
|
|
||||||
|
if(user == "Blender" && movie == "BigBuckBunny")
|
||||||
|
{
|
||||||
|
metaData.ThumbnailUrl = "https://imgs.search.brave.com/3euIrrvtlxdwORlondpP-QTiWhC1_ARU5VlvgmkEnao/rs:fit:500:0:0/g:ce/aHR0cHM6Ly9tLm1l/ZGlhLWFtYXpvbi5j/b20vaW1hZ2VzL00v/TVY1Qk5qUmpZalJo/Tm1RdE5XRTBZUzAw/TldJd0xXRmhZalV0/TVRrelpUVXdZVEU0/TVRCaVhrRXlYa0Zx/Y0dkZVFYVnlOakEz/T1RJNU1qQUAuanBn";
|
||||||
|
metaData.BrowserStream= "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4";
|
||||||
|
metaData.DownloadStream = "https://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_320x180.mp4";
|
||||||
|
metaData.PosterUrl = "https://imgs.search.brave.com/3euIrrvtlxdwORlondpP-QTiWhC1_ARU5VlvgmkEnao/rs:fit:500:0:0/g:ce/aHR0cHM6Ly9tLm1l/ZGlhLWFtYXpvbi5j/b20vaW1hZ2VzL00v/TVY1Qk5qUmpZalJo/Tm1RdE5XRTBZUzAw/TldJd0xXRmhZalV0/TVRrelpUVXdZVEU0/TVRCaVhrRXlYa0Zx/Y0dkZVFYVnlOakEz/T1RJNU1qQUAuanBn";
|
||||||
|
}
|
||||||
|
return metaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateUser(CMSConfiguration configuration, string user,string properName, string email, string password)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class Movie
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public long Id {get;set;}
|
||||||
|
|
||||||
|
public string ProperName {get;set;}="";
|
||||||
|
|
||||||
|
public string Name {get;set;}="";
|
||||||
|
[JsonIgnore]
|
||||||
|
public long UserId {get;set;}
|
||||||
|
|
||||||
|
public DateTime CreationTime {get;set;}
|
||||||
|
public DateTime LastUpdated {get;set;}
|
||||||
|
|
||||||
|
public string Description {get;set;}="";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public object Scriban(string thumbnail)
|
||||||
|
{
|
||||||
|
return new {
|
||||||
|
Proper = System.Web.HttpUtility.HtmlEncode( ProperName),
|
||||||
|
Name = System.Web.HttpUtility.HtmlEncode(Name),
|
||||||
|
Description = System.Web.HttpUtility.HtmlEncode(Description),
|
||||||
|
Thumbnail = thumbnail
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Tesses.WebServer;
|
||||||
|
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class PathValueServer : Server
|
||||||
|
{
|
||||||
|
public IServer Server {get;set;}
|
||||||
|
int paths;
|
||||||
|
|
||||||
|
public PathValueServer(int paths=1)
|
||||||
|
{
|
||||||
|
Server = new NotFoundServer();
|
||||||
|
this.paths=paths;
|
||||||
|
}
|
||||||
|
public PathValueServer(IServer inner,int paths=1)
|
||||||
|
{
|
||||||
|
|
||||||
|
Server = inner;
|
||||||
|
this.paths = paths;
|
||||||
|
}
|
||||||
|
public string GetValue(ServerContext ctx)
|
||||||
|
{
|
||||||
|
lock(kvps)
|
||||||
|
{
|
||||||
|
if(kvps.ContainsKey(ctx))
|
||||||
|
{
|
||||||
|
return kvps[ctx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
private void SetValue(ServerContext ctx,string val)
|
||||||
|
{
|
||||||
|
lock(kvps)
|
||||||
|
{
|
||||||
|
if(kvps.ContainsKey(ctx))
|
||||||
|
{
|
||||||
|
kvps[ctx] = val;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
kvps.Add(ctx,val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveValue(ServerContext ctx)
|
||||||
|
{
|
||||||
|
lock(kvps)
|
||||||
|
{
|
||||||
|
kvps.Remove(ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<ServerContext,string> kvps=new Dictionary<ServerContext, string>();
|
||||||
|
public override async Task GetAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string[] path=ctx.UrlPath.Split(new char[]{'/'},System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
SetValue(ctx,string.Join("/",path.Take(paths)));
|
||||||
|
ctx.UrlPath = $"/{string.Join("/",path.Skip(paths))}";
|
||||||
|
|
||||||
|
await Server.GetAsync(ctx);
|
||||||
|
RemoveValue(ctx);
|
||||||
|
}
|
||||||
|
public override async Task OptionsAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string[] path=ctx.UrlPath.Split(new char[]{'/'},System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
SetValue(ctx,string.Join("/",path.Take(paths)));
|
||||||
|
ctx.UrlPath = $"/{string.Join("/",path.Skip(paths))}";
|
||||||
|
|
||||||
|
await Server.OptionsAsync(ctx);
|
||||||
|
RemoveValue(ctx);
|
||||||
|
|
||||||
|
}
|
||||||
|
public override async Task OtherAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string[] path=ctx.UrlPath.Split(new char[]{'/'},System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
SetValue(ctx,string.Join("/",path.Take(paths)));
|
||||||
|
ctx.UrlPath = $"/{string.Join("/",path.Skip(paths))}";
|
||||||
|
|
||||||
|
await Server.OtherAsync(ctx);
|
||||||
|
RemoveValue(ctx);
|
||||||
|
|
||||||
|
}
|
||||||
|
public override async Task PostAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
string[] path=ctx.UrlPath.Split(new char[]{'/'},System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
SetValue(ctx,string.Join("/",path.Take(paths)));
|
||||||
|
ctx.UrlPath = $"/{string.Join("/",path.Skip(paths))}";
|
||||||
|
|
||||||
|
await Server.PostAsync(ctx);
|
||||||
|
RemoveValue(ctx);
|
||||||
|
|
||||||
|
}
|
||||||
|
public override async Task<bool> BeforeAsync(ServerContext ctx)
|
||||||
|
{
|
||||||
|
var urlPath = ctx.UrlPath;
|
||||||
|
string[] path=ctx.UrlPath.Split(new char[]{'/'},System.StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
SetValue(ctx,string.Join("/",path.Take(paths)));
|
||||||
|
ctx.UrlPath = $"/{string.Join("/",path.Skip(paths))}";
|
||||||
|
|
||||||
|
var r= await Server.BeforeAsync(ctx);
|
||||||
|
ctx.UrlPath = urlPath;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Assets\**" />
|
||||||
|
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="LiteDb" Version="5.0.17" />
|
||||||
|
<PackageReference Include="Microsoft.SyndicationFeed.ReaderWriter" Version="1.0.2" />
|
||||||
|
<PackageReference Include="PlaylistsNET" Version="1.4.0" />
|
||||||
|
<PackageReference Include="Scriban" Version="5.9.0" />
|
||||||
|
<PackageReference Include="Tesses.WebServer" Version="1.0.4.1" />
|
||||||
|
<PackageReference Include="Tesses.WebServer.Swagme" Version="1.0.2" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,106 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace Tesses.CMS
|
||||||
|
{
|
||||||
|
public class UserAccount
|
||||||
|
{
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsVerified {get;set;}=false;
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsInvited {get;set;}=false;
|
||||||
|
[JsonIgnore]
|
||||||
|
public bool IsAdmin {get;set;}=false;
|
||||||
|
public void NewSalt()
|
||||||
|
{
|
||||||
|
byte[] bytes=new byte[32];
|
||||||
|
using(var rnd = RandomNumberGenerator.Create())
|
||||||
|
rnd.GetBytes(bytes);
|
||||||
|
|
||||||
|
}
|
||||||
|
public string GetPasswordHash(string password)
|
||||||
|
{
|
||||||
|
string pass = $"{password}{Salt}";
|
||||||
|
using(var sha256Managed = SHA256Managed.Create())
|
||||||
|
{
|
||||||
|
return Convert.ToBase64String(sha256Managed.ComputeHash(Encoding.UTF8.GetBytes(pass)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool PasswordCorrect(string password)
|
||||||
|
{
|
||||||
|
string hash=GetPasswordHash(password);
|
||||||
|
|
||||||
|
return PasswordHash == hash ;
|
||||||
|
}
|
||||||
|
[JsonIgnore]
|
||||||
|
public long Id {get;set;}
|
||||||
|
|
||||||
|
public string Username {get;set;}="";
|
||||||
|
[JsonIgnore]
|
||||||
|
public string PasswordHash {get;set;}="";
|
||||||
|
[JsonIgnore]
|
||||||
|
public string Email {get;set;}="";
|
||||||
|
[JsonIgnore]
|
||||||
|
public string Salt {get;set;}="";
|
||||||
|
|
||||||
|
public string ProperName {get;set;}="";
|
||||||
|
|
||||||
|
public string AboutMe {get;set;}="";
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<MailEntry> AccountsToMail {get;set;}=new List<MailEntry> ();
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public List<WebHook> Webhooks {get;set;}=new List<WebHook>();
|
||||||
|
public object Scriban()
|
||||||
|
{
|
||||||
|
return new {
|
||||||
|
Username = System.Web.HttpUtility.HtmlEncode(Username),
|
||||||
|
Proper = System.Web.HttpUtility.HtmlEncode(ProperName),
|
||||||
|
About = System.Web.HttpUtility.HtmlEncode(AboutMe)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MailEntry
|
||||||
|
{
|
||||||
|
public long UserId {get;set;}
|
||||||
|
|
||||||
|
public bool EnableMovies {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledAlbums {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledSingles {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledShows {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledSoftware {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledOther {get;set;}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class WebHook
|
||||||
|
{
|
||||||
|
public long UserId {get;set;}
|
||||||
|
|
||||||
|
public string Url {get;set;}
|
||||||
|
|
||||||
|
public bool EnableMovies {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledAlbums {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledSingles {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledShows {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledSoftware {get;set;}
|
||||||
|
|
||||||
|
public bool EnabledOther {get;set;}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue