-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Makes LinkGenerator an instance class and exposes it via an interface…
… through IExecutionState
- Loading branch information
1 parent
0c192e4
commit e1ef957
Showing
17 changed files
with
299 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Statiq.Common | ||
{ | ||
/// <summary> | ||
/// Helps generate normalized links. | ||
/// </summary> | ||
public interface ILinkGenerator | ||
{ | ||
/// <summary> | ||
/// Generates a normalized link given a path and other conditions. | ||
/// </summary> | ||
/// <param name="path">The path to get a link for.</param> | ||
/// <param name="host">The host for the link (or <c>null</c> to omit the host).</param> | ||
/// <param name="root">The root path for the link (or <c>null</c> for no root path).</param> | ||
/// <param name="scheme">The scheme for the link (or <c>null</c> for "http").</param> | ||
/// <param name="hidePages">An array of file names to hide (or <c>null</c> to not hide any files).</param> | ||
/// <param name="hideExtensions">An array of file extensions to hide (or <c>null</c> to not hide extensions or an empty array to hide all file extensions).</param> | ||
/// <param name="lowercase">Indicates that the link should be rendered in all lowercase.</param> | ||
/// <param name="makeAbsolute"> | ||
/// If <paramref name="path"/> is relative, setting this to <c>true</c> (the default value) will assume the path relative from the root of the site | ||
/// and make it absolute by prepending a slash and <paramref name="root"/> to the path. Otherwise, <c>false</c> will leave relative paths as relative | ||
/// and won't prepend a slash (but <paramref name="host"/>, <paramref name="scheme"/>, and <paramref name="root"/> will have no effect). | ||
/// If <paramref name="path"/> is absolute, this value has no effect and <paramref name="host"/>, <paramref name="scheme"/>, and <paramref name="root"/> | ||
/// will be applied as appropriate. | ||
/// </param> | ||
/// <returns>A generated link.</returns> | ||
string GetLink( | ||
NormalizedPath path, | ||
string host, | ||
in NormalizedPath root, | ||
string scheme, | ||
string[] hidePages, | ||
string[] hideExtensions, | ||
bool lowercase, | ||
bool makeAbsolute = true); | ||
|
||
/// <summary> | ||
/// Checks if a string contains an absolute URI with a "http" or "https" scheme and returns it if it does. | ||
/// </summary> | ||
/// <param name="str">The string to check.</param> | ||
/// <param name="absoluteUri">The resulting absolute URI.</param> | ||
/// <returns><c>true</c> if the string contains an absolute URI, <c>false</c> otherwise.</returns> | ||
bool TryGetAbsoluteHttpUri(string str, out string absoluteUri); | ||
|
||
/// <summary> | ||
/// Adds a query and/or fragment to a URL or path. | ||
/// </summary> | ||
/// <param name="path">The path or URL.</param> | ||
/// <param name="queryAndFragment"> | ||
/// The query and/or fragment to add. If a value is provided for this parameter | ||
/// and it does not start with "?" or "#" then it will be assumed a query and a "?" will be prefixed. | ||
/// </param> | ||
/// <returns>The path or URL with an appended query and/or fragment.</returns> | ||
string AddQueryAndFragment(string path, string queryAndFragment); | ||
|
||
/// <summary> | ||
/// Adds a query and/or fragment to a path. | ||
/// </summary> | ||
/// <param name="path">The path.</param> | ||
/// <param name="queryAndFragment"> | ||
/// The query and/or fragment to add. If a value is provided for this parameter | ||
/// and it does not start with "?" or "#" then it will be assumed a query and a "?" will be prefixed. | ||
/// </param> | ||
/// <returns>The path with an appended query and/or fragment.</returns> | ||
NormalizedPath AddQueryAndFragment(NormalizedPath path, string queryAndFragment); | ||
} | ||
} |
Oops, something went wrong.