Package: webstaterator
webstateratorAjinja2powered static website generator that generates pages based on a JSON data models.Why?I wanted to convert myPHPwebsites to static sites to save money but could not find a python based tool that allowed me to use a data model to do so.Why the stupid name?I needed a name to create the repo, a friend suggestedwebstaterator. Good work Sasha!InstallpipinstallwebstateratorRunningWebstaterator is available via the CLI usingwebstaterator. Help can be found usingwebstaterator -hModesActionInfoArgumentsExampleVerifyCheck that a website setup is correct-w,--website-  website.jsonwebstaterator verify -w website.jsonBuildBuild a website-w,--website- website json.-o,--output- output directorywebstaterator -w website.json -o build/TemplateGenerate a template for a website-o,--output- output directorywebstaterator template -o website/Website jsonThe website description JSON powerswebstaterator. It can be used to describe two types of page, a standard page and a list page.A standard page simply takes ajinja2template, a file name, and an option data model and outputs a page.A list page  on top of the standard page attributes, specifies a target element within the data model. This will result in a page for every child element targeted in the list page.Format{"name":"my example website","model":"model.json","template":"templates/","assets":["images"],"pages":[{"name":"index","template":"main.html","filename":"index.html"}]}name:The name of the websitemodel [optional]:The path to a json objecttemplate:The path to a directory containing a set ofjinja2template filesassets [optional]:One or more directories to be copied into the build folder. This can be things like images, CSS, or JavaScriptpages:An array of pages see below for more detailsBasic Pagesname:Name of the page, can be used to access the URL on other pages or check which page is currently being renderedtemplate:Thejinja2template file (found in the provided template directory)filename:The name of the output file. This is the file name use on the live siteList Pagesname:Name of the page, can be used to access the URL on other pages or check which page is currently being renderedtemplate:Thejinja2template file (found in the provided template directory)filename:The name of the output file. This is the file name use on the live site. Unlike a basic page a list filenamemustinclude{}so that a unique filename can be created for every item in the listlist:The dot delimited path to the target array or dictionary within the provided data model.id [optional]:If the target of list is an array useidto specify the child attribute to use as an id.List example targeting a dictionaryGiven the following data model{"example":{"people":{"Chris":{"height":6.1,"age":34,"face":"ugly"},"Steve":{"height":5.11,"age":40,"face":"round"},"Karen":{"height":5.2,"age":38,"face":"trapazoid"}}}}and the page"pages":[{"name":"people","template":"people.html","filename":"person-{}.html","list":"example.people"}]the output would beperson-Chris.htmlperson-Steve.htmlperson-Karen.htmlwhen generating each page the value in the dictionary will be made available via thetargetvariable. So when renderingperson-Chris.htmlthe following will be available to the templatepeople.html:-{"height":6.1,"age":34,"face":"ugly"}List example targeting an arrayThe same example would look like this if we used an array instead of a dictionary{"example":{"people":[{"name":"Chris","height":6.1,"age":34,"face":"ugly"},{"name":"Steve","height":5.11,"age":40,"face":"round"},{"name":"Karen","height":5.2,"age":38,"face":"trapazoid"}]}}and the page"pages":[{"name":"people","template":"people.html","filename":"person-{}.html","list":"example.people","id":"name"}]Notice this time we need to include an id to specify which attribute to use as an id.the output for the above would beperson-Chris.htmlperson-Steve.htmlperson-Karen.htmlTemplatesEachjinja2template will have access to the following variables :-links- A dict of links with page name as key and an array of URLs as the valuepage_link- The URL for the current pagemodel- The JSON file loaded described in the website JSON if providedIf the page is a list page the template will also have access to :-target- The child data element found in model that is linked to this list page.Custom formattersjinja2supportscustom filters. The following custom filters are available inwebstaterator.filterpurposeargumentsdefaultsexampledate_fmtFormatsdate objects and stringsdate_format, date_in_format%d %b %y,%Y-%m-%d{{ event["start"]|date_fmt("%b %Y") }}markdown_fmtConverts markdown string to HTML5nonenone{{ event["blurb"]|markdown_fmt }}