static string readJournalContent(string filePath) { switch (getJournalFileType(filePath)) { case JournalFileType.Markdown: return(MarkdownReader.fromFile(filePath)); case JournalFileType.HTML: return(File.ReadAllText(filePath)); } throw new ArgumentException("invalid journal file type"); }
static JournalEntry loadJournalEntry(Journal journal, string filePath) { var filename = JournalEntryFilename.fromFilename(Path.GetFileName(filePath)); var content = readJournalContent(filePath); var entryId = journal.Id + "/" + ReadableURL.read(filename.ToString()); var header = "[](module:BlogEntryHeader?entry={0}&name={1}&date={2})".format( HttpUtility.UrlEncode(entryId), HttpUtility.UrlEncode(filename.NamePart), HttpUtility.UrlEncode(DateReader.printDateTimeCode(filename.DateTimeCode))); var headerHTML = MarkdownReader.fromString(header); var date = DateReader.fromDateTimeCode(filename.DateTimeCode); return(new JournalEntry { Id = entryId, Filename = filename, Content = headerHTML + content, Date = date }); }