Skip to content

Commit

Permalink
plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
starlying committed Jun 19, 2017
1 parent 610e0db commit 6c23668
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 17 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified source/Plugins/SiteServer.Plugin.Oss/SiteServer.Plugin.Oss.dll
Binary file not shown.
Binary file modified source/Plugins/SiteServer.Plugin.Poll/SiteServer.Plugin.Poll.dll
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions source/SiteServer.CMS/Core/PageUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,5 +735,17 @@ public static string GetUserAvatarUrl(string apiUrl, UserInfo userInfo)

return SiteFilesAssets.GetUrl(apiUrl, "default_avatar.png");
}

public static string GetApiUrl(PublishmentSystemInfo publishmentSystemInfo = null)
{
if (publishmentSystemInfo == null) return PageUtils.GetApiUrl();

var apiUrl = publishmentSystemInfo.Additional.ApiUrl;
if (publishmentSystemInfo.Additional.IsMultiDeployment)
{
apiUrl = publishmentSystemInfo.Additional.InnerApiUrl;
}
return apiUrl;
}
}
}
2 changes: 2 additions & 0 deletions source/SiteServer.CMS/Core/PublishmentSystemManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ private static void fileWatcher_OnFileChange(object sender, EventArgs e)

public static PublishmentSystemInfo GetPublishmentSystemInfo(int publishmentSystemId)
{
if (publishmentSystemId <= 0) return null;

var list = GetPublishmentSystemInfoKeyValuePairList();

foreach (var pair in list)
Expand Down
8 changes: 2 additions & 6 deletions source/SiteServer.CMS/Plugin/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,8 @@ public static List<PluginMenu> GetAllMenus(string topId, int siteId)
{
var plugins = AllPlugins.Where(o => !o.Metadata.Disabled && o.Metadata.Menus != null);

var apiUrl = PageUtils.GetApiUrl();
if (siteId > 0)
{
var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(siteId);
apiUrl = publishmentSystemInfo.Additional.ApiUrl;
}
var publishmentSystemInfo = PublishmentSystemManager.GetPublishmentSystemInfo(siteId);
var apiUrl = PageUtility.GetApiUrl(publishmentSystemInfo);

var menus = new List<PluginMenu>();
foreach (var pluginPair in plugins)
Expand Down
13 changes: 7 additions & 6 deletions source/SiteServer.CMS/Plugin/PluginsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using BaiRong.Core;
using SiteServer.Plugin;

namespace SiteServer.CMS.Plugin
Expand Down Expand Up @@ -38,8 +39,8 @@ public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> metadat
}
catch (Exception e)
{
Log.Exception($"|PluginsLoader.CSharpPlugins|Couldn't load assembly for {metadata.Name}", e);
return;
LogUtils.AddErrorLog(e, $"Couldn't load assembly for {metadata.Name}");
continue;
}
var types = assembly.GetTypes();
Type type;
Expand All @@ -49,8 +50,8 @@ public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> metadat
}
catch (InvalidOperationException e)
{
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
return;
LogUtils.AddErrorLog(e, $"Can't find class implement IPlugin for <{metadata.Name}>");
continue;
}
IPlugin plugin;
try
Expand All @@ -59,8 +60,8 @@ public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> metadat
}
catch (Exception e)
{
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't create instance for <{metadata.Name}>", e);
return;
LogUtils.AddErrorLog(e, $"Can't create instance for <{metadata.Name}>");
continue;
}
#endif
plugins.Add(new PluginPair(metadata, plugin));
Expand Down
7 changes: 2 additions & 5 deletions source/SiteServer.CMS/StlParser/Utility/StlUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,8 @@ public static void ParseStl(PublishmentSystemInfo publishmentSystemInfo, PageInf
{
fileTemplateId = pageInfo.TemplateInfo.TemplateId;
}
var apiUrl = pageInfo.PublishmentSystemInfo.Additional.ApiUrl;
if (pageInfo.PublishmentSystemInfo.Additional.IsMultiDeployment)
{
apiUrl = pageInfo.PublishmentSystemInfo.Additional.InnerApiUrl;
}

var apiUrl = PageUtility.GetApiUrl(pageInfo.PublishmentSystemInfo);
var ajaxUrl = ActionsTrigger.GetUrl(apiUrl, pageInfo.PublishmentSystemId, contextInfo.ChannelId, contextInfo.ContentId, fileTemplateId, true);
pageInfo.AddPageEndScriptsIfNotExists("CreateDoubleClick", $@"
<script type=""text/javascript"" language=""javascript"">document.ondblclick=function(x){{location.href = '{ajaxUrl}';}}</script>");
Expand Down

0 comments on commit 6c23668

Please sign in to comment.