# Staticman fighting spam

**URL:** <https://talk.jekyllrb.com/t/staticman-fighting-spam/2388>\
**Category:** Help\
**Created:** [December 2, 2018, 3:08am UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388 "2018-12-02T03:08:36Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![TerminalAddict](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/terminaladdict/32/1300_2.png) [@TerminalAddict](https://talk.jekyllrb.com/u/TerminalAddict)\
**Post date:** [December 2, 2018, 3:08am UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/1 "2018-12-02T03:08:36Z")

</div>

I guess a few of us here use staticman ?

What are you all doing to fight spam ?  
I’m getting two or three each week, and it looks like someone actually typing stuff in, and completing the captcha 😮

What are other doing ?

---

<div class="post-metadata">

**Author:** ![TerminalAddict](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/terminaladdict/32/1300_2.png) [@TerminalAddict](https://talk.jekyllrb.com/u/TerminalAddict)\
**Post date:** [December 5, 2018, 1:54am UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/2 "2018-12-05T01:54:40Z")

</div>

spam is so boring ☹

Here’s another:

**the visit to the page:**  
`136.169.197.73 - - [05/Dec/2018:14:43:31 +1300] "GET /development/2018/11/06/Comments-on-blogs-vs-Social-Media.html HTTP/1.0" 200 167824 "https://terminaladdict.com/development/2018/11/06/Comments-on-blogs-vs-Social-Media.html" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"`

**and then post to staticman:**  
`136.169.197.73 - - [05/Dec/2018:14:43:41 +1300] "POST /v2/entry/TerminalAddict/ta.com-website/master/comments HTTP/1.0" 200 724 "https://terminaladdict.com/development/2018/11/06/Comments-on-blogs-vs-Social-Media.html" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"`

anyone got any brilliant ideas?  
will trade ideas for links to porn sites 😆

---

<div class="post-metadata">

**Author:** ![TerminalAddict](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/terminaladdict/32/1300_2.png) [@TerminalAddict](https://talk.jekyllrb.com/u/TerminalAddict)\
**Post date:** [December 10, 2018, 8:31am UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/3 "2018-12-10T08:31:52Z")

</div>

update:  
this seems to be working (for now)

```
<fieldset>
    <div class="g-recaptcha" data-sitekey="xxx" data-callback="verifyCaptcha"></div>
</fieldset>
<fieldset>
  <button type="button" id="comment-form-submit" class="btn" disabled="disabled" aria-disabled="true" >Submit Comment</button>
  <noscript>Your browser does not support JavaScript! You can't submit a comment.</noscript>
</fieldset>

```

then some JS

```
var verifyCaptcha = function(response) {
    if(response.length == 0) {
    } else {
    	var _el=$('#comment-form-submit');
        _el.removeAttr("disabled");
        _el.addClass('button-primary dark-blue-bg');
        _el.attr('aria-disabled', 'false');
        _el.attr('type', 'submit');
    }
};
```

---

<div class="post-metadata">

**Author:** ![Frank](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/frank/32/26_2.png) [@Frank](https://talk.jekyllrb.com/u/Frank)\
**Post date:** [December 10, 2018, 12:44pm UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/4 "2018-12-10T12:44:30Z")

</div>

Why don’t you activate moderation in your staticman config file?

---

<div class="post-metadata">

**Author:** ![TerminalAddict](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/terminaladdict/32/1300_2.png) [@TerminalAddict](https://talk.jekyllrb.com/u/TerminalAddict)\
**Post date:** [December 10, 2018, 5:43pm UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/5 "2018-12-10T17:43:33Z")

</div>

I do have moderation.  
It’s just super boring dealing with spam 🙂

So I’m trying to stop it before it turns into a pull request

---

<div class="post-metadata">

**Author:** ![mmistakes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/mmistakes/32/2169_2.png) [@mmistakes](https://talk.jekyllrb.com/u/mmistakes)\
**Post date:** [December 10, 2018, 8:24pm UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/6 "2018-12-10T20:24:32Z")

</div>

From what I can tell Staticman has [support for Akismet](https://staticman.net/docs/configuration#akismet.enabled)… which should help filter out spam. That said I’ve never had any luck or confirmation if it’s actually turned on after enabling it in the config or that it’s doing anything.

---

<div class="post-metadata">

**Author:** ![TerminalAddict](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/terminaladdict/32/1300_2.png) [@TerminalAddict](https://talk.jekyllrb.com/u/TerminalAddict)\
**Post date:** [December 11, 2018, 2:26am UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/7 "2018-12-11T02:26:54Z")

</div>

> [@mmistakes](#):
>
> From what I can tell Staticman has [support for Akismet](https://staticman.net/docs/configuration#akismet.enabled)… which should help filter out spam. That said I’ve never had any luck or confirmation if it’s actually turned on after enabling it in the config or that it’s doing anything.

I don’t think Akismet in staticman actually does anything ?

Anyway … I spoke too soon ☹

```
185.234.219.246 - - [11/Dec/2018:15:15:03 +1300] "GET /development/2018/11/06/Comments-on-blogs-vs-Social-Media.html HTTP/1.0" 200 167948 "https://terminaladdict.com/development/2018/11/06/Comments-on-blogs-vs-Social-Media.html" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0"
185.234.219.246 - - [11/Dec/2018:15:15:13 +1300] "POST /v2/entry/TerminalAddict/ta.com-website/master/comments HTTP/1.0" 200 1275 "https://terminaladdict.com/development/2018/11/06/Comments-on-blogs-vs-Social-Media.html" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0"

```

---

<div class="post-metadata">

**Author:** ![Infominer](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/infominer/32/2905_2.png) [@Infominer](https://talk.jekyllrb.com/u/Infominer)\
**Post date:** [October 20, 2020, 8:43am UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/8 "2020-10-20T08:43:28Z")

</div>

I know this is an old thread, but I came looking for answers, then found some, so…

akismet support is only available with self-hosted or on heroku

you need to set up environment variables with your site name and akismet api key wherever staticman is hosted.

> **[Staticman at Heroku](https://spinningnumbers.org/a/staticman-heroku.html#akismet---under-construction)**
>
> Staticman is a small web service that handles the POST requests from your forms, runs various forms of validation and manipulation and pushes the result to your repository as data files.

---

<div class="post-metadata">

**Author:** ![TerminalAddict](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/terminaladdict/32/1300_2.png) [@TerminalAddict](https://talk.jekyllrb.com/u/TerminalAddict)\
**Post date:** [October 21, 2020, 8:14pm UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/9 "2020-10-21T20:14:52Z")

</div>

well after nearly two years I can report that that html/js change fixed my spam problem.

Specifically, changing the html to button type=“button”, then dynamically changing to type=“submit” takes care of 99.999%  
This JS function seems to be the bizzo!

```
var verifyCaptcha = function(response) {
    if(response.length == 0) {
    } else {
    	var _el=$('#comment-form-submit');
        _el.removeAttr("disabled");
        _el.addClass('button-primary dark-blue-bg');
        _el.attr('aria-disabled', 'false');
        _el.attr('type', 'submit');
    }
};
```

---

<div class="post-metadata">

**Author:** ![willymcallister](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/willymcallister/32/180_2.png) [@willymcallister](https://talk.jekyllrb.com/u/willymcallister)\
**Post date:** [November 15, 2020, 1:26am UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/10 "2020-11-15T01:26:13Z")

</div>

Sounds promising. Can you say a bit more about this. What file is this code in? How/From where is it called? (I wrote the “Staticman at Heroku” post mentioned above. I’ve never figured out how to get Staticman to trigger an Akismet spam check.)

---

<div class="post-metadata">

**Author:** ![TerminalAddict](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/terminaladdict/32/1300_2.png) [@TerminalAddict](https://talk.jekyllrb.com/u/TerminalAddict)\
**Post date:** [November 18, 2020, 7:54pm UTC](https://talk.jekyllrb.com/t/staticman-fighting-spam/2388/11 "2020-11-18T19:54:47Z")

</div>

I have recaptcha … in my \_includes/post\_comments.html I have:

```auto
<div class="g-recaptcha" data-sitekey="yoursitekeyhere" data-callback="verifyCaptcha"></div>
<script src='https://www.google.com/recaptcha/api.js'></script>
<button type="button" id="comment-form-submit" class="btn btn-secondary" disabled="disabled">Submit Comment</button>
<noscript>Your browser does not support JavaScript! You can't submit a comment.</noscript>

```

the data-callback runs a Js function called verifyCaptcha … which I posted above.

That Js function changes the “button type” from button to type=submit which allows the form to be submitted.  
Plus it removes the disabled attribute.

Here is the working example:

> **[Jekyll Getting Started](https://terminaladdict.com/linux/jekyll/bash/development/2018/10/17/Jekyll-Getting-Started.html)**
>
> So my web development has taken an interesting path, not that different to some others.I start back in 1907 doing hand coded html, then moved to hand coded php, then dreamweaver, then CMS.Eventually making it to Wordpress then back to PHP, and now to...
