This repository has been archived by the owner on Jul 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
513 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain | ||
|
||
*.jpg binary | ||
*.png binary | ||
*.gif binary | ||
|
||
*.cs text=auto diff=csharp | ||
*.vb text=auto | ||
*.c text=auto | ||
*.cpp text=auto | ||
*.cxx text=auto | ||
*.h text=auto | ||
*.hxx text=auto | ||
*.py text=auto | ||
*.rb text=auto | ||
*.java text=auto | ||
*.html text=auto | ||
*.htm text=auto | ||
*.css text=auto | ||
*.scss text=auto | ||
*.sass text=auto | ||
*.less text=auto | ||
*.js text=auto | ||
*.lisp text=auto | ||
*.clj text=auto | ||
*.sql text=auto | ||
*.php text=auto | ||
*.lua text=auto | ||
*.m text=auto | ||
*.asm text=auto | ||
*.erl text=auto | ||
*.fs text=auto | ||
*.fsx text=auto | ||
*.hs text=auto | ||
|
||
*.csproj text=auto merge=union | ||
*.vbproj text=auto merge=union | ||
*.fsproj text=auto merge=union | ||
*.dbproj text=auto merge=union | ||
*.sln text=auto eol=crlf merge=union |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) | ||
bin | ||
obj | ||
|
||
# mstest test results | ||
TestResults | ||
[Oo]bj/ | ||
[Bb]in/ | ||
*.user | ||
target/ | ||
*ReSharper* | ||
*resharper* | ||
*.suo | ||
*.cache | ||
Thumbs.db | ||
*.bak | ||
*.swp | ||
*.docstates | ||
*.dotCover | ||
packages/ | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<solution> | ||
<add key="disableSourceControlIntegration" value="true" /> | ||
</solution> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir> | ||
|
||
<!-- Enable the restore command to run before builds --> | ||
<RestorePackages Condition=" '$(RestorePackages)' == '' ">false</RestorePackages> | ||
|
||
<!-- Property that enables building a package from a project --> | ||
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage> | ||
|
||
<!-- Download NuGet.exe if it does not already exist --> | ||
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition=" '$(PackageSources)' == '' "> | ||
<!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config --> | ||
<!-- | ||
<PackageSource Include="https://nuget.org/api/v2/" /> | ||
<PackageSource Include="https://my-nuget-source/nuget/" /> | ||
--> | ||
</ItemGroup> | ||
|
||
<PropertyGroup Condition=" '$(OS)' == 'Windows_NT'"> | ||
<!-- Windows specific commands --> | ||
<NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath> | ||
<PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig> | ||
<PackagesDir>$([System.IO.Path]::Combine($(SolutionDir), "packages"))</PackagesDir> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition=" '$(OS)' != 'Windows_NT'"> | ||
<!-- We need to launch nuget.exe with the mono command if we're not on windows --> | ||
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath> | ||
<PackagesConfig>packages.config</PackagesConfig> | ||
<PackagesDir>$(SolutionDir)packages</PackagesDir> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- NuGet command --> | ||
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath> | ||
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources> | ||
|
||
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand> | ||
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand> | ||
|
||
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir> | ||
|
||
<!-- Commands --> | ||
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" -o "$(PackagesDir)"</RestoreCommand> | ||
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand> | ||
|
||
<!-- Make the build depend on restore packages --> | ||
<BuildDependsOn Condition="$(RestorePackages) == 'true'"> | ||
RestorePackages; | ||
$(BuildDependsOn); | ||
</BuildDependsOn> | ||
|
||
<!-- Make the build depend on restore packages --> | ||
<BuildDependsOn Condition="$(BuildPackage) == 'true'"> | ||
$(BuildDependsOn); | ||
BuildPackage; | ||
</BuildDependsOn> | ||
</PropertyGroup> | ||
|
||
<Target Name="CheckPrerequisites"> | ||
<!-- Raise an error if we're unable to locate nuget.exe --> | ||
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" /> | ||
<SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " /> | ||
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" /> | ||
</Target> | ||
|
||
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites"> | ||
<Exec Command="$(RestoreCommand)" | ||
Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" /> | ||
|
||
<Exec Command="$(RestoreCommand)" | ||
LogStandardErrorAsError="true" | ||
Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" /> | ||
</Target> | ||
|
||
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites"> | ||
<Exec Command="$(BuildCommand)" | ||
Condition=" '$(OS)' != 'Windows_NT' " /> | ||
|
||
<Exec Command="$(BuildCommand)" | ||
LogStandardErrorAsError="true" | ||
Condition=" '$(OS)' == 'Windows_NT' " /> | ||
</Target> | ||
|
||
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> | ||
<ParameterGroup> | ||
<OutputFilename ParameterType="System.String" Required="true" /> | ||
</ParameterGroup> | ||
<Task> | ||
<Reference Include="System.Core" /> | ||
<Using Namespace="System" /> | ||
<Using Namespace="System.IO" /> | ||
<Using Namespace="System.Net" /> | ||
<Using Namespace="Microsoft.Build.Framework" /> | ||
<Using Namespace="Microsoft.Build.Utilities" /> | ||
<Code Type="Fragment" Language="cs"> | ||
<![CDATA[ | ||
try { | ||
OutputFilename = Path.GetFullPath(OutputFilename); | ||
Log.LogMessage("Downloading latest version of NuGet.exe..."); | ||
WebClient webClient = new WebClient(); | ||
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename); | ||
return true; | ||
} | ||
catch (Exception ex) { | ||
Log.LogErrorFromException(ex); | ||
return false; | ||
} | ||
]]> | ||
</Code> | ||
</Task> | ||
</UsingTask> | ||
|
||
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll"> | ||
<ParameterGroup> | ||
<EnvKey ParameterType="System.String" Required="true" /> | ||
<EnvValue ParameterType="System.String" Required="true" /> | ||
</ParameterGroup> | ||
<Task> | ||
<Using Namespace="System" /> | ||
<Code Type="Fragment" Language="cs"> | ||
<![CDATA[ | ||
try { | ||
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process); | ||
} | ||
catch { | ||
} | ||
]]> | ||
</Code> | ||
</Task> | ||
</UsingTask> | ||
</Project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RssToEmail", "RssToEmail\RssToEmail.csproj", "{9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}" | ||
EndProject | ||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{F3147DA2-AA3E-48CB-98EC-7DBB8D76EEB7}" | ||
ProjectSection(SolutionItems) = preProject | ||
.nuget\NuGet.Config = .nuget\NuGet.Config | ||
.nuget\nuget.exe = .nuget\nuget.exe | ||
.nuget\NuGet.targets = .nuget\NuGet.targets | ||
EndProjectSection | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x86 = Debug|x86 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Debug|x86.ActiveCfg = Debug|x86 | ||
{9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Debug|x86.Build.0 = Debug|x86 | ||
{9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Release|x86.ActiveCfg = Release|x86 | ||
{9E3553CC-2C00-4C22-BC6A-5C11FB9B0222}.Release|x86.Build.0 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<configuration> | ||
<appSettings> | ||
<!-- semi colon deliminated list of feed urls --> | ||
<add key="urls" value="http://ayende.com/blog/rss"/> | ||
<!-- Email addresses --> | ||
<add key="to" value=""/> | ||
<add key="from" value=""/> | ||
<add key="SendAllForNewFeeds" value="false"/> | ||
</appSettings> | ||
<connectionStrings> | ||
<add name="RavenDB" connectionString="DataDir=~\App_Data\Database" /> | ||
</connectionStrings> | ||
<system.net> | ||
<mailSettings> | ||
<smtp deliveryMethod="Network"> | ||
<network host="localhost" port="25" defaultCredentials="false"/> | ||
</smtp> | ||
</mailSettings> | ||
</system.net> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace RssToEmail.Models | ||
{ | ||
public class Feed | ||
{ | ||
public string Id { get; set; } | ||
public string Url { get; set; } | ||
public IList<string> SentItems { get; set; } | ||
|
||
public Feed() | ||
{ | ||
SentItems = new List<string>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Configuration; | ||
using System.Linq; | ||
using System.Net.Mail; | ||
using QDFeedParser; | ||
using Raven.Client.Embedded; | ||
using RssToEmail.Models; | ||
|
||
namespace RssToEmail | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
var urls = ConfigurationManager.AppSettings["urls"].Split(new [] { ';',',' }, StringSplitOptions.RemoveEmptyEntries); | ||
var to = new MailAddress(ConfigurationManager.AppSettings["to"]); | ||
bool sendAllForNewFeeds; | ||
bool.TryParse(ConfigurationManager.AppSettings["SendAllForNewFeeds"] ?? "false", out sendAllForNewFeeds); | ||
|
||
var feeds = new HttpFeedFactory(); | ||
var documentStore = new EmbeddableDocumentStore | ||
{ | ||
ConnectionStringName = "RavenDB" | ||
}.Initialize(); | ||
|
||
foreach (var url in urls) | ||
{ | ||
var feed = feeds.CreateFeed(new Uri(url)); | ||
var from = new MailAddress(ConfigurationManager.AppSettings["from"], feed.Title); | ||
|
||
var session = documentStore.OpenSession(); | ||
var savedFeed = session.Query<Feed>().SingleOrDefault(x => x.Url == url) ?? | ||
new Feed { | ||
Url = url | ||
}; | ||
var isNew = !savedFeed.SentItems.Any(); | ||
foreach (var item in feed.Items) | ||
{ | ||
// Ignore previously processed items | ||
if (savedFeed.SentItems.Contains(item.Id)) | ||
continue; | ||
|
||
// Only send an email if the url is not new or if the user configures that new urls should send all current items | ||
if (!isNew || sendAllForNewFeeds) | ||
{ | ||
try | ||
{ | ||
var message = new MailMessage(from, to) { | ||
Subject = "[New Post] " + item.Title, | ||
Body = item.Content + string.Format("<p style=\"font-size:12px;line-height:1.4em;margin:10px 0px 10px 0px\">View the original article: <a href=\"{0}\">{0}</a></p>", item.Link), | ||
IsBodyHtml = true | ||
}; | ||
|
||
var smtp = new SmtpClient(); | ||
smtp.Send(message); | ||
} | ||
catch (Exception ex) | ||
{ | ||
// Ignore this for now... we'll just try again next time the app runs | ||
continue; | ||
} | ||
} | ||
|
||
savedFeed.SentItems.Add(item.Id); | ||
} | ||
session.Store(savedFeed); | ||
session.SaveChanges(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.