Metadata-Version: 2.4
Name: flask-flashy
Version: 0.1.0
Summary: Custom flash system allowing custom keyword arguments for Flask.
Home-page: https://github.com/UsernameIsInUse/flask-flashy
Author: Alex Chichester
Author-email: alexcchichester@gmail.com
License: BSD 3-clause
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Flask
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: summary

# flask-flashy

Alternative to flask's flash system which allows you to pass in keyword arguments.

## How it works

Flask's default `flash()` method simply takes two strings and passes them into the session (the message and category, eg `flash('Username Is In Use', 'warning')`), which is then obtained and cleared by `get_flashed_messages()` in jinja.

flask-flashy has a class-based flashing system, allowing you to pass in as many keyword arguments as you'd like, while still keeping the default message and category to align with flask and allow for minimal edits to convert (eg `flash('Username Is In Use. Login Instead?', 'warning', url=url_for('login'), timestamp=datetime.now() )`).

## Installation & Basic Usage

Install via pip:

```bash
pip install flask-flashy
```

After installing, wrap your Flask app with a `Flashy(app)`, or call `Flashy.init_app(app)`

```python
from flask import Flask
from flask_flashy import Flashy

app = Flask(__name__)
flashy = Flashy(app)
```

or to initialize later or use with blueprints:

```python
from flask import Flask
from flask_flashy import Flashy

app = Flask(__name__)
flashy = Flashy()
flashy.init_app(app)
```

## Examples

After initializing the app, simply call for a flash in a route, passing in the message, optionally a second string as a category (will default to 'message' if not provided), and as many custom keyword arguments as you'd like.

```python
@app.route('/')
def index():
  flashy.flash('Woah there partner!', 'danger', url='https://example.com/')
  return render_template('index.html')
```

Then get the flashes in the template using jinja:

```html
{% with messages = get_flashy_messages() %}
{% if messages %}
<ul>
{% for message in messages %}
{% if message.url %}
<a href="{{ message.url }}"><li class="{{ message.category }}">{{ message.message }}</li></a>
{% else %}
<li class="{{ message.category }}">{{ message.message }}</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}
{% endwith %}
```

And style and use to your hearts content.

## TODO

- Category sorting like vanilla flask
- Fun flask-like logo
- ???

## Release History

- 0.1.0 - Initial release on pypi.
