Staticman...The Journey Continues

In this post I will do a quick dive on how I setup my own staticman instance in Heroku since the public API and Dev API are no longer responding.

First, this site from yasoob does a great job running down how to get this setup in Github and on Heroku. I will just add af ew changes I made based on the content of Issue #299.

As pointed out in yasoob’s post, and in a ton of issues on the repo, there are a few things amiss with the master branch. And some of the fixes mentioned in the post did not work for me, but here is what did…

As pointed out by the trusty VincentTam in his comment on Issue #299 he points out that in his deploy release he is uing 55d1430. So, that is what I used as well. And after some testing everything seems to work fine. I am using v3 on both of my sites and the Mailgun integration and all is working as expected. I have not tested GitLab integration as I do not have a GitLab setup, but I may give it a shot in the future.

So, here is the quick and dirty on how I did it:

  1. Fork the Staticman Repo
  2. Create a Heroku app as mentioned above
  3. Run git checkout -b workaround 55d1430 to create a branch named workaround from the commit mentioned above.
  4. Push that branch to Heroku using git push -f heroku workaround:master. I add the -f because I felt like living dangerously

If you configured all of your environment variables properly you should be good to go! I am running this instance on both NetworkHobo and Dan C Williams using the v3 API without issue.

I know this is quick, but I needed to get it out of my head. Please comment below if there are any questions. Thanks!


See also

21 comments

Xin Zhang
Friday, Aug 23, 2019

How did you encrypt the Mailgun API key and domain name? According to this tutorial that link doesn’t work any more.
Reply to Xin Zhang

Dan
In reply to Xin Zhang
Friday, Aug 23, 2019

Xin,

I just tried it and it worked for me. Here is the link I sent in my browser:

http://staticman-blog.herokuapp.com/v2/encrypt/test_data_to_encrypt

And here I received the encrypted string that was returned in the browser:

SnyVZNWY85qLOTS OF CHARACTERS9QDLMh5waZ2d34w==

If you are still having problems we can look into it further.

Xin Zhang
In reply to Xin Zhang
Friday, Aug 23, 2019

Aha, I see. forgot to add the data after that link, sorry for that mistake.

BTW, mailgun needs to be upgraded by adding card, otherwise we can’t add new domain. But, there’s something wrong with that. I can’t click the button upgrade after filling all info. Anyway, I opened a ticket for that and will let you know later.

Thanks!

Dan
In reply to Xin Zhang
Friday, Aug 23, 2019

Interesting. I haven’t touch my Mailgun in quite some time. I am curious to see what you find.

Xin Zhang
In reply to Xin Zhang
Wednesday, Aug 28, 2019

Now, the comment system works now. But, I can’t get the notification. Here’re some information:

  1. staticman.yml
  2. config.toml
  3. I can’t figure out any errors with these two files. So, maybe it’s related to the encrypted codes. I add the API key (from the ‘Settings - Details - Private API key’ at the side panel of mailgun) and domain name (from the ‘Sending - Domains’) by adding them to the end of http://dreambooker-staticman.herokuapp.com/v2/encrypt/.

Is there anything worng?

Reply to Thread

Xin Zhang
Wednesday, Aug 28, 2019

BTW, sometimes when I add notifications to staticman.yml, I would get the commit error when comment. Here’re codes:

  # Notification settings. When enabled, users can choose to receive notifications
  # via email when someone adds a reply or a new comment. This requires an account
  # with Mailgun, which you can get for free at http://mailgun.com.
  notifications:
    # Enable notifications
    enabled: true 
    # (!) ENCRYPTED
    #
    # Mailgun API key
    apikey: "L+YWcagHChYeXNAoo4FfGowImk3vffKqSV1JCQahWxehBZYvCU4blH5aK7WxL9FKnfBzkOpZAErWWqOJlTjxaF1dY2iSvhUhD4WunZMdgTOfZUrGNiE/Ev9xGaR432HHsOLn4pf9zkCF4qDbdR5A24t5pJsi4PC0TX2GyXjkyRDQAqkt91F5w/LknXRI0f7zbP3O8cxJnX5BrN+H5MiQaF+LZLYA6qy1Wi8/PKm2ZhYiLHHOUuXq0yRU1YEp3iXy/UDWIcUedNnnL3pGuJYxNCwsrr4A9lERiqDRT9RmOR+6SlanygLmlkRRR6y74x7T4j48KKLn5AC5gBw4P2yHDg=="
    # (!) ENCRYPTED
    #
    # Mailgun domain (encrypted)
    domain: "EaD+MUdSifQARd9Q6rg+MA5/tGRUdIKM15nwk0d5fWZlsdsIGHt01Ceplu5gxFCk1Gsq//oquZ2d/16xbwC/hG6ncRsiFca3xdkasmamiwwL3ibl1eVd1EaLxSYHQKDkCi4ta5VcER1CjFrz7shEQrU+B6lOnbcBSWDnunmIwb1cyNxpTcRQ+pmPQV7//hpNDYwu+Nih32rx5gSGmIMaoqJSAgfm0g/IUqvf+mvF7JSNHbIeY6xnnwod8sxG/nA3v3X/P97OZuM28/PFMEKSXbt3mBgks+KFunW765Sxppr7slfZHWBEqSBwU98BOT/oBggK5w4yjZHT6ag/jM9S+w=="
Reply to Xin Zhang

JINXIANG LU
Sunday, Sep 8, 2019

working?
Reply to JINXIANG LU

wini3d
Wednesday, Sep 11, 2019

Hey Dan, Thanks for this. btw, does this include the nested replies feature?

Also would be nice to have a One Click Heroku deployment.

https://github.com/eduardoboucas/staticman/issues/305

Reply to wini3d

Dan
In reply to wini3d
Wednesday, Sep 11, 2019

No worries. The nesting replies really relies upon tracking the reply IDs in your forms and how you structure your output in the Hugo templates. You can see how I do it in the repo for this site.

Comment Form Partial

Render Comments into Post Partial

Hope this helps! Let me know if you have any other questions.

Reply to Thread

Wini3D
Thursday, Sep 12, 2019

Thanks Dan, I’m actually using Jekyll and trying to add nested replies. I can’t find a clean version to copy to like using it with jekyll/minima theme.

Btw, do you have the heroku repo available for forking somewhere or on github? I can’t seem to get it running with my own heroku app instance and getting this message when posting comments:

{“success”:false,“rawError”:{“message”:“{\“message\”:\“Not Found\“,\“documentation_url\”:\“https://developer.github.com/v3/git/refs/#create-a-reference"}","statusCode":404},"errorCode":"GITHUB_CREATING_PR"}

Reply to Wini3D

Dan
In reply to Wini3D
Thursday, Sep 12, 2019

I currently do not have it up on Github, just here locally. I am getting ready to get on a plane but I can try to get something cleaned and pushed up.

As far as Jekyll, I have not used it. But, I know Minimal Mistakes was one of the pioneers in using Staticman with Replie, Check Here. I used a lot of his logic when learning how to do Staticman in Hugo.

Wini3D
In reply to Wini3D
Thursday, Sep 12, 2019

Thanks Dan and no worries. I got it sorted out with your tutorial here and created the right access token.

Now, I just need to display the nested replies format which I can’t still figure out. :/

Dan
In reply to Wini3D
Friday, Sep 13, 2019

Awesome! Is your site code on Github? I can give it a look when I have some time.

Wini3D
In reply to Wini3D
Friday, Sep 13, 2019

Thanks. Yes, here is my site code. https://github.com/wini3d/minimaj

It seems there is a problem with replying_to not getting sorted out. I have checked some jekyll staticman v2 enabled blogs and I see the _parent is used for the _parent and _id sorting and it works. I then see the new staticman v3 used _parent for the url and not the parent id.

Reply to Thread

Wini3D
Friday, Sep 13, 2019

Hey Dan, I finally figured it out! I just stumbled upon this blog by Chris Risner and just replaced the sorting to “” instead of blank. Everything is working fine now!
Reply to Wini3D

Dan
In reply to Wini3D
Friday, Sep 13, 2019

That is FANTASTIC news!
Reply to Thread

Yudy
Thursday, Sep 19, 2019

i have manage to deploy staticman to heroku (build notification was success)

-----> Build succeeded!

-----> Discovering process types

       Procfile declares types -> web

-----> Compressing...

       Done: 32.7M

-----> Launching...

       Released v4

       https://xxxx.herokuapp.com/ deployed to Heroku

but when i access the https://xxxx.herokuapp.com “the application eror”

any idea?

Reply to Yudy

Yudy
In reply to Yudy
Saturday, Sep 21, 2019

Ah I just figure it out… somehow the $(cat ./key.pem) not working so i have to put RSA_PRIVATE_KEY manualy in heroku dashboard.

Dan
In reply to Yudy
Saturday, Sep 21, 2019

Glad you figured it out! Sorry for the delay. I was traveling all week and am just now catching up.
Reply to Thread

Test
Saturday, Oct 5, 2019

This is a test comment
Reply to Test

Dan
In reply to Test
Sunday, Oct 6, 2019

This is a test reply
Reply to Thread

Say something

Send me an email when someone comments on this post.

Thank you

Your post has been submitted and will be published once it has been approved.

Click here to see the pull request you generated.

OK

OOPS!

Your post has not been submitted. Please return to the page and try again. Thank You!

If this error persists, please open an issue by clicking here.

OK