migrate to new git
This commit is contained in:
83
web/App_Code/Sites.cs
Normal file
83
web/App_Code/Sites.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
/// <summary>
|
||||
/// Summary description for Sites
|
||||
/// </summary>
|
||||
public static class Sites
|
||||
{
|
||||
public static List<Site> sites = new List<Site>();
|
||||
public static SiteResource resource = new SiteResource();
|
||||
private static string appurl
|
||||
{
|
||||
get
|
||||
{
|
||||
return HttpContext.Current.Server.MapPath("~");
|
||||
}
|
||||
}
|
||||
private static string site_host
|
||||
{
|
||||
get
|
||||
{
|
||||
string host = HttpContext.Current.Request.Url.Host;
|
||||
string r = "default";
|
||||
var h = sites.FirstOrDefault(q=>q.url == host);
|
||||
if (h != null) { r = h.folder; }
|
||||
return r;
|
||||
}
|
||||
}
|
||||
private static string site_root
|
||||
{
|
||||
get
|
||||
{
|
||||
string r = "";
|
||||
r = appurl;
|
||||
return HttpContext.Current.Server.MapPath("~");
|
||||
}
|
||||
}
|
||||
public static double MaxAge = 3600 * 24 * 365;
|
||||
static Sites()
|
||||
{
|
||||
JObject o=get_jsonfile(@"sites\sites-config.json");
|
||||
sites = o["sites"].ToObject<List<Site>>();
|
||||
resource = o["resource"].ToObject<SiteResource>();
|
||||
//resource.Add(new KeyValuePair<string, string>("assets", "assets"));
|
||||
//resource.Add(new KeyValuePair<string, string>("config", "config"));
|
||||
}
|
||||
private static JObject get_jsonfile(string jsonfile)
|
||||
{
|
||||
JObject o;
|
||||
//string appurl = HttpContext.Current.Server.MapPath("~");
|
||||
string path = Path.Combine(appurl, jsonfile);
|
||||
o = JObject.Parse(File.ReadAllText(path));
|
||||
return o;
|
||||
}
|
||||
public static string get_url(string path, string url)
|
||||
{
|
||||
string r="";
|
||||
char s = Path.DirectorySeparatorChar;
|
||||
url = url.Replace('/', s);
|
||||
r = $@"{appurl}sites{s}{site_host}{s}{path}{s}{url}";
|
||||
return r;
|
||||
}
|
||||
|
||||
}
|
||||
public class Site
|
||||
{
|
||||
public string url { get; set; }
|
||||
public string folder { get; set; }
|
||||
public string connection { get; set; }
|
||||
public string title { get; set; }
|
||||
}
|
||||
public class SiteResource
|
||||
{
|
||||
public string assets { get; set; }
|
||||
public string config { get; set; }
|
||||
public string modules { get; set; }
|
||||
public string upload { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user