From 8f84e57f53835ccac1abbceb0592e471fa1cd660 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Mon, 25 Jul 2016 20:05:47 +0000 Subject: [PATCH] Add explicit configuration support for Akismet The Akismet spam detection feature can be configured through a settings page, but in order to be able to keep the API key private (in hiera) we need to be able to set it through configuration management instead. Change-Id: Ie64ece3e84af407b5e4124c874f59dad5ab23d4e --- manifests/config.pp | 1 + manifests/init.pp | 2 ++ manifests/site/config.pp | 1 + templates/settings.py.erb | 5 +++++ 4 files changed, 9 insertions(+) diff --git a/manifests/config.pp b/manifests/config.pp index 9c44b75..1db8845 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -7,6 +7,7 @@ class askbot::config ( $db_password, $redis_password, + $akismet_api_key = undef, $askbot_debug = false, $custom_theme_enabled = false, $custom_theme_name = undef, diff --git a/manifests/init.pp b/manifests/init.pp index d876fa4..252c60e 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -57,6 +57,7 @@ class askbot ( $db_password, $redis_password, + $akismet_api_key = undef, $askbot_branch = 'master', $askbot_debug = false, $askbot_ensure = 'present', @@ -155,6 +156,7 @@ class askbot ( redis_max_memory => $redis_max_memory, redis_bind => $redis_bind, redis_password => $redis_password, + akismet_api_key => $akismet_api_key, site_ssl_enabled => $site_ssl_enabled, site_ssl_cert_file_contents => $site_ssl_cert_file_contents, site_ssl_key_file_contents => $site_ssl_key_file_contents, diff --git a/manifests/site/config.pp b/manifests/site/config.pp index 8da9385..a23e931 100644 --- a/manifests/site/config.pp +++ b/manifests/site/config.pp @@ -21,6 +21,7 @@ class askbot::site::config ( $smtp_port, $solr_enabled, $template_settings, + $akismet_api_key = undef, ) { case $db_provider { diff --git a/templates/settings.py.erb b/templates/settings.py.erb index 5b5af9b..9226948 100644 --- a/templates/settings.py.erb +++ b/templates/settings.py.erb @@ -94,6 +94,11 @@ ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/' # Make up some unique string, and don't share it with anybody. SECRET_KEY = '44fb9b7219e3743bffabb6861cbc9a28' +<% if @akismet_api_key != nil -%> +# To help mitigate spam, Akismet integration needs the API key for your account +AKISMET_API_KEY = '<%= @akismet_api_key %>' +<% end -%> + # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'askbot.skins.loaders.Loader',