Skip to content

Commit

Permalink
Provider Namespace Fixes & Use of Mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
pgodwin committed Jun 24, 2017
1 parent 6b7d566 commit 5e9cce6
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 9 deletions.
Expand Up @@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using System;
using GopherServer.Core.Models;

namespace GopherServer.Providers.FileProvider
{
Expand All @@ -28,14 +29,13 @@ public DirectoryListingResult(string path, string baseDirectory)
this.Items.AddRange(files.Select(f =>
new DirectoryItem(this.GetItemType(f.FullName), f.Name, f.FullName.Replace(baseDirectory, string.Empty))));



}

private ItemType GetItemType(string fullName)
{
// TODO: Handle mapping these
return ItemType.FILE;
//return ItemType.FILE;
return Core.Helpers.FileTypeHelpers.GetItemTypeFromFileName(fullName);
}
}
}
Expand Up @@ -7,6 +7,7 @@
using GopherServer.Providers.MacintoshGarden.Results;
using GopherServer.Providers.MacintoshGarden.Models;
using System.Net;
using GopherServer.Core.Models;

namespace GopherServer.Providers.MacintoshGarden
{
Expand Down
@@ -1,4 +1,5 @@
using GopherServer.Core.Helpers;
using GopherServer.Core.Models;
using GopherServer.Core.Results;
using System;
using System.Collections.Generic;
Expand All @@ -15,7 +16,7 @@ public SearchResult(Models.SearchResults results)
this.Items.Add(new DirectoryItem("Search Results"));
this.Items.Add(new DirectoryItem("--------------"));

this.Items.Add(new DirectoryItem(ItemType.INDEXSEARCH, "New Search", "/search/"));
this.Items.Add(new DirectoryItem(Core.Models.ItemType.INDEXSEARCH, "New Search", "/search/"));

foreach (var result in results.Results)
{
Expand Down
@@ -1,4 +1,5 @@
using GopherServer.Core.Helpers;
using GopherServer.Core.Models;
using GopherServer.Core.Results;
using GopherServer.Providers.MacintoshGarden.Models;
using System;
Expand Down Expand Up @@ -38,7 +39,7 @@ public SoftwareResult(SoftwareItem item) : base()
foreach (var link in download.Links)
{
this.Items.Add(new DirectoryItem(link.Text + ":"));
this.Items.Add(new DirectoryItem(ItemType.BINHEX, download.Title, "BIN:" + link.Url));
this.Items.Add(new DirectoryItem(Core.Helpers.FileTypeHelpers.GetItemTypeFromFileName(link.Url), download.Title, "BIN:" + link.Url));
}
this.Items.Add(new DirectoryItem("Filesize: " + download.Size));
this.Items.Add(new DirectoryItem("OS: " + download.Os));
Expand Down
1 change: 1 addition & 0 deletions GopherServer.Providers.Rss/GopherResults/FeedItemResult.cs
Expand Up @@ -6,6 +6,7 @@
using System.ServiceModel.Syndication;
using System.Text;
using System.Threading.Tasks;
using GopherServer.Core.Models;

namespace GopherServer.Core.Rss.GopherResults
{
Expand Down
@@ -1,4 +1,5 @@
using GopherServer.Core.Results;
using GopherServer.Core.Models;
using GopherServer.Core.Results;
using GopherServer.Core.Rss.Data;
using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion GopherServer.Providers.Rss/GopherResults/FeedResult.cs
@@ -1,11 +1,11 @@
using GopherServer.Core.Results;
using GopherServer.Core.Helpers;
using GopherServer.Core.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GopherServer.Core.Models;

namespace GopherServer.Core.Rss.GopherResults
{
Expand Down
3 changes: 2 additions & 1 deletion GopherServer.Providers.Rss/RssController.cs
@@ -1,4 +1,5 @@
using GopherServer.Core.Results;
using GopherServer.Core.Models;
using GopherServer.Core.Results;
using GopherServer.Core.Rss.Data;
using GopherServer.Core.Rss.GopherResults;
using System;
Expand Down
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Threading.Tasks;
using WordPressRestApi.Models;
using GopherServer.Core.Models;

namespace GopherServer.Core.WpJson.Extensions
{
Expand Down
1 change: 1 addition & 0 deletions GopherServer.Providers.WpJson/WordPressClient.cs
@@ -1,4 +1,5 @@
using GopherServer.Core.Helpers;
using GopherServer.Core.Models;
using GopherServer.Core.Results;
using GopherServer.Core.WpJson.Extensions;
using HtmlAgilityPack;
Expand Down
19 changes: 18 additions & 1 deletion GopherServer/App.config
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="gopherFileMappings" type="GopherServer.Configuration.ExtensionMappingConfigSection, GopherServer" />
<section name="gopherFileMappings" type="GopherServer.Core.Configuration.ExtensionMappingConfigSection, GopherServer.Core" />
</configSections>
<appSettings>
<!-- What Address should the server listen on? -->
Expand Down Expand Up @@ -35,6 +35,8 @@
<!--<add key="providerName" value="GopherServer.Providers.MacintoshGarden" />-->

<add key="providerName" value="GopherServer.Providers.FileProvider" />

<add key="FileProvider.RootDirectory" value="J:\"/>

<!-- Temporary Provider Specific Configuration -->
<!-- TODO: each provider should be able to define their own config options -->
Expand All @@ -52,6 +54,17 @@
<add fileExtension=".1st" gopherType="FILE" />
<add fileExtension=".readme" gopherType="FILE" />
<add fileExtension=".log" gopherType="FILE" />

<add fileExtension=".pdf" gopherType="DOC" />
<add fileExtension=".doc" gopherType="DOC" />
<add fileExtension=".wps" gopherType="DOC" />
<add fileExtension=".docx" gopherType="DOC" />
<add fileExtension=".wp" gopherType="DOC" />
<add fileExtension=".wpd" gopherType="DOC" />
<add fileExtension=".wp7" gopherType="DOC" />
<add fileExtension=".wp6" gopherType="DOC" />
<add fileExtension=".wp5" gopherType="DOC" />
<add fileExtension=".wp4" gopherType="DOC" />

<!-- Images -->
<add fileExtension=".gif" gopherType="GIF" />
Expand Down Expand Up @@ -80,6 +93,8 @@
<add fileExtension=".pict" gopherType="IMAGE" />
<add fileExtension=".wmf" gopherType="IMAGE" />
<add fileExtension=".emf" gopherType="IMAGE" />
<add fileExtension=".eps" gopherType="IMAGE" />
<add fileExtension=".svg" gopherType="IMAGE" />


<add fileExtension=".exe" gopherType="BINARY" />
Expand All @@ -94,6 +109,7 @@
<add fileExtension=".hqx" gopherType="BINHEX" />
<add fileExtension=".sea" gopherType="BINARY" />

<!-- Html -->
<add fileExtension=".htm" gopherType="HTML" />
<add fileExtension=".html" gopherType="HTML" />

Expand All @@ -110,6 +126,7 @@
<add fileExtension=".opus" gopherType="AUDIO" />
<add fileExtension=".mid" gopherType="AUDIO" />
<add fileExtension=".rmi" gopherType="AUDIO" />

</gopherFileMappings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
Expand Down
4 changes: 4 additions & 0 deletions GopherServer/GopherServer.Server.csproj
Expand Up @@ -53,6 +53,10 @@
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GopherServer.Providers.FileProvider\GopherServer.Providers.FileProvider.csproj">
<Project>{42ed6433-c91a-449d-9cef-bf3c7f006ff0}</Project>
<Name>GopherServer.Providers.FileProvider</Name>
</ProjectReference>
<ProjectReference Include="..\GopherServer.Providers.MacintoshGarden\GopherServer.Providers.MacintoshGarden.csproj">
<Project>{cd67eecb-5262-4b8e-8a0a-05aba2e20c6b}</Project>
<Name>GopherServer.Providers.MacintoshGarden</Name>
Expand Down

0 comments on commit 5e9cce6

Please sign in to comment.