diff --git a/.dockerignore b/.dockerignore deleted file mode 100644 index 968886bb2..000000000 --- a/.dockerignore +++ /dev/null @@ -1,123 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so -*.o -*.c - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -*.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 -.hypothesis/ -.pytest_cache/ -TEST-*.xml -results.xml - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ -docs/doctrees/ -docs/html/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed files -*.sage.py - -# dotenv -.env - -# virtualenv -.venv -venv/ -ENV/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ - -# Local files -*.dump -*.dump.gz -*.local.cfg -*.swp -*.swo -tmp/ -.vscode/ - -# Nikola output -output -cache -.doit.db -.git diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e7fd0edf7..000000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM tiangolo/uwsgi-nginx-flask:python3.9 - -RUN apt-get update && apt-get install -y rsync - -ENV UWSGI_CHEAPER 1 -ENV UWSGI_PROCESSES 2 - -COPY requirements_freeze.txt /tmp/requirements_wiki.txt -RUN pip install --no-cache-dir -r /tmp/requirements_wiki.txt - -COPY ./app /app -RUN mkdir /app/wiki_repo \ - && git clone https://github.com/PyAr/wiki.git /app/wiki_repo \ - && cd /app/wiki_repo \ - && nikola build \ - && cp -r /app/wiki_repo/output/* /usr/share/nginx/html \ No newline at end of file diff --git a/README.rst b/README.rst index 94fb0be8e..b2a893355 100644 --- a/README.rst +++ b/README.rst @@ -2,17 +2,19 @@ Este es el repositorio de los contenidos de la Wiki de Python Argentina | http://wiki.python.org.ar/ + Podés editar los contenidos (incluso agregar páginas) y proponer un pull request, que se sincronizará automáticamente con la wiki una vez que sea mezclado. -Antes de clonar el repo, asegurate de tener instalado [Git LFS](https://git-lfs.github.com/) - Pueden ver como colaborar en la página de `Cómo colaborar -`__ +`__ Cómo buildear las páginas ========================= +El contenido de la wiki está escrito en `Markdown `__ o `reStructeredText `__ y se +transforma a `HTML` con `nikola `__, un generador de sitios estáticos escrito en python. + .. code-block:: console pip install -U pip @@ -20,14 +22,3 @@ Cómo buildear las páginas nikola build nikola serve - -Cómo buildear la imagen de docker -================================= - -.. code-block:: console - - docker build --no-cache --tag tzulberti/wiki -f Dockerfile . - - -Se necesita el `--no-cache` para que la parte de clonar el repo de la -wiki no use un cache sino que se haga todo el tiempo. diff --git a/app/main.py b/app/main.py deleted file mode 100644 index 9c3d4e796..000000000 --- a/app/main.py +++ /dev/null @@ -1,173 +0,0 @@ -# Script used to pull the repository and if needed run nikola -# to update the changes - -import os -import shutil -import subprocess -import threading -import logging -import sys -from queue import Queue - -from flask import Flask - -import sentry_sdk -from flask import Flask -from sentry_sdk.integrations.flask import FlaskIntegration - -logging.basicConfig( - level=logging.DEBUG, - format='%(asctime)s %(levelname)-8s %(message)s', - datefmt='%Y-%m-%d %H:%M:%S', - stream=sys.stdout -) - -REPO_URL = os.environ.get("REPO_URL", "https://github.com/PyAr/wiki.git") -BRANCH_NAME = os.environ.get("BRANCH_NAME", "master") -CLONE_PATH = os.environ.get("CLONE_PATH", "/app/wiki_repo") -DESTINATION_PATH = os.environ.get("DESTINATION_PATH", "/usr/share/nginx/html") - -sentry_dsn = os.environ.get("SENTRY_DSN") -if sentry_dsn: - sentry_sdk.init( - dsn=sentry_dsn, - integrations=[FlaskIntegration()], - # Set traces_sample_rate to 1.0 to capture 100% - # of transactions for performance monitoring. - # We recommend adjusting this value in production. - traces_sample_rate=1.0, - ) - -# Como nota general todas las URLs empiezan con _ para asegurarme de -# que no haya conflicto con alguna pagina existente. Si se actualiza -# las URLs usadas en este archivo tambien se tiene que actualizar el -# nginx/defaults.conf que esta en este repo -app = Flask(__name__) -queue = Queue() - - -@app.route("/_update/async", methods=["GET", "POST", "PUT"]) -def update_async(): - """Actualiza la wiki pero no espera para saber el resultado de la operacion. - - Este es el endpoint usado por github. - """ - try: - queue.put(1) - return {"succcess": 1, "updated": "unknown"} - except Exception as e: - logging.exception("Error when calling update async") - return {"succcess": 0, "error": str(e)} - - -@app.route("/_update/sync", methods=["GET", "POST", "PUT"]) -def update_sync(): - """Actualiza la wiki pero espera el resultado de la misma. - - Este endpoint es para debug o por si lo queremos forzar. - """ - try: - return {"succcess": 1, "updated": update_wiki()} - except Exception as e: - logging.exception("Error when calling update sync") - return {"succcess": 0, "error": str(e)} - - -def worker(): - while True: - val = queue.get() - try: - update_wiki() - except Exception as e: - logging.exception("Error on woker") - - -def update_wiki(): - """Actualiza la wiki - - Para esto: - 1. Se clona el repo - 2. Hace un pull con los ultimos cambios - 3. Corre nikola - 4. Copia los archivos al path final - """ - force_build = False - if not os.path.exists(CLONE_PATH): - logging.info(f"{CLONE_PATH} not found. Clonning repo") - subprocess.check_call(["git", "clone", REPO_URL, CLONE_PATH]) - force_build = True - else: - logging.info(f"{CLONE_PATH} found") - # the path might exists but there might be no .git folder. This - # might happen if a new Wiki version was deployed - if not os.path.exists(os.path.join(CLONE_PATH, ".git")): - logging.info(f"{CLONE_PATH} isn't a git repo. Clonning repo") - force_build = True - os.chdir("/") - shutil.rmtree(CLONE_PATH) - subprocess.check_call(["git", "clone", REPO_URL, CLONE_PATH]) - os.chdir(CLONE_PATH) - - should_build = False - if force_build: - should_build = True - else: - # git rev-parse HEAD - # git ls-remote origin -h refs/heads/master - local_head = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip() - remote_head = ( - subprocess.check_output( - ["git", "ls-remote", "origin", "-h", "refs/heads/master"] - ) - .split()[0] - .strip() - ) - logging.info(f"The git versions are: local:{local_head}, remote:{remote_head}") - should_build = local_head != remote_head - if should_build: - logging.info("Doing a git pull") - subprocess.check_call(["git", "pull"]) - - if not should_build: - logging.info("No changes. Not buidling nikola") - return False - - logging.info("Building nikola") - subprocess.check_call(["nikola", "build"]) - - logging.info("Copying files") - cmd = [ - "rsync", - "-t", - "-r", - "--delete", - "--inplace", - os.path.join(CLONE_PATH, "output/"), - DESTINATION_PATH, - ] - subprocess.check_call(cmd) - return should_build - - -@app.route("/_debug/ping") -def ping(): - """Debug endpoint para testear que la webapp esta corriendo""" - return {"succcess": 0} - - -@app.route("/_debug/test_sentry") -def test_sentry(): - """Debug endpoint para testear que sentry esta configurado""" - 1 / 0 - - -@app.route("/_debug/git_commit") -def git_commit(): - """Debug endpoint para testear el utlimo commit que se esta usando.""" - if not os.path.exists(CLONE_PATH): - return {"succcess": 0, "error": "Repo not cloned"} - os.chdir(CLONE_PATH) - local_head = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip() - return {"succcess": 1, "local_commit": str(local_head)} - -threading.Thread(target=worker).start() diff --git a/app/nginx.conf b/app/nginx.conf deleted file mode 100644 index 0d842fcfb..000000000 --- a/app/nginx.conf +++ /dev/null @@ -1,33 +0,0 @@ -user nginx; -worker_processes 1; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - - -events { - worker_connections 1024; -} - - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - #gzip on; - - include /app/nginx/*.conf; -} - -daemon off; \ No newline at end of file diff --git a/app/nginx/default.conf b/app/nginx/default.conf deleted file mode 100644 index 368f112d2..000000000 --- a/app/nginx/default.conf +++ /dev/null @@ -1,47 +0,0 @@ -server { - listen 80; - listen [::]:80; - server_name localhost; - - #access_log /var/log/nginx/host.access.log main; - - location / { - root /usr/share/nginx/html; - index index.html index.htm; - } - - location /_update/sync { - include uwsgi_params; - uwsgi_pass unix:///tmp/uwsgi.sock; - } - - location /_update/async { - include uwsgi_params; - uwsgi_pass unix:///tmp/uwsgi.sock; - } - - location /_debug/ping { - include uwsgi_params; - uwsgi_pass unix:///tmp/uwsgi.sock; - } - - location /_debug/git_commit { - include uwsgi_params; - uwsgi_pass unix:///tmp/uwsgi.sock; - } - - location /_debug/test_sentry { - include uwsgi_params; - uwsgi_pass unix:///tmp/uwsgi.sock; - } - - #error_page 404 /404.html; - - # redirect server error pages to the static page /50x.html - # - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } - -} diff --git a/app/uwsgi.ini b/app/uwsgi.ini deleted file mode 100644 index 7bd1dab04..000000000 --- a/app/uwsgi.ini +++ /dev/null @@ -1,5 +0,0 @@ -[uwsgi] -module = main -callable = app -enable-threads = true -lazy-apps=true \ No newline at end of file diff --git a/pages/colaborandoenelwiki.rst b/pages/colaborandoenelwiki.rst index 148a8da5f..123e89637 100644 --- a/pages/colaborandoenelwiki.rst +++ b/pages/colaborandoenelwiki.rst @@ -39,6 +39,10 @@ Hay dos formas de proponer mejoras: En cualquier caso, siempre es necesario que se creen una cuenta en `GitHub `_ + +Los contenidos de la wiki pueden ser escritos en `Markdown `__ o en `reStructeredText`. +`Markdown` es muy sencillo de aprender y utilizar pero tiene una sintaxis limitada a diferencia de `reStructeredText` que permite una mayor configurabilidad. + Si no saben mucho de reStructuredText, estos son algunos links que les pueden ayudar: diff --git a/requirements.txt b/requirements.txt index d9d033d5d..bd195c1bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1 @@ nikola[extras]==8.3.1 -flask==2.0.1 -sentry-sdk[flask] \ No newline at end of file diff --git a/requirements_freeze.txt b/requirements_freeze.txt deleted file mode 100644 index fa6956c88..000000000 --- a/requirements_freeze.txt +++ /dev/null @@ -1,34 +0,0 @@ -Babel==2.9.1 -blinker==1.4 -certifi==2021.10.8 -charset-normalizer==2.0.12 -click==8.0.3 -cloudpickle==2.0.0 -docutils==0.18.1 -doit==0.34.2 -Flask==2.0.1 -idna==3.3 -itsdangerous==2.0.1 -Jinja2==3.0.2 -Logbook==1.5.3 -lxml==4.8.0 -Mako==1.1.6 -Markdown==2.6.11 -MarkupSafe==2.0.1 -natsort==8.1.0 -Nikola==8.0.2 -piexif==1.1.3 -Pillow==9.0.1 -Pygments==2.11.2 -pyinotify==0.9.6 -PyRSS2Gen==1.1 -python-dateutil==2.8.2 -pytz==2021.3 -requests==2.27.1 -sentry-sdk==1.5.6 -six==1.16.0 -Unidecode==1.3.3 -urllib3==1.26.8 -uWSGI==2.0.20 -Werkzeug==2.0.2 -Yapsy==1.12.2 \ No newline at end of file