From 9f562b20fdb4176eba512e402f38668c40db30bd Mon Sep 17 00:00:00 2001 From: Evgeny Bogodukhov Date: Wed, 13 Jul 2016 21:50:22 +0400 Subject: [PATCH 1/5] Added ability to set a JavaScript callback function --- flask_recaptcha.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/flask_recaptcha.py b/flask_recaptcha.py index d2c2648..dca3d8a 100644 --- a/flask_recaptcha.py +++ b/flask_recaptcha.py @@ -56,18 +56,26 @@ def init_app(self, app=None): @app.context_processor def get_code(): - return dict(recaptcha=Markup(self.get_code())) + def _get_code(callback="recaptcha_callback"): + return Markup(self.get_code(callback=callback)) + return dict(recaptcha=_get_code(callback=None), recaptcha_callback=_get_code) - def get_code(self): + def get_code(self, callback=None): """ + :param callback: adds a JavaScript callback function name Returns the new ReCaptcha code :return: """ + if callback: + data_callback = ' data-callback="{CALLBACK}"'.format(CALLBACK=callback) + else: + data_callback = "" return "" if not self.is_enabled else ("""
- """.format(SITE_KEY=self.site_key, THEME=self.theme, TYPE=self.type, SIZE=self.size, TABINDEX=self.tabindex)) + data-tabindex="{TABINDEX}"{DATA_CALLBACK}> + """.format(SITE_KEY=self.site_key, THEME=self.theme, TYPE=self.type, SIZE=self.size, TABINDEX=self.tabindex, + DATA_CALLBACK=data_callback)) def verify(self, response=None, remote_ip=None): if self.is_enabled: From 25cd7dc7a5abd02953295940d1793a28fc0fc298 Mon Sep 17 00:00:00 2001 From: Evgeny Bogodukhov Date: Wed, 13 Jul 2016 22:22:07 +0400 Subject: [PATCH 2/5] Fixed an example of a configuration option --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1d5ae44..3a83acf 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,7 @@ The following are **Optional** arguments. RECAPTCHA_THEME = "dark" RECAPTCHA_TYPE = "image" RECAPTCHA_SIZE = "compact" - RECAPTCHA_RTABINDEX = 10 + RECAPTCHA_TABINDEX = 10 --- From c692035a36677dd4e6dc513f9132df7c1ae8dce9 Mon Sep 17 00:00:00 2001 From: Evgeny Bogodukhov Date: Wed, 13 Jul 2016 23:00:47 +0400 Subject: [PATCH 3/5] Update doc --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3a83acf..7b94149 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,9 @@ Returns bool Just include **{{ recaptcha }}** wherever you want to show the recaptcha +Additionally, you can use the syntax **{{ recaptcha_callback() }}** +or **{{ recaptcha_callback(callback="some_callback_function") }}** +to use Javascript callback function (default name - 'recaptcha_callback'). ## Config From 4d1ca9bbc5979cc6f77a7b73544ab775aeb1d7e7 Mon Sep 17 00:00:00 2001 From: Evgeny Bogodukhov Date: Wed, 13 Jul 2016 23:06:16 +0400 Subject: [PATCH 4/5] Update doc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7b94149..05bb5bc 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Just include **{{ recaptcha }}** wherever you want to show the recaptcha Additionally, you can use the syntax **{{ recaptcha_callback() }}** or **{{ recaptcha_callback(callback="some_callback_function") }}** -to use Javascript callback function (default name - 'recaptcha_callback'). +to use JavaScript callback function (default name - 'recaptcha_callback'). ## Config From dbc6efff09dc1d6fc120c3fa336643158c9fcfe0 Mon Sep 17 00:00:00 2001 From: Evgeny Bogodukhov Date: Mon, 14 Nov 2016 14:28:38 +0400 Subject: [PATCH 5/5] Bump version to 0.4.3 --- flask_recaptcha.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flask_recaptcha.py b/flask_recaptcha.py index dca3d8a..d51c1ca 100644 --- a/flask_recaptcha.py +++ b/flask_recaptcha.py @@ -4,7 +4,7 @@ """ __NAME__ = "Flask-ReCaptcha" -__version__ = "0.4.2" +__version__ = "0.4.3" __license__ = "MIT" __author__ = "Mardix" __copyright__ = "(c) 2015 Mardix"