forked from Code52/pretzel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSiteContext.cs
84 lines (73 loc) · 2.38 KB
/
SiteContext.cs
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
namespace Pretzel.Logic.Templating.Context
{
public class SiteContext
{
private const string ExcerptSeparatorDefault = "<!--more-->";
private string engine;
private string title;
private string excerptSeparator = ExcerptSeparatorDefault;
public IDictionary<string, object> Config { get; set; }
public string SourceFolder { get; set; }
public string OutputFolder { get; set; }
public IEnumerable<Tag> Tags { get; set; }
public IEnumerable<Category> Categories { get; set; }
public IList<Page> Posts { get; set; }
public DateTime Time { get; set; }
public Boolean UseDrafts { get; set; }
public List<Page> Pages { get; set; }
public string Title
{
get
{
if(Config.Keys.Contains("title"))
{
title = Config["title"].ToString();
}
return title;
}
set { title = value; }
}
public string ExcerptSeparator
{
get
{
if (Config.Keys.Contains("excerpt_separator"))
{
excerptSeparator = Config["excerpt_separator"].ToString();
}
return excerptSeparator;
}
set { excerptSeparator = value; }
}
public string Engine
{
get
{
if (engine == null)
{
if (!Config.ContainsKey("pretzel"))
{
engine = string.Empty;
return engine;
}
var pretzelSettings = Config["pretzel"] as Dictionary<string, object>;
if (pretzelSettings != null && pretzelSettings.ContainsKey("engine"))
engine = (string)pretzelSettings["engine"];
else
engine = string.Empty;
}
return engine;
}
}
public SiteContext()
{
Tags = new List<Tag>();
Categories = new List<Category>();
Posts = new List<Page>();
Pages = new List<Page>();
Config = new Dictionary<string, object>();
}
}
}