Skip to content

Commit a948d4b

Browse files
committed
initial
0 parents  commit a948d4b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+3965
-0
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# ---> Go
2+
3+
# Test binary, build with `go test -c`
4+
*.test
5+
6+
# Output of the go coverage tool, specifically when used with LiteIDE
7+
*.out
8+
9+
*.log
10+
11+
12+
# Binary
13+
hugobot
14+
15+
# Sqlite
16+
*.sqlite-*

Dockerfile

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM golang:1.11-alpine as builder
2+
3+
MAINTAINER Chakib <[email protected]>
4+
5+
# Copy source
6+
COPY . /go/src/hugobot
7+
8+
# install dependencies and build
9+
RUN apk add --no-cache --upgrade \
10+
ca-certificates \
11+
git \
12+
openssh \
13+
make \
14+
alpine-sdk
15+
16+
RUN cd /go/src/hugobot \
17+
&& make install
18+
19+
################################
20+
#### FINAL IMAGE
21+
###############################
22+
23+
24+
FROM alpine as final
25+
26+
ENV WEBSITE_PATH=/website
27+
ENV HUGOBOT_DB_PATH=/db
28+
29+
RUN apk add --no-cache --upgrade \
30+
ca-certificates \
31+
bash \
32+
sqlite \
33+
jq
34+
35+
COPY --from=builder /go/bin/hugobot /bin/
36+
37+
38+
RUN mkdir -p ${HUGOBOT_DB_PATH}
39+
RUN mkdir -p ${WEBSITE_PATH}
40+
41+
42+
VOLUME ${HUGOBOT_DB_PATH}
43+
44+
45+
# Expose API ports
46+
EXPOSE 8734
47+
48+
# copy entrypoint
49+
COPY "docker-entrypoint.sh" /entry
50+
51+
ENTRYPOINT ["/entry"]
52+
CMD ["hugobot", "server"]

Dockerfile-sqliteweb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM coleifer/sqlite
2+
RUN apk add --no-cache --virtual .build-reqs build-base gcc make \
3+
&& pip install --no-cache-dir cython \
4+
&& pip install --no-cache-dir flask peewee sqlite-web \
5+
&& apk del .build-reqs
6+
EXPOSE 8080
7+
VOLUME /db
8+
WORKDIR /db
9+
CMD sqlite_web -H 0.0.0.0 -x $SQLITE_DATABASE -P

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
TARGET=hugobot
2+
3+
GOINSTALL := GO111MODULE=on go install -v
4+
GOBUILD := GO111MODULE=on go build -v
5+
PKG := hugobot
6+
7+
.PHONY: all build install
8+
9+
10+
all: build
11+
12+
build:
13+
$(GOBUILD) -o $(TARGET)
14+
15+
install:
16+
$(GOINSTALL)
17+
18+
19+
20+
21+
22+

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
**MIRRORED FROM**: https://git.sp4ke.com/sp4ke/hugobot
2+
3+
# HUGOBOT
4+
5+
*hugobot* is a an automated content fetch and aggregation bot for [Hugo][hugo] data
6+
driven websites. It has the following features:
7+
8+
9+
## Data fetch
10+
11+
- Add feeds to the bot in the `feeds` sqlite table
12+
- Currently handles these types of feeds: `RSS`, `Github Releases`, `Newsletters`
13+
- Define your own feed types by implementing the `JobHandler` interface (see
14+
`handlers/handlers.go`).
15+
- Hugobot automatically fetch new posts from the feeds you defined
16+
- It runs periodically to download new posts in the defined feeds.
17+
- Everything is saved on an sqlite
18+
- The scheduler can handle any number of tasks and uses leveldb for
19+
caching/resuming jobs.
20+
21+
22+
## Hugo export
23+
24+
- Data is automatically exported to the configured Hugo website path.
25+
- It can export `markdwon` files or `json/toml` data files
26+
- All fields in the exported files can be customized
27+
- You can define custom output formats by using the `FormatHandler` interface.
28+
29+
30+
## API
31+
32+
- *hugobot* also includes a webserver API that can be used with Hugo [Data
33+
Driven Mode][data-driven].
34+
35+
- WIP: Insert and query data
36+
37+
- An example usage is the automated generation of Bitcoin addresses for new
38+
articles on [bitcointechweekly.com][btw-btc]
39+
40+
## Sqliteweb interface
41+
42+
- See Docker files
43+
44+
45+
[data-driven]:https://gohugo.io/templates/data-templates/#data-driven-content
46+
[btw-btc]:https://bitcointechweekly.com/btc/3Jv15g4G5LDnBJPDh1e2ja8NPnADzMxhVh
47+
[hugo]:https://gohugo.io

api.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package main
2+
3+
import (
4+
"io"
5+
"os"
6+
"strconv"
7+
8+
"git.sp4ke.com/sp4ke/hugobot/v3/feeds"
9+
10+
"git.sp4ke.com/sp4ke/hugobot/v3/config"
11+
12+
"git.sp4ke.com/sp4ke/hugobot/v3/bitcoin"
13+
14+
gum "git.sp4ke.com/sp4ke/gum.git"
15+
"github.com/gin-gonic/gin"
16+
)
17+
18+
var (
19+
apiLogFile *os.File
20+
)
21+
22+
type API struct {
23+
router *gin.Engine
24+
}
25+
26+
func (api *API) Run(m gum.UnitManager) {
27+
28+
feedsRoute := api.router.Group("/feeds")
29+
{
30+
feedCtrl := &feeds.FeedCtrl{}
31+
32+
feedsRoute.POST("/", feedCtrl.Create)
33+
feedsRoute.DELETE("/:id", feedCtrl.Delete)
34+
feedsRoute.GET("/", feedCtrl.List) // Get all
35+
//feedsRoute.Get("/:id", feedCtrl.GetById) // Get one
36+
}
37+
38+
btcRoute := api.router.Group("/btc")
39+
{
40+
btcRoute.GET("/address", bitcoin.GetAddressCtrl)
41+
}
42+
43+
// Run router
44+
go func() {
45+
46+
err := api.router.Run(":" + strconv.Itoa(config.C.ApiPort))
47+
if err != nil {
48+
panic(err)
49+
}
50+
}()
51+
52+
// Wait for stop signal
53+
<-m.ShouldStop()
54+
55+
// Shutdown
56+
api.Shutdown()
57+
m.Done()
58+
}
59+
60+
func (api *API) Shutdown() {}
61+
62+
func NewApi() *API {
63+
apiLogFile, _ = os.Create(".api.log")
64+
gin.DefaultWriter = io.MultiWriter(apiLogFile, os.Stdout)
65+
66+
api := &API{
67+
router: gin.Default(),
68+
}
69+
70+
return api
71+
}

0 commit comments

Comments
 (0)