A search engine for confession hours by scraping parish websites.
This is the codebase of the confessio.fr project.
Copy the .env.sample
file to .env
and fill in the values.
We recommend using pyenv to manage python versions. Install it following the instructions here.
pyenv virtualenv 3.11.4 confessio
pyenv activate confessio
pip install -r requirements.txt
For MacOS, follow instructions here.
Also, you can configure GDAL_LIBRARY_PATH and GEOS_LIBRARY_PATH env var in .env.
Works currently on postgresql 15.4, and requires postgis and pgvector extensions.
psql postgres
CREATE DATABASE confessio;
Create user and grant privileges:
CREATE USER confessio
GRANT ALL PRIVILEGES ON DATABASE confessio TO confessio;
CREATE EXTENSION postgis;
CREATE EXTENSION vector;
The migrations can not be applied from the beginning because it crashes at some point. If you'd like to start from scratch, you can load the prod database dump in local (see below).
To detect new migrations:
$ python manage.py makemigrations
To apply existing migrations:
$ python manage.py migrate
Create the Superuser
$ python manage.py createsuperuser
This will download and load the latest prod database dump in local. Your psql user must be superadmin.
# Remove and recreate confessio database
$ psql postgres -c "DROP DATABASE confessio;" && psql postgres -c "CREATE DATABASE confessio;"
# Download and load the latest prod database dump
$ python manage.py dbrestore --uncompress
$ python manage.py runserver
At this point, the app runs at http://127.0.0.1:8000/
.
To install required packages for tests and linter, run:
pip install -r ci_requirements.txt
# without django loading
python -m unittest discover scraping
# OR with django loading
python manage.py test
flake8
Consider adding a pre-commit hook (vim .git/hooks/pre-commit
), but if you don't github actions will catch you.
echo "Running flake8..."
flake8 .
if [ $? -ne 0 ]; then
echo "flake8 failed. Please fix the above issues before committing."
exit 1
fi
echo "Running unit tests..."
python -m unittest discover scraping
if [ $? -ne 0 ]; then
echo "Unit tests failed. Please fix the above issues before committing."
exit 1
fi
Inside /home
directory:
django-admin makemessages -l fr
django-admin compilemessages
You'll find all self implemented commands in home/management/commands/
.
For example, to crawl all websites:
python manage.py crawl_websites
We use ansible to deploy to production. See ansible README for instructions.
On local machine you can check S3 backups like this:
# add credentials, you will be asked for AWS access and secret key
aws configure --profile confessio
# check daily backup
aws s3 ls confessio-dbbackup-daily --profile confessio
./prod.sh manage crawl_websites
./prod.sh manage "crawl_websites -n 'Sainte Claire Entre Loire et Rhins'"
and if you want to launch the command in tmux (in session "manage_tmux"):
./prod.sh manage_tmux crawl_websites
./prod.sh manage_tmux "crawl_websites -n 'Sainte Claire Entre Loire et Rhins'"
-- Check that no home_url ends with slash
select name, home_url from home_website hp where home_url like '%/';
-- Check that no home_url ends with space
select name, home_url from home_website hp where home_url like '% ';
Legacy documentation of Django Pixel Bootstrap 5
This part is to be removed once the project has been entirely freed from Django Pixel module.
Open-source Django project crafted on top of Pixel Bootstrap 5, an open-source design from Themesberg
.
The product is designed to deliver the best possible user experience with highly customizable feature-rich pages.
- π Django Pixel Bootstrap 5 -
Product page
- π Django Pixel Bootstrap 5 -
LIVE Demo
The project is coded using a simple and intuitive structure presented below:
< PROJECT ROOT >
|
|-- core/
| |-- settings.py # Project Configuration
| |-- urls.py # Project Routing
|
|-- home/
| |-- views.py # APP Views
| |-- urls.py # APP Routing
| |-- models.py # APP Models
| |-- tests.py # Tests
| |-- templates/ # Theme Customisation
| |-- pages #
| |-- custom-index.html # Custom Footer
|
|-- requirements.txt # Project Dependencies
|
|-- env.sample # ENV Configuration (default values)
|-- manage.py # Start the app - Django default start script
|
|-- ************************************************************************
When a template file is loaded, Django
scans all template directories starting from the ones defined by the user, and returns the first match or an error in case the template is not found.
The theme used to style this starter provides the following files:
# This exists in ENV: LIB/theme_pixel
< UI_LIBRARY_ROOT >
|
|-- templates/ # Root Templates Folder
| |
| |-- accounts/
| | |-- sign-in.html # Sign IN Page
| | |-- sign-up.html # Sign UP Page
| |
| |-- includes/
| | |-- footer.html # Footer component
| | |-- navigation.html # Navigation Bar
| | |-- scripts.html # Scripts Component
| |
| |-- layouts/
| | |-- base.html # Masterpage
| |
| |-- pages/
| |-- index.html # Dashboard Page
| |-- about.html # About Page
| |-- *.html # All other pages
|
|-- ************************************************************************
When the project requires customization, we need to copy the original file that needs an update (from the virtual environment) and place it in the template folder using the same path.
For instance, if we want to customize the index.html these are the steps:
- β
Step 1
: create thetemplates
DIRECTORY inside thehome
app - β
Step 2
: configure the project to use this new template directorycore/settings.py
TEMPLATES section
- β
Step 3
: copy theindex.html
from the original location (inside your ENV) and save it to thehome/templates
DIR- Source PATH:
<YOUR_ENV>/LIB/theme_pixel/template/pages/index.html
- Destination PATH:
<PROJECT_ROOT>home/templates/pages/index.html
- Source PATH:
To speed up all these steps, the codebase is already configured (
Steps 1, and 2
) and acustom index
can be found at this location:
home/templates/pages/custom-index.html
By default, this file is unused because the theme
expects index.html
(without the custom-
prefix).
In order to use it, simply rename it to index.html
. Like this, the default version shipped in the library is ignored by Django.
In a similar way, all other files and components can be customized easily.
Django Pixel Bootstrap 5 - Django Starter provided by AppSeed