~jpgleeson/piaine

68ae65db03422f9f5cee4659371a2e3b6e471b8a — jpgleeson 19 days ago 783f7bd
Tags

Tags are read from each file now, and a central store of them is kept. This needs to be pruned of duplicates next, and then for each one, run through each post to see if they're included on that tag page. Then generate that tag page.
4 files changed, 54 insertions(+), 1 deletions(-)

M PageConsumer.cs
M Post.cs
M Program.cs
M Variable.cs
M PageConsumer.cs => PageConsumer.cs +23 -0
@@ 13,6 13,7 @@ namespace piaine
        {
            variablesInPage = new List<Variable>();
            int currentLine = 0;
            TagParser tagparser;

            foreach (string s in inputLines)
            {


@@ 48,6 49,13 @@ namespace piaine
                    textParser textParser = new textParser();
                    v.literal = textParser.parseString(v.literal);
                }
                else if (v.name == "tags")
                {
                    TagCollectionVariable tagList;
                    tagList = new TagCollectionVariable(v.name, new List<string>());
                    tagparser = new TagParser();
                    tagList.literalList = tagparser.parseString(v.literal);
                }
            }
        }



@@ 90,5 98,20 @@ namespace piaine

            return DateTime.Today;
        }

        public List<string> getPageTags()
        {
            TagCollectionVariable tagList = new TagCollectionVariable();
            foreach (Variable v in variablesInPage)
            {
                if (v.name == "tags")
                {
                    tagList = new TagCollectionVariable(v.name, new List<string>());
                    TagParser tagparser = new TagParser();
                    tagList.literalList = tagparser.parseString(v.literal);
                }
            }
            return tagList.literalList;
        }
    }
}

M Post.cs => Post.cs +1 -0
@@ 10,6 10,7 @@ namespace piaine
        public DateTime date;
        public string path;
        public pageType typeOfPage;
        public List<string> tags;
    }

    public enum pageType

M Program.cs => Program.cs +10 -1
@@ 11,6 11,7 @@ namespace piaine
            string inputString = readTemplateFile("post.html");
            List<string> outputStrings = new List<string>();
            List<string> inputLines = new List<string>();
            List<string> tags = new List<string>();

            Scanner scanner = new Scanner(inputString);



@@ 63,7 64,10 @@ namespace piaine
                    post.typeOfPage = pageType.post;
                }


                if (post.tags != null)
                {
                    tags.AddRange(post.tags);
                }

                outputStrings = parser.writeVariablesInSource(inputString, pageConsumer.variablesInPage);



@@ 98,6 102,11 @@ namespace piaine

            buildAtomFile(posts);

            foreach (string s in tags)
            {
                Console.WriteLine(s);
            }

            Console.WriteLine("Files generated. Press any key to exit.");

            Console.ReadKey();

M Variable.cs => Variable.cs +20 -0
@@ 9,10 9,30 @@ namespace piaine
        public string name;
        public string literal;

        public Variable()
        {

        }

        public Variable(string desName, string desLiteral)
        {
            name = desName;
            literal = desLiteral;
        }
    }

    public class TagCollectionVariable : Variable
    {
        public List<string> literalList;

        public TagCollectionVariable()
        {

        }
        public TagCollectionVariable(string desName, List<string> desList)
        {
            name = desName;
            literalList = desList;
        }
    }
}