Coder Social home page Coder Social logo

ullaakut / bloggo Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 1.0 3.57 MB

The blogging CMS for go doggos

License: Apache License 2.0

Go 84.02% API Blueprint 4.29% Dockerfile 0.84% CSS 3.99% HTML 5.84% TSQL 1.01%
blog cms fast go jwt lightweight simple

bloggo's People

Contributors

dependabot-preview[bot] avatar ullaakut avatar veliona avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

5l1v3r1

bloggo's Issues

Write API Blueprints

  • Write a model for BlogPost
  • Define all routes
  • Add a script to automatically generate the API blueprint
  • Add a static HTML version of the blueprint to the repository
  • Remember to put the Authorization header in the routes that require it!

Blog setup page

  • Give an introduction to Bloggo on the first load of the app
  • Make the user create his admin account
  • Redirect the user to the home page

CreatedAt value has the right date but the hours/minutes/second are always set to 0

[
    {
        "id": 3,
        "author": "auth0|596f27c2c3709661e9cea37d",
        "title": "Lorem ipsum",
        "content": "Dolor sit amet",
        "created_at": "2018-08-03T00:00:00+02:00"
    },
    {
        "id": 4,
        "author": "auth0|596f27c2c3709661e9cea37d",
        "title": "Lorem ipsum 2",
        "content": "Dolor sit amet",
        "created_at": "2018-08-03T00:00:00+02:00"
    },
    {
        "id": 5,
        "author": "auth0|596f27c2c3709661e9cea37d",
        "title": "Lorem ipsum 3",
        "content": "Dolor sit amette",
        "created_at": "2018-08-03T00:00:00+02:00"
    },
    {
        "id": 6,
        "title": "EDITED TITLE",
        "content": "EDITED CONTENT",
        "created_at": "2018-08-03T00:00:00+02:00"
    }
]

It could be due to a configuration issue in gorm or MySQL. Need to investigate.

Add token signature verification

I just realized that currently, token signatures are not verified at all!

This means we need to store the secret somewhere to put it in the configuration. Normally I would password-protect it and ensure that a human inputs the credentials to decrypt it and deploy the stack, but to keep the testing of this project fast and easy, I will just get it from the environment and set it in the docker-compose.yml file, but don't do this at home!

  • Update postman collection token
  • Update README tokens
  • Update unit test tokens
  • Update documentation to explain that the secret should be set when creating your own token

Add pre-commit hook for UT & format

It could be neat to have a git hook that would make sure that all unit tests are passing before committing new code.

It could also run goimports or goreturns automatically on all of the code base.

Integrate frontend from mockups

  • Build a simple static website that does a simple ajax request to the API and appends the results of the API call to the list of articles

Something like what I did for my personal website should be quick & easy:

	<script>
		$(function(){

			$.ajax({
				type: "GET",
				headers: {
					"Access-Control-Allow-Origin": "*",
				},
				url: "https://ommnvjncbj.execute-api.us-east-2.amazonaws.com/Unknown/posts"
			})
			.done(function(data) {
				// console.log(data["body"])
				var posts = jQuery.parseJSON(data["body"])

				$.each(posts, function(k, v) {
					console.log(v["id"])
					console.log(v["title"])
					console.log(v["firstPublishedAt"])
					console.log(v["uniqueSlug"])


					$("#articles .row").append(`
					<article class="6u 12u$(xsmall) work-item">
						<a href="https://medium.com/@brendanleglaunec/` + v["uniqueSlug"] + `" class="image fit">
							<h3 class="medium-post">` + v["title"] + `</h3>
						</a>
					</article>`)
				})
			})
		})
	</script>

Automatically mount data in the database to make testing easier

  • Manually fill the db using adminer
  • Dump the db into a .sql file
  • Mount this file like this:
  mysql:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - ./data/blog_posts.sql:/docker-entrypoint-initdb.d/01-blog_posts.sql
      - ./data/users.sql:/docker-entrypoint-initdb.d/02-users.sql

Design homepage

  • Photoshop a basic blog home page
  • Menu with search, profile and settings
  • Profile, bio, social media links
  • Blog articles
  • For now no worries about the footer

Add Dockerfile & docker-compose.yml

  • Make multi-stage Dockerfile to build Bloggo
  • Make docker-compose file that also launches the DB (& config service if needed) automatically
  • Dockerize API blueprints

Add DynamoDB repositories

  • Add a database repository to make Bloggo able to use a DynamoDB database instead of just MySQL.

See #10 for more information.

Base structure of the Bloggo

I started working on it after work today, and spent a few hours recycling a previous project of mine to build the structure of Bloggo. Also I found a name for the project, Bloggo, which sounds pretty cool.

  • Basic static configuration (no config file/env override yet)
  • Readme describing the project
  • Basic authentication service (for now simplified by removing the database from the equation and using a map) used as middleware
  • Basic blod post CRUD (for now simplified by removing the database from the equation and using a map)
  • Structured logging
  • Gracefully stopping server

I also started writing an API Blueprint but it's not the right time to do it yet, however it's a great reminder that I have to do it in the future.

Theme customization page

Depends on issues #76 & #67 & #78

  • Allow the user to choose between preset themes
  • When the user chooses a theme, send a request to the backend to update the theme
  • Provide a button to the grid customization page (which will come later on)

Theme customization

  • Allow the user to change the main background color
  • Allow the user to change the sidebar background image
  • Allow the user to change the fonts (choosing between preset fonts)
  • Allow the user to change the font colors

API

  • When the user is uploading images for his theme, use the backend route to upload them
  • The backend will give you the path to the image that has been uploaded
  • Using this path, the colors and fonts that the user chose, generate a css file using Javascript
  • Upload this css file using the backend route from #76

Polish documentation for release

  • Add a gif demonstrating the API
  • Update dependencies (remove go & dep)
  • Mention the postman collection in testing
  • Add an index to the readme
  • Add goreport, latest release & license badges

Theme backend route

  • Add route to change the theme

  • Allow to upload css files and use them as the main css file used by Bloggo

  • Keep previous css files archived

  • Store css files info in database

  • Add theme repository (create, get, update, delete)

  • Add theme controller

Add route to edit blog post

  • Add repository Delete method
  • Add blog controller Delete method
  • Add repository mock Delete method
  • Add validation of new entity
  • Enforce author to user ID token to avoid stealing of blog posts

Image upload route

  • Make the difference between theme images, blog post images and avatars

  • Add route, repository and controller for uploading images

  • Support at least PNG and JPG

  • Support max size of 2mb

  • Add image upload controller

  • Add image upload repository

  • Keep image paths in the database

Add logo

Logo should have a gopher and a doggo

Plug to ELK to take full advantage of the structured logs

  • Either use Greylog or ELK
  • Add Greylog/ELK to docker-compose
  • Forward docker logs to logstash using gelf log driver and giving it the address of the local logstash instance
  • Setup Kibana/Greylog boards to visualize traffic & other metrics

Setup CI

  • Choose which CI tool to use (CircleCI, Travis, Jenkins...)
  • Add configuration file for CI
  • Automate tests
  • Automate builds
  • Automate docker hub deployments when a new release is made
  • Automate binary builds when a new release is made

Add more routes to the API

  • A route to get blog post IDs: This would be useful if we were to add a frontend, to avoid loading all of the data from the API while we might want to display only 10 blog posts on a page for example.
    OR
  • Modify the RealAll route by adding an optional pagination/limit parameter

Add coveralls integration to enforce unit test coverage

This would help to make it obvious when a new feature is not unit tested, or a change reduces the test coverage. Thanks to coveralls, maintaining a high test coverage can be enforced.

  • Modify CI script to go get github.com/mattn/goveralls
  • Add coveralls token to CI configuration
  • Give coveralls repo access

Configurable configuration!

screenshot 2018-08-01 at 22 59 35

Currently, the configuration is simply hardcoded since we just use the default values defined in config.go. It would be nice to at least be able to configure the app using the environment.

Why not also, if I have time, add a configuration file or a k/v store containing the config.

Fix test coverage missing since add of CreatedAt field

I really should have set up an automated test coverage tool. Because of not including one, I completely forgot to double check my unit tests, and it turned out that they were no longer at 100%.

Also, I apparently missed a path in my unit tests for the access service, so this also needs to be fixed.

  • Unit tests back to 100% for controllers
  • Unit tests back to 100% for service

HTTP error messages aren't found in response body

The logs seem normal, but in Postman we don't seem to receive the error message that is displayed in the logs.

I think it's due to the way resources not found are handled, I forgot to add .Error() to give the string value to echo.NewHTTPError(httpCode, interface{}), and I think passing an error in the interface{} parameter just returns an empty object.

screenshot 2018-08-04 at 00 17 30

screenshot 2018-08-04 at 00 17 40

Grid layout

  • Use CSS grids to make a grid layout that matches the mockup
  • Fill it with the names of the different parts
  • Make sure it is responsive
  • Make sure the basic version is the mobile version
  • Make sure that if the browser does not support CSS grids, the mobile version is served

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.