ln.skyspot/http/SkySpotApplication.cs

47 lines
1.4 KiB
C#
Raw Normal View History

2019-04-24 07:13:56 +02:00
// /**
// * File: SkySpotApplication.cs
// * Author: haraldwolff
// *
// * This file and it's content is copyrighted by the Author and / or copyright holder.
// * Any use wihtout proper permission is illegal and may lead to legal actions.
// *
// *
// **/
using System;
using ln.http.resources;
2019-04-24 12:55:33 +02:00
using System.IO;
2019-04-24 07:13:56 +02:00
namespace skyspot.http
{
public class SkySpotApplication : ResourceApplication
{
2019-04-24 12:55:33 +02:00
public String TemplatePath { get; private set; }
2019-04-24 07:13:56 +02:00
public SkySpotApplication()
2019-04-24 12:55:33 +02:00
:this(Path.Combine(Environment.CurrentDirectory,"www"))
{}
public SkySpotApplication(String templatePath)
2019-04-24 07:13:56 +02:00
{
2019-04-24 12:55:33 +02:00
/* Development Shortcut */
if (Directory.Exists("../../www"))
templatePath = "../../www";
TemplatePath = Path.GetFullPath(templatePath);
DirectoryResource templates = new DirectoryResource(TemplatePath);
templates.ResourceTypeHook = ResourceTypeHook;
2019-04-26 08:15:12 +02:00
templates.DefaultResource = templates.GetResource("index.html");
2019-04-24 12:55:33 +02:00
RootResource = templates;
2019-04-24 07:13:56 +02:00
}
2019-04-24 12:55:33 +02:00
private Resource ResourceTypeHook(DirectoryResource directoryResource, FileInfo fileInfo)
{
if (fileInfo.Extension.Equals(".html"))
return new TemplateResource(directoryResource, fileInfo.FullName);
return null;
}
2019-04-24 07:13:56 +02:00
}
}