Skip to content
Permalink
Browse files

Add proper Drone config, README and fix issues (ineff/errcheck)

  • Loading branch information...
Depado committed Aug 22, 2019
1 parent 300fb9e commit 1660561ffd7a78a160e88e9a0ebed5b44444ff91
Showing with 89 additions and 33 deletions.
  1. +57 −17 .drone.yml
  2. +9 −9 README.md
  3. +9 −1 cmd/generate.go
  4. +1 −1 cmd/new.go
  5. +1 −1 cmd/root.go
  6. +1 −1 cmd/serve.go
  7. +6 −2 filesystem/filesystem.go
  8. +5 −1 views/views.go
@@ -1,19 +1,59 @@
workspace:
base: /go
path: src/github.com/Depado/smallblog/
---
kind: pipeline
name: default

pipeline:
prerequisites:
image: golang:1.10
commands:
- go get -u github.com/golang/dep/cmd/dep
- dep ensure
steps:
- name: fetch
image: docker:git
commands:
- git fetch --tags

test:
image: golang:1.10
commands:
- bash coverage.sh

codecov:
image: robertstettner/drone-codecov
secrets: [ codecov_token ]
- name: test
image: golang:latest
volumes:
- name: deps
path: /go
commands:
- go test -race -coverprofile=coverage.txt -covermode=atomic
environment:
GO111MODULE: "on"

- name: linter
image: golang:latest
volumes:
- name: deps
path: /go
commands:
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.17.1
- ./bin/golangci-lint run
environment:
GO111MODULE: "on"

- name: coverage
image: plugins/codecov
settings:
token:
from_secret: codecov_token
files:
- coverage.txt

- name: telegram
image: appleboy/drone-telegram
settings:
to: 790376882
format: markdown
token:
from_secret: telegram_token
message: >
*{{repo.name}}*
[Build {{build.number}}]({{build.link}}) by {{commit.author}} {{#success build.status}}succeeded{{else}}failed{{/success}} in {{buildtime build.started}}
`{{truncate commit.sha 8}}`: "{{commit.message}}"
when:
status:
- success
- failure

volumes:
- name: deps
host:
path: /var/lib/cache/godeps/
@@ -1,9 +1,8 @@
# Smallblog

![Go Version](https://img.shields.io/badge/go-1.9-brightgreen.svg)
![Go Version](https://img.shields.io/badge/go-1.10-brightgreen.svg)
![Go Version](https://img.shields.io/badge/go-latest-brightgreen)
[![Go Report Card](https://goreportcard.com/badge/github.com/Depado/smallblog)](https://goreportcard.com/report/github.com/Depado/smallblog)
[![Build Status](https://drone.depado.eu/api/badges/Depado/smallblog/status.svg)](https://drone.depado.eu/Depado/smallblog)
[![Build Status](https://drone.depa.do/api/badges/Depado/smallblog/status.svg)](https://drone.depa.do/Depado/smallblog)
[![codecov](https://codecov.io/gh/Depado/smallblog/branch/master/graph/badge.svg)](https://codecov.io/gh/Depado/smallblog)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Depado/smallblog/blob/master/LICENSE)

@@ -26,19 +25,20 @@ that's not as fun.

## Features

- Filesystem monitoring : Drop a new file or modify a file, bam, your blog is
updated
- Filesystem monitoring: Create, modify or delete a file and your blog is
updated
- Automatic syntax highlighting using [bfchroma](https://github.com/Depado/bfchroma)
(which uses [chroma](https://github.com/alecthomas/chroma) under the hood)
(which uses [chroma](https://github.com/alecthomas/chroma) under the hood)
- Supports [admonitions](https://python-markdown.github.io/extensions/admonition/)
using [bfadmonition](https://github.com/Depado/bfadmonition)
- No CGO dependencies
- Tag system
- Simple and customizable template and CSS for easy reading
- Comments using [gitalk](https://github.com/gitalk/gitalk)
- Supports global assets for all your articles
- Can generate a static site :
- Can generate a static site:
- Tags won't work
- Raw markdown won't work
- Can't test without a proper web server like Caddy or Nginx

## Tutorial

@@ -213,7 +213,7 @@ post's title if it is omitted.

## Example Article

`pages/example-article`
`pages/example-article.md`

```
title: "Example article !"
@@ -29,13 +29,21 @@ var generate = &cobra.Command{
logrus.WithError(err).Fatal("Couldn't parse directory")
}
t, err := template.ParseGlob("templates/*.tmpl")
if err != nil {
logrus.WithError(err).Fatal("Unable to parse templates")
}
for _, v := range models.MPages {
var fd *os.File
v.Slug = v.Slug + ".html"
if fd, err = os.Create(filepath.Join(pages, v.Slug)); err != nil {
logrus.WithError(err).Fatal("Couldn't create file")
}
t.ExecuteTemplate(fd, "post.tmpl", gin.H{"post": v, "gitalk": models.GetGitalk(), "local": true})
if err = t.ExecuteTemplate(
fd, "post.tmpl",
gin.H{"post": v, "gitalk": models.GetGitalk(), "local": true},
); err != nil {
logrus.WithError(err).Fatal("Unable to execute template")
}
}
var fd *os.File
if fd, err = os.Create(filepath.Join(output, "index.html")); err != nil {
@@ -88,5 +88,5 @@ func init() {
newCmd.Flags().String("author.github", "", "github username of the author (overrides global conf)")
newCmd.Flags().String("author.site", "", "website of the author (overrides global conf)")
newCmd.Flags().String("author.avatar", "", "URL to the author's avatar (overrides global conf)")
viper.BindPFlags(newCmd.Flags())
viper.BindPFlags(newCmd.Flags()) // nolint: errcheck
}
@@ -46,7 +46,7 @@ func init() {
rootCmd.PersistentFlags().Bool("blog.share", false, "add a Twitter share button on articles")

// Flag binding
viper.BindPFlags(rootCmd.PersistentFlags())
viper.BindPFlags(rootCmd.PersistentFlags()) // nolint: errcheck
}

func initialize() {
@@ -32,5 +32,5 @@ func init() {
serve.Flags().String("gitalk.repo", "", "repository where the comments will be stored")
serve.Flags().String("gitalk.owner", "", "repository owner")
serve.Flags().StringArray("gitalk.admins", []string{}, "gitalk admins")
viper.BindPFlags(serve.Flags())
viper.BindPFlags(serve.Flags()) // nolint: errcheck
}
@@ -5,6 +5,7 @@ import (
"path/filepath"

"github.com/rjeczalik/notify"
"github.com/sirupsen/logrus"

"github.com/Depado/smallblog/models"
)
@@ -30,11 +31,14 @@ func Watch(dir string) {
case notify.Write, notify.InMovedTo:
if p, ok := m[filepath.Base(ei.Path())]; ok {
// Existing file, needs to be parsed.
p.UpdateFromFile(ei.Path())
if err = p.UpdateFromFile(ei.Path()); err != nil {
logrus.WithError(err).WithField("file", ei.Path()).Error("Unable to update post")
}
} else {
// New file. Needs to be parsed and inserted.
p := new(models.Page)
var p *models.Page
if p, err = models.NewPageFromFile(ei.Path()); err != nil {
logrus.WithError(err).WithField("file", ei.Path()).Error("Unable to update post")
continue
}
m[filepath.Base(ei.Path())] = p
@@ -7,6 +7,7 @@ import (
"sort"

"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"

"github.com/Depado/smallblog/models"
@@ -69,7 +70,10 @@ func Post(c *gin.Context) {
func RawPost(c *gin.Context) {
slug := c.Param("slug")
if val, ok := models.MPages[slug]; ok {
c.Writer.Write([]byte(val.Raw))
if _, err := c.Writer.Write([]byte(val.Raw)); err != nil {
logrus.WithError(err).Error("Unable to write raw markdown")
c.String(http.StatusInternalServerError, "500 internal server error")
}
} else {
c.String(http.StatusNotFound, "404 not found")
}

0 comments on commit 1660561

Please sign in to comment.
You can’t perform that action at this time.