Giter Site home page Giter Site logo

aerth / cosgo Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 1.0 980 KB

:pencil: Experimental (broken?) Contact Form Server. Saves to local .mbox file... Option for GPG, SendGrid. Easy Heroku deployment.

License: MIT License

Go 77.44% Shell 4.91% Makefile 8.14% HTML 9.52%
contact-form server gpg gnupg webform contact

cosgo's Introduction

cosgo

when all you needed was a contact form, anyways.

Go Report Card

  • Save the mail: Contact form saves messages to a local .mbox file
  • Read the mail with something like: mutt -Rf cosgo.mbox
  • Option to send mail using Sendgrid
  • Option to use GPG for encrypting the messages
  • Customize: Uses two Go style templates, templates/index.html and templates/error.html
  • Static Files: /sitemap.xml /favicon.ico, /robots.txt. Extensions limited to .woff, .ttf, .css, .js .png .jpg and custom -ext flag
  • Easy to convert static web sites to cosgo theme.
  • No database, from no log to (very verbose) debug log
  • No dependencies. Runs 'out of the box'

The MIT License (MIT)

Copyright (c) 2016 aerth

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Usage Examples

First, cd into a new empty directory such as $HOME/cosgo, 
this will allow you to easily see which files cosgo creates on boot.
cosgo -h # show flags
cosgo # normal boot and serve
cosgo -debug # more verbosity
cosgo -nolog -quiet # no output whatsoever
cosgo -bind 127.0.0.1 -port 8000 # nginx or hidden service setup (bind only to localhost)
cosgo -bind 0.0.0.0 -port 8000 # listen and serve (bind to all interfaces)
cosgo -gpg publickey.asc # loads publickey.asc into memory

See newest version in action! It is automatically deployed at https://cosgo.herokuapp.com/


Installation

Releases:

  1. Extract the archive.
  2. Copy the binary to /usr/local/bin/ ( or extract everything to C:/cosgo/ )
  3. Run cosgo from the command line. This will listen on all interfaces, port 8080 and create static/templates directories.
  4. Edit templates, static files

Building from source:

# Grab latest source code ( also check https://isupon.us for more info )
git clone https://github.com/aerth/cosgo.git && cd cosgo
# make deps # optional, cosgo comes with vendor directory.
# Build a static binary
make

# Install to /usr/local/bin/cosgo
sudo make install


Theme

Customize the theme by modifying ./templates/index.html and ./templates/error.html Included in the binary is the bare minimal and is not intended to look very fancy. If they don't exist, the templates and static directories will be created where you run cosgo from. (since v0.9) You can upload your static .css .js .png .jpeg .woff and .ttf files in ./static/foldername/file You can include them in your templates as /static/{foldername}/whatever.css They will be available like any typical static file server. Some web design themes look in /assets, which won't be served by cosgo. You can use the -static flag to change this.

Copy favicon.ico into static/. it will be served as if it were located at /favicon.ico

Also copy robot.txt into static/, it will be served at /robots.txt

/static /static/js/jquery.js /static/css/style.css /static/favicon.ico /static/robots.txt

/templates/index.html /templates/error.html


cron

COSGO_DESTINATION=[email protected]
COSGOPORT=8080

@reboot /demon/$USER/cosgo -port $COSGOPORT> /dev/null 2>&1

Sample Nginx Config

server {
        server_name default_address example.com example.net;
        listen 80;
        location / {
        proxy_pass http://127.0.0.1:8080; # Change to your cosgo port
        }
}

Fortunes

Cosgo now has a random fortune for each visitor. Default is disabled. To enable it, make a file called "fortunes.txt" with double-line separated pre-formatted text.

Such as

Welcome!


Welcome!!

Here is a shell script that populates the file with standard unix "fortune" command.


#!/bin/sh
# double line separated fortunes. some get cut off but oh well.
echo "Populating fortunes.txt, press Ctrl C when you think its big enough."
for i in $(cat fortunes.txt); do 
fortune -o >> fortunes.txt && echo "" >> fortunes.txt;

More information at Wiki

More code examples at https://github.com/aerth/cosgo/wiki

Please add your use case. It could make cosgo better. Report any bugs or feature requests directly at https://isupon.us


Historical Information

  • Casgo is short for "Contact API server in Golang"
  • Turns out theres another casgo. Now this is cosgo.
  • Cosgo is still not to be confused with Costco, the warehouse-style superstore.
  • It began as a fork of https://github.com/munrocape/staticcontact

cosgo's People

Contributors

aerth avatar munrocape avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

anoduck

cosgo's Issues

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.