-
Notifications
You must be signed in to change notification settings - Fork 104
/
Makefile
83 lines (69 loc) · 2.85 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
VENV := $(shell echo ${VIRTUAL_ENV})
PY=$(VENV)/bin/python
PELICAN?=$(VENV)/bin/pelican
PELICANOPTS=
PORT?=8000
BASEDIR=$(CURDIR)
INPUTDIR=$(BASEDIR)/content
OUTPUTDIR=$(BASEDIR)/output
CONFFILE=$(BASEDIR)/pelicanconf.py
PUBLISHCONF=$(BASEDIR)/publishconf.py
PAGESDIR=$(INPUTDIR)/pages
DATE := $(shell date +'%Y-%m-%d %H:%M:%S')
SLUG := $(shell echo '${NAME}' | sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z)
EXT ?= md
EDITOR ?= vim
at_output=mkdir -p $(OUTPUTDIR) && cd $(OUTPUTDIR)
DEBUG ?= 0
ifeq ($(DEBUG), 1)
PELICANOPTS += -D
endif
help:
@echo 'Makefile para um website usando Pelican '
@echo ' '
@echo 'Uso: '
@echo ' make up gera o site e o serve na porta '
@echo ' make html (re)gera o site '
@echo ' make newpost NAME="POST NAME" cria um novo post com o nome de entrada '
@echo ' make newpage NAME="PAGE NAME" cria nova página com o nome de entrada '
@echo ' make clean remove os arquivos gerados '
@echo ' make serve [PORT=8000] serve o site em http://localhost:8000 '
@echo ' '
@echo 'Especifique a variável DEBUG=1 para habilitar debugging, ex. make DEBUG=1 up '
@echo ' '
up: html serve
clean:
[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
html:
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
serve:
@echo "Starting test server is running on http://0.0.0.0:$(PORT)"
$(PELICAN) -l $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
publish:
"$(PELICAN)" "$(INPUTDIR)" -o "$(OUTPUTDIR)" -s "$(PUBLISHCONF)" $(PELICANOPTS)
newpost:
ifdef NAME
echo "Title: $(NAME)" > $(INPUTDIR)/$(SLUG).$(EXT)
echo "Slug: $(SLUG)" >> $(INPUTDIR)/$(SLUG).$(EXT)
echo "Date: $(DATE)" >> $(INPUTDIR)/$(SLUG).$(EXT)
echo "Tags: " >> $(INPUTDIR)/$(SLUG).$(EXT)
echo "" >> $(INPUTDIR)/$(SLUG).$(EXT)
echo "" >> $(INPUTDIR)/$(SLUG).$(EXT)
${EDITOR} ${INPUTDIR}/${SLUG}.${EXT}
else
@echo 'Variável NAME não está definida.'
@echo 'Faça make newpost NAME='"'"'nome do post'"'"
endif
newpage:
ifdef NAME
echo "Title: $(NAME)" > $(PAGESDIR)/$(SLUG).$(EXT)
echo "Description: " > $(PAGESDIR)/$(SLUG).$(EXT)
echo "Slug: $(SLUG)" >> $(PAGESDIR)/$(SLUG).$(EXT)
echo "" >> $(PAGESDIR)/$(SLUG).$(EXT)
echo "" >> $(PAGESDIR)/$(SLUG).$(EXT)
${EDITOR} ${PAGESDIR}/${SLUG}.$(EXT)
else
@echo 'Variável NAME não está definida.'
@echo 'Faça make newpage NAME='"'"'Nome da página'"'"
endif
.PHONY: up html help clean serve newpost newpage