grav-plugin-form icon indicating copy to clipboard operation
grav-plugin-form copied to clipboard

Addition to recent update on development build - Turnstile build still missing language / tooltip help info

Open spamhater-grav opened this issue 1 year ago • 0 comments

Sorry I not sure how to do a pull request but referring to a recent update that you have completed @rhukster ref https://github.com/getgrav/grav-plugin-form/commit/38c85c30bba2e8257921a6ee2fe7da4388e4f9bd

where you fixed some blueprint and language settings for tunstile, but today I noticed some of the refs are pointing to google_recaptcha

The turnstile plugin code in the blueprint is currently this BLUEPRINT.YAML

    turnstile_captcha:
      type: section
      title: PLUGIN_FORM.TURNSTILE_CAPTCHA

      fields:
        turnstile.theme:
          type: select
          label: PLUGIN_FORM.TURNSTILE_THEME
          default: light
          options:
            light: PLUGIN_FORM.TURNSTILE_THEME_LIGHT
            dark: PLUGIN_FORM.TURNSTILE_THEME_DARK
        turnstile.site_key:
          type: text
          label: PLUGIN_FORM.TURNSTILE_SITE_KEY
          help: PLUGIN_FORM.TURNSTILE_SITE_KEY_HELP
          default: ''
        turnstile.secret_key:
          type: text
          label: PLUGIN_FORM.TURNSTILE_SECRET_KEY
          help: PLUGIN_FORM.TURNSTILE_SECRET_KEY_HELP
          default: ''

But entries are pointing to google recaptcha language.yaml enteries.

So the change listed are to stop using the google_recaptcha enteries and incorrect help hint and point them to the cloudflare turnstile options

LANGUAGE.YAML

en:
  PLUGIN_FORM:
  TURNSTILE_CAPTCHA: "Cloudflare Turnstile Captcha" 
  TURNSTILE_THEME: "Theme" 
  TURNSTILE_SITE_KEY_HELP: "For more info visit https://www.cloudflare.com/turnstile/" 
  TURNSTILE_SECRET_KEY_HELP: "For more info visit https://www.cloudflare.com/turnstile/" 

OR giving them a complete set of enteries

BLUEPRINT.YAML

    turnstile_captcha:
      type: section
      title: PLUGIN_FORM.TURNSTILE_CAPTCHA

      fields:
        turnstile.theme:
          type: select
          label: PLUGIN_FORM.TURNSTILE_CAPTCHA_THEME
          default: light
          options:
            light: PLUGIN_FORM.TURNSTILE_THEME_LIGHT
            dark: PLUGIN_FORM.TURNSTILE_THEME_DARK
        turnstile.site_key:
          type: text
          label: PLUGIN_FORM.TURNSTILE_CAPTCHA_SITE_KEY
          help: PLUGIN_FORM.TURNSTILE_CAPTCHA_SITE_KEY_HELP
          default: ''
        turnstile.secret_key:
          type: text
          label: PLUGIN_FORM.TURNSTILE_CAPTCHA_SECRET_KEY
          help: PLUGIN_FORM.TURNSTILE_CAPTCHA_SECRET_KEY_HELP
          default: ''

And then and the additional lines added to language.yaml , sorry only provided :en versions LANGUAGE.YAML

en:
  PLUGIN_FORM:
  TURNSTILE_CAPTCHA: "Cloudflare Turnstile Captcha"
  TURNSTILE_THEME: = "Theme"       
  TURNSTILE_THEME_LIGHT: "Light Theme"
  TURNSTILE_THEME_LIGHT: "Dark Theme"
  TURNSTILE_SITE_KEY: "Cloudflares Turnstyle Site API Key"
  TURNSTILE_SITE_KEY_HELP: "For more info visit https://www.cloudflare.com/turnstile/"
  TURNSTILE_SECRET_KEY: "Cloudflares Turnstyle Secret API Key"
  TURNSTILE_SITE_KEY_HELP: "For more info visit https://www.cloudflare.com/turnstile/"

Finally not sure if you want to include a new blueprint field for the .js api code integration which comes from the dashboard

BLUEPRINT.YAML

        turnstile.client.js:
          type: text
          label: PLUGIN_FORM.TURNSTILE_CLIENT_JS
          help: PLUGIN_FORM.TURNSTILE_CLIENT_JS_HELP
          default: ''

LANGUAGES.YAML

          TURNSTILE_CLIENT_JS: "Cloudflares Turnstyle Dashboard Client JS Code"
          TURNSTILE_CLIENT_JS_HELP: "For more info https://www.cloudflare.com/turnstile/"

Logic in Twig Template to support if it is present, to provide an override if this code changes

Currently from dashboard : <script src=https://challenges.cloudflare.com/turnstile/v0/api.js" async defer>

and converted to

{% do assets.addjs('https://challenges.cloudflare.com/turnstile/v0/api.js', { group: 'bottom' }) %}

(not sure if that is the best asset call selection) - then added in to the defered js group at load time of form.

Hope this is alright, and some of it useful without having to do too much lead work.

Thanks Spamhater image

spamhater-grav avatar Jan 12 '23 06:01 spamhater-grav