("language");
- if (string.IsNullOrEmpty(language) || language?.ToLower() == "auto")
- {
- html.Append($"");
- html.Append($"{scopeBody.Replace("\r\n", "\n").Replace("\n", SoftBreak)}
");
- }
- else
- {
- html.Append($"");
- html.Append($"{scopeBody.Replace("\r\n", "\n").Replace("\n", SoftBreak)}
");
- }
-
- return new HandlerResult(html.ToString())
- {
- Instructions = [Constants.HandlerResultInstruction.DisallowNestedProcessing]
- };
+ html.Append($"");
+ html.Append($"{scopeBody.Replace("\r\n", "\n").Replace("\n", SoftBreak)}
");
+ }
+ else
+ {
+ html.Append($"");
+ html.Append($"{scopeBody.Replace("\r\n", "\n").Replace("\n", SoftBreak)}
");
}
- //------------------------------------------------------------------------------------------------------------------------------
+ return new HandlerResult(html.ToString())
+ {
+ Instructions = [HandlerResultInstruction.DisallowNestedProcessing]
+ };
+ }
case "stripedtable":
case "table":
+ {
+ var html = new StringBuilder();
+
+ var hasBorder = function.Parameters.Get("hasBorder");
+ var isFirstRowHeader = function.Parameters.Get("isFirstRowHeader");
+
+ html.Append($"("hasBorder");
- var isFirstRowHeader = function.Parameters.Get("isFirstRowHeader");
-
- html.Append($"");
-
- var lines = scopeBody.Split(['\n'], StringSplitOptions.RemoveEmptyEntries).Select(o => o.Trim()).Where(o => o.Length > 0);
-
- int rowNumber = 0;
-
- foreach (var lineText in lines)
- {
- var columns = lineText.Split("||");
-
- if (rowNumber == 0 && isFirstRowHeader)
- {
- html.Append($"");
- }
- else if (rowNumber == 1 && isFirstRowHeader || rowNumber == 0 && isFirstRowHeader == false)
- {
- html.Append($"");
- }
-
- html.Append($"");
- foreach (var columnText in columns)
- {
- if (rowNumber == 0 && isFirstRowHeader)
- {
- html.Append($"| {columnText} | ");
- }
- else
- {
- html.Append($"{columnText} | ");
- }
- }
-
- if (rowNumber == 0 && isFirstRowHeader)
- {
- html.Append($"");
- }
- html.Append($"
");
-
- rowNumber++;
- }
-
- html.Append($"");
- html.Append($"
");
-
- return new HandlerResult(html.ToString());
+ html.Append(" table-striped");
}
- //------------------------------------------------------------------------------------------------------------------------------
+ if (hasBorder)
+ {
+ html.Append(" table-bordered");
+ }
+
+ html.Append($"\">");
+
+ var lines = scopeBody.Split(['\n'], StringSplitOptions.RemoveEmptyEntries).Select(o => o.Trim())
+ .Where(o => o.Length > 0);
+
+ int rowNumber = 0;
+
+ foreach (var lineText in lines)
+ {
+ var columns = lineText.Split("||");
+
+ if (rowNumber == 0 && isFirstRowHeader)
+ {
+ html.Append($"");
+ }
+ else if (rowNumber == 1 && isFirstRowHeader || rowNumber == 0 && isFirstRowHeader == false)
+ {
+ html.Append($"");
+ }
+
+ html.Append($"");
+ foreach (var columnText in columns)
+ {
+ if (rowNumber == 0 && isFirstRowHeader)
+ {
+ html.Append($"| {columnText} | ");
+ }
+ else
+ {
+ html.Append($"{columnText} | ");
+ }
+ }
+
+ if (rowNumber == 0 && isFirstRowHeader)
+ {
+ html.Append($"");
+ }
+
+ html.Append($"
");
+
+ rowNumber++;
+ }
+
+ html.Append($"");
+ html.Append($"
");
+
+ return new HandlerResult(html.ToString());
+ }
case "bullets":
+ {
+ var html = new StringBuilder();
+
+ var type = function.Parameters.Get("type");
+
+ if (type == "unordered")
{
- var html = new StringBuilder();
+ var lines = scopeBody.Split(['\n'], StringSplitOptions.RemoveEmptyEntries).Select(o => o.Trim())
+ .Where(o => o.Length > 0);
- string type = function.Parameters.Get("type");
+ int currentLevel = 0;
- if (type == "unordered")
+ foreach (var line in lines)
{
- var lines = scopeBody.Split(['\n'], StringSplitOptions.RemoveEmptyEntries).Select(o => o.Trim()).Where(o => o.Length > 0);
-
- int currentLevel = 0;
-
- foreach (var line in lines)
+ var newIndent = 0;
+ for (; newIndent < line.Length && line[newIndent] == '>'; newIndent++)
{
- int newIndent = 0;
- for (; newIndent < line.Length && line[newIndent] == '>'; newIndent++)
- {
- //Count how many '>' are at the start of the line.
- }
- newIndent++;
-
- if (newIndent < currentLevel)
- {
- for (; currentLevel != newIndent; currentLevel--)
- {
- html.Append($"");
- }
- }
- else if (newIndent > currentLevel)
- {
- for (; currentLevel != newIndent; currentLevel++)
- {
- html.Append($"");
- }
- }
-
- html.Append($"- {line.Trim(['>'])}
");
+ //计算行开头有多少个“>”.
}
- for (; currentLevel > 0; currentLevel--)
+ newIndent++;
+
+ if (newIndent < currentLevel)
{
- html.Append($"
");
+ for (; currentLevel != newIndent; currentLevel--)
+ {
+ html.Append($"");
+ }
}
+ else if (newIndent > currentLevel)
+ {
+ for (; currentLevel != newIndent; currentLevel++)
+ {
+ html.Append($"");
+ }
+ }
+
+ html.Append($"- {line.Trim(['>'])}
");
}
- else if (type == "ordered")
+
+ for (; currentLevel > 0; currentLevel--)
{
- var lines = scopeBody.Split(['\n'], StringSplitOptions.RemoveEmptyEntries).Select(o => o.Trim()).Where(o => o.Length > 0);
-
- int currentLevel = 0;
-
- foreach (var line in lines)
- {
- int newIndent = 0;
- for (; newIndent < line.Length && line[newIndent] == '>'; newIndent++)
- {
- //Count how many '>' are at the start of the line.
- }
- newIndent++;
-
- if (newIndent < currentLevel)
- {
- for (; currentLevel != newIndent; currentLevel--)
- {
- html.Append($"");
- }
- }
- else if (newIndent > currentLevel)
- {
- for (; currentLevel != newIndent; currentLevel++)
- {
- html.Append($"");
- }
- }
-
- html.Append($"- {line.Trim(['>'])}
");
- }
-
- for (; currentLevel > 0; currentLevel--)
- {
- html.Append($"
");
- }
+ html.Append($"
");
+ }
+ }
+ else if (type == "ordered")
+ {
+ var lines = scopeBody.Split(['\n'], StringSplitOptions.RemoveEmptyEntries).Select(o => o.Trim())
+ .Where(o => o.Length > 0);
+
+ var currentLevel = 0;
+
+ foreach (var line in lines)
+ {
+ var newIndent = 0;
+ for (; newIndent < line.Length && line[newIndent] == '>'; newIndent++)
+ {
+ //计算行开头有多少个“>”.
+ }
+
+ newIndent++;
+
+ if (newIndent < currentLevel)
+ {
+ for (; currentLevel != newIndent; currentLevel--)
+ {
+ html.Append($"");
+ }
+ }
+ else if (newIndent > currentLevel)
+ {
+ for (; currentLevel != newIndent; currentLevel++)
+ {
+ html.Append($"");
+ }
+ }
+
+ html.Append($"- {line.Trim(['>'])}
");
+ }
+
+ for (; currentLevel > 0; currentLevel--)
+ {
+ html.Append($"
");
}
- return new HandlerResult(html.ToString());
}
- //------------------------------------------------------------------------------------------------------------------------------
+ return new HandlerResult(html.ToString());
+ }
case "definesnippet":
+ {
+ var html = new StringBuilder();
+
+ var name = function.Parameters.Get("name");
+
+ if (!state.Snippets.TryAdd(name, scopeBody))
{
- var html = new StringBuilder();
-
- string name = function.Parameters.Get("name");
-
- if (!state.Snippets.TryAdd(name, scopeBody))
- {
- state.Snippets[name] = scopeBody;
- }
-
- return new HandlerResult(html.ToString());
+ state.Snippets[name] = scopeBody;
}
- //------------------------------------------------------------------------------------------------------------------------------
+ return new HandlerResult(html.ToString());
+ }
case "alert":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- string titleText = function.Parameters.Get("titleText");
- string style = function.Parameters.Get("styleName").ToLower();
- style = style == "default" ? "" : $"alert-{style}";
+ var titleText = function.Parameters.Get("titleText");
+ var style = function.Parameters.Get("styleName").ToLower();
+ style = style == "default" ? "" : $"alert-{style}";
- if (!string.IsNullOrEmpty(titleText)) scopeBody = $"{titleText}
{scopeBody}";
- html.Append($"{scopeBody}
");
- return new HandlerResult(html.ToString());
- }
+ if (!string.IsNullOrEmpty(titleText)) scopeBody = $"{titleText}
{scopeBody}";
+ html.Append($"{scopeBody}
");
+ return new HandlerResult(html.ToString());
+ }
case "order":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- string direction = function.Parameters.Get("direction");
- var lines = scopeBody.Split("\n").Select(o => o.Trim()).ToList();
+ var direction = function.Parameters.Get("direction");
+ var lines = scopeBody.Split("\n").Select(o => o.Trim()).ToList();
- if (direction == "ascending")
- {
- html.Append(string.Join("\r\n", lines.OrderBy(o => o)));
- }
- else
- {
- html.Append(string.Join("\r\n", lines.OrderByDescending(o => o)));
- }
- return new HandlerResult(html.ToString());
- }
-
- //------------------------------------------------------------------------------------------------------------------------------
+ html.Append(direction == "ascending"
+ ? string.Join("\r\n", lines.OrderBy(o => o))
+ : string.Join("\r\n", lines.OrderByDescending(o => o)));
+ return new HandlerResult(html.ToString());
+ }
case "jumbotron":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- string titleText = function.Parameters.Get("titleText", "");
- html.Append($"");
- if (!string.IsNullOrEmpty(titleText)) html.Append($"
{titleText}
");
- html.Append($"
{scopeBody}
");
- html.Append($"
");
- return new HandlerResult(html.ToString());
- }
-
- //------------------------------------------------------------------------------------------------------------------------------
+ var titleText = function.Parameters.Get("titleText", "");
+ html.Append($"");
+ if (!string.IsNullOrEmpty(titleText)) html.Append($"
{titleText}
");
+ html.Append($"
{scopeBody}
");
+ html.Append($"
");
+ return new HandlerResult(html.ToString());
+ }
case "foreground":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- var style = BGFGStyle.GetForegroundStyle(function.Parameters.Get("styleName", "default")).Swap();
- html.Append($"{scopeBody}
");
- return new HandlerResult(html.ToString());
- }
-
- //------------------------------------------------------------------------------------------------------------------------------
+ var style = BGFGStyle.GetForegroundStyle(function.Parameters.Get("styleName", "default")).Swap();
+ html.Append($"{scopeBody}
");
+ return new HandlerResult(html.ToString());
+ }
case "background":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- var style = BGFGStyle.GetBackgroundStyle(function.Parameters.Get("styleName", "default"));
- html.Append($"{scopeBody}
");
- return new HandlerResult(html.ToString());
- }
-
- //------------------------------------------------------------------------------------------------------------------------------
+ var style = BGFGStyle.GetBackgroundStyle(function.Parameters.Get("styleName", "default"));
+ html.Append(
+ $"{scopeBody}
");
+ return new HandlerResult(html.ToString());
+ }
case "collapse":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- string linkText = function.Parameters.Get("linktext");
- string uid = "A" + Guid.NewGuid().ToString().Replace("-", "");
- html.Append($"{linkText}");
- html.Append($"");
- return new HandlerResult(html.ToString());
- }
-
- //------------------------------------------------------------------------------------------------------------------------------
+ var linkText = function.Parameters.Get("linktext");
+ var uid = "A" + Guid.NewGuid().ToString().Replace("-", "");
+ html.Append(
+ $"{linkText}");
+ html.Append($"");
+ return new HandlerResult(html.ToString());
+ }
case "callout":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- string titleText = function.Parameters.Get("titleText");
- string style = function.Parameters.Get("styleName").ToLower();
- style = style == "default" ? "" : style;
+ string titleText = function.Parameters.Get("titleText");
+ string style = function.Parameters.Get("styleName").ToLower();
+ style = style == "default" ? "" : style;
- html.Append($"");
- if (string.IsNullOrWhiteSpace(titleText) == false) html.Append($"
{titleText}
");
- html.Append($"{scopeBody}");
- html.Append($"");
- return new HandlerResult(html.ToString());
- }
-
- //------------------------------------------------------------------------------------------------------------------------------
+ html.Append($"");
+ if (string.IsNullOrWhiteSpace(titleText) == false) html.Append($"
{titleText}
");
+ html.Append($"{scopeBody}");
+ html.Append($"");
+ return new HandlerResult(html.ToString());
+ }
case "card":
- {
- var html = new StringBuilder();
+ {
+ var html = new StringBuilder();
- string titleText = function.Parameters.Get("titleText");
- var style = BGFGStyle.GetBackgroundStyle(function.Parameters.Get("styleName", "default"));
+ var titleText = function.Parameters.Get("titleText");
+ var style = BGFGStyle.GetBackgroundStyle(function.Parameters.Get("styleName", "default"));
- html.Append($"");
- if (string.IsNullOrEmpty(titleText) == false)
- {
- html.Append($"");
- }
- html.Append("
");
- html.Append($"
{scopeBody}
");
- html.Append("
");
- html.Append("
");
- return new HandlerResult(html.ToString());
-
- }
+ html.Append($"");
+ if (string.IsNullOrEmpty(titleText) == false)
+ html.Append($"");
+ html.Append("
");
+ html.Append($"
{scopeBody}
");
+ html.Append("
");
+ html.Append("
");
+ return new HandlerResult(html.ToString());
+ }
}
- return new HandlerResult() { Instructions = [Constants.HandlerResultInstruction.Skip] };
+ return new HandlerResult() { Instructions = [HandlerResultInstruction.Skip] };
}
}
-}
+}
\ No newline at end of file
diff --git a/ZelWiki.Engine.Implementation/StandardFunctionHandler.cs b/ZelWiki.Engine.Implementation/StandardFunctionHandler.cs
index 6c0d3dc..364edce 100644
--- a/ZelWiki.Engine.Implementation/StandardFunctionHandler.cs
+++ b/ZelWiki.Engine.Implementation/StandardFunctionHandler.cs
@@ -14,7 +14,7 @@ using Constants = ZelWiki.Engine.Library.Constants;
namespace ZelWiki.Engine.Implementation
{
///
- /// Handled standard function calls.
+ /// 处理函数调用.
///
public class StandardFunctionHandler : IStandardFunctionHandler
{
@@ -26,34 +26,46 @@ namespace ZelWiki.Engine.Implementation
{
if (_collection == null)
{
- _collection = new FunctionPrototypeCollection(FunctionPrototypeCollection.WikiFunctionType.Standard);
+ _collection =
+ new FunctionPrototypeCollection(FunctionPrototypeCollection.WikiFunctionType.Standard);
- #region Prototypes.
+ #region
_collection.Add("##Snippet: [name]");
_collection.Add("##Seq: {key}='Default'");
_collection.Add("##Set: [key] | [value]");
_collection.Add("##Get: [key]");
_collection.Add("##Color: [color] | [text]");
- _collection.Add("##Tag: [pageTags]"); //This is left here for backwards compatibility, Tag does not change the output so it should be a processing instruction.
- _collection.Add("##SearchList: [searchPhrase] | {styleName(List,Full)}='Full' | {pageSize}='5' | {pageSelector}='true' | {allowFuzzyMatching}='false' | {showNamespace}='false'");
- _collection.Add("##TagList: [pageTags] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
- _collection.Add("##NamespaceGlossary: [namespaces] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
- _collection.Add("##NamespaceList: [namespaces] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
- _collection.Add("##TagGlossary: [pageTags] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
- _collection.Add("##RecentlyModified: {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
- _collection.Add("##TextGlossary: [searchPhrase] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
+ _collection.Add("##Tag: [pageTags]");
+ _collection.Add(
+ "##SearchList: [searchPhrase] | {styleName(List,Full)}='Full' | {pageSize}='5' | {pageSelector}='true' | {allowFuzzyMatching}='false' | {showNamespace}='false'");
+ _collection.Add(
+ "##TagList: [pageTags] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
+ _collection.Add(
+ "##NamespaceGlossary: [namespaces] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
+ _collection.Add(
+ "##NamespaceList: [namespaces] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
+ _collection.Add(
+ "##TagGlossary: [pageTags] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
+ _collection.Add(
+ "##RecentlyModified: {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
+ _collection.Add(
+ "##TextGlossary: [searchPhrase] | {Top}='1000' | {styleName(List,Full)}='Full' | {showNamespace}='false'");
_collection.Add("##Image: [name] | {scale}='100' | {altText}=''");
_collection.Add("##File: [name] | {linkText} | {showSize}='false'");
- _collection.Add("##Related: {styleName(List,Flat,Full)}='Full' | {pageSize}='10' | {pageSelector}='true'");
- _collection.Add("##Similar: {similarity}='80' | {styleName(List,Flat,Full)}='Full' | {pageSize}='10' | {pageSelector}='true'");
+ _collection.Add(
+ "##Related: {styleName(List,Flat,Full)}='Full' | {pageSize}='10' | {pageSelector}='true'");
+ _collection.Add(
+ "##Similar: {similarity}='80' | {styleName(List,Flat,Full)}='Full' | {pageSize}='10' | {pageSelector}='true'");
_collection.Add("##EditLink: {linkText}='edit'");
_collection.Add("##Inject: [pageName]");
_collection.Add("##Include: [pageName]");
_collection.Add("##BR: {Count}='1'");
_collection.Add("##HR: {Height}='1'");
- _collection.Add("##Revisions:{styleName(Full,List)}='Full' | {pageSize}='5' | {pageSelector}='true' | {pageName}=''");
- _collection.Add("##Attachments:{styleName(Full,List)}='Full' | {pageSize}='5' | {pageSelector}='true' | {pageName}=''");
+ _collection.Add(
+ "##Revisions:{styleName(Full,List)}='Full' | {pageSize}='5' | {pageSelector}='true' | {pageName}=''");
+ _collection.Add(
+ "##Attachments:{styleName(Full,List)}='Full' | {pageSize}='5' | {pageSelector}='true' | {pageName}=''");
_collection.Add("##Title:");
_collection.Add("##Navigation:");
_collection.Add("##Name:");
@@ -62,10 +74,11 @@ namespace ZelWiki.Engine.Implementation
_collection.Add("##Created:");
_collection.Add("##LastModified:");
_collection.Add("##AppVersion:");
- _collection.Add("##ProfileGlossary: {Top}='1000' | {pageSize}='100' | {searchToken}=''");
- _collection.Add("##ProfileList: {Top}='1000' | {pageSize}='100' | {searchToken}=''");
+ _collection.Add(
+ "##ProfileGlossary: {Top}='1000' | {pageSize}='100' | {searchToken}=''");
+ _collection.Add(
+ "##ProfileList: {Top}='1000' | {pageSize}='100' | {searchToken}=''");
- //System functions (we don't advertize these, but they aren't unsafe):
_collection.Add("##SystemEmojiCategoryList:");
_collection.Add("##SystemEmojiList:");
@@ -100,1087 +113,1074 @@ namespace ZelWiki.Engine.Implementation
}
///
- /// Called to handle function calls when proper prototypes are matched.
+ /// 当匹配到合适的原型时,调用它来处理函数调用。
///
- /// Reference to the wiki state object
- /// The parsed function call and all its parameters and their values.
- /// This is not a scope function, this should always be null
+ ///
+ ///
+ ///
+ ///
+ ///
public HandlerResult Handle(IZelEngineState state, FunctionCall function, string? scopeBody = null)
{
switch (function.Name.ToLower())
{
- //------------------------------------------------------------------------------------------------------------------------------
- //Creates a glossary all user profiles.
case "profileglossary":
+ {
+ if (!GlobalConfiguration.EnablePublicProfiles)
{
- if (!ZelWiki.Models.GlobalConfiguration.EnablePublicProfiles)
+ return new HandlerResult("公共配置文件已禁用.");
+ }
+
+ var html = new StringBuilder();
+ var refTag = state.GetNextQueryToken();
+ var pageNumber = int.Parse(state.QueryString[refTag].ToString().DefaultWhenNullOrEmpty("1"));
+ var pageSize = function.Parameters.Get("pageSize");
+ var searchToken = function.Parameters.Get("searchToken");
+ var topCount = function.Parameters.Get("top");
+ var profiles = UsersRepository.GetAllPublicProfilesPaged(pageNumber, pageSize, searchToken);
+
+ var glossaryName = "glossary_" + new Random().Next(0, 1000000).ToString();
+ var alphabet = profiles.Select(p => p.AccountName.Substring(0, 1).ToUpper()).Distinct();
+
+ if (profiles.Any())
+ {
+ html.Append("");
+ foreach (var alpha in alphabet)
{
- return new HandlerResult("Public profiles are disabled.");
+ html.Append("" + alpha + " ");
}
- var html = new StringBuilder();
- string refTag = state.GetNextQueryToken();
- int pageNumber = int.Parse(state.QueryString[refTag].ToString().DefaultWhenNullOrEmpty("1"));
- var pageSize = function.Parameters.Get("pageSize");
- var searchToken = function.Parameters.Get("searchToken");
- var topCount = function.Parameters.Get("top");
- var profiles = UsersRepository.GetAllPublicProfilesPaged(pageNumber, pageSize, searchToken);
+ html.Append("");
- string glossaryName = "glossary_" + new Random().Next(0, 1000000).ToString();
- var alphabet = profiles.Select(p => p.AccountName.Substring(0, 1).ToUpper()).Distinct();
-
- if (profiles.Count() > 0)
+ html.Append("");
+ foreach (var alpha in alphabet)
{
- html.Append("");
- foreach (var alpha in alphabet)
- {
- html.Append("" + alpha + " ");
- }
- html.Append("");
+ html.Append("- " + alpha + "
");
html.Append("");
- foreach (var alpha in alphabet)
+ foreach (var profile in profiles.Where(p =>
+ p.AccountName.ToLower().StartsWith(alpha.ToLower())))
{
- html.Append("- " + alpha + "
");
-
- html.Append("");
- foreach (var profile in profiles.Where(p => p.AccountName.ToLower().StartsWith(alpha.ToLower())))
- {
- html.Append($"- {profile.AccountName}");
- html.Append("
");
- }
- html.Append("
");
+ html.Append(
+ $"- {profile.AccountName}");
+ html.Append("
");
}
html.Append("
");
}
- return new HandlerResult(html.ToString());
+
+ html.Append("
");
}
- //------------------------------------------------------------------------------------------------------------------------------
- //Creates a list of all user profiles.
+ return new HandlerResult(html.ToString());
+ }
+
case "profilelist":
+ {
+ if (!GlobalConfiguration.EnablePublicProfiles)
{
- if (!ZelWiki.Models.GlobalConfiguration.EnablePublicProfiles)
- {
- return new HandlerResult("Public profiles are disabled.");
- }
-
- var html = new StringBuilder();
- string refTag = state.GetNextQueryToken();
- int pageNumber = int.Parse(state.QueryString[refTag].ToString().DefaultWhenNullOrEmpty("1"));
- var pageSize = function.Parameters.Get("pageSize");
- var searchToken = function.Parameters.Get("searchToken");
- var profiles = UsersRepository.GetAllPublicProfilesPaged(pageNumber, pageSize, searchToken);
-
- if (profiles.Count() > 0)
- {
- html.Append("");
-
- foreach (var profile in profiles)
- {
- html.Append($"- {profile.AccountName}");
- html.Append("
");
- }
-
- html.Append("
");
- }
-
- if (profiles.Count > 0 && profiles.First().PaginationPageCount > 1)
- {
- html.Append(PageSelectorGenerator.Generate(refTag, state.QueryString, profiles.First().PaginationPageCount));
- }
-
- return new HandlerResult(html.ToString());
+ return new HandlerResult("公共配置文件已禁用.");
}
- //------------------------------------------------------------------------------------------------------------------------------
+ var html = new StringBuilder();
+ var refTag = state.GetNextQueryToken();
+ var pageNumber = int.Parse(state.QueryString[refTag].ToString().DefaultWhenNullOrEmpty("1"));
+ var pageSize = function.Parameters.Get("pageSize");
+ var searchToken = function.Parameters.Get("searchToken");
+ var profiles = UsersRepository.GetAllPublicProfilesPaged(pageNumber, pageSize, searchToken);
+
+ if (profiles.Any())
+ {
+ html.Append("");
+
+ foreach (var profile in profiles)
+ {
+ html.Append(
+ $"- {profile.AccountName}");
+ html.Append("
");
+ }
+
+ html.Append("
");
+ }
+
+ if (profiles.Count > 0 && profiles.First().PaginationPageCount > 1)
+ {
+ html.Append(PageSelectorGenerator.Generate(refTag, state.QueryString,
+ profiles.First().PaginationPageCount));
+ }
+
+ return new HandlerResult(html.ToString());
+ }
case "attachments":
+ {
+ var refTag = state.GetNextQueryToken();
+
+ var pageNumber = int.Parse(state.QueryString[refTag].ToString().DefaultWhenNullOrEmpty("1"));
+
+ var navigation =
+ NamespaceNavigation.CleanAndValidate(function.Parameters.Get("pageName",
+ state.Page.Navigation));
+ var styleName = function.Parameters.Get("styleName").ToLower();
+ var pageSize = function.Parameters.Get("pageSize");
+ var pageSelector = function.Parameters.Get("pageSelector");
+ var attachments =
+ PageFileRepository.GetPageFilesInfoByPageNavigationAndPageRevisionPaged(navigation, pageNumber,
+ pageSize, state.Revision);
+ var html = new StringBuilder();
+
+ if (attachments.Count > 0)
{
- string refTag = state.GetNextQueryToken();
-
- int pageNumber = int.Parse(state.QueryString[refTag].ToString().DefaultWhenNullOrEmpty("1"));
-
- var navigation = NamespaceNavigation.CleanAndValidate(function.Parameters.Get("pageName", state.Page.Navigation));
- string styleName = function.Parameters.Get("styleName").ToLower();
- var pageSize = function.Parameters.Get("pageSize");
- var pageSelector = function.Parameters.Get("pageSelector");
- var attachments = PageFileRepository.GetPageFilesInfoByPageNavigationAndPageRevisionPaged(navigation, pageNumber, pageSize, state.Revision);
- var html = new StringBuilder();
-
- if (attachments.Count() > 0)
+ html.Append("