Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ source/DasBlog.Web.UI/content
# dasblog-core test infrasructure
test_results/
test_results.xml
/source/DasBlog.Tests/FunctionalTests/Properties/launchSettings.json
/source/DasBlog.Web.UI/Properties/ServiceDependencies/dasblog-linux - Zip Deploy/profile.arm.json
/source/DasBlog.Web.UI/Properties/ServiceDependencies/dasblog-linux - Zip Deploy
/source/DasBlog.Web.UI/Properties/ServiceDependencies
source/DasBlog.Tests/FunctionalTests/Properties/launchSettings.json
source/DasBlog.Web.UI/Properties/ServiceDependencies/*
source/DasBlog.Web.UI/.config
10 changes: 10 additions & 0 deletions source/DasBlog.Services/ConfigFile/Interfaces/IOEmbedProviders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace DasBlog.Services.ConfigFile.Interfaces
{
public interface IOEmbedProviders
{
public List<OEmbedProvider> Providers { get; set; }
}

}
5 changes: 4 additions & 1 deletion source/DasBlog.Services/ConfigFile/Interfaces/ISiteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,5 +364,8 @@ public interface ISiteConfig

[XmlAnyAttribute]
XmlAttribute[] anyAttributes { get; set; }
}
bool EnableRewritingHashtagsToCategoryLinks { get; set; }
bool EnableRewritingBareLinksToEmbeddings { get; set; }
bool EnableRewritingBareLinksToIcons { get; set; }
}
}
58 changes: 58 additions & 0 deletions source/DasBlog.Services/ConfigFile/OEmbedProviders.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System.Collections.Generic;
using DasBlog.Services.ConfigFile.Interfaces;
using System.Text.Json.Serialization;
using System.Reflection;
using System;

namespace DasBlog.Services.ConfigFile
{

public class OEmbedProviders : IOEmbedProviders
{
public OEmbedProviders() { }

[JsonPropertyName("providers")]
public List<OEmbedProvider> Providers { get; set; }

}

public class OEmbedEndpoint
{
[JsonPropertyName("schemes")]
public List<string> Schemes { get; set; }

[JsonPropertyName("url")]
public string Url { get; set; }

[JsonPropertyName("discovery")]
public bool? Discovery { get; set; }

[JsonPropertyName("formats")]
public List<string> Formats { get; set; }
}

public class OEmbedProvider : IComparer<OEmbedProvider>, IComparable<OEmbedProvider>
{
[JsonPropertyName("provider_name")]
public string Provider_Name { get; set; }

[JsonPropertyName("provider_url")]
public string Provider_Url { get; set; }

[JsonPropertyName("endpoints")]
public List<OEmbedEndpoint> Endpoints { get; set; }

[JsonPropertyName("usage_count")]
public long UsageCount { get; set; }

public int Compare(OEmbedProvider x, OEmbedProvider y)
{
return -1 * x.UsageCount.CompareTo(y.UsageCount);
}

public int CompareTo(OEmbedProvider other)
{
return -1 * UsageCount.CompareTo(other.UsageCount);
}
}
}
6 changes: 5 additions & 1 deletion source/DasBlog.Services/ConfigFile/SiteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,11 @@ public string Root {
public bool EnableTrackbackService { get; set; }
public bool EnablePingbackService { get; set; }
public bool EnableStartPageCaching { get; set; }
public bool EnableBlogrollDescription { get; set; }
public bool EnableRewritingHashtagsToCategoryLinks { get; set; }
public bool EnableRewritingBareLinksToEmbeddings { get; set; }
public bool EnableRewritingBareLinksToIcons { get; set; }

public bool EnableBlogrollDescription { get; set; }
public bool EnableUrlRewriting { get; set; }
public bool EnableCrossposts { get; set; }
public bool UseUserCulture { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions source/DasBlog.Services/DasBlog.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Coravel" Version="4.1.2" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
<PackageReference Include="Kveer.XmlRPC" Version="1.2.0" />
<PackageReference Include="MailKit" Version="2.15.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Quartz.AspNetCore" Version="3.3.3" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public class ConfigFilePathsDataOption
public string BinaryFolder { get; set; }

public string BinaryUrlRelative { get; set; }
public string OEmbedProvidersFilePath { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using System.IO;
using DasBlog.Services.ConfigFile;
using DasBlog.Services.FileManagement.Interfaces;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace DasBlog.Services.FileManagement
{
public class OEmbedProvidersFileService : IConfigFileService<OEmbedProviders>
{
private readonly ConfigFilePathsDataOption options;

public OEmbedProvidersFileService(IOptions<ConfigFilePathsDataOption> optionsAccessor)
{
options = optionsAccessor.Value;
}

public bool SaveConfig(OEmbedProviders config)
{
var ser = new JsonSerializer();
using (var writer = new StreamWriter(options.OEmbedProvidersFilePath))
{
try
{
ser.Serialize(writer, config);
return true;
}
catch (Exception e)
{
// TODO log
Console.WriteLine(e);
throw;
}
}
}
}
}
2 changes: 2 additions & 0 deletions source/DasBlog.Services/IDasBlogSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public interface IDasBlogSettings
IMetaTags MetaTags { get; set; }
ISiteSecurityConfig SecurityConfiguration { get; }

IOEmbedProviders OEmbedProviders { get; set; }

string WebRootDirectory { get; }

string RssUrl { get; }
Expand Down
Loading