Git Product home page Git Product logo

waylonwalker / markata Goto Github PK

View Code? Open in Web Editor NEW
90.0 3.0 6.0 1.99 MB

A plugins all the way down static site generator written in python. Plugins all the way down means that you can completely change the behavior of how it works by swapping plugins, installing new ones, or creating your own all in python.

Home Page: https://markata.dev

License: MIT License

Python 66.44% HTML 13.19% JavaScript 1.58% XSLT 10.40% Jinja 8.38%
markata static-site-generator markdown hacktoberfest

markata's Introduction


Markata

Markdown to site, plugins all the way down

A static site generator that will give you a great site with many standard web features like rss, sitemaps, and seo tags, out of the box. Running markata build will get you a that only requires you to write Markdown. If you have additional features that you want, don't worry, since markata is built completely on plugins you can develop and install your own plugins to add the features you want.

This has been a pet project for me to learn library development, plugin driven design, diskcache, and more. It is the core of what builds my own site waylonwalker.com.

UPCOMING NEXT RELEASE

The next release will be jinja filled. Out with all the single file templates, template strings, looping through card generation, we will have a proper jinja env with includes, bases, and all the things. It will be much easier to maintain and render faster.

Disclaimer

Make sure that you pin down what version of markata you want to use. If you are starting a new project that's probably the latest version from pypi. Things are likely to change in major releases, I do my best to document them, and not to break patches.

QuickStart

Markata is fully configurable through a markata.toml file, but the defaults allow to build your site right out of the box with nothing more than Markdown.

Installation

markata is hosted on pypi and can be installed using pip.

python -m pip install markata

Create Some Content

Make some .md files in your current working directory. By default, markata will recursively look in all subdirectories for markdown files **/*.md.

mkdir pages
echo '# My First Post' > first-post.md
echo '# Hello World' > hello-world.md

This example shows how you can build a site from only a single markdown file.

Build your site

Install markata into your virtual environment and run markata build. It will create your site in ./markout, leave its cache in ./.markata.cache, and copy all assets from ./static into ./markout by default.

python -m pip install markata
markata build

# or if pipx is your thing
pipx run markata build

Building a Blog with Markata using a template

The markata cli includes a new command that will present you with questions to fill in the jinja variables in this repo.

markata new blog [directory]

# start the site and watch for changes
hatch run tui

Now if you open localhost:8000, you will be presented with an example site that will walk you through some features of markata. You can play with it at your own pace, or drop all the pages and start writing your own content.

Motivation

Markata is able to build your site purely from Markdown, allowing you to get started creating your own content quickly. Out of the box it will cover your seo tags, rss feeds, sitemap, and og images. Since it is built completely from plugins you can remove, modify, or add to any of its behavior.

  • configurable
  • plugins
  • seo
  • rss
  • sitemap
  • og-image

Using Markata

The docs are still a work in progress, but the base_cli walks through how to effectively use the markata build command. At this point Markata is far from stable and will change quite a bit, should you choose to use it on real site make sure you pin to the version that you want to build from. I will let you know as it becomes more stable and ready to use without diligence of pinning to the version you want.

Honestly A big motivation for me was wanting to learn and understand how to create a project that is completely plugin driven. This is highly a learning project for me, and it has grown into something I use every day.

Examples Gallary

Markata has a project gallery to show off sites built with markata. Please submit yours, and check out the project-gallery for inspiration.

markata's People

Contributors

davep avatar mmngreco avatar mr-destructive avatar waylonwalker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

markata's Issues

Cli to fork templates

Make a cli to copy the existing default templates into a templates directory, and activate it in markata.toml.

Automatically create feeds for tags

Talking to pypeaday, it seems confusing out of the box that markata does not create feeds for each tag.

I need to think through ideas on how to make this happen in configuration to make it generally useful. You could make a custom hook on your own site to automate this, but generically inside markata its hard for me to know what keys will be in your front matter and what keys you want to create feeds for.

Here is some example configuration options.

# proposed config, not real

[markata.feeds]
feed_for_each='tags'

[markata.feeds]
feed_for_each=['tags']

"hatch run tui" seems to be broken.

"hatch run tui" seems to be broken.

Issue produced on windows 10 as shows below.

`PS C:\Users\user\tmp\markata> pip show markata
Name: markata
Version: 0.5.2
Summary: Static site generator plugins all the way down.
Home-page:
Author:
Author-email: Waylon Walker [email protected], [email protected]
License: Copyright (c) 2012-2022 Waylon Walker

    Permission is hereby granted, free of charge, to any person obtaining
    a copy of this software and associated documentation files (the
    "Software"), to deal in the Software without restriction, including
    without limitation the rights to use, copy, modify, merge, publish,
    distribute, sublicense, and/or sell copies of the Software, and to
    permit persons to whom the Software is furnished to do so, subject to
    the following conditions:

    The above copyright notice and this permission notice shall be
    included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Location: c:\users\user\appdata\local\programs\python\python39\lib\site-packages
Requires: anyconfig, beautifulsoup4, checksumdir, cookiecutter, copier, deepmerge, diskcache, feedgen, jinja2, more-itertools, pathspec, pillow, pluggy, pymdown-extensions, python-frontmatter, python-slugify, pytz, rich, textual, toml, typer
Required-by:
PS C:\Users\user\tmp\markata> pip show textual
Name: textual
Version: 0.3.0
Summary: Modern Text User Interface framework
Home-page: https://github.com/Textualize/textual
Author: Will McGugan
Author-email: [email protected]
License: MIT
Location: c:\users\user\appdata\local\programs\python\python39\lib\site-packages
Requires: importlib-metadata, nanoid, rich, typing-extensions
Required-by: markata
PS C:\Users\user\tmp\markata> hatch.exe run tui
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\user\AppData\Local\hatch\env\virtual\testing-markata\amOosx_h\testing-markata\lib\sit │
│ e-packages\markata\plugins\tui.py:55 in tui │
│ │
│ 52 def cli(app, markata): │
│ 53 │ @app.command() │
│ 54 │ def tui(): │
│ ❱ 55 │ │ MarkataApp.run(log="textual.log") │
│ 56 │
│ 57 │
│ 58 if name == "main": │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: run() got an unexpected keyword argument 'log'`

Tracebacks are way too long

Tracebacks often get deep into the frameworks that markata is built upon, pluggy, click, typer, It would be nice to suppress these.

RSS and Feeds should be merged

The existing rss plugin is quite rigid due to being one of the first plugins built into markata. What would be really nice is to automatically make RSS feeds for each feed, with the option to turn off HTML or RSS.

Example existing feeds config

The existing feeds plugin allows you to create feeds from a filter, template, and card_template

[markata.feeds]
template="pages/templates/archive_template.html"
card_template="plugins/feed_card_template.html"

[markata.feeds.archive]
filter="date<=today and templateKey in ['blog-post', 'til'] and status.lower()=='published'"
[markata.feeds.blog]
filter="date<=today and templateKey in ['blog-post'] and status.lower()=='published'"
[markata.feeds.draft]
filter="status=='draft'"

After building you will end up with this kind of directory structure.

├── markout
│   ├── 404.html
│   ├── archive
│   │       └── index.html
│   ├── blog
│   │       └── index.html
│   ├── draft
│   │       └── index.html

Future state

Allow configurable turning RSS and HTML feeds on in configuration.

[markata.feeds]
template="pages/templates/archive_template.html"
card_template="plugins/feed_card_template.html"
rss=true
html=true

[markata.feeds.archive]
filter="date<=today and templateKey in ['blog-post', 'til'] and status.lower()=='published'"
[markata.feeds.blog]
filter="date<=today and templateKey in ['blog-post'] and status.lower()=='published'"
html=false
[markata.feeds.draft]
filter="status=='draft'"
rss=false
├── markout
│   ├── 404.html
│   ├── archive
│   │       ├── index.html
│   │       └── rss.xml
│   ├── blog
│   │       └── rss.xml
│   ├── draft
│   │       └── index.html

Auto Linker plugin

It would be nice to have a set of keywords to be able to automatically link to resources, but only if its in plain text. i.e. not in code or fenced blocke

clean up __init__

It all started so simple with just one file and plugins, now there is way too much in the top level API, lets clean this up before anyone depends on something they shouldn't.

Broken Build

Markata run broke in my GH Actions this morning

Run markata build --no-pretty
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.12/x64/bin/markata", line 33, in <module>
    sys.exit(load_entry_point('markata==0.2.0', 'console_scripts', 'markata')())
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/cli/cli.py", line 76, in cli
    m = Markata()
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/__init__.py", line 117, in __init__
    self.configure()
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/__init__.py", line 102, in wrapper
    result = function(self, *args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/__init__.py", line 231, in configure
    self._pm.hook.configure(markata=self)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/plugins/setup_logging.py", line 210, in configure
    setup_log(markata, logging.DEBUG)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/plugins/setup_logging.py", line 111, in setup_log
    path = setup_html_log(markata, level)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/plugins/setup_logging.py", line 180, in setup_html_log
    template = Template(template_file.read_text(), undefined=SilentUndefined)
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/pathlib.py", line 1236, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors) as f:
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/pathlib.py", line 1222, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/pathlib.py", line 1078, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/markata/plugins/default_log_template.html'
Error: Process completed with exit code 1.

Is this me geing a dope?

wrong url following the readme quickstart

I've started using markata and following the quick-start from the readme I've found an issue with index's urls.

MRE

mkdir pages
cd pages
echo '# My First Post' > first-post.md
echo '# Hello World' > hello-world.md
pipx run markata build

When I've opened the output markout/index.html both links didn't work. Here's the html code:

<li class='post'>
<a href="/hello-world/">
    Hello World
</a>
</li>

<li class='post'>
<a href="/first-post/">
    First Post
</a>

I guess that maybe the relative path ( . ) is missed; what it works in my case:

  <li class='post'>
- <a href="/hello-world/">
+ <a href="./hello-world/index.html">
      Hello World
  </a>
  </li>
  
  <li class='post'>
- <a href="/first-post/">
+ <a href="./first-post/index.html">
      First Post
  </a>

markdown-it-py[plugins]

Swap the markdown parser for markdown-it. This is a more modern and well maintained library, it also supports data fields in code blocks which will work well with darkmark

Tui --full

There needs to be a way to full run along with fast run

I couldn't find the markata.toml description

Hi Waylon,

I'm trying markata and it looks very nice and I would like to know more about how to change makata's configuration throught markata.toml and I couldn't find the doc about it, could you point where I could find it?

default html and css need split and not hard embeded

It should be easier to theme out the site by just adding CSS somewhere. Folks with little to no front end web skills should be able to easily grab some themes somewhere and add it to their site.

One solution that could make this a bit easier to do is a react Helmet like plugin that allows users to configure what gets added to the head of their pages.

Make markata cache directory configurable

Trying to run on pipedream I ran into this issue where markata could not start becuase the directory was read only. The cache should have a configurable directory and the ability to opt out.

image

Nav links in markata.toml should be affected by start_url

If start_url is set in markata.toml and a nav link is set as Home='/', what should happen is the nav link is rendered to point to /<start_url>, but this doesn't currently happen in markata~=0.6.0.dev0 (this is what I set in CI - I will get a real version later)

Allow specifying `alt` override in title

Problem:

In my index.md in the frontmatter where I put the title of my landing page, I have some html that renders a hand waving...

<a href="https://pype.dev/"><img src="https://media.giphy.com/media/hvRJCLFzcasrR4ia7z/giphy.gif" width="50px" height="50px"></a>

But then the html string gets rendered in the chrome tab
image

It's be nice to specify the actual alt text for the title in this case so the tab can have a sane text representation in the browser

unable to make cli callback plugins

Typer only allows one main callback. To implement this correctly I need to allow plugin authors a way to append to a list of callbacks, rather than using @app.callback which overwrites the main callback.

pyproject.toml support

Adding pyproject.toml and setup.cfg to the list of files in the standard config module with a key of markata would support this.

url typo

Hi Waylon,

I was just checking out your repo and noticed a typo where you link to the docs.

Good luck with the project!

image

Edit on GitHub

It would be nice to have a edit on github plugin/link.

Deploy something with Markata | Hacktoberfest

Take this Hacktoberfest to create a static site for yourself. This can be a portfolio, blog, your own digital garden, anything you ca dream up. When complete deploy it to so that it is accessible by others, and contribute to our examples page. If you find any hiccups throughout the process PR's are more than welcome to fix issues that you find in markata itself or in the docs. Before spending your valuable time on something, I would suggest to raise an issue to discuss whether your intended fix is desired or not, and please indicate to others whether or not you would like to work on the issue.

Site Ideas

Please make something that you want for yourself. Something that is all yours, and brings you joy. If you are struggling with ideas here are a few.

Some Free Hosting Ideas (Not a sponsor)

  • Netlify
  • Cloudflare pages
  • GitHub Pages
  • Vercel

Submitting a Project Gallery Entry

  • Fork the markata repo
  • create a markdown file in the docs/gallery using the following template
  • if you have images make sure you keep them relatively small (<100kb)
    • I really like squoosh to compress images for web use.
    • put your compressed images in the static/ directory and link to them with a leading /
  • Open a PR into the main branch

template for a gallery entry

---
title: WaylonWalker.com 
codeUrl: https://github.com/WaylonWalker/waylonwalker.com/
url: https://waylonwalker.com

---

Markdown content here

[![Waylonwalker.com home page](/waylonwalker.com.webp)](https://waylonwalker.com)

> Link images like this ☝ 

Todo (for maintainers before hacktoberfestst)

  • Create examples Page #95
  • Create template for adding to the examples
  • Make sure that release workflow does not run on a docs change

Covers should work out of the box

Currently covers require config and a template image, default should give you nice og images that are white text on black background.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.