{"id":13501609,"url":"https://github.com/wiltonsr/Flask-Toastr","last_synced_at":"2025-03-29T09:30:58.504Z","repository":{"id":46305177,"uuid":"172092027","full_name":"wiltonsr/Flask-Toastr","owner":"wiltonsr","description":"Showing non-blocking notifications with Flask's flash and toastr.","archived":false,"fork":false,"pushed_at":"2022-08-23T18:01:16.000Z","size":37,"stargazers_count":52,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-13T09:21:22.617Z","etag":null,"topics":["flask","flask-extension","flask-extensions","hacktoberfest","jinja2","python27","python3","toastr"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/Flask-Toastr/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wiltonsr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://www.paypal.com/donate/?cmd=_donations\u0026business=5QJ62BNMRC75W\u0026currency_code=USD\u0026source=url"]}},"created_at":"2019-02-22T15:47:39.000Z","updated_at":"2024-09-13T19:18:49.000Z","dependencies_parsed_at":"2022-09-13T15:22:30.762Z","dependency_job_id":null,"html_url":"https://github.com/wiltonsr/Flask-Toastr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiltonsr%2FFlask-Toastr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiltonsr%2FFlask-Toastr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiltonsr%2FFlask-Toastr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiltonsr%2FFlask-Toastr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiltonsr","download_url":"https://codeload.github.com/wiltonsr/Flask-Toastr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222248800,"owners_count":16955314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","flask-extension","flask-extensions","hacktoberfest","jinja2","python27","python3","toastr"],"created_at":"2024-07-31T22:01:43.465Z","updated_at":"2024-10-31T20:31:56.034Z","avatar_url":"https://github.com/wiltonsr.png","language":"Python","funding_links":["https://www.paypal.com/donate/?cmd=_donations\u0026business=5QJ62BNMRC75W\u0026currency_code=USD\u0026source=url","https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=5QJ62BNMRC75W\u0026currency_code=USD\u0026source=url"],"categories":["Python"],"sub_categories":[],"readme":"Flask-Toastr\n============\n\n[![](https://img.shields.io/badge/python-3.4+-blue.svg)](https://www.python.org/download/releases/3.4.0/) [![](https://img.shields.io/badge/python-2.7+-blue.svg)](https://www.python.org/download/releases/2.7.2/) [![](https://img.shields.io/github/license/ResidentMario/missingno.svg)](https://github.com/wiltonsr/Flask-Toastr/blob/master/README.md)\n\nShowing Flask's flash non-blocking notifications in templates using [toastr](https://github.com/CodeSeven/toastr).\n\nDonate to help keep this project maintained.\n\u003ca href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations\u0026business=5QJ62BNMRC75W\u0026currency_code=USD\u0026source=url\"\u003e\n\u003cimg src=\"https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif\" border=\"0\" name=\"submit\" title=\"PayPal - The safer, easier way to pay online!\" alt=\"Donate with PayPal button\" /\u003e\u003c/a\u003e\n\nQuick Start\n-----------\n\nStep 1: Initialize the extension:\n\n    from flask_toastr import Toastr\n    toastr = Toastr(app)\n\nStep 2: In your `\u003chead\u003e` and bottom of `\u003cbody\u003e`sections of your base template add the following code:\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    {{ toastr.include_jquery() }}\n    {{ toastr.include_toastr_css() }}\n    {{ toastr.message() }}\n  \u003c/head\u003e\n  \u003cbody\u003e\n    {{ toastr.include_toastr_js() }}\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThis extension also supports the [Flask application factory pattern](http://flask.pocoo.org/docs/latest/patterns/appfactories/) by allowing you to create a Toastr object and then separately initialize it for an app:\n\n```python\ntoastr = Toastr()\n\ndef create_app(config):\n  app = Flask(__name__)\n  app.config.from_object(config)\n  # initialize toastr on the app within create_app()\n  toastr.init_app(app)\n\napp = create_app(prod_config)\n```\n\nNote that jQuery is required. If you are already including it on your own then you can remove the `include_jquery()` line. Secure HTTP is used if the request under which these are executed is secure.\n\nThe `include_jquery()`, `include_toastr_js()` and `include_toastr_css()` methods take some optional arguments. If you pass a `version` argument to any of these calls, then the requested version will be loaded from the default CDN. In addition, it is also possible to pass `js_filename` and `css_filename` to `include_toastr_js()` and `include_toastr_css()`, respectively.\n\nStep 3: Use the `flash()` method with or without category in your views. For example:\n\n```python\n@app.route('/')\ndef index():\n    flash(\"All OK\")\n    flash(\"All OK\", 'success')\n    flash(\"All Normal\", 'info')\n    flash(\"Not So OK\", 'error')\n    flash(\"So So\", 'warning')\n    return render_template('index.html')\n```\n\nOr you could also use `flash()` method with custom titles, see [#14](https://github.com/wiltonsr/Flask-Toastr/issues/14) for details:\n\n```python\n@app.route('/')\ndef index():\n    flash(\"Message\", 'Custom Title')\n    flash({'title': \"Custom Title\", 'message': \"Error Message\"}, 'error')\n    return render_template('index.html')\n```\n\nStep 4: Enjoy\n\nParameters\n--------\n\nConfig                    | Default           | Possible Values         | Description   | Reference           |\n------------------------- | ----------------- | ----------------------- | ------------- | --------------------|\nTOASTR_VERSION            | '2.1.4'           | [Releases from here](https://github.com/CodeSeven/toastr/releases) | Version of Toastr | https://github.com/CodeSeven/toastr/tags |\nTOASTR_JQUERY_VERSION     | '2.1.0'           | [Releases from here](https://github.com/jquery/jquery/releases) | Version of JQuery | https://releases.jquery.com/jquery/ |\nTOASTR_CSS_FILENAME       | 'toastr.min.css'  | CDN file name           | CSS Filename used in CDN Toastr's link | https://github.com/CodeSeven/toastr#cdns |\nTOASTR_JS_FILENAME        | 'toastr.min.js'   | CDN file name           | JS Filename used in CDN Toastr's link | https://github.com/CodeSeven/toastr#cdns |\nTOASTR_CLOSE_BUTTON       | 'true'            | 'true' or 'false'       | Enable or Disable close button | https://github.com/CodeSeven/toastr#close-button |\nTOASTR_SHOW_EASING        | 'swing'           | 'swing' or 'linear'     | Override the animation easing to show the toasts  | https://github.com/CodeSeven/toastr#animation-options |\nTOASTR_HIDE_EASING        | 'linear'          | 'swing' or 'linear'     | Override the animation easing to hide the toasts  | https://github.com/CodeSeven/toastr#animation-options |\nTOASTR_CLOSE_EASING       | 'linear'          | 'swing' or 'linear'     | Override the animation easing to close the toasts | https://github.com/CodeSeven/toastr#animation-options |\nTOASTR_SHOW_METHOD        | 'fadeIn'          | 'fadeIn', 'fadeOut', 'slideDown', 'slideUp, 'show', 'hide' | Override the animation method to show the toasts  | https://github.com/CodeSeven/toastr#animation-options |\nTOASTR_HIDE_METHOD        | 'fadeOut'         | 'fadeIn', 'fadeOut', 'slideDown', 'slideUp, 'show', 'hide' | Override the animation method to hide the toasts  | https://github.com/CodeSeven/toastr#animation-options |\nTOASTR_CLOSE_METHOD       | 'fadeOut'         | 'fadeIn', 'fadeOut', 'slideDown', 'slideUp, 'show', 'hide' | Override the animation method to close the toasts | https://github.com/CodeSeven/toastr#animation-options |\nTOASTR_TIMEOUT            | 15000             | any `int` value (in ms) | Time to notification close | https://github.com/CodeSeven/toastr#timeouts |\nTOASTR_EXTENDED_TIMEOUT   | 1000              | any `int` value (in ms) | Time to notification close after hover mouse or click | https://github.com/CodeSeven/toastr#timeouts |\nTOASTR_POSITION_CLASS     | 'toast-top-right' | 'toast-top-right', 'toast-bottom-right', 'toast-bottom-left', 'toast-top-left', 'toast-top-full-width', 'toast-bottom-full-width', 'toast-top-center', 'toast-bottom-center' | Notification Positon | https://codeseven.github.io/toastr/demo.html |\nTOASTR_PREVENT_DUPLICATES | 'false'           | 'true' or 'false'       | Doesn't show same notification | https://github.com/CodeSeven/toastr#prevent-duplicates |\nTOASTR_NEWS_ON_TOP        | 'false'           | 'true' or 'false'       | Notification's aparition order | https://github.com/CodeSeven/toastr#display-sequence |\nTOASTR_PROGRESS_BAR       | 'true'            | 'true' or 'false'       | Enable or Disable progress bar | https://github.com/CodeSeven/toastr#progress-bar |\nTOASTR_OPACITY            | True              | True or False           | Enable or Disable notification's opacity | https://stackoverflow.com/a/17640150/7041939 |\n\n    Note: The values `true` and `false` are passed to JS, that is Case Sensitive.\n    Therefore they must be passed in lowercase.\n\nExamples\n--------\n\n```\nTo run the example in your local environment:\n\n  1. Clone the repository:\n\n        git clone https://github.com/wiltonsr/Flask-Toastr.git\n        cd Flask-Toastr\n\n  2. Create and activate a virtual environment:\n\n        virtualenv env\n        source env/bin/activate\n\n  3. Install requirements:\n\n        pip install -r 'example/requirements.txt'\n\n  4. Run the application:\n\n        python example/app.py\n```\n\nFunction Reference\n------------------\n\nConsult the [toastr documentation](https://github.com/CodeSeven/toastr#toastr) for more details.\n\nDevelopment\n-----------\n\nThis extension is just a project to improve my python and flask skills. Any suggestions or tips are welcome.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiltonsr%2FFlask-Toastr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiltonsr%2FFlask-Toastr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiltonsr%2FFlask-Toastr/lists"}