Package: easel
EaselShowcasing work for the lazy. Built on Flask, YAML, Markdown and directories.InstallationCreate an environmentCreate a project directory and a venv directory within:$mkdirmy-easel
$cdmy-easel
$python3-mvenvvenvActivate the environmentBefore you work on your project, activate the corresponding environment:$sourcevenv/bin/activateYour shell prompt will change to show the name of the activated environment.Install EaselWithin the activated environment, use the following command to install Easel:$pipinstalleaselEasel is now installed.A Lazy SiteCreate a siteCreate a site directory and asite.yamlfile:$mkdirmy-site
$cdmy-site
$touchsite.yamlAdd the following to thesite.yamlfile:# my-easel/my-site/site.yamltitle:my-easelfavicon:year:2020name:My Namepage:width:colors:accent-base:accent-light:menu:width:align:header:label:my-easelimage:path:width:height:items:-type:link-pagelabel:my-pagelinks-to:my-pageEvery site requires asite.yamlin the site's root directory. It's used to configure general site attributes namely the menu. Note that none of the items require a value, however all the itemsmustbe present. For example,menu:itemscan be an empty list, Easel will render no menu in this case. However ifmenu:itemsis missing aConfigErrorwill be thrown.Note that undermenu:itemswe have a single item with the attributelinks-toset tomy-page. This is a path relative to thepagesdirectory referring to the directorymy-pagewe will be making shortly. Note thatlinks-toalways requires a path relative to thepagesdirectory.Our Easel directory should now look like this:my-easel
├──my-site
│└──site.yaml
└──venvCreate a pageCreate a page directory and apage.yamlfile:$mkdirmy-page
$cdmy-page
$touchpage.yamlAdd the following to thepage.yamlfile:# my-easel/my-site/my-page/page.yaml# Lazy Page# Specify this page is the 'landing' page.is-landing:true# Page type.type:lazy# Lazy Page options.options:show-captions:trueEach page directorymustcontain apage.yamlfile. In the same way thatsite.yamlconfigures the site,page.yamlconfigures the page. For this page we will do the laziest thing possible, create aLazypage. This particular type of page auto populates its contents from the contents of its respective folder sorted alphabetically by the absolute path of each item.Our Easel directory should now look like this:my-easel
├──my-site
│├──site.yaml
│└──pages
│└──my-page
│└──page.yaml
└──venvNow make sure to add some content: images, videos etc to themy-pagedirectory:my-easel
├──my-site
│├──site.yaml
│└──pages
│└──my-page
│├──page.yaml
│├──image-01.jpg
│├──image-02.jpg
│├──video.mp4
│└──...
└──venvA Minimal ApplicationA minimal Easel application looks something like this:fromeaselimportEaseleasel=Easel("my-site")if__name__=="__main__":easel.run()Note thatmy-siterefers to the directorymy-site. We're providing a relative path here, telling Easel that our site directory is in the same directory as our application.Now save it asrun.pyin yourmy-easeldirectory next to yourmy-sitedirectory.Finally, our Easel directory should look like this:my-easel
├──run.py
├──my-site
│├──site.yaml
│└──pages
│├──my-page
││├──page.yaml
││├──image-001.jpg
││├──image-002.jpg
││└──...
│└──...
└──venvTo run the application simply run the script.$pythonrun.py*Runningonhttp://127.0.0.1:5000/So what did that code do?First we imported the Easel class. An instance of this class will hold our Flask application.Next we create an instance of this class. The first argument is the path to the directory containing your site along with its config files, pages and contents.Finally we placeeasel.run()in a guard statement so we can run a local development server when we directly run our script.This launches a very simple builtin server, which is good enough for testing but probably not what you want to use in production. For deployment options seeFlask Deployment Options.Now head over tohttp://127.0.0.1:5000/, and you should see your beautiful work greeting.APICustom Types# Import Easel's Page, Menu and Content factories.fromeasel.site.pagesimportpage_factoryfromeasel.site.menusimportmenu_factoryfromeasel.site.contentsimportcontent_factory# Import your custom types.from.customimportCustomPage,CustomMenu,CustomContent# Register your custom types.page_factory.register_page_type("custom-page",CustomPage)menu_factory.register_menu_type("custom-menu",CustomMenu)content_factory.register_content_type("custom-content",CustomContent)Custom Assets (templates & static files)easel=Easel(site="my-site",custom_assets="my-custom-assets",)The assets directorymustfollow the following structure.my-custom-assets
│
├──templates
│├──page.jinja2
│└──...
│
└──static├──css├──js├──fonts└──imagesAdditionally it must contain apage.jinja2template in thetemplatesdirectory. This is the entry-point for rendering pages. Seeeasel.main.views.render_pageandeasel.main.views.page_landing.Links / ResourcesReleases:https://pypi.org/project/easel/Flask documentation:https://github.com/pallets/flask