Add support for IsPublic to all Setting types, enable Url Mapping for internal links
This commit is contained in:
@ -24,6 +24,14 @@ namespace Oqtane.Services
|
||||
/// <returns></returns>
|
||||
Task<UrlMapping> GetUrlMappingAsync(int urlMappingId);
|
||||
|
||||
/// <summary>
|
||||
/// Get one specific <see cref="UrlMapping"/>
|
||||
/// </summary>
|
||||
/// <param name="siteId">ID-reference of a <see cref="Site"/></param>
|
||||
/// <param name="url">A url</param>
|
||||
/// <returns></returns>
|
||||
Task<UrlMapping> GetUrlMappingAsync(int siteId, string url);
|
||||
|
||||
/// <summary>
|
||||
/// Add / save a new <see cref="UrlMapping"/> to the database.
|
||||
/// </summary>
|
||||
|
@ -131,22 +131,13 @@ namespace Oqtane.Services
|
||||
foreach (KeyValuePair<string, string> kvp in settings)
|
||||
{
|
||||
string value = kvp.Value;
|
||||
bool ispublic = false;
|
||||
if (value.StartsWith("[Public]"))
|
||||
{
|
||||
switch (entityName)
|
||||
{
|
||||
case EntityNames.Site:
|
||||
case EntityNames.ModuleDefinition:
|
||||
ispublic = true;
|
||||
break;
|
||||
default:
|
||||
ispublic = false;
|
||||
break;
|
||||
}
|
||||
value = value.Substring(8); // remove [Public]
|
||||
}
|
||||
bool ispublic = true;
|
||||
|
||||
if (value.StartsWith("[Private]"))
|
||||
{
|
||||
value = value.Substring(9); // remove [Private]
|
||||
ispublic = false;
|
||||
}
|
||||
|
||||
Setting setting = settingsList.FirstOrDefault(item => item.SettingName.Equals(kvp.Key, StringComparison.OrdinalIgnoreCase));
|
||||
if (setting == null)
|
||||
@ -205,7 +196,7 @@ namespace Oqtane.Services
|
||||
|
||||
public Dictionary<string, string> SetSetting(Dictionary<string, string> settings, string settingName, string settingValue)
|
||||
{
|
||||
return SetSetting(settings, settingName, settingValue, false);
|
||||
return SetSetting(settings, settingName, settingValue, true);
|
||||
}
|
||||
|
||||
public Dictionary<string, string> SetSetting(Dictionary<string, string> settings, string settingName, string settingValue, bool isPublic)
|
||||
@ -214,7 +205,7 @@ namespace Oqtane.Services
|
||||
{
|
||||
settings = new Dictionary<string, string>();
|
||||
}
|
||||
settingValue = (isPublic) ? "[Public]" + settingValue : settingValue;
|
||||
settingValue = (isPublic) ? settingValue : "[Private]" + settingValue;
|
||||
if (settings.ContainsKey(settingName))
|
||||
{
|
||||
settings[settingName] = settingValue;
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Oqtane.Documentation;
|
||||
using Oqtane.Shared;
|
||||
using System.Net;
|
||||
|
||||
namespace Oqtane.Services
|
||||
{
|
||||
@ -33,6 +34,11 @@ namespace Oqtane.Services
|
||||
return await GetJsonAsync<UrlMapping>($"{Apiurl}/{urlMappingId}");
|
||||
}
|
||||
|
||||
public async Task<UrlMapping> GetUrlMappingAsync(int siteId, string url)
|
||||
{
|
||||
return await GetJsonAsync<UrlMapping>($"{Apiurl}/url/{siteId}?url={WebUtility.UrlEncode(url)}");
|
||||
}
|
||||
|
||||
public async Task<UrlMapping> AddUrlMappingAsync(UrlMapping role)
|
||||
{
|
||||
return await PostJsonAsync<UrlMapping>(Apiurl, role);
|
||||
|
Reference in New Issue
Block a user