diff --git a/Ficdown.Console/Program.cs b/Ficdown.Console/Program.cs index c5a94b9..37185bd 100644 --- a/Ficdown.Console/Program.cs +++ b/Ficdown.Console/Program.cs @@ -27,6 +27,8 @@ private static int Main(string[] args) string tempdir = null; string format = null; string author = null; + string bookid = null; + string language = "en"; string images = null; var debug = false; @@ -59,6 +61,12 @@ private static int Main(string[] args) case "--author": author = args[i + 1]; break; + case "--bookid": + bookid = args[i + 1]; + break; + case "--language": + language = args[i + 1]; + break; case "--images": images = args[i + 1]; break; @@ -140,7 +148,7 @@ private static int Main(string[] args) { case "html": Directory.CreateDirectory(output); - rend = new HtmlRenderer(); + rend = new HtmlRenderer(language); break; case "epub": if (string.IsNullOrWhiteSpace(author)) @@ -148,7 +156,7 @@ private static int Main(string[] args) Console.WriteLine(@"Epub format requires the --author argument."); return 1; } - rend = new EpubRenderer(author); + rend = new EpubRenderer(author, bookid, language); break; default: ShowHelp(); @@ -183,6 +191,8 @@ private static void ShowHelp() [--template ""/path/to/template/dir""] [--images ""/path/to/images/dir""] [--author ""Author Name""] + [--bookid ""ePub Book ID""] + [--language ""language""] [--debug]"); } } diff --git a/Ficdown.Parser.Tests/IntegrationTests.cs b/Ficdown.Parser.Tests/IntegrationTests.cs index abf4676..7df5597 100644 --- a/Ficdown.Parser.Tests/IntegrationTests.cs +++ b/Ficdown.Parser.Tests/IntegrationTests.cs @@ -21,7 +21,7 @@ public void CanParseValidStoryFile() { File.Delete(file); } - var rend = new HtmlRenderer(); + var rend = new HtmlRenderer("en"); rend.Render(story, path, true); } } diff --git a/Ficdown.Parser/Render/EpubRenderer.cs b/Ficdown.Parser/Render/EpubRenderer.cs index a7eae5d..c7a6eeb 100644 --- a/Ficdown.Parser/Render/EpubRenderer.cs +++ b/Ficdown.Parser/Render/EpubRenderer.cs @@ -90,10 +90,14 @@ public void DeleteBuildDir() public class EpubRenderer : HtmlRenderer { private readonly string _author; + private readonly string _bookId; + private readonly string _language; - public EpubRenderer(string author) : base() + public EpubRenderer(string author, string bookId, string language) : base(language) { _author = author; + _bookId = bookId ?? Guid.NewGuid().ToString("D"); + _language = language ?? "en"; } public override void Render(Model.Parser.ResolvedStory story, string outPath, bool debug = false) @@ -113,6 +117,8 @@ into fname select new Chapter(Path.Combine(temppath, fname), fname, fname.Replace(".html", string.Empty))); var epub = new Epub(Story.Name, _author, chapters); + epub.BookId = _bookId; + epub.Language = _language; epub.AddResourceFile(new ResourceFile("styles.css", Path.Combine(temppath, "styles.css"), "text/css")); if (!string.IsNullOrWhiteSpace(ImageDir)) diff --git a/Ficdown.Parser/Render/HtmlRenderer.cs b/Ficdown.Parser/Render/HtmlRenderer.cs index 9ad6160..b1e521a 100644 --- a/Ficdown.Parser/Render/HtmlRenderer.cs +++ b/Ficdown.Parser/Render/HtmlRenderer.cs @@ -9,6 +9,8 @@ public class HtmlRenderer : IRenderer { + private readonly string _language; + protected readonly Markdown Markdown; public string IndexTemplate { get; set; } @@ -18,8 +20,9 @@ public class HtmlRenderer : IRenderer protected ResolvedStory Story { get; set; } - public HtmlRenderer() + public HtmlRenderer(string language) { + _language = language; Markdown = new Markdown(); } @@ -39,6 +42,7 @@ protected void GenerateHtml(ResolvedStory story, string outPath, bool debug) { var index = FillTemplate(IndexTemplate ?? Template.Index, new Dictionary { + {"Language", _language}, {"Title", story.Name}, {"Description", Markdown.Transform(story.Description)}, {"FirstScene", string.Format("{0}.html", story.FirstPage)} @@ -64,6 +68,7 @@ protected void GenerateHtml(ResolvedStory story, string outPath, bool debug) var scene = FillTemplate(SceneTemplate ?? Template.Scene, new Dictionary { + {"Language", _language}, {"Title", story.Name}, {"Content", Markdown.Transform(content)} }); diff --git a/Ficdown.Parser/Render/Views/index.html b/Ficdown.Parser/Render/Views/index.html index 862043b..12f0dfb 100644 --- a/Ficdown.Parser/Render/Views/index.html +++ b/Ficdown.Parser/Render/Views/index.html @@ -1,8 +1,9 @@ - + + - + - + @Title @@ -11,4 +12,4 @@

@Title

@Description

Begin reading...

- \ No newline at end of file + diff --git a/Ficdown.Parser/Render/Views/scene.html b/Ficdown.Parser/Render/Views/scene.html index 358f193..a14c5f2 100644 --- a/Ficdown.Parser/Render/Views/scene.html +++ b/Ficdown.Parser/Render/Views/scene.html @@ -1,12 +1,13 @@ - + + - + - + @Title @Content - \ No newline at end of file +