{ "info": { "author": "Mara contributors", "author_email": "", "bugtrack_url": null, "classifiers": [], "description": "# Mara page\n\n[![Build Status](https://travis-ci.org/mara/mara-page.svg?branch=master)](https://travis-ci.org/mara/mara-page)\n[![PyPI - License](https://img.shields.io/pypi/l/mara-page.svg)](https://github.com/mara/mara-page/blob/master/LICENSE)\n[![PyPI version](https://badge.fury.io/py/mara-page.svg)](https://badge.fury.io/py/mara-page)\n[![Slack Status](https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social)](https://communityinviter.com/apps/mara-users/public-invite)\n\nMinimal API for defining pages of Flask-based backends independently from the actual backend infrastructure.\n \nWhen a web app is spread across many independent Flask blueprints, then this library can be used to add\n\n- navigation entries\n- page titles \n- resource-based ACL protection\n- page-specific CSS and JS files\n\nwithout having access to a global layout or the Flask app. \n\n\nThe library provides a drop-in werkzeug ``Response`` class that is enriched with additional information that a \nbackend can use to render the final html page.\n \n## Example\n\nThis is a simple web ui for displaying the current time:\n \n```python\n\"\"\"Clock UI\"\"\"\n\nimport flask\nfrom awesome_clock import clock\nfrom mara_page import acl, navigation, response, bootstrap, _\n\n# The flask blueprint that handles\nblueprint = flask.Blueprint('awesome_clock', __name__, url_prefix='/clock', static_folder='static')\n\n# Defines an ACL resource (needs to be handled by the application)\nacl_resource = acl.AclResource('Clock')\n\n\ndef navigation_entry():\n \"\"\"Defines a part of the navigation tree (needs to be handled by the application)\"\"\"\n return navigation.NavigationEntry(\n label='Awesome clock', icon='clock-o', description='Something that tells the time',\n children=[\n navigation.NavigationEntry(\n label='What time is it now?',\n uri_fn=lambda: flask.url_for('awesome_clock.clock_page', when='now'),\n icon='question-circle', description='Should be able to display the current time'),\n\n navigation.NavigationEntry(\n label='And now?', icon='refresh', description='For the impatient',\n uri_fn=lambda: flask.url_for('awesome_clock.clock_page', when='and-now'))\n ])\n\n\n@blueprint.route('/')\n@acl.require_permission(acl_resource) # Requires permission to the `'Clock'` resource\ndef clock_page(when: str):\n \"\"\"Defines the `/clock` page\"\"\"\n return response.Response(\n # The actual page content (can be also a call to `flask.render_template`\n # or anything else that produces a string)\n html=bootstrap.card(header_left=_.h1['What time is it now?'],\n body=[_.p['The current time is ', str(clock.what_time_is_it_now())],\n _.img(src=flask.url_for('awesome_clock.static', filename='cuckoo-clock.jpg'),\n style='max-width:100%')]),\n # The page title\n title='Awesome clock',\n\n # Action buttons\n action_buttons=[\n response.ActionButton('javascript:location.reload()', 'Refresh', 'Refresh clock', 'refresh'),\n response.ActionButton('javascript:location.reload()', 'Update', 'Refresh clock', 'clock-o')\n ]\n )\n```\n\nIt is up to the actual Flask app to define how to render such a response and what to do with the ACL resources and navigation entries. \nThe [mara app](https://github.com/mara/mara-app) will render the response like this:\n\n![Example backend](https://github.com/mara/mara-page/raw/master/docs/awesome-clock.png)", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mara/mara-page", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "mara-page", "package_url": "https://pypi.org/project/mara-page/", "platform": "", "project_url": "https://pypi.org/project/mara-page/", "project_urls": { "Homepage": "https://github.com/mara/mara-page" }, "release_url": "https://pypi.org/project/mara-page/1.5.1/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Minimal API for defining pages of Flask-based backends independently from the actual backend infrastructure", "version": "1.5.1" }, "last_serial": 5490173, "releases": { "1.4.1": [ { "comment_text": "", "digests": { "md5": "b5779bec9a158d91e2d0ea3f9bca0665", "sha256": "57c5d62092701c1c41c6437d5fcff19532b230be7a11dcfd887f0a7fc4613b05" }, "downloads": -1, "filename": "mara-page-1.4.1.tar.gz", "has_sig": false, "md5_digest": "b5779bec9a158d91e2d0ea3f9bca0665", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7598, "upload_time": "2019-07-04T14:28:02", "url": "https://files.pythonhosted.org/packages/cf/14/60bd7f408fdaf1dcaea2c14f3ef003a1b6755427a6cd1175259a2da7eb5a/mara-page-1.4.1.tar.gz" } ], "1.5.0": [ { "comment_text": "", "digests": { "md5": "91d702e2df8dc853dd9cc63499d3954c", "sha256": "26209e0923053e465a0714909e50bd2a7f03ac065c1f4009303f85ee8e2c30d5" }, "downloads": -1, "filename": "mara-page-1.5.0.tar.gz", "has_sig": false, "md5_digest": "91d702e2df8dc853dd9cc63499d3954c", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7849, "upload_time": "2019-07-04T19:57:45", "url": "https://files.pythonhosted.org/packages/02/c7/f96f3172be25ed4d578de73d6d8561a475a162579052b2e3c574831473b3/mara-page-1.5.0.tar.gz" } ], "1.5.1": [ { "comment_text": "", "digests": { "md5": "b73c0198b71a91433123877ee3044ec3", "sha256": "6e6c1d20e2652a0e378d27bd7f5382f3a97112f6ed05df8fe06490f33bca71a0" }, "downloads": -1, "filename": "mara-page-1.5.1.tar.gz", "has_sig": false, "md5_digest": "b73c0198b71a91433123877ee3044ec3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8290, "upload_time": "2019-07-05T08:14:38", "url": "https://files.pythonhosted.org/packages/42/c6/1dfed6066d91480617e22fc74a499af09c0702d05b2b46754503a43c88e0/mara-page-1.5.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b73c0198b71a91433123877ee3044ec3", "sha256": "6e6c1d20e2652a0e378d27bd7f5382f3a97112f6ed05df8fe06490f33bca71a0" }, "downloads": -1, "filename": "mara-page-1.5.1.tar.gz", "has_sig": false, "md5_digest": "b73c0198b71a91433123877ee3044ec3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8290, "upload_time": "2019-07-05T08:14:38", "url": "https://files.pythonhosted.org/packages/42/c6/1dfed6066d91480617e22fc74a499af09c0702d05b2b46754503a43c88e0/mara-page-1.5.1.tar.gz" } ] }