Skip to content

Commit

Permalink
Add minimal example.
Browse files Browse the repository at this point in the history
  • Loading branch information
HowardvanRooijen committed Mar 26, 2019
1 parent dd4ca98 commit aa8d8b7
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 3 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

Expand Down Expand Up @@ -317,7 +317,7 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
Expand All @@ -326,5 +326,9 @@ ASALocalRun/
# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Ignore the Wyam files
output/*
config.wyam.*
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,68 @@ Currently the newsletter is generated via a tool which deals with publishing the
"LastUpdated": "2018-03-31T09:15:25+00:00"
}

```

The rendered newsletter can be [found here](https://campaigns.endjin.com/t/ViewEmailArchive/t/D2371CB2A187A272/C67FD2F38AC4859C/).

The aim is to try and generate a blog like site that contains a ToC of the editions of the newsletter then a page with the actual content. The content of this can be generated from the Newsletter.NewsletterItems collection in the JSON document.

I've created two modules which can either process a directory full of editions in JSON format, or a single edition:

``` csharp
public class NewsTopicsModule : IModule
{
private string newscollectionsFilePath;

public NewsTopicsModule(string newscollectionsFilePath)
{
this.newscollectionsFilePath = newscollectionsFilePath;
}

public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
{
foreach (var filePath in Directory.EnumerateFiles(this.newscollectionsFilePath))
{
var newscollection = JsonConvert.DeserializeObject<NewsCollection>(File.ReadAllText(filePath));

var metadata = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("NewsletterContent", newscollection.Newsletter),
new KeyValuePair<string, object>("NewsletterFrom", newscollection.FromDate),
new KeyValuePair<string, object>("NewsletterTo", newscollection.ToDate)
};

yield return context.GetDocument(metadata);
}
}
}
```

and

```csharp
public class NewsTopicModule : IModule
{
private string newscollectionFilePath;

public NewsTopicModule(string newscollectionFilePath)
{
this.newscollectionFilePath = newscollectionFilePath;
}

public IEnumerable<IDocument> Execute(IReadOnlyList<IDocument> inputs, IExecutionContext context)
{
var newscollection = JsonConvert.DeserializeObject<NewsCollection>(File.ReadAllText(this.newscollectionFilePath));

var metadata = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("NewsletterContent", newscollection.Newsletter),
new KeyValuePair<string, object>("NewsletterFrom", newscollection.FromDate),
new KeyValuePair<string, object>("NewsletterTo", newscollection.ToDate)
};

yield return context.GetDocument(metadata);
}
}

```
25 changes: 25 additions & 0 deletions Solutions/Endjin.AzureWeekly.Wyam.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.489
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Endjin.AzureWeekly.WyamModules", "Endjin.AzureWeekly.Wyam\Endjin.AzureWeekly.WyamModules.csproj", "{578FC577-1EBB-4DBC-8E4C-47E4CC0C59B3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{578FC577-1EBB-4DBC-8E4C-47E4CC0C59B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{578FC577-1EBB-4DBC-8E4C-47E4CC0C59B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{578FC577-1EBB-4DBC-8E4C-47E4CC0C59B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{578FC577-1EBB-4DBC-8E4C-47E4CC0C59B3}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {73561AD8-8E5A-4C5C-9055-93D682164EAB}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Wyam.Common" Version="2.2.4" />
</ItemGroup>

</Project>
Loading

0 comments on commit aa8d8b7

Please sign in to comment.