C# Class Subtext.Framework.Format.UrlFormats

Default Implemenation of UrlFormats
Exibir arquivo Open project: ayende/Subtext Class Usage Examples

Protected Properties

Property Type Description
fullyQualifiedUrl string

Public Methods

Method Description
AdminUrl ( string Page ) : string
AggBugkUrl ( int EntryID ) : string
ArticleCategoryUrl ( string categoryName, int categoryID ) : string
ArticleUrl ( Entry entry ) : string
CommentApiUrl ( int entryId ) : string
CommentRssUrl ( int entryId ) : string
DateFromUrl ( string url ) : System.DateTime

Returns a DateTime instance parsed from the url.

DayUrl ( System.DateTime dt ) : string
EntryFullyQualifiedUrl ( System.DateTime entryDate, string entryID ) : string
EntryFullyQualifiedUrl ( System.DateTime entryDate, string entryName, int entryId ) : string
EntryFullyQualifiedUrl ( Entry entry ) : string
EntryUrl ( Entry entry ) : string

Returns a relative URL to the entry.

FeedbackFullyQualifiedUrl ( int parentId, string parentEntryName, System.DateTime parentCreateDate, FeedbackItem feedback ) : Uri

Returns the fully URL to the specified feedback item.

FeedbackUrl ( int parentId, string parentEntryName, System.DateTime parentCreateDate, FeedbackItem feedback ) : string

Returns the URL to the specified feedback item.

GalleryUrl ( string category, int GalleryID ) : string
GetBlogSubfolderFromRequest ( string rawUrl, string applicationPath ) : string

Parses out the subfolder of the blog from the requested URL. It simply searches for the first "folder" after the host and Request.ApplicationPath.

For example, if a blog is hosted at the virtual directory http://localhost/Subtext.Web/ and request is made for http://localhost/Subtext.Web/, the subfolder name is "" (empty string). Howver, a request for http://localhost/Subtext.Web/MyBlog/ would return "MyBlog" as the subfolder.

Likewise, if a blog is hosted at http://localhost/, a request for http://localhost/MyBlog/ would return "MyBlog" as the subfolder.

GetEditLink ( Entry entry ) : string

Builds the HyperLink.NavigateUrl for an EditPost Link by determining the current Subfolder and adding it to the URL if necessary.

GetFeedbackEditLink ( FeedbackItem feedback ) : string
GetHostFromExternalUrl ( string url ) : string

Parses out the host from an external URL.

GetImageFullUrl ( string imageUrl ) : string

Get the fully qualified url for an image for a given url to the image. The given url could be fully qualified, or some type of local url.

GetPostIDFromUrl ( string uri ) : int

Parses out the post ID from URL.

GetRequestedFileName ( string uri ) : string

Gets the name of the requested file.

GetUriReferrerSafe ( HttpRequest request ) : Uri

From Jason Block @ http://www.angrycoder.com/article.aspx?cid=5&y=2003&m=4&d=15 Basically, it's [Request.UrlReferrer] doing a lazy initialization of its internal _referrer field, which is a Uri-type class. That is, it's not created until it's needed. The point is that there are a couple of spots where the UriFormatException could leak through. One is in the call to GetKnownRequestHeader(). _wr is a field of type HttpWorkerRequest. 36 is the value of the HeaderReferer constant - since that's being blocked in this case, it may cause that exception to occur. However, HttpWorkerRequest is an abstract class, and it took a trip to the debugger to find out that _wr is set to a System.Web.Hosting.ISAPIWorkerRequestOutOfProc object. This descends from System.Web.Hosting.ISAPIWorkerRequest, and its implementation of GetKnownRequestHeader() didn't seem to be the source of the problem.

ImageUrl ( string category, int ImageID ) : string
IsInDirectory ( String rootFolderName ) : bool

Determines whether the current request is in the specified directory.

IsInSpecialDirectory ( string folderName ) : bool

Determines whether the current request is a request within a special directory.

MonthUrl ( System.DateTime dt ) : string
PostCategoryUrl ( string categoryName, int categoryID ) : string
ResolveLinks ( string body ) : string
ShortenUrl ( string url, int max ) : string
StripHostFromUrl ( string url ) : string

Return the url with the http://host stripped off the front. The given url may or maynot have the http://host on it.

StripSurroundingSlashes ( string target ) : string

Strips the surrounding slashes from the specified string.

TrackBackUrl ( int entryId ) : string
UrlFormats ( Uri fullyQualifiedUrl ) : System
YearUrl ( System.DateTime dt ) : string

Protected Methods

Method Description
GetFullyQualifiedUrl ( string formatString ) : string

Returns a fully qualified Url using the specified format string.

GetUrl ( string formatString ) : string

Returns a fully qualified Url using the specified format string.

Private Methods

Method Description
EntryUrl ( int entryId, string entryName, System.DateTime entryDate ) : string

Method Details

AdminUrl() public method

public AdminUrl ( string Page ) : string
Page string
return string

AggBugkUrl() public method

public AggBugkUrl ( int EntryID ) : string
EntryID int
return string

ArticleCategoryUrl() public method

public ArticleCategoryUrl ( string categoryName, int categoryID ) : string
categoryName string
categoryID int
return string

ArticleUrl() public method

public ArticleUrl ( Entry entry ) : string
entry Subtext.Framework.Components.Entry
return string

CommentApiUrl() public method

public CommentApiUrl ( int entryId ) : string
entryId int
return string

CommentRssUrl() public method

public CommentRssUrl ( int entryId ) : string
entryId int
return string

DateFromUrl() public static method

Returns a DateTime instance parsed from the url.
public static DateFromUrl ( string url ) : System.DateTime
url string URL.
return System.DateTime

DayUrl() public method

public DayUrl ( System.DateTime dt ) : string
dt System.DateTime
return string

EntryFullyQualifiedUrl() public method

public EntryFullyQualifiedUrl ( System.DateTime entryDate, string entryID ) : string
entryDate System.DateTime
entryID string
return string

EntryFullyQualifiedUrl() public method

public EntryFullyQualifiedUrl ( System.DateTime entryDate, string entryName, int entryId ) : string
entryDate System.DateTime
entryName string
entryId int
return string

EntryFullyQualifiedUrl() public method

public EntryFullyQualifiedUrl ( Entry entry ) : string
entry Subtext.Framework.Components.Entry
return string

EntryUrl() public method

Returns a relative URL to the entry.
public EntryUrl ( Entry entry ) : string
entry Subtext.Framework.Components.Entry The entry.
return string

FeedbackFullyQualifiedUrl() public method

Returns the fully URL to the specified feedback item.
public FeedbackFullyQualifiedUrl ( int parentId, string parentEntryName, System.DateTime parentCreateDate, FeedbackItem feedback ) : Uri
parentId int The id of the parent entry.
parentEntryName string If exists.
parentCreateDate System.DateTime
feedback Subtext.Framework.Components.FeedbackItem The feedback.
return System.Uri

FeedbackUrl() public method

Returns the URL to the specified feedback item.
public FeedbackUrl ( int parentId, string parentEntryName, System.DateTime parentCreateDate, FeedbackItem feedback ) : string
parentId int The id of the parent entry.
parentEntryName string If exists.
parentCreateDate System.DateTime
feedback Subtext.Framework.Components.FeedbackItem The feedback.
return string

GalleryUrl() public method

public GalleryUrl ( string category, int GalleryID ) : string
category string
GalleryID int
return string

GetBlogSubfolderFromRequest() public static method

Parses out the subfolder of the blog from the requested URL. It simply searches for the first "folder" after the host and Request.ApplicationPath.

For example, if a blog is hosted at the virtual directory http://localhost/Subtext.Web/ and request is made for http://localhost/Subtext.Web/, the subfolder name is "" (empty string). Howver, a request for http://localhost/Subtext.Web/MyBlog/ would return "MyBlog" as the subfolder.

Likewise, if a blog is hosted at http://localhost/, a request for http://localhost/MyBlog/ would return "MyBlog" as the subfolder.

public static GetBlogSubfolderFromRequest ( string rawUrl, string applicationPath ) : string
rawUrl string The raw url.
applicationPath string The virtual application name as found in the Request.ApplicationName property.
return string

GetEditLink() public static method

Builds the HyperLink.NavigateUrl for an EditPost Link by determining the current Subfolder and adding it to the URL if necessary.
public static GetEditLink ( Entry entry ) : string
entry Subtext.Framework.Components.Entry The entry to be edited
return string

GetFeedbackEditLink() public static method

public static GetFeedbackEditLink ( FeedbackItem feedback ) : string
feedback Subtext.Framework.Components.FeedbackItem
return string

GetFullyQualifiedUrl() protected method

Returns a fully qualified Url using the specified format string.
protected GetFullyQualifiedUrl ( string formatString ) : string
formatString string The pattern.
return string

GetHostFromExternalUrl() public static method

Parses out the host from an external URL.
public static GetHostFromExternalUrl ( string url ) : string
url string The URL.
return string

GetImageFullUrl() public static method

Get the fully qualified url for an image for a given url to the image. The given url could be fully qualified, or some type of local url.
public static GetImageFullUrl ( string imageUrl ) : string
imageUrl string url to an image
return string

GetPostIDFromUrl() public static method

Parses out the post ID from URL.
public static GetPostIDFromUrl ( string uri ) : int
uri string The URI.
return int

GetRequestedFileName() public static method

Gets the name of the requested file.
public static GetRequestedFileName ( string uri ) : string
uri string The URI.
return string

GetUriReferrerSafe() public static method

From Jason Block @ http://www.angrycoder.com/article.aspx?cid=5&y=2003&m=4&d=15 Basically, it's [Request.UrlReferrer] doing a lazy initialization of its internal _referrer field, which is a Uri-type class. That is, it's not created until it's needed. The point is that there are a couple of spots where the UriFormatException could leak through. One is in the call to GetKnownRequestHeader(). _wr is a field of type HttpWorkerRequest. 36 is the value of the HeaderReferer constant - since that's being blocked in this case, it may cause that exception to occur. However, HttpWorkerRequest is an abstract class, and it took a trip to the debugger to find out that _wr is set to a System.Web.Hosting.ISAPIWorkerRequestOutOfProc object. This descends from System.Web.Hosting.ISAPIWorkerRequest, and its implementation of GetKnownRequestHeader() didn't seem to be the source of the problem.
public static GetUriReferrerSafe ( HttpRequest request ) : Uri
request System.Web.HttpRequest
return System.Uri

GetUrl() protected method

Returns a fully qualified Url using the specified format string.
protected GetUrl ( string formatString ) : string
formatString string The pattern.
return string

ImageUrl() public method

public ImageUrl ( string category, int ImageID ) : string
category string
ImageID int
return string

IsInDirectory() public static method

Determines whether the current request is in the specified directory.
public static IsInDirectory ( String rootFolderName ) : bool
rootFolderName String Name of the root folder.
return bool

IsInSpecialDirectory() public static method

Determines whether the current request is a request within a special directory.
public static IsInSpecialDirectory ( string folderName ) : bool
folderName string Name of the folder.
return bool

MonthUrl() public method

public MonthUrl ( System.DateTime dt ) : string
dt System.DateTime
return string

PostCategoryUrl() public method

public PostCategoryUrl ( string categoryName, int categoryID ) : string
categoryName string
categoryID int
return string

ResolveLinks() public static method

public static ResolveLinks ( string body ) : string
body string
return string

ShortenUrl() public static method

public static ShortenUrl ( string url, int max ) : string
url string
max int
return string

StripHostFromUrl() public static method

Return the url with the http://host stripped off the front. The given url may or maynot have the http://host on it.
public static StripHostFromUrl ( string url ) : string
url string
return string

StripSurroundingSlashes() public static method

Strips the surrounding slashes from the specified string.
public static StripSurroundingSlashes ( string target ) : string
target string The target.
return string

TrackBackUrl() public method

public TrackBackUrl ( int entryId ) : string
entryId int
return string

UrlFormats() public method

public UrlFormats ( Uri fullyQualifiedUrl ) : System
fullyQualifiedUrl System.Uri
return System

YearUrl() public method

public YearUrl ( System.DateTime dt ) : string
dt System.DateTime
return string

Property Details

fullyQualifiedUrl protected_oe property

protected string fullyQualifiedUrl
return string