public static JournalData read(Journal journal) { var entries = Directory.EnumerateFiles(journal.Path) .Where(isJournalFileType) .Select(f => loadJournalEntry(journal, f)) .OrderByDescending(entry => entry.Filename.ToString()) .ToArray(); return new JournalData {Journal = journal, Entries = entries}; }
public static Site make(dynamic parameters) { var commentProvider = new IntenseDebateCommentProvider("9c0758183a14e567cb74c0d8c265f005"); var searchProvider = new GoogleCustomSearchProvider("005424054565942892879:knukodny3cw"); var site = new Site("Replicator.org", "www.replicator.org", parameters); var homePage = new Page("home", "About"); var journal = new Journal("journal", "Journal", "Armin's Journal"); journal .comments(commentProvider) .search(searchProvider); var twitter = new ExternalPage("connect", "Twitter", "http://www.twitter.com/pragmatrix"); var projects = new Page("projects", "Projects"); var github = new ExternalPage("github", "Github", "http://www.github.com/pragmatrix"); var bookmarks = new ExternalPage("bookmarks", "Bookmarks", "https://pinboard.in/u:pragmatrix"); var xing = new ExternalPage("xing", "Xing", "http://www.xing.com/profile/Armin_Sander"); var page404 = new Page("404", "Page Not Found, Error 404"); var feedRef = new ExternalPage("feed", "", "/" + journal.FeedSitePath); feedRef.referenceClass("icon-rss"); var menu = new Menu(); menu .page(homePage) .page(projects) .page(journal.indexReference("Journal")) .page(github) .page(twitter) .page(xing) .page(bookmarks) .page(feedRef); site .page(page404) .css("replicator.css") // nice header font: Orbitron, but less readable than Audiowide .cssRef("https://fonts.googleapis.com/css?family=Questrial|Ubuntu+Mono|Audiowide") .slogan("... live programming is next") .home(homePage) .menu(menu) .journal(journal) .loadContentFromDirectory("Pages") .fontAwesome(); // this should be part of the site generator! using (var f = File.Open("Site/moved-permanently", FileMode.Create, FileAccess.Write)) using (var writer = new StreamWriter(f)) { writer.WriteLine("Redirect permanent /node/feed /journal/feed"); forwardOldContentPages(writer); forwardNodePages(writer); } return site; }
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 }; }
public Site journal(Journal journal) { Journals.Add(journal); var journalFeed = new Feed(journal.Title, "https://" + DomainName + "/" + journal.FeedSitePath); feed(journalFeed); this.resources(journal.Id, journal.Id); return this; }