diff --git a/README.md b/README.md index 4d81456..9ee3d31 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ https://python.microformats.io ## Deployment -All commits to the `master` branch get auto-deployed to the live website (running on [Heroku](https://python.microformats.io)) +All commits to the `main` branch get auto-deployed to the live website (running on [Heroku](https://python.microformats.io)) ## Getting Started @@ -15,8 +15,8 @@ This website is built using Python Flask. To start working with this project, first clone the repository for this project: ``` -git clone https://github.com/indieweb/microformats-python-parser-website.git -cd microformats-python-parser-website +git clone https://github.com/microformats/microformats-parser-website-python.git +cd microformats-parser-website-python ``` Next, install the required dependencies: @@ -32,6 +32,8 @@ uv run -- app.py --debug (debug mode) uv run -- gunicorn --bind localhost:8080 app:app (production mode) ``` +In debug mode the port defaults to 8080; use `-p`/`--port` to change it. + You can view your running local application at this URL: ``` @@ -40,19 +42,20 @@ http://localhost:8080 ## Requirements -- Python 3.9 +- Python 3.14.5 +- [uv](https://docs.astral.sh/uv/) ## Contributions 1. Fork it -2. Get it running (see Installation above) +2. Get it running (see Getting Started above) 3. Create your feature branch (`git checkout -b my-new-feature`) 4. Commit your changes (`git commit -am 'Add some feature'`) 5. Push to the branch (`git push origin my-new-feature`) 6. Create new Pull Request If you find bugs, have feature requests or questions, please -[file an issue](https://github.com/indieweb/microformats-parser-website-python/issues). +[file an issue](https://github.com/microformats/microformats-parser-website-python/issues). ## License @@ -63,4 +66,5 @@ http://creativecommons.org/publicdomain/zero/1.0 ## Contributors - Kyle Mahan / [@kylewm](https://github.com/kylewm) (Author) -- [@capjamesg](https://github.com/capjamesg) (Contributor) \ No newline at end of file +- [@capjamesg](https://github.com/capjamesg) (Contributor) +- Martijn van der Ven / [@Zegnat](https://github.com/Zegnat) (Contributor) diff --git a/app.py b/app.py index 0f29ceb..8441029 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,8 @@ import json +import tomllib import traceback from collections import OrderedDict +from pathlib import Path import mf2py import mf2util @@ -11,6 +13,10 @@ mf2py.Parser.user_agent = "python.microformats.io (mf2py/" + mf2py.__version__ + ") Mozilla/5.0 Chrome/29.0.1547.57 Safari/537.36" mf2py.Parser.dict_class = OrderedDict +SITE_VERSION = tomllib.loads( + (Path(__file__).parent / "pyproject.toml").read_text(encoding="utf-8") +)["project"]["version"] + @app.route("/", methods=["GET", "POST"]) def index(): try: @@ -50,7 +56,11 @@ def fetch_mf2(url): response.headers["Content-Type"] = "application/json" return response - return render_template("index.jinja2", mf2py_version=mf2py.__version__) + return render_template( + "index.jinja2", + site_version=SITE_VERSION, + mf2py_version=mf2py.__version__, + ) except BaseException as e: traceback.print_exc() return jsonify(error="%s: %s" % (type(e).__name__, e)), 400 diff --git a/templates/index.jinja2 b/templates/index.jinja2 index 57e5a10..21d712d 100644 --- a/templates/index.jinja2 +++ b/templates/index.jinja2 @@ -6,115 +6,123 @@ Python Microformats Parser - - - + + -
- -

- Microformats Parser (Python) - {{ mf2py_version }} -

- -
-
- - -
- -
- - -
- -
- -
- - -
- -

OR parse just a snippet of HTML

- -
-
- - -
- -
- - -
- -
- - -
- - -
+
+

Microformats Parser (Python)

+ +
+ +
+

Parse a URL

+ +
+
+ + +
+ +
+ +
+ +
+
+ +
+ + +
mf2util interprets certain post types (currently h-entry and h-event) and returns a normalized result.
+
+ + +
+
+ +
+

OR parse just a snippet of HTML

+ +
+
+ + +
+ +
+ + +
+ +
+ +
+ +
+
+ + +
+
+ +
+
+

Bookmarklet

+

Drag this link to your bookmarks toolbar to parse a page with one click!

+ mf2 parser +
+
+ +
-
+ +