-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
74 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from flask_modals.modal import ( | ||
Modal, | ||
render_template_modal, | ||
render_template_redirect | ||
render_template_redirect, | ||
redirect_to | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{% if include %} | ||
{{ turbo() }} | ||
{{ turbo(url=url) }} | ||
{% elif include is false %} | ||
<meta name="turbo-visit-control" content="reload"> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'''Copyright notice - The code below is adapted from the Turbo-Flask | ||
extension by Miguel Grinberg (https://github.com/miguelgrinberg/turbo-flask), | ||
which is under MIT license. | ||
''' | ||
|
||
from flask import request, current_app | ||
from jinja2 import Markup | ||
|
||
|
||
_CDN = 'https://cdn.skypack.dev' | ||
_PKG = '@hotwired/turbo' | ||
_VER = 'v7.0.0-beta.5-LhgiwOUjafYu3bb8VbTv' | ||
|
||
|
||
class Turbo: | ||
|
||
def load(self, version=_VER, url=None): | ||
|
||
if url is None: | ||
url = f'{_CDN}/pin/{_PKG}@{version}/min/{_PKG}.js' | ||
return Markup(f'<script type="module" src="{url}"></script>') | ||
|
||
def can_stream(self): | ||
'''Returns `True` if the client accepts turbo streams.''' | ||
|
||
stream_mimetype = 'text/vnd.turbo-stream.html' | ||
best = request.accept_mimetypes.best_match([ | ||
stream_mimetype, 'text/html']) | ||
return best == stream_mimetype | ||
|
||
def _make_stream(self, action, content, target): | ||
return (f'<turbo-stream action="{action}" target="{target}">' | ||
f'<template>{content}</template></turbo-stream>') | ||
|
||
def replace(self, content, target): | ||
return self._make_stream('replace', content, target) | ||
|
||
def update(self, content, target): | ||
return self._make_stream('update', content, target) | ||
|
||
def stream(self, response_stream): | ||
'''Create a turbo stream response.''' | ||
|
||
return current_app.response_class( | ||
response_stream, mimetype='text/vnd.turbo-stream.html') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
setuptools.setup( | ||
name='Flask-Modals', | ||
version='0.2.5', | ||
version='0.2.6', | ||
author='Debashish Palit', | ||
author_email='[email protected]', | ||
description='Use forms in Bootstrap 4 modals with Flask.', | ||
|
@@ -16,10 +16,7 @@ | |
package_data={'flask_modals': ['templates/modals/*.html', | ||
'static/js/main.js']}, | ||
include_package_data=True, | ||
install_requires=[ | ||
'flask>=1.1.0', | ||
'turbo-flask', | ||
], | ||
install_requires=['Flask'], | ||
zip_safe=False, | ||
classifiers=[ | ||
'Programming Language :: Python :: 3', | ||
|