Camila Blanc Fick
Contenidos
Conocé más sobre el proyecto
Trata del desarrollo portfolio sencillo creado con Pelican para presentarlo en un Workshop del Campus Party 2021.
Originalmente dado por LinuxChix y editado por Jucha y camilaebf.
En colaboración a la comunidad Argentina de SysArmy & Nerdearla.
GitHub Pages
Source code for this site is available on branch /src, as GHP suggests on this page.
Pelican
¿Qué es Pelican?
Dockerizá tu entorno de desarrollo
Descarga la imagen o generala
Para descargar la imagen ejecuta en tu terminal
:
`docker pull camilaebf/pelican-dev-env:latest`
Ejectur el contenedor y acceder a la consola
`docker run -it --name pelicandevenv --rm --volume ${PWD}:/usr/src/app -p 8080:8000 camilaebf/pelican-dev-env:latest sh`
Este comando automáticamente descarga la imagen camilaebf/pelican-dev-env:latest
Esta imagen incluye las dependencias necesarias para tener andando tu sitio con Pelican dadas en el taller.
Crea tu propia imagen de docker
o bien creá un Dockerfile
para modificar la imagen a gusto:
FROM python:3.9.6-alpine
WORKDIR /usr/src/app
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
RUN apk add git
EXPOSE 8000
y un archivo de texto requirements.txt
:
pelican
typogrify
markdown
ghp-import
en el mismo directorio que el archivo Dockerfile
.
Ventajas: añadir más dependencias que pueda requerir según el contenido.
Contruyelo con:
`docker build -t pelicandevenv .`
No te olvides de agregar '.' al final del comando para refernciar al Dockerfile en el directorio actual.
Para ejecturarlo y acceder a la consola:
`docker run -it --name pelicandevenv --rm --volume ${PWD}:/usr/src/app -p 8080:8000 pelicandevenv:latest sh`
Curso docker en este link
Clonar el repositorio
Desde el directorio raiz del proyecto, donde inicialmente te encuentras, vamos a clonar el repositorio:
`git clone https://github.com/CamilaEBF/camilaebf.github.io.git`
TIP: puedes verificar en dónde te encuentras con el comando pwd
También podes verificar cual es el servidor remoto git remote -v
Ahora verás actualizado el directorio con el nombre del repositorio. Accedemos a él:
Rama src
Crear la rama y acceder a ella:
TIP: puedes verificar el estado de tu rama con git status
.
Ahora pasemos a crear el archivo .gitignore
:
Y en VS Code, o tu IDE de preferencia, escribe:
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
tests/output
# Translations
*.mo
*.pot
# Django stuff:
*.log
# Sphinx documentation
docs/_build/
# PyBuilder
target/
venv
# NPM
node_modules
Esto evitará que se almacene contenido que no se necesite en el repositorio remoto.
Crea el sitio con Pelican
Para crear el sitio con Pelican, ejecuta en tu terminal
:
Hará unas preguntas para su inicialización:
> Where do you want to create your new web site? [.]
> What will be the title of this web site? CamilaEBF
> Who will be the author of this web site? CamilaEBF
> What will be the default language of this web site? [en] es
> Do you want to specify a URL prefix? e.g., https://example.com (Y/n) https://camilaebf.github.io
> Do you want to enable article pagination? (Y/n) Y
> How many articles per page do you want? [10] Y
> What is your time zone? [Europe/Paris] America/Buenos_Aires
> Do you want to generate a tasks.py/Makefile to automate generation and publishing? (Y/n) *Y*
> Do you want to upload your website using FTP? (y/N) N
> Do you want to upload your website using SSH? (y/N) N
> Do you want to upload your website using Dropbox? (y/N) N
> Do you want to upload your website using S3? (y/N) N
> Do you want to upload your website using Rackspace Cloud Files? (y/N) N
> Do you want to upload your website using GitHub Pages? (y/N) Y
Done. Your new project is available at /usr/src/app
Contenido por defecto
Generaremos una página de inicio con una lista de artículos.
`/usr/src/app # pelican content`
Ejecutá el sitio
Veamos cómo se ve el sitio:
`/usr/src/app # pelican --listen -b 0.0.0.0`
## Accede
Desde tu navegador `http://localhost:8080`
Configura el tema Flex
Flex es el tema minimalista de Pelican.
Para instalarlo primero vamos a clonarlo:
`git clone https://github.com/alexandrevicenzi/Flex.git themes/Flex`
Nos creará una carpeta y clonará el repositorio del tema.
Opcional Plugins: git clone --recursive https://github.com/getpelican/pelican-plugins
Editar pelicanconf.py
Inicialmente tenemos:
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 | #!/usr/bin/env python
# -*- coding: utf-8 -*- #
AUTHOR = 'nombreDeUsuario'
SITENAME = 'nombreDeUsuario'
SITEURL = ''
PATH = 'content'
TIMEZONE = 'America/Buenos_Aires'
DEFAULT_LANG = 'es'
# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
# Blogroll
LINKS = (('Pelican', 'https://getpelican.com/'),
('Python.org', 'https://www.python.org/'),
('Jinja2', 'https://palletsprojects.com/p/jinja/'),
('You can modify those links in your config file', '#'),)
# Social widget
SOCIAL = (('You can add links in your config file', '#'),
('Another social link', '#'),)
DEFAULT_PAGINATION = 10
# Uncomment following line if you want document-relative URLs when developing
#RELATIVE_URLS = True
|
Quedando:
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 | #!/usr/bin/env python
# -*- coding: utf-8 -*- #
from datetime import datetime
AUTHOR = 'CamilaEBF'
SITENAME = 'CamilaEBF'
SITEURL = 'http://localhost:8080'
PATH = 'content'
TIMEZONE = 'America/Buenos_Aires'
DEFAULT_LANG = 'es'
DATE_FORMATS = {
"es": "%d-%m-%Y",
}
USE_FOLDER_AS_CATEGORY = False
COPYRIGHT_YEAR = datetime.now().year
DEFAULT_PAGINATION = 7
# Theme Settings
SITELOGO = "/images/title.jpg"
FAVICON = "/images/favicon.ico"
THEME = "themes/Flex"
PYGMENTS_STYLE = "native"
# Feed generation is usually not desired when developing
FEED_ALL_ATOM = None
CATEGORY_FEED_ATOM = None
TRANSLATION_FEED_ATOM = None
AUTHOR_FEED_ATOM = None
AUTHOR_FEED_RSS = None
# Main Menu
MAIN_MENU = True
MENUITEMS = (("Categories", "/categories"), ("Tags", "/tags"),)
# Blogroll
LINKS = (("Home", "https://camilaebf.xyz"),)
# Social widget
SOCIAL = (
("linkedin", "https://www.linkedin.com/in/camilablancfick/"),
("github", "https://github.com/CamilaEBF")
)
# Formatting for URLS
ARTICLE_URL = "{slug}"
PAGE_URL = "pages/{slug}"
CATEGORY_URL = "category/{slug}"
TAG_URL = "tag/{slug}"
AUTHOR_SAVE_AS = False
AUTHORS_SAVE_AS = False
DEFAULT_PAGINATION = 10
# Uncomment following line if you want document-relative URLs when developing
#RELATIVE_URLS = True
|
Luego, necesitamos instalar el tema con pelican:
`pelican-themes --install themes/Flex --verbose`
Ahora generamos los archivos del sitio:
`pelican content -o output -s pelicanconf.py`
Verificamos que se haya generado el sitio:
`pelican --listen -b 0.0.0.0`
Publicarlo
Los archivos del sitio se encuentran en la rama src y vamos a guardar la compilacion de la pagina en la rama main:
`ghp-import output -b main`
Pusheamos los cambios en github, si todavía no configuraste GitHub Pages, ingresa a la pagina de configuraciones del pryecto, bajo la pestaña Pages y selecciona la opcion "Source" y luego "Publish site".
Ahi seleccionas la rama en que se encuentran los archivos y publicas la pagina.
Like it? Star it