-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_PageStart.cshtml
More file actions
48 lines (40 loc) · 1.58 KB
/
_PageStart.cshtml
File metadata and controls
48 lines (40 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@using System.Xml.Linq
@using System.Xml
@using System.Web.Optimization
@{
//intialize variables
var hostUrl = Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
var currentUrl = Request.Url.GetComponents(UriComponents.AbsoluteUri, UriFormat.Unescaped);
int userCount = 0;
//load xml
var load = new Comic();
var account = load.LoadComic("/App_Data/account.xml");
var settings = load.LoadComic("/App_Data/WebcomicX.xml");
var bundles = BundleTable.Bundles;
var themeCss = "";
var themeScript = "";
BundleTable.EnableOptimizations = true;
try {
var theme = settings.Descendants("Settings").Descendants("Theme").ElementAt(0).Value;
if (HttpContext.Current.Request["theme"] != null) {
theme = HttpContext.Current.Request["theme"];
}
themeScript = "~/content/themes/" + theme + "/scripts/";
themeCss = "~/content/themes/" + theme + "/styles/";
bundles.Add(new StyleBundle(themeCss + "css").IncludeDirectory(
themeCss, "*.css"));
bundles.Add(new ScriptBundle(themeScript + "js").IncludeDirectory(themeScript, "*.js"));
} catch {
}
//count the number of accounts for this webcomic
foreach (var user in account.Descendants("User")) {
userCount++;
}
//if their are no accounts send user to setup page
if (userCount <= 0) {
var accountUrl = hostUrl + VirtualPathUtility.ToAbsolute("~/webcomicx/admin/account/setup");
if (currentUrl != accountUrl) {
Response.Redirect(accountUrl);
}
}
}