Added GetMainUrl "smart" method.

This commit is contained in:
Dario Solera 2010-12-26 16:02:53 +00:00
parent 12c9da210b
commit 8c35eed690

View file

@ -605,6 +605,24 @@ namespace ScrewTurn.Wiki {
}
}
/// <summary>
/// Gets the main URL of the wiki, defaulting to the current request URL if none is configured manually.
/// </summary>
/// <returns>The URL of the wiki.</returns>
public static Uri GetMainUrl() {
Uri mainUrl = new Uri(MainUrl);
if(mainUrl.Host == "www.server.com") {
try {
// STW never uses internal URLs with slashes, so trimming to the last slash should work
// Example: http://server/wiki/namespace.page.ashx
string temp = HttpContext.Current.Request.Url.ToString();
mainUrl = new Uri(temp.Substring(0, temp.LastIndexOf("/") + 1));
}
catch { }
}
return mainUrl;
}
/// <summary>
/// Gets the correct path to use with Cookies.
/// </summary>
@ -878,14 +896,11 @@ namespace ScrewTurn.Wiki {
/// <summary>
/// Gets or sets the IP/Host filter for page editing.
/// </summary>
public static string IpHostFilter
{
public static string IpHostFilter {
get {
return Provider.GetSetting("IpHostFilter");
return GetString(Provider.GetSetting("IpHostFilter"), "");
}
set
{
set {
Provider.SetSetting("IpHostFilter", value);
}
}