Coder Social home page Coder Social logo

hugojoco's Introduction

Hugo JSON Comments

Hugo JSON Comments is a little Go program that listens to POST requests. If they match a specific format it processes them and saves them as JSON files into the Hugo source folder.

These files can then read using Hugo's readDir function and looped through. In the loop each of them can be read with the getJSON function. The decoded comment objects can then used to display the comments.

See http://saimiri.io/2016/06/comments-in-hugo/ for a more detailed explanation.

Note: This is still at proof-of-concept level, although I have it in production on my own site.

Installation

Usage

Typical usage might be:

$ hugojoco -source=/path/to/hugo -touch=.comment -salt=5VpsqeMX6N0IiUw3e0zfPLxDQ9J5CScvW0nQhUUWNfwziPDeDKHLA60LCsmUcsL2jfmIcChZXtnv1NhGOhpRsQ6o9OyUyeU3ZzDBlD6FTGOLInkm8dia3NuaSsPwlct4

This launches hugojoco, which then listens for incoming POST requests until terminated.

With default settings, hugojoco

  • processes comments posted at :8080/comment
  • saves each comment to ./comments directory
  • tries to look for content files in ./content directory
  • uses no salt for hashing email addresses

Switches

See hugojoco -h for options.

-source

Sets the source directory of your site. Default: "."

-content

Sets the content directory of your site relative to the source directory. Default: "content"

-comments

Sets the comments directory (that is, where the comments are saved) of your site relative to the source directory. Default: "comments"

-salt

The salt to use when hashing the email addresses for internal use. This is not intended to make the hash more secure but to make it unique for each site. Default: none

-address

The IP address to use for the server. Default: any address

-port

The port that the server listens to. Default: 8080

-path

The URL path that is used to process comments. Default: /comment

-touch

The file to modify when a comment is posted. This may be needed with some watch scripts that detect only modification of existing files, not the creation of new files or directories. This is relative to the source directory. Default: none

Using With nginx

If you are using nginx you can redirect requests to hugojoco with proxy_pass:

location /comment {
    proxy_pass http://127.0.0.1:8080;
  }

hugojoco's People

Contributors

saimiri avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.