-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit for BlogEngine.NET 3.1
- Loading branch information
0 parents
commit 474102e
Showing
2,415 changed files
with
605,810 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Ignore file for Visual Studio | ||
|
||
# use glob syntax | ||
syntax: glob | ||
|
||
# Ignore Visual Studio files | ||
*.obj | ||
*.exe | ||
*.pdb | ||
*.user | ||
*.aps | ||
*.pch | ||
*.vspscc | ||
*_i.c | ||
*_p.c | ||
*.ncb | ||
*.suo | ||
*.tlb | ||
*.tlh | ||
*.bak | ||
*.cache | ||
*.ilk | ||
*.log | ||
*.lib | ||
*.sbr | ||
*.scc | ||
*.pubxml | ||
*/extensions/** | ||
*/Scripts/Combined/** | ||
*/Styles/Combined/** | ||
[Bb]in | ||
[Db]ebug*/ | ||
obj/ | ||
Thumbs.db | ||
[Rr]elease*/ | ||
_ReSharper*/ | ||
[Tt]est[Rr]esult* | ||
[Bb]uild[Ll]og.* | ||
*.[Pp]ublish.xml | ||
glob:BlogEngine/BlogEngine.NET/App_Data/logger.txt | ||
*/{B02E9840-1261-47AB-AE40-D333E73BB2C0}/** | ||
*/PrecompiledWeb/** | ||
glob:BlogEngine/BlogEngine.NET/{B02E9840-1261-47AB-AE40-D333E73BB2C0}/CodeAnalysisLog.xml | ||
glob:BlogEngine/BlogEngine.NET/{B02E9840-1261-47AB-AE40-D333E73BB2C0}/WebProject.lastcodeanalysissucceeded | ||
|
||
BlogEngine/BlogEngine.NET/App_Data/posts/a092ddd5-91ee-4bfa-9310-476558668e5a.xml | ||
BlogEngine/BlogEngine.NET/App_Data/posts/c1a8e5a7-812c-4468-b664-9de20d93dcaa.xml | ||
BlogEngine/BlogEngine.NET/App_Data/quicknotes.xml | ||
BlogEngine/BlogEngine.NET/website.publishproj |
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,73 @@ | ||
namespace BlogEngine.Core.API.BlogML | ||
{ | ||
/// <summary> | ||
/// The base reader. | ||
/// </summary> | ||
public class BaseReader | ||
{ | ||
#region Constructors and Destructors | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref = "BaseReader" /> class. | ||
/// </summary> | ||
public BaseReader() | ||
{ | ||
this.Author = string.Empty; | ||
this.RemoveDuplicates = false; | ||
this.ApprovedCommentsOnly = false; | ||
this.Message = string.Empty; | ||
} | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether ApprovedCommentsOnly. | ||
/// </summary> | ||
public bool ApprovedCommentsOnly { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets Author. | ||
/// </summary> | ||
public string Author { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets Message. | ||
/// </summary> | ||
public string Message { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether RemoveDuplicates. | ||
/// </summary> | ||
public bool RemoveDuplicates { get; set; } | ||
|
||
#endregion | ||
|
||
#region Public Methods | ||
|
||
/// <summary> | ||
/// Imports this instance. | ||
/// </summary> | ||
/// <returns> | ||
/// Always returns false. | ||
/// </returns> | ||
public virtual bool Import() | ||
{ | ||
return false; | ||
} | ||
|
||
/// <summary> | ||
/// Validates this instance. | ||
/// </summary> | ||
/// <returns> | ||
/// Always returns false. | ||
/// </returns> | ||
public virtual bool Validate() | ||
{ | ||
return false; | ||
} | ||
|
||
#endregion | ||
} | ||
} |
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,112 @@ | ||
namespace BlogEngine.Core.API.BlogML | ||
{ | ||
using System; | ||
using System.Globalization; | ||
using System.Text.RegularExpressions; | ||
|
||
/// <summary> | ||
/// Blog Importer | ||
/// </summary> | ||
public class BlogImporter | ||
{ | ||
#region Public Methods | ||
|
||
/// <summary> | ||
/// Add new blog post to system | ||
/// </summary> | ||
/// <returns> | ||
/// string containing unique post identifier | ||
/// </returns> | ||
public string AddPost(BlogMlExtendedPost extPost) | ||
{ | ||
if (!Security.IsAdministrator) | ||
{ | ||
throw new InvalidOperationException("BlogImporter.AddPost: Wrong credentials"); | ||
} | ||
|
||
using (var p = new Post()) | ||
{ | ||
p.Title = extPost.BlogPost.Title; | ||
p.DateCreated = extPost.BlogPost.DateCreated; | ||
p.DateModified = extPost.BlogPost.DateModified; | ||
p.Content = extPost.BlogPost.Content.UncodedText; | ||
p.Description = extPost.BlogPost.Excerpt.UncodedText; | ||
p.IsPublished = extPost.BlogPost.Approved; | ||
|
||
if (!string.IsNullOrEmpty(extPost.PostUrl)) | ||
{ | ||
// looking for a Slug with patterns such as: | ||
// /some-slug.aspx | ||
// /some-slug.html | ||
// /some-slug | ||
// | ||
Match slugMatch = Regex.Match(extPost.PostUrl, @"/([^/\.]+)(?:$|\.[\w]{1,10}$)", RegexOptions.IgnoreCase); | ||
if (slugMatch.Success) | ||
p.Slug = slugMatch.Groups[1].Value.Trim(); | ||
} | ||
|
||
if(extPost.BlogPost.Authors != null && extPost.BlogPost.Authors.Count > 0) | ||
p.Author = extPost.BlogPost.Authors[0].Ref; | ||
|
||
if (extPost.Categories != null && extPost.Categories.Count > 0) | ||
p.Categories.AddRange(extPost.Categories); | ||
|
||
if(extPost.Tags != null && extPost.Tags.Count > 0) | ||
p.Tags.AddRange(extPost.Tags); | ||
|
||
// skip if post with this url already exists | ||
var s = PostUrl(p.Slug, p.DateCreated); | ||
var list = Post.Posts.FindAll(ps => ps.RelativeLink == s); | ||
if (list.Count > 0) | ||
{ | ||
return string.Empty; | ||
} | ||
|
||
if(extPost.Comments != null && extPost.Comments.Count > 0) | ||
{ | ||
foreach (var comment in extPost.Comments) | ||
{ | ||
p.ImportComment(comment); | ||
} | ||
} | ||
|
||
p.Import(); | ||
return p.Id.ToString(); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Force Reload of all posts | ||
/// </summary> | ||
public void ForceReload() | ||
{ | ||
if (!Security.IsAdministrator) | ||
{ | ||
throw new InvalidOperationException("BlogImporter.ForeceReload: Wrong credentials"); | ||
} | ||
|
||
Post.Reload(); | ||
} | ||
|
||
/// <summary> | ||
/// post url | ||
/// </summary> | ||
/// <param name="slug">post slug</param> | ||
/// <param name="dateCreated">date created</param> | ||
/// <returns></returns> | ||
static string PostUrl(string slug, DateTime dateCreated) | ||
{ | ||
var theslug = Utils.RemoveIllegalCharacters(slug) + BlogConfig.FileExtension; | ||
|
||
return BlogSettings.Instance.TimeStampPostLinks | ||
? string.Format( | ||
"{0}post/{1}{2}", | ||
Utils.RelativeWebRoot, | ||
dateCreated.ToString("yyyy/MM/dd/", CultureInfo.InvariantCulture), | ||
theslug) | ||
: string.Format("{0}post/{1}", Utils.RelativeWebRoot, theslug); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
BlogEngine/BlogEngine.Core/API/BlogML/BlogMLExtendedPost.cs
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,36 @@ | ||
namespace BlogEngine.Core.API.BlogML | ||
{ | ||
using global::BlogML.Xml; | ||
using System.Collections.Generic; | ||
|
||
/// <summary> | ||
/// Extended BlogML post | ||
/// </summary> | ||
public class BlogMlExtendedPost | ||
{ | ||
/// <summary> | ||
/// Gets or sets blog post | ||
/// </summary> | ||
public BlogMLPost BlogPost { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets post URL | ||
/// </summary> | ||
public string PostUrl { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets post tags | ||
/// </summary> | ||
public StateList<string> Tags { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets post categories | ||
/// </summary> | ||
public StateList<Category> Categories { get; set; } | ||
|
||
/// <summary> | ||
/// Post comments | ||
/// </summary> | ||
public List<Comment> Comments { get; set; } | ||
} | ||
} |
Oops, something went wrong.