Skip to content

Commit 8549f03

Browse files
committed
arquivos iniciais do pelican
1 parent 4991142 commit 8549f03

File tree

6 files changed

+346
-0
lines changed

6 files changed

+346
-0
lines changed

Makefile

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
PY=python
2+
PELICAN=pelican
3+
PELICANOPTS=
4+
5+
BASEDIR=$(CURDIR)
6+
INPUTDIR=$(BASEDIR)/content
7+
OUTPUTDIR=$(BASEDIR)/output
8+
CONFFILE=$(BASEDIR)/pelicanconf.py
9+
PUBLISHCONF=$(BASEDIR)/publishconf.py
10+
11+
FTP_HOST=localhost
12+
FTP_USER=anonymous
13+
FTP_TARGET_DIR=/
14+
15+
SSH_HOST=localhost
16+
SSH_PORT=22
17+
SSH_USER=root
18+
SSH_TARGET_DIR=/var/www
19+
20+
S3_BUCKET=my_s3_bucket
21+
22+
CLOUDFILES_USERNAME=my_rackspace_username
23+
CLOUDFILES_API_KEY=my_rackspace_api_key
24+
CLOUDFILES_CONTAINER=my_cloudfiles_container
25+
26+
DROPBOX_DIR=~/Dropbox/Public/
27+
28+
DEBUG ?= 0
29+
ifeq ($(DEBUG), 1)
30+
PELICANOPTS += -D
31+
endif
32+
33+
help:
34+
@echo 'Makefile for a pelican Web site '
35+
@echo ' '
36+
@echo 'Usage: '
37+
@echo ' make html (re)generate the web site '
38+
@echo ' make clean remove the generated files '
39+
@echo ' make regenerate regenerate files upon modification '
40+
@echo ' make publish generate using production settings '
41+
@echo ' make serve [PORT=8000] serve site at http://localhost:8000'
42+
@echo ' make devserver [PORT=8000] start/restart develop_server.sh '
43+
@echo ' make stopserver stop local server '
44+
@echo ' make ssh_upload upload the web site via SSH '
45+
@echo ' make rsync_upload upload the web site via rsync+ssh '
46+
@echo ' make dropbox_upload upload the web site via Dropbox '
47+
@echo ' make ftp_upload upload the web site via FTP '
48+
@echo ' make s3_upload upload the web site via S3 '
49+
@echo ' make cf_upload upload the web site via Cloud Files'
50+
@echo ' make github upload the web site via gh-pages '
51+
@echo ' '
52+
@echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html'
53+
@echo ' '
54+
55+
html:
56+
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
57+
58+
clean:
59+
[ ! -d $(OUTPUTDIR) ] || rm -rf $(OUTPUTDIR)
60+
61+
regenerate:
62+
$(PELICAN) -r $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS)
63+
64+
serve:
65+
ifdef PORT
66+
cd $(OUTPUTDIR) && $(PY) -m pelican.server $(PORT)
67+
else
68+
cd $(OUTPUTDIR) && $(PY) -m pelican.server
69+
endif
70+
71+
devserver:
72+
ifdef PORT
73+
$(BASEDIR)/develop_server.sh restart $(PORT)
74+
else
75+
$(BASEDIR)/develop_server.sh restart
76+
endif
77+
78+
stopserver:
79+
kill -9 `cat pelican.pid`
80+
kill -9 `cat srv.pid`
81+
@echo 'Stopped Pelican and SimpleHTTPServer processes running in background.'
82+
83+
publish:
84+
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(PUBLISHCONF) $(PELICANOPTS)
85+
86+
ssh_upload: publish
87+
scp -P $(SSH_PORT) -r $(OUTPUTDIR)/* $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR)
88+
89+
rsync_upload: publish
90+
rsync -e "ssh -p $(SSH_PORT)" -P -rvz --delete $(OUTPUTDIR)/ $(SSH_USER)@$(SSH_HOST):$(SSH_TARGET_DIR) --cvs-exclude
91+
92+
dropbox_upload: publish
93+
cp -r $(OUTPUTDIR)/* $(DROPBOX_DIR)
94+
95+
ftp_upload: publish
96+
lftp ftp://$(FTP_USER)@$(FTP_HOST) -e "mirror -R $(OUTPUTDIR) $(FTP_TARGET_DIR) ; quit"
97+
98+
s3_upload: publish
99+
s3cmd sync $(OUTPUTDIR)/ s3://$(S3_BUCKET) --acl-public --delete-removed
100+
101+
cf_upload: publish
102+
cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) .
103+
104+
github: publish
105+
ghp-import $(OUTPUTDIR)
106+
git push origin gh-pages
107+
108+
.PHONY: html help clean regenerate serve devserver publish ssh_upload rsync_upload dropbox_upload ftp_upload s3_upload cf_upload github

content/exemplo.rst

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Exemplo de Publicação
2+
#####################
3+
4+
:date: 2014-04-24 17:21
5+
:tags: exemplo
6+
:category: Geral
7+
:slug: exemplo-de-publicacao
8+
:author: André Luiz
9+
:summary: Exemplo de Publicação
10+
11+
===========
12+
Lorem Ipsum
13+
===========
14+
15+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
16+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
17+
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
18+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
19+
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
20+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

develop_server.sh

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/usr/bin/env bash
2+
##
3+
# This section should match your Makefile
4+
##
5+
PY=python
6+
PELICAN=pelican
7+
PELICANOPTS=
8+
9+
BASEDIR=$(pwd)
10+
INPUTDIR=$BASEDIR/content
11+
OUTPUTDIR=$BASEDIR/output
12+
CONFFILE=$BASEDIR/pelicanconf.py
13+
14+
###
15+
# Don't change stuff below here unless you are sure
16+
###
17+
18+
SRV_PID=$BASEDIR/srv.pid
19+
PELICAN_PID=$BASEDIR/pelican.pid
20+
21+
function usage(){
22+
echo "usage: $0 (stop) (start) (restart) [port]"
23+
echo "This starts pelican in debug and reload mode and then launches"
24+
echo "A pelican.server to help site development. It doesn't read"
25+
echo "your pelican options so you edit any paths in your Makefile"
26+
echo "you will need to edit it as well"
27+
exit 3
28+
}
29+
30+
function alive() {
31+
kill -0 $1 >/dev/null 2>&1
32+
}
33+
34+
function shut_down(){
35+
PID=$(cat $SRV_PID)
36+
if [[ $? -eq 0 ]]; then
37+
if alive $PID; then
38+
echo "Killing pelican.server"
39+
kill $PID
40+
else
41+
echo "Stale PID, deleting"
42+
fi
43+
rm $SRV_PID
44+
else
45+
echo "pelican.server PIDFile not found"
46+
fi
47+
48+
PID=$(cat $PELICAN_PID)
49+
if [[ $? -eq 0 ]]; then
50+
if alive $PID; then
51+
echo "Killing Pelican"
52+
kill $PID
53+
else
54+
echo "Stale PID, deleting"
55+
fi
56+
rm $PELICAN_PID
57+
else
58+
echo "Pelican PIDFile not found"
59+
fi
60+
}
61+
62+
function start_up(){
63+
local port=$1
64+
echo "Starting up Pelican and pelican.server"
65+
shift
66+
$PELICAN --debug --autoreload -r $INPUTDIR -o $OUTPUTDIR -s $CONFFILE $PELICANOPTS &
67+
pelican_pid=$!
68+
echo $pelican_pid > $PELICAN_PID
69+
cd $OUTPUTDIR
70+
$PY -m pelican.server $port &
71+
srv_pid=$!
72+
echo $srv_pid > $SRV_PID
73+
cd $BASEDIR
74+
sleep 1
75+
if ! alive $pelican_pid ; then
76+
echo "Pelican didn't start. Is the pelican package installed?"
77+
return 1
78+
elif ! alive $srv_pid ; then
79+
echo "pelican.server didn't start. Is there something else which uses port 8000?"
80+
return 1
81+
fi
82+
echo 'Pelican and pelican.server processes now running in background.'
83+
}
84+
85+
###
86+
# MAIN
87+
###
88+
[[ ($# -eq 0) || ($# -gt 2) ]] && usage
89+
port=''
90+
[[ $# -eq 2 ]] && port=$2
91+
92+
if [[ $1 == "stop" ]]; then
93+
shut_down
94+
elif [[ $1 == "restart" ]]; then
95+
shut_down
96+
start_up $port
97+
elif [[ $1 == "start" ]]; then
98+
if ! start_up $port; then
99+
shut_down
100+
fi
101+
else
102+
usage
103+
fi

fabfile.py

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from fabric.api import *
2+
import fabric.contrib.project as project
3+
import os
4+
5+
# Local path configuration (can be absolute or relative to fabfile)
6+
env.deploy_path = 'output'
7+
DEPLOY_PATH = env.deploy_path
8+
9+
# Remote server configuration
10+
production = 'root@localhost:22'
11+
dest_path = '/var/www'
12+
13+
# Rackspace Cloud Files configuration settings
14+
env.cloudfiles_username = 'my_rackspace_username'
15+
env.cloudfiles_api_key = 'my_rackspace_api_key'
16+
env.cloudfiles_container = 'my_cloudfiles_container'
17+
18+
19+
def clean():
20+
if os.path.isdir(DEPLOY_PATH):
21+
local('rm -rf {deploy_path}'.format(**env))
22+
local('mkdir {deploy_path}'.format(**env))
23+
24+
def build():
25+
local('pelican -s pelicanconf.py')
26+
27+
def rebuild():
28+
clean()
29+
build()
30+
31+
def regenerate():
32+
local('pelican -r -s pelicanconf.py')
33+
34+
def serve():
35+
local('cd {deploy_path} && python -m SimpleHTTPServer'.format(**env))
36+
37+
def reserve():
38+
build()
39+
serve()
40+
41+
def preview():
42+
local('pelican -s publishconf.py')
43+
44+
def cf_upload():
45+
rebuild()
46+
local('cd {deploy_path} && '
47+
'swift -v -A https://auth.api.rackspacecloud.com/v1.0 '
48+
'-U {cloudfiles_username} '
49+
'-K {cloudfiles_api_key} '
50+
'upload -c {cloudfiles_container} .'.format(**env))
51+
52+
@hosts(production)
53+
def publish():
54+
local('pelican -s publishconf.py')
55+
project.rsync_project(
56+
remote_dir=dest_path,
57+
exclude=".DS_Store",
58+
local_dir=DEPLOY_PATH.rstrip('/') + '/',
59+
delete=True
60+
)

pelicanconf.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*- #
3+
from __future__ import unicode_literals
4+
5+
AUTHOR = u'PythonClub'
6+
SITENAME = u'PythonClub'
7+
SITEURL = ''
8+
9+
TIMEZONE = 'Europe/Paris'
10+
11+
DEFAULT_LANG = u'pt'
12+
13+
# Feed generation is usually not desired when developing
14+
FEED_ALL_ATOM = None
15+
CATEGORY_FEED_ATOM = None
16+
TRANSLATION_FEED_ATOM = None
17+
18+
# Blogroll
19+
LINKS = (('Pelican', 'http://getpelican.com/'),
20+
('Python.org', 'http://python.org/'),
21+
('Jinja2', 'http://jinja.pocoo.org/'),
22+
('You can modify those links in your config file', '#'),)
23+
24+
# Social widget
25+
SOCIAL = (('You can add links in your config file', '#'),
26+
('Another social link', '#'),)
27+
28+
DEFAULT_PAGINATION = 10
29+
30+
# Uncomment following line if you want document-relative URLs when developing
31+
#RELATIVE_URLS = True

publishconf.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*- #
3+
from __future__ import unicode_literals
4+
5+
# This file is only used if you use `make publish` or
6+
# explicitly specify it as your config file.
7+
8+
import os
9+
import sys
10+
sys.path.append(os.curdir)
11+
from pelicanconf import *
12+
13+
SITEURL = ''
14+
RELATIVE_URLS = False
15+
16+
FEED_ALL_ATOM = 'feeds/all.atom.xml'
17+
CATEGORY_FEED_ATOM = 'feeds/%s.atom.xml'
18+
19+
DELETE_OUTPUT_DIRECTORY = True
20+
21+
# Following items are often useful when publishing
22+
23+
#DISQUS_SITENAME = ""
24+
#GOOGLE_ANALYTICS = ""

0 commit comments

Comments
 (0)