diff --git a/Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml b/Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml
index a78b0f8..bda7f75 100644
--- a/Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml
+++ b/Teknik/Areas/Blog/Views/Blog/ViewPost.cshtml
@@ -28,7 +28,7 @@
@if (Model != null)
{
- if (Model.Blog.User.Username == User.Identity.Name)
+ if (User.IsInRole("Admin") || Model.Blog.User.Username == User.Identity.Name)
{
@@ -65,7 +65,7 @@
}
- - @((Model.BlogId == Constants.SERVERBLOGID) ? Model.Config.BlogConfig.Title : Model.Blog.Title)
+ - @((Model.System) ? Model.Config.BlogConfig.Title : (string.IsNullOrEmpty(Model.Blog.Title) ? string.Format("{0}'s Blog", Model.Blog.User.Username) : Model.Blog.Title))
- @Model.Title
diff --git a/Teknik/Areas/Home/Controllers/HomeController.cs b/Teknik/Areas/Home/Controllers/HomeController.cs
index 148fdac..a519fb1 100644
--- a/Teknik/Areas/Home/Controllers/HomeController.cs
+++ b/Teknik/Areas/Home/Controllers/HomeController.cs
@@ -22,12 +22,12 @@ namespace Teknik.Areas.Home.Controllers
HomeViewModel model = new HomeViewModel();
// Grab the latest site blog posts
List
lastSite = new List();
- var foundSite = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Where(p => p.Published && p.BlogId == Constants.SERVERBLOGID).Take(10);
+ var foundSite = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Where(p => p.Published && p.System).Take(10);
if (foundSite != null)
lastSite = foundSite.ToList();
// Grab the latest user blog posts
List lastPosts = new List();
- var foundPosts = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Where(p => p.Published && p.BlogId != Constants.SERVERBLOGID).Take(10);
+ var foundPosts = db.Posts.Include("Blog").Include("Blog.User").OrderBy(post => post.DatePosted).Where(p => p.Published && !p.System).Take(10);
if (foundPosts != null)
lastPosts = foundPosts.ToList();
// Grab the latest podcasts
diff --git a/Teknik/Areas/Profile/Controllers/ProfileController.cs b/Teknik/Areas/Profile/Controllers/ProfileController.cs
index 9c22bc8..a7ae984 100644
--- a/Teknik/Areas/Profile/Controllers/ProfileController.cs
+++ b/Teknik/Areas/Profile/Controllers/ProfileController.cs
@@ -52,7 +52,7 @@ namespace Teknik.Areas.Profile.Controllers
model.Quote = user.Quote;
// fill in Blog details
- var blog = db.Blogs.Where(b => b.UserId == user.UserId && b.BlogId != Constants.SERVERBLOGID);
+ var blog = db.Blogs.Where(b => b.UserId == user.UserId);
if (blog != null && blog.Any())
{
Blog.Models.Blog foundBlog = blog.First();
@@ -169,7 +169,7 @@ namespace Teknik.Areas.Profile.Controllers
User user = db.Users.Where(u => u.Username == User.Identity.Name).First();
if (user != null)
{
- var foundBlog = db.Blogs.Where(b => b.UserId == user.UserId && b.BlogId != Constants.SERVERBLOGID);
+ var foundBlog = db.Blogs.Where(b => b.UserId == user.UserId);
if (foundBlog != null && foundBlog.Any())
{
Blog.Models.Blog blog = foundBlog.First();
diff --git a/Teknik/Areas/Profile/Views/Profile/Index.cshtml b/Teknik/Areas/Profile/Views/Profile/Index.cshtml
index 22ea742..c191cb0 100644
--- a/Teknik/Areas/Profile/Views/Profile/Index.cshtml
+++ b/Teknik/Areas/Profile/Views/Profile/Index.cshtml
@@ -11,10 +11,10 @@
@if (!Model.Error)
{
- bool OwnProfile = (Model.Username == User.Identity.Name);
+ bool OwnProfile = (Model.Username == User.Identity.Name || User.IsInRole("Admin"));
-
@Model.Username>
+
@Model.Username
@@ -26,10 +26,7 @@
Last Seen @Model.LastSeen.ToString("MMMM dd, yyyy")
}
Email @Model.Email
- @if (!string.IsNullOrEmpty(Model.BlogTitle))
- {
-
Blog @Model.BlogTitle
- }
+
Blog @(string.IsNullOrEmpty(Model.BlogTitle) ? string.Format("{0}'s Blog", Model.Username) : Model.BlogTitle)
Git Public Repos
@if (OwnProfile)
{
diff --git a/Teknik/Configuration/Config.cs b/Teknik/Configuration/Config.cs
index 01a3d38..6e4a0a8 100644
--- a/Teknik/Configuration/Config.cs
+++ b/Teknik/Configuration/Config.cs
@@ -81,19 +81,33 @@ namespace Teknik.Configuration
public static string Serialize(Config config)
{
- return JsonConvert.SerializeObject(config);
+ return JsonConvert.SerializeObject(config, Formatting.Indented);
}
public static Config Load()
{
Config config = new Config();
string path = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
- if (File.Exists(Path.Combine(path, "Config.json")))
+ if (!File.Exists(Path.Combine(path, "Config.json")))
+ {
+ Config.Save(Path.Combine(path, "Config.json"), config);
+ }
+ else
{
string configContents = File.ReadAllText(Path.Combine(path, "Config.json"));
config = Config.Deserialize(configContents);
}
return config;
}
+
+ public static void Save(string path, Config config)
+ {
+ if (!Directory.Exists(Path.GetDirectoryName(path)))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(path));
+ }
+ string configContents = Config.Serialize(config);
+ File.WriteAllText(path, configContents);
+ }
}
}
\ No newline at end of file