diff --git a/.vs/BlogParser/FileContentIndex/1cd3514f-7afd-4670-96b9-96bbf392a542.vsidx b/.vs/BlogParser/FileContentIndex/1cd3514f-7afd-4670-96b9-96bbf392a542.vsidx new file mode 100644 index 0000000..f07b066 Binary files /dev/null and b/.vs/BlogParser/FileContentIndex/1cd3514f-7afd-4670-96b9-96bbf392a542.vsidx differ diff --git a/.vs/BlogParser/FileContentIndex/3bbff7f7-41b6-444c-8751-8616f6d237da.vsidx b/.vs/BlogParser/FileContentIndex/3bbff7f7-41b6-444c-8751-8616f6d237da.vsidx new file mode 100644 index 0000000..94044e9 Binary files /dev/null and b/.vs/BlogParser/FileContentIndex/3bbff7f7-41b6-444c-8751-8616f6d237da.vsidx differ diff --git a/.vs/BlogParser/FileContentIndex/b8706520-615a-4af1-ae24-0315e08d7f5a.vsidx b/.vs/BlogParser/FileContentIndex/b8706520-615a-4af1-ae24-0315e08d7f5a.vsidx new file mode 100644 index 0000000..1ffb30e Binary files /dev/null and b/.vs/BlogParser/FileContentIndex/b8706520-615a-4af1-ae24-0315e08d7f5a.vsidx differ diff --git a/.vs/BlogParser/FileContentIndex/e91363f2-4075-4743-9674-e806d72db9b2.vsidx b/.vs/BlogParser/FileContentIndex/e91363f2-4075-4743-9674-e806d72db9b2.vsidx new file mode 100644 index 0000000..27719ce Binary files /dev/null and b/.vs/BlogParser/FileContentIndex/e91363f2-4075-4743-9674-e806d72db9b2.vsidx differ diff --git a/.vs/BlogParser/FileContentIndex/read.lock b/.vs/BlogParser/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 diff --git a/.vs/BlogParser/v17/.suo b/.vs/BlogParser/v17/.suo new file mode 100644 index 0000000..b4e841e Binary files /dev/null and b/.vs/BlogParser/v17/.suo differ diff --git a/.vs/BlogParser/v17/Browse.VC.db b/.vs/BlogParser/v17/Browse.VC.db new file mode 100644 index 0000000..a9c8f08 Binary files /dev/null and b/.vs/BlogParser/v17/Browse.VC.db differ diff --git a/.vs/BlogParser/v17/TestStore/0/000.testlog b/.vs/BlogParser/v17/TestStore/0/000.testlog new file mode 100644 index 0000000..062657a Binary files /dev/null and b/.vs/BlogParser/v17/TestStore/0/000.testlog differ diff --git a/.vs/BlogParser/v17/TestStore/0/testlog.manifest b/.vs/BlogParser/v17/TestStore/0/testlog.manifest new file mode 100644 index 0000000..e92ede2 Binary files /dev/null and b/.vs/BlogParser/v17/TestStore/0/testlog.manifest differ diff --git a/.vs/BlogParser/v17/ipch/AutoPCH/6cbd321b1e94c6df/BLOGPARSER.ipch b/.vs/BlogParser/v17/ipch/AutoPCH/6cbd321b1e94c6df/BLOGPARSER.ipch new file mode 100644 index 0000000..aadb8c1 Binary files /dev/null and b/.vs/BlogParser/v17/ipch/AutoPCH/6cbd321b1e94c6df/BLOGPARSER.ipch differ diff --git a/.vs/BlogParser/v17/ipch/AutoPCH/866249b749aa1001/PAGEFACTORY.ipch b/.vs/BlogParser/v17/ipch/AutoPCH/866249b749aa1001/PAGEFACTORY.ipch new file mode 100644 index 0000000..0bb0992 Binary files /dev/null and b/.vs/BlogParser/v17/ipch/AutoPCH/866249b749aa1001/PAGEFACTORY.ipch differ diff --git a/.vs/BlogParser/v17/ipch/AutoPCH/a56a7e3530802310/INLINECODE.ipch b/.vs/BlogParser/v17/ipch/AutoPCH/a56a7e3530802310/INLINECODE.ipch new file mode 100644 index 0000000..10d69aa Binary files /dev/null and b/.vs/BlogParser/v17/ipch/AutoPCH/a56a7e3530802310/INLINECODE.ipch differ diff --git a/.vs/BlogParser/v17/ipch/AutoPCH/b48ea63bfebfe7e9/COMPONENT.ipch b/.vs/BlogParser/v17/ipch/AutoPCH/b48ea63bfebfe7e9/COMPONENT.ipch new file mode 100644 index 0000000..415adff Binary files /dev/null and b/.vs/BlogParser/v17/ipch/AutoPCH/b48ea63bfebfe7e9/COMPONENT.ipch differ diff --git a/.vs/BlogParser/v17/ipch/AutoPCH/bdd51d36c69bbf94/COMPONENTLIST.ipch b/.vs/BlogParser/v17/ipch/AutoPCH/bdd51d36c69bbf94/COMPONENTLIST.ipch new file mode 100644 index 0000000..97b19c6 Binary files /dev/null and b/.vs/BlogParser/v17/ipch/AutoPCH/bdd51d36c69bbf94/COMPONENTLIST.ipch differ diff --git a/.vs/BlogParser/v17/ipch/AutoPCH/d0882f356aa8fe85/HEADER.ipch b/.vs/BlogParser/v17/ipch/AutoPCH/d0882f356aa8fe85/HEADER.ipch new file mode 100644 index 0000000..01e8e7b Binary files /dev/null and b/.vs/BlogParser/v17/ipch/AutoPCH/d0882f356aa8fe85/HEADER.ipch differ diff --git a/BlogParser.aps b/BlogParser.aps new file mode 100644 index 0000000..43c304f Binary files /dev/null and b/BlogParser.aps differ diff --git a/BlogParser.cpp b/BlogParser.cpp new file mode 100644 index 0000000..ad40aca --- /dev/null +++ b/BlogParser.cpp @@ -0,0 +1,33 @@ +#include +#include "PageFactory.h" + +int main() +{ + PageFactory* pageFactory = new PageFactory(); + + pageFactory->buildPage("#Hello world"); + + std::cout << pageFactory->getPage(); +} + +/** +* ####### The Plan ####### +* We have a factory, this contains a dictionary with a reference to a load of static objects(?) +* This dictionary is built on startup, each object has a start and end tag and the dictionary holds both +* (its given these on build) +* The factory goes through a given text fileand for each character, checks if its in the dictionary, +* if it is we call that object and pass it all the text until its end char. It will then produce +* output html that is stored in the factory as that page. +* +* Main issues with this: +* We cant have components of a page inside each other :( +* We'll deal with this later +* +* Also, are we building this page on each request? if so how does the user request a file that doesnt exist? +* I guess these are questions for oat++ to answer +*/ + +/* +BIG ISSUE: +we need our identifiers to be char[]'s since we have things like ## which is more than one char. +*/ \ No newline at end of file diff --git a/BlogParser.sln b/BlogParser.sln new file mode 100644 index 0000000..ab50e0c --- /dev/null +++ b/BlogParser.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32901.215 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlogParser", "BlogParser.vcxproj", "{8691FEF7-3635-4958-8DE1-70B3A0D439E5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Debug|x64.ActiveCfg = Debug|x64 + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Debug|x64.Build.0 = Debug|x64 + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Debug|x86.ActiveCfg = Debug|Win32 + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Debug|x86.Build.0 = Debug|Win32 + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Release|x64.ActiveCfg = Release|x64 + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Release|x64.Build.0 = Release|x64 + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Release|x86.ActiveCfg = Release|Win32 + {8691FEF7-3635-4958-8DE1-70B3A0D439E5}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {70669855-DF9B-4D65-9364-ED1AFEACF708} + EndGlobalSection +EndGlobal diff --git a/BlogParser.vcxproj b/BlogParser.vcxproj new file mode 100644 index 0000000..bfaca51 --- /dev/null +++ b/BlogParser.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {8691fef7-3635-4958-8de1-70b3a0d439e5} + BlogParser + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BlogParser.vcxproj.filters b/BlogParser.vcxproj.filters new file mode 100644 index 0000000..9bfcd86 --- /dev/null +++ b/BlogParser.vcxproj.filters @@ -0,0 +1,51 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {99991709-bfaf-4089-ba9a-66292f776f3e} + + + {c445922c-4e2c-45ee-91eb-0f1d01e4d42c} + + + + + Source Files + + + Source Files + + + Source Files\Components + + + Source Files\Components + + + + + Header Files + + + Header Files + + + Header Files\Components + + + Header Files + + + \ No newline at end of file diff --git a/BlogParser.vcxproj.user b/BlogParser.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/BlogParser.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Component.cpp b/Component.cpp new file mode 100644 index 0000000..0cc69a8 --- /dev/null +++ b/Component.cpp @@ -0,0 +1 @@ +#include "Component.h" diff --git a/Component.h b/Component.h new file mode 100644 index 0000000..a918e0c --- /dev/null +++ b/Component.h @@ -0,0 +1,10 @@ +#pragma once +class Component +{ +public: + char startIdentifier; + char endIdentifier; + + virtual std::string generateHTML(std::string markDown); +}; + diff --git a/ComponentList.h b/ComponentList.h new file mode 100644 index 0000000..a6d6128 --- /dev/null +++ b/ComponentList.h @@ -0,0 +1,7 @@ +#pragma once +#include +#include "Component.h" + +std::vector componentList = { + +}; \ No newline at end of file diff --git a/Header.cpp b/Header.cpp new file mode 100644 index 0000000..488141f --- /dev/null +++ b/Header.cpp @@ -0,0 +1,6 @@ +#include "Header.h" + +std::string Header::generateHTML(std::string markDown) +{ + return "

" + markDown + "

"; +} \ No newline at end of file diff --git a/Header.h b/Header.h new file mode 100644 index 0000000..895021f --- /dev/null +++ b/Header.h @@ -0,0 +1,8 @@ +#pragma once +#include +#include "Component.h" +class Header : public Component +{ + std::string generateHTML(std::string markDown); +}; + diff --git a/PageFactory.cpp b/PageFactory.cpp new file mode 100644 index 0000000..9055ac5 --- /dev/null +++ b/PageFactory.cpp @@ -0,0 +1,48 @@ +#include "PageFactory.h" + +PageFactory::PageFactory() +{ + // generate component dictionary + for (Component component : componentList) + { + componentDictionary.push_back({ component.startIdentifier, &component }); + } +} + +void PageFactory::buildPage(std::string markDown) +{ + Component* currentComponent; + + bool readingChunk = false; + std::string currentChunk; + /* + Something worth noting here is that we dont pass the start + and end identifier into the component. + */ + for (char character : markDown) + { + if (readingChunk) + { + if (character == currentComponent->endIdentifier) + { + finalPage = currentComponent->generateHTML(currentChunk); + readingChunk = false; + currentChunk = ""; + } + else + { + currentChunk.push_back(character); + } + } + else + { + // search dictionary to find a component + // if found, get component, set readingChunk to true + } + } +} + +std::string PageFactory::getPage() +{ + return finalPage; +} \ No newline at end of file diff --git a/PageFactory.h b/PageFactory.h new file mode 100644 index 0000000..7494bb4 --- /dev/null +++ b/PageFactory.h @@ -0,0 +1,25 @@ +#pragma once +#include +#include +#include "Component.h" +#include "ComponentList.h" +#include + +class PageFactory +{ + struct ComponentDictItem + { + char identifier; + Component* component; + }; + + std::vector componentDictionary; + + std::string finalPage; + +public: + PageFactory(); + void buildPage(std::string markDown); + std::string getPage(); +}; + diff --git a/resource.h b/resource.h new file mode 100644 index 0000000..64ce827 --- /dev/null +++ b/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by BlogParser.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif