Friday, September 8, 2017

Govern CMS EDMX Diagram

I'm making good progress on my new Government Content Management System (Govern CMS).

Probably have another 1-2 weeks of development before I have a minimum viable product.

Here is my Entity Framework EDMX for that System:


Thursday, September 7, 2017

HTML Helpers - ASP.NET MVC's equivalent of JSTL Custom Taglibs

I have found the equivalent of Java's JSTL Custom Taglibs: HTML Helpers.

I started moving logic out of my Razor Views and into HTML Helper classes.

Here's my first, and it's a beauty (uses recursion to build out nested lists):


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
    public static class CategoryExtensions
    {
        public static IHtmlString CategoryDisplay(this HtmlHelper helper, IEnumerable<category> categories, int indentSize)
        {
            string indentString = "";
            for (int i = 0; i < indentSize; i++)
            {
                indentString += " ";
            }
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("<div class="\"dd\"" name="\"category-nestable\"" id="\"nestable\"">\n");
            stringBuilder.Append(BuildList(categories, indentString));
            stringBuilder.Append(indentString).Append("</div>");
            return new HtmlString(stringBuilder.ToString());
        }
 
        private static IHtmlString BuildList(IEnumerable<category> categories, string indentString)
        {
            StringBuilder stringBuilder = new StringBuilder();
 
            stringBuilder.Append(indentString).Append("  <ol class="\"dd-list\"">\n");
 
            foreach (Category category in categories)
            {
                stringBuilder.Append(indentString).Append("    <li class="\"dd-item\"" data-type="\"section\"" data-id="\""" +="" category.categoryid="" "\"="" id="\""">\n");
                stringBuilder.Append(indentString).Append("      <div class="\"dd-handle\"">\n");
                stringBuilder.Append(indentString).Append("        <span style="\"font-weight:" bold\"="">" + category.CategoryName + "</span>\n");
                stringBuilder.Append(indentString).Append("      </div>\n");
                if (category.SubCategories.Any())
                {
                    indentString += "  ";
                    stringBuilder.Append(BuildList(category.SubCategories, indentString));
                }
                stringBuilder.Append(indentString).Append("    </li>\n");
            }
            stringBuilder.Append(indentString).Append("  </ol>\n");
 
            return new HtmlString(stringBuilder.ToString());
        }
    }
</category></category>
I'm glad to get the logic out of the Razor views (which should not have such complex logic) and into proper C# classes.

Friday, September 1, 2017

Angular 4 node_modules

Wow ... I'm planning on building my Angular 4 App this weekend.  I am working through the tutorial and just had a moment of horror ...


217 MB for a JavaScript Framework?!  You've got to be kidding me.  

There are over 700 subdirectories under node_modules. 

Now, I did take a look at the HTML generated and it does not appear to reference node_modules.  I am going to see if I can get away with NOT deploying it.