Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
archive
  • Loading branch information
kijanawoodard committed Nov 4, 2013
1 parent 48ed632 commit ce65020
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/Blog.Web/Actions/PostGet/Index.cshtml
@@ -0,0 +1,23 @@
@model Blog.Web.Actions.PostGet.PostIndexViewModel

@{
ViewBag.Title = "All Posts";
Layout = "~/Views/_Layout.cshtml";
}

<h2>Archive</h2>

<section id="archive">
<h4>@Model.Active.Count posts @(Model.Future.Any() ? Model.Future.Count + " future" : "")</h4>
<ul>
@foreach (var post in Model.Active)
{
<li>
<small>@post.PublishedAtCst.ToString("yyyy.MMM.dd")</small>
<a href="@Url.Action("Execute", "PostGet", new {slug = post.Slug})" title="@post.Title">
<span>@post.Title</span>
</a>
</li>
}
</ul>
</section>
16 changes: 16 additions & 0 deletions src/Blog.Web/Actions/PostGet/PostGetController.cs
Expand Up @@ -23,6 +23,8 @@ public void Execute(IContainer container)
result = new MarkdownContentStorage(root).Handle(message, result);
return result;
});

mediator.Subscribe<PostIndexRequest, PostIndexViewModel>(message => new FilteredPostVault().Handle(message));
}
}

Expand All @@ -41,6 +43,12 @@ public ActionResult Execute(PostRequest request)
if (model.Post == null) return HttpNotFound();
return View(model);
}

public ActionResult Index()
{
var model = _mediator.Send<PostIndexRequest, PostIndexViewModel>(new PostIndexRequest());
return View(model);
}
}

public class PostRequest
Expand All @@ -60,4 +68,12 @@ public class PostGetViewModel
public bool HasPrevious { get { return Previous != null; } }
public bool HasNext { get { return Next != null; } }
}

public class PostIndexRequest { }

public class PostIndexViewModel
{
public IReadOnlyCollection<Post> Active { get; set; }
public IReadOnlyCollection<Post> Future { get; set; }
}
}
3 changes: 3 additions & 0 deletions src/Blog.Web/Blog.Web.csproj
Expand Up @@ -274,6 +274,9 @@
<ItemGroup>
<Content Include="Actions\DisplayErrors\Http404.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Actions\PostGet\Index.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
Expand Down
4 changes: 3 additions & 1 deletion src/Blog.Web/Content/css/site.css
Expand Up @@ -82,4 +82,6 @@ footer p {
/* Large format tablet and desktop */
@media only screen and (min-width: 768px) {

}
}

#archive ul { list-style-type: none;margin: 0;}
9 changes: 9 additions & 0 deletions src/Blog.Web/Infrastructure/FilteredPostVault.cs
Expand Up @@ -44,6 +44,15 @@ public PostGetViewModel Handle(PostRequest message, PostGetViewModel result)
return result;
}

public PostIndexViewModel Handle(PostIndexRequest message)
{
var result = new PostIndexViewModel();
result.Active = ActivePosts;
result.Future = FuturePosts;

return result;
}

public AtomGetViewModel Handle(AtomRequest message)
{
return new AtomGetViewModel {Posts = ActivePosts};
Expand Down
5 changes: 5 additions & 0 deletions src/Blog.Web/Initialization/RouteConfig.cs
Expand Up @@ -9,6 +9,11 @@ public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
null,
"posts",
new { controller = "PostGet", action = "Index" });

routes.MapRoute(
null,
"atom",
Expand Down

0 comments on commit ce65020

Please sign in to comment.