forked from BlogEngine/BlogEngine.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial check in
- Loading branch information
0 parents
commit 4604072
Showing
2,359 changed files
with
418,623 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,183 @@ | ||
## Ignore Visual Studio temporary files, build results, and | ||
## files generated by popular Visual Studio add-ons. | ||
|
||
# User-specific files | ||
*.suo | ||
*.user | ||
*.sln.docstates | ||
|
||
# Build results | ||
[Dd]ebug/ | ||
[Dd]ebugPublic/ | ||
[Rr]elease/ | ||
[Rr]eleases/ | ||
x64/ | ||
x86/ | ||
build/ | ||
bld/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
|
||
# Roslyn cache directories | ||
*.ide/ | ||
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
#NUNIT | ||
*.VisualState.xml | ||
TestResult.xml | ||
|
||
# Build Results of an ATL Project | ||
[Dd]ebugPS/ | ||
[Rr]eleasePS/ | ||
dlldata.c | ||
|
||
*_i.c | ||
*_p.c | ||
*_i.h | ||
*.ilk | ||
*.meta | ||
*.obj | ||
*.pch | ||
*.pdb | ||
*.pgc | ||
*.pgd | ||
*.rsp | ||
*.sbr | ||
*.tlb | ||
*.tli | ||
*.tlh | ||
*.tmp | ||
*.tmp_proj | ||
*.log | ||
*.vspscc | ||
*.vssscc | ||
.builds | ||
*.pidb | ||
*.svclog | ||
*.scc | ||
|
||
# Chutzpah Test files | ||
_Chutzpah* | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
*.aps | ||
*.ncb | ||
*.opensdf | ||
*.sdf | ||
*.cachefile | ||
|
||
# Visual Studio profiler | ||
*.psess | ||
*.vsp | ||
*.vspx | ||
|
||
# TFS 2012 Local Workspace | ||
$tf/ | ||
|
||
# Guidance Automation Toolkit | ||
*.gpState | ||
|
||
# ReSharper is a .NET coding add-in | ||
_ReSharper*/ | ||
*.[Rr]e[Ss]harper | ||
*.DotSettings.user | ||
|
||
# JustCode is a .NET coding addin-in | ||
.JustCode | ||
|
||
# TeamCity is a build add-in | ||
_TeamCity* | ||
|
||
# DotCover is a Code Coverage Tool | ||
*.dotCover | ||
|
||
# NCrunch | ||
_NCrunch_* | ||
.*crunch*.local.xml | ||
|
||
# MightyMoose | ||
*.mm.* | ||
AutoTest.Net/ | ||
|
||
# Web workbench (sass) | ||
.sass-cache/ | ||
|
||
# Installshield output folder | ||
[Ee]xpress/ | ||
|
||
# DocProject is a documentation generator add-in | ||
DocProject/buildhelp/ | ||
DocProject/Help/*.HxT | ||
DocProject/Help/*.HxC | ||
DocProject/Help/*.hhc | ||
DocProject/Help/*.hhk | ||
DocProject/Help/*.hhp | ||
DocProject/Help/Html2 | ||
DocProject/Help/html | ||
|
||
# Click-Once directory | ||
publish/ | ||
|
||
# Publish Web Output | ||
*.[Pp]ublish.xml | ||
*.azurePubxml | ||
# TODO: Comment the next line if you want to checkin your web deploy settings | ||
# but database connection strings (with potential passwords) will be unencrypted | ||
*.pubxml | ||
*.publishproj | ||
|
||
# NuGet Packages | ||
*.nupkg | ||
# The packages folder can be ignored because of Package Restore | ||
**/packages/* | ||
# except build/, which is used as an MSBuild target. | ||
!**/packages/build/ | ||
# If using the old MSBuild-Integrated Package Restore, uncomment this: | ||
#!**/packages/repositories.config | ||
|
||
# Windows Azure Build Output | ||
csx/ | ||
*.build.csdef | ||
|
||
# Windows Store app package directory | ||
AppPackages/ | ||
|
||
# Others | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
[Ss]tyle[Cc]op.* | ||
~$* | ||
*~ | ||
*.dbmdl | ||
*.dbproj.schemaview | ||
*.pfx | ||
*.publishsettings | ||
node_modules/ | ||
|
||
# RIA/Silverlight projects | ||
Generated_Code/ | ||
|
||
# Backup & report files from converting an old project file | ||
# to a newer Visual Studio version. Backup files are not needed, | ||
# because we have git ;-) | ||
_UpgradeReport_Files/ | ||
Backup*/ | ||
UpgradeLog*.XML | ||
UpgradeLog*.htm | ||
|
||
# SQL Server files | ||
*.mdf | ||
*.ldf | ||
|
||
# Business Intelligence projects | ||
*.rdl.data | ||
*.bim.layout | ||
*.bim_*.settings | ||
|
||
# Microsoft Fakes | ||
FakesAssemblies/ |
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 | ||
} | ||
} |
Oops, something went wrong.