Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Hawk/src/Hawk/Services/FileSystemRepo.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
29 lines (26 sloc)
960 Bytes
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
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using Hawk.Models; | |
namespace Hawk.Services | |
{ | |
static class FileSystemRepo | |
{ | |
public const string ITEM_JSON = "hawk-post.json"; | |
public const string COMMENTS_JSON = "hawk-comments.json"; | |
public const string RENDERED_CONTENT_FILENAME = "rendered-content.html"; | |
public const string CONTENT_FILENAME = "content.md"; | |
public static readonly string[] IMG_EXTENSIONS = { ".png", ".gif", ".jpg" }; | |
public static IEnumerable<string> EnumeratePostDirectories(string path) | |
{ | |
return Directory | |
.EnumerateDirectories(path) | |
.Where(dir => File.Exists(Path.Combine(dir, ITEM_JSON))); | |
} | |
public static IEnumerable<Post> EnumeratePosts(string path) | |
{ | |
return EnumeratePostDirectories(path) | |
.Select(dir => Post.FromDirectory(dir)); | |
} | |
} | |
} |