tesses-cms/Tesses.CMS/CMSConfiguration.cs

80 lines
2.1 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Mail;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Tesses.WebServer;
namespace Tesses.CMS
{
public class CMSConfiguration
{
public CMSEmailConfiguration Email {get;set;}
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 string BrowserTranscodeMp3 {get;set;}="-b:a 160k";
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 CMSEmailConfiguration
{
public string Host {get;set;}="";
public string Email {get;set;}="";
public string User {get;set;}="";
public string Pass {get;set;}="";
public int Port {get;set;}=587;
[JsonConverter(typeof(StringEnumConverter))]
public MailKit.Security.SecureSocketOptions Encryption {get;set;}= MailKit.Security.SecureSocketOptions.StartTls;
}
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
}
}