Skip to content

Commit

Permalink
Now uses WetzUtilities. Nuget update. Version bumped to 2.0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pdwetz committed Feb 2, 2019
1 parent 8c8f586 commit b25e4e6
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 282 deletions.
9 changes: 5 additions & 4 deletions KindleBookHelper.Core/Book.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
KindleBookHelper - Converts raw text file to html format that can be consumed by KindleGen.
Copyright (C) 2018 Peter Wetzel
Copyright (C) 2019 Peter Wetzel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -19,6 +19,7 @@
using Serilog;
using System;
using System.Collections.Generic;
using WetzUtilities;

namespace KindleBookHelper.Core
{
Expand All @@ -39,10 +40,10 @@ public class Book
public string Forward { get; set; }

[JsonIgnore]
public string TitleFileSafe { get { return Title.URLFriendly(); } }
public string TitleFileSafe => Title.URLFriendly();

[JsonIgnore]
public int EndNavPlayOrder { get { return 3 + Poems.Count; } }
public int EndNavPlayOrder => 3 + Poems.Count;
// TODO Pre-work free-form content
[JsonIgnore]
public List<Poem> Poems { get; set; }
Expand All @@ -51,7 +52,7 @@ public class Book
public string OriginalText { get; set; }

[JsonIgnore]
public int Copyright { get { return DateTime.Now.Year; } }
public int Copyright => DateTime.Now.Year;

[JsonIgnore]
public string EndPlaceholder { get; set; }
Expand Down
17 changes: 15 additions & 2 deletions KindleBookHelper.Core/BookProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Newtonsoft.Json;
using Nustache.Core;
using Serilog;
using WetzUtilities;

namespace KindleBookHelper.Core
{
Expand Down Expand Up @@ -73,13 +74,25 @@ public Book Process()
var cssFilePath = Path.Combine(targetDirectoryPath, "poetry.css");
if (!File.Exists(cssFilePath))
{
var css = FileUtilities.LoadTextResource(_assembly, "KindleBookHelper.Core.templates.poetry.css");
FileUtilities.WriteTextFile(cssFilePath, css);
var css = LoadTextResource(_assembly, "KindleBookHelper.Core.templates.poetry.css");
FileUtilities.WriteTextFile(targetDirectoryPath, "poetry.css", css);
}
Log.Information("Finished processing book {Title}", book.Title);
return book;
}

private string LoadTextResource(Assembly assembly, string resourceName)
{
var data = "";
using (var sr = new StreamReader(assembly.GetManifestResourceStream(resourceName)))
{
data = sr.ReadToEnd();
sr.DiscardBufferedData();
sr.Close();
}
return data;
}

private void RenderTemplate(string targetDirectoryPath, string template, Book book)
{
var targetFilePath = Path.Combine(targetDirectoryPath, $"{book.TitleFileSafe}.{template}");
Expand Down
69 changes: 0 additions & 69 deletions KindleBookHelper.Core/FileUtilities.cs

This file was deleted.

11 changes: 6 additions & 5 deletions KindleBookHelper.Core/KindleBookHelper.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Nustache.Core, Version=1.16.0.8, Culture=neutral, PublicKeyToken=efd6f3d8f76ecd9f, processorArchitecture=MSIL">
<HintPath>..\packages\Nustache.1.16.0.8\lib\net20\Nustache.Core.dll</HintPath>
</Reference>
<Reference Include="Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10, processorArchitecture=MSIL">
<HintPath>..\packages\Serilog.2.7.1\lib\net46\Serilog.dll</HintPath>
<HintPath>..\packages\Serilog.2.8.0\lib\net46\Serilog.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand All @@ -47,15 +47,16 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WetzUtilities, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WetzUtilities.1.0.0\lib\netstandard2.0\WetzUtilities.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Book.cs" />
<Compile Include="BookProcessor.cs" />
<Compile Include="FileUtilities.cs" />
<Compile Include="Poem.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Stanza.cs" />
<Compile Include="StringExtensions.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="templates\html.template">
Expand Down
5 changes: 3 additions & 2 deletions KindleBookHelper.Core/Poem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
KindleBookHelper - Converts raw text file to html format that can be consumed by KindleGen.
Copyright (C) 2018 Peter Wetzel
Copyright (C) 2019 Peter Wetzel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -18,13 +18,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using WetzUtilities;

namespace KindleBookHelper.Core
{
public class Poem
{
public string Title { get; set; }
public string TitleUrlSafe { get { return Title.URLFriendly(); } }
public string TitleUrlSafe => Title.URLFriendly();
public List<Stanza> Stanzas { get; set; }

public Poem(string text)
Expand Down
6 changes: 3 additions & 3 deletions KindleBookHelper.Core/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("KindleBookHelper")]
[assembly: AssemblyCopyright("Copyright © 2018 Peter Wetzel")]
[assembly: AssemblyCopyright("Copyright © 2019 Peter Wetzel")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]
[assembly: Guid("3b63a76a-c55e-4cae-84c4-d07a2cbc1afe")]

[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
148 changes: 0 additions & 148 deletions KindleBookHelper.Core/StringExtensions.cs

This file was deleted.

5 changes: 3 additions & 2 deletions KindleBookHelper.Core/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net472" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net472" />
<package id="Nustache" version="1.16.0.8" targetFramework="net472" />
<package id="Serilog" version="2.7.1" targetFramework="net472" />
<package id="Serilog" version="2.8.0" targetFramework="net472" />
<package id="WetzUtilities" version="1.0.0" targetFramework="net472" />
</packages>
Loading

0 comments on commit b25e4e6

Please sign in to comment.