Skip to content

denisbakhtin/blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog boilerplate

Provides essentials that most web blogs need - MVC pattern, user authorisation, SQL db migration, admin dashboard, javascript form validation, rss feeds, etc.

It consists of the following core components:

TODO

  • Social plugins (share, like buttons)
  • Post updates on twitter, google +, linkedin

Usage

git clone https://github.com/denisbakhtin/blog.git
cd blog
go get .

Copy sample config cp config/config.json.example config/config.json, create postgresql database, modify config/config.json accordingly.

Use go run main.go -migrate=up to apply initial database migrations. go run main.go to launch web server. Or if you have https://github.com/cespare/reflex installed make debug.

Deployment

make build

Upload ginblog binary and public directory to your server. If you find rice embed-go is running slow on your system, consider using other go.rice packing options with go generate command.

Project structure

/config

Contains application configuration file.

/controllers

All your controllers that serve defined routes.

/migrations

Database schema migrations

/models

You database models.

/public

It has all your static files

/shared

Shared functions and structs.

/views

Your views using standard Go template system.

main.go

This file starts your web application, contains routes definition & some custom middlewares.

Make it your own

I assume you have followed installation instructions and you have ginblog installed in your GOPATH location.

Let's say I want to create Amazing Blog. I create new GitHub repository https://github.com/denisbakhtin/blog (of course replace that with your own repository).

Now I have to prepare blog. First thing is that I have to delete its .git directory.

I issue:

rm -rf src/github.com/denisbakhtin/blog/.git

Then I want to replace all references from github.com/denisbakhtin/blog to github.com/denisbakhtin/amazingblog:

grep -rl 'github.com/denisbakhtin/blog' ./ | xargs sed -i 's/github.com\/denisbakhtin\/blog/github.com\/denisbakhtin\/amazingblog/g'

Now I have to move all blog files to the new location:

mv src/github.com/denisbakhtin/blog/ src/github.com/denisbakhtin/amazingblog

And push it to my new repository at GitHub:

cd src/github.com/denisbakhtin/amazingblog
git init
git add --all .
git commit -m "Amazing Blog First Commit"
git remote add origin https://github.com/denisbakhtin/amazingblog.git
git push -u origin master

You can now go back to your GOPATH and check if everything is ok:

go install github.com/denisbakhtin/amazingblog

And that's it.

Continuous Development

For Continuous Development I recommend using Reflex - https://github.com/cespare/reflex

You can install Reflex by issuing:

go get github.com/cespare/reflex

Then create a config file reflex.conf in your GOPATH:

# Restart server when .go, .html files change
-sr '(\.go|\.html)$' go run main.go

Now if you run:

reflex -c reflex.conf

Project will automatically rebuild itself when a change to *.go, *.html files occurs. For more options read https://github.com/cespare/reflex#usage

Releases

No releases published

Packages

No packages published