Skip to content

Commit 4604072

Browse files
committed
Initial check in
Initial check in
0 parents  commit 4604072

2,359 files changed

Lines changed: 418623 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
[Dd]ebug/
11+
[Dd]ebugPublic/
12+
[Rr]elease/
13+
[Rr]eleases/
14+
x64/
15+
x86/
16+
build/
17+
bld/
18+
[Bb]in/
19+
[Oo]bj/
20+
21+
# Roslyn cache directories
22+
*.ide/
23+
24+
# MSTest test Results
25+
[Tt]est[Rr]esult*/
26+
[Bb]uild[Ll]og.*
27+
28+
#NUNIT
29+
*.VisualState.xml
30+
TestResult.xml
31+
32+
# Build Results of an ATL Project
33+
[Dd]ebugPS/
34+
[Rr]eleasePS/
35+
dlldata.c
36+
37+
*_i.c
38+
*_p.c
39+
*_i.h
40+
*.ilk
41+
*.meta
42+
*.obj
43+
*.pch
44+
*.pdb
45+
*.pgc
46+
*.pgd
47+
*.rsp
48+
*.sbr
49+
*.tlb
50+
*.tli
51+
*.tlh
52+
*.tmp
53+
*.tmp_proj
54+
*.log
55+
*.vspscc
56+
*.vssscc
57+
.builds
58+
*.pidb
59+
*.svclog
60+
*.scc
61+
62+
# Chutzpah Test files
63+
_Chutzpah*
64+
65+
# Visual C++ cache files
66+
ipch/
67+
*.aps
68+
*.ncb
69+
*.opensdf
70+
*.sdf
71+
*.cachefile
72+
73+
# Visual Studio profiler
74+
*.psess
75+
*.vsp
76+
*.vspx
77+
78+
# TFS 2012 Local Workspace
79+
$tf/
80+
81+
# Guidance Automation Toolkit
82+
*.gpState
83+
84+
# ReSharper is a .NET coding add-in
85+
_ReSharper*/
86+
*.[Rr]e[Ss]harper
87+
*.DotSettings.user
88+
89+
# JustCode is a .NET coding addin-in
90+
.JustCode
91+
92+
# TeamCity is a build add-in
93+
_TeamCity*
94+
95+
# DotCover is a Code Coverage Tool
96+
*.dotCover
97+
98+
# NCrunch
99+
_NCrunch_*
100+
.*crunch*.local.xml
101+
102+
# MightyMoose
103+
*.mm.*
104+
AutoTest.Net/
105+
106+
# Web workbench (sass)
107+
.sass-cache/
108+
109+
# Installshield output folder
110+
[Ee]xpress/
111+
112+
# DocProject is a documentation generator add-in
113+
DocProject/buildhelp/
114+
DocProject/Help/*.HxT
115+
DocProject/Help/*.HxC
116+
DocProject/Help/*.hhc
117+
DocProject/Help/*.hhk
118+
DocProject/Help/*.hhp
119+
DocProject/Help/Html2
120+
DocProject/Help/html
121+
122+
# Click-Once directory
123+
publish/
124+
125+
# Publish Web Output
126+
*.[Pp]ublish.xml
127+
*.azurePubxml
128+
# TODO: Comment the next line if you want to checkin your web deploy settings
129+
# but database connection strings (with potential passwords) will be unencrypted
130+
*.pubxml
131+
*.publishproj
132+
133+
# NuGet Packages
134+
*.nupkg
135+
# The packages folder can be ignored because of Package Restore
136+
**/packages/*
137+
# except build/, which is used as an MSBuild target.
138+
!**/packages/build/
139+
# If using the old MSBuild-Integrated Package Restore, uncomment this:
140+
#!**/packages/repositories.config
141+
142+
# Windows Azure Build Output
143+
csx/
144+
*.build.csdef
145+
146+
# Windows Store app package directory
147+
AppPackages/
148+
149+
# Others
150+
sql/
151+
*.Cache
152+
ClientBin/
153+
[Ss]tyle[Cc]op.*
154+
~$*
155+
*~
156+
*.dbmdl
157+
*.dbproj.schemaview
158+
*.pfx
159+
*.publishsettings
160+
node_modules/
161+
162+
# RIA/Silverlight projects
163+
Generated_Code/
164+
165+
# Backup & report files from converting an old project file
166+
# to a newer Visual Studio version. Backup files are not needed,
167+
# because we have git ;-)
168+
_UpgradeReport_Files/
169+
Backup*/
170+
UpgradeLog*.XML
171+
UpgradeLog*.htm
172+
173+
# SQL Server files
174+
*.mdf
175+
*.ldf
176+
177+
# Business Intelligence projects
178+
*.rdl.data
179+
*.bim.layout
180+
*.bim_*.settings
181+
182+
# Microsoft Fakes
183+
FakesAssemblies/
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
namespace BlogEngine.Core.API.BlogML
2+
{
3+
/// <summary>
4+
/// The base reader.
5+
/// </summary>
6+
public class BaseReader
7+
{
8+
#region Constructors and Destructors
9+
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref = "BaseReader" /> class.
12+
/// </summary>
13+
public BaseReader()
14+
{
15+
this.Author = string.Empty;
16+
this.RemoveDuplicates = false;
17+
this.ApprovedCommentsOnly = false;
18+
this.Message = string.Empty;
19+
}
20+
21+
#endregion
22+
23+
#region Properties
24+
25+
/// <summary>
26+
/// Gets or sets a value indicating whether ApprovedCommentsOnly.
27+
/// </summary>
28+
public bool ApprovedCommentsOnly { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets Author.
32+
/// </summary>
33+
public string Author { get; set; }
34+
35+
/// <summary>
36+
/// Gets or sets Message.
37+
/// </summary>
38+
public string Message { get; set; }
39+
40+
/// <summary>
41+
/// Gets or sets a value indicating whether RemoveDuplicates.
42+
/// </summary>
43+
public bool RemoveDuplicates { get; set; }
44+
45+
#endregion
46+
47+
#region Public Methods
48+
49+
/// <summary>
50+
/// Imports this instance.
51+
/// </summary>
52+
/// <returns>
53+
/// Always returns false.
54+
/// </returns>
55+
public virtual bool Import()
56+
{
57+
return false;
58+
}
59+
60+
/// <summary>
61+
/// Validates this instance.
62+
/// </summary>
63+
/// <returns>
64+
/// Always returns false.
65+
/// </returns>
66+
public virtual bool Validate()
67+
{
68+
return false;
69+
}
70+
71+
#endregion
72+
}
73+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
namespace BlogEngine.Core.API.BlogML
2+
{
3+
using System;
4+
using System.Globalization;
5+
using System.Text.RegularExpressions;
6+
7+
/// <summary>
8+
/// Blog Importer
9+
/// </summary>
10+
public class BlogImporter
11+
{
12+
#region Public Methods
13+
14+
/// <summary>
15+
/// Add new blog post to system
16+
/// </summary>
17+
/// <returns>
18+
/// string containing unique post identifier
19+
/// </returns>
20+
public string AddPost(BlogMlExtendedPost extPost)
21+
{
22+
if (!Security.IsAdministrator)
23+
{
24+
throw new InvalidOperationException("BlogImporter.AddPost: Wrong credentials");
25+
}
26+
27+
using (var p = new Post())
28+
{
29+
p.Title = extPost.BlogPost.Title;
30+
p.DateCreated = extPost.BlogPost.DateCreated;
31+
p.DateModified = extPost.BlogPost.DateModified;
32+
p.Content = extPost.BlogPost.Content.UncodedText;
33+
p.Description = extPost.BlogPost.Excerpt.UncodedText;
34+
p.IsPublished = extPost.BlogPost.Approved;
35+
36+
if (!string.IsNullOrEmpty(extPost.PostUrl))
37+
{
38+
// looking for a Slug with patterns such as:
39+
// /some-slug.aspx
40+
// /some-slug.html
41+
// /some-slug
42+
//
43+
Match slugMatch = Regex.Match(extPost.PostUrl, @"/([^/\.]+)(?:$|\.[\w]{1,10}$)", RegexOptions.IgnoreCase);
44+
if (slugMatch.Success)
45+
p.Slug = slugMatch.Groups[1].Value.Trim();
46+
}
47+
48+
if(extPost.BlogPost.Authors != null && extPost.BlogPost.Authors.Count > 0)
49+
p.Author = extPost.BlogPost.Authors[0].Ref;
50+
51+
if (extPost.Categories != null && extPost.Categories.Count > 0)
52+
p.Categories.AddRange(extPost.Categories);
53+
54+
if(extPost.Tags != null && extPost.Tags.Count > 0)
55+
p.Tags.AddRange(extPost.Tags);
56+
57+
// skip if post with this url already exists
58+
var s = PostUrl(p.Slug, p.DateCreated);
59+
var list = Post.Posts.FindAll(ps => ps.RelativeLink == s);
60+
if (list.Count > 0)
61+
{
62+
return string.Empty;
63+
}
64+
65+
if(extPost.Comments != null && extPost.Comments.Count > 0)
66+
{
67+
foreach (var comment in extPost.Comments)
68+
{
69+
p.ImportComment(comment);
70+
}
71+
}
72+
73+
p.Import();
74+
return p.Id.ToString();
75+
}
76+
}
77+
78+
/// <summary>
79+
/// Force Reload of all posts
80+
/// </summary>
81+
public void ForceReload()
82+
{
83+
if (!Security.IsAdministrator)
84+
{
85+
throw new InvalidOperationException("BlogImporter.ForeceReload: Wrong credentials");
86+
}
87+
88+
Post.Reload();
89+
}
90+
91+
/// <summary>
92+
/// post url
93+
/// </summary>
94+
/// <param name="slug">post slug</param>
95+
/// <param name="dateCreated">date created</param>
96+
/// <returns></returns>
97+
static string PostUrl(string slug, DateTime dateCreated)
98+
{
99+
var theslug = Utils.RemoveIllegalCharacters(slug) + BlogConfig.FileExtension;
100+
101+
return BlogSettings.Instance.TimeStampPostLinks
102+
? string.Format(
103+
"{0}post/{1}{2}",
104+
Utils.RelativeWebRoot,
105+
dateCreated.ToString("yyyy/MM/dd/", CultureInfo.InvariantCulture),
106+
theslug)
107+
: string.Format("{0}post/{1}", Utils.RelativeWebRoot, theslug);
108+
}
109+
110+
#endregion
111+
}
112+
}

0 commit comments

Comments
 (0)