NTP Analyzer  0.8.2
Analyze the operation of time servers
BootstrapPageRender.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System;
23 using System.Text;
24 
25 namespace Ntp.Analyzer.Render
26 {
27  public abstract class BootstrapPageRender : HtmlObjectRender
28  {
29  protected BootstrapPageRender(Uri webPath, string title)
30  : base(webPath)
31  {
32  Title = title;
33  }
34 
35  protected virtual string Title { get; }
36 
37  public override string Render()
38  {
39  var builder = new StringBuilder();
40 
41  builder.AppendLine("<body>");
42  builder.Append(RenderPageBody());
43 
44  return builder.ToString();
45  }
46 
47  public override string RenderFooter()
48  {
49  var builder = new StringBuilder();
50 
51  builder.Append(RenderPageFooter());
52 
53  builder.AppendLine(this.AppendWithWebpath(
54  @" <script src=""{0}{1}""></script>",
55  "js/jquery.js"));
56 
57  builder.AppendLine(this.AppendWithWebpath(
58  @" <script src=""{0}{1}""></script>",
59  "js/bootstrap.min.js"));
60 
61  builder.AppendLine("</body>");
62  builder.AppendLine("</html>");
63 
64  return builder.ToString();
65  }
66 
67  public override string RenderHead()
68  {
69  var builder = new StringBuilder();
70 
71  builder.AppendLine("<!DOCTYPE html>");
72  builder.AppendLine(@"<html lang=""en""><head>");
73  builder.AppendLine(@" <meta charset=""UTF-8"">");
74  builder.AppendLine(@" <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">");
75 
76  builder.Append(" <title>");
77  builder.Append(Title);
78  builder.AppendLine("</title>");
79 
80  builder.AppendLine(this.AppendWithWebpath(
81  @" <link href=""{0}{1}"" rel=""stylesheet"" media=""screen"">",
82  "css/bootstrap.min.css"));
83 
84  builder.Append(RenderPageHead());
85 
86  builder.AppendLine("</head>");
87 
88  return builder.ToString();
89  }
90 
91  protected abstract string RenderPageBody();
92 
93  protected abstract string RenderPageFooter();
94 
95  protected abstract string RenderPageHead();
96  }
97 }
BootstrapPageRender(Uri webPath, string title)