Django Aggregator of a Lot of External Contents (DALEC) is a generic app to aggregate contents from various external sources. Purposes are to manage (retrieve, clean, displayβ¦) those contents in a generic way independent of the source.
It's designed to be customized / extended to fit your needs.
This app is tested to runs with:
- Django 2.2, 3.2, 4.2
- Python 3.7, 3.9, 3.11
To ensure code quality and consistency:
- Python formatted with black
- Python validated with flake8.
- Python static types checked with mypy
- Python tests coverage checked with coverage (100% tested)
- JS tested with jest
- JS formatted with prettier
- Tests runned in local via tox and on github via github actions workflow
- versionned with semver logic
Contents are categorized via :
app
: the app which is requested to retrieve contents (eg.gitlab
)content_type
: the type of contents we want to retrieve from this app (eg.issue
,activity
,commit
,merge requests
β¦)channel
: some apps can be requested to get a more or less filtered contents. For example, in Gitlab, it's called "scope". You can retrieve issues from:- the whole site (
channel=None
andchannel_object=None
for us) - a specific group (
channel="group"
andchannel_object="<gitlab_group_id>"
) - a specific project (
channel="project"
andchannel_object="<gitlab_project_id>"
) - a specific author (
channel="author"
andchannel_object="<gitlab_user_id>"
) - a specific assignee (
channel="assignee"
andchannel_object="<gitlab_user_id>"
) - etc.
- the whole site (
channel_object
: the ID (for the app requested) of the channel's related objectchannel_objects
: the list of IDs (for the app requested) of the channel's related objects (eg."['42','443']"
)
Before you ask: yes, some contents can be duplicated (eg. an issue from the "group" channel
could be duplicated in the "project" channel). It's normal and wanted. Remember : the purpose
of this app is to retrieve and display the last N contents of something
. If the issue we are
talking about is in the last N issues of project "cybermen"
, it does not mean it's also in
the last N issues of group "dr-who-best-friends"
. To manage different timelines for each channel,
and keep a KISS Model, we need those duplicates.
- π¦ dalec-gitlab: get issues and activities from a gitlab instance
- β dalec-nextcloud: get events and activities from a nextcloud instance
- π£ dalec-discourse: get last messages or topics from a discourse instance
- π dalec-openproject: get tasks from an openproject instance
- π dalec-caldav: events and tasks from a caldav instance (eg: nextcloud agenda)
- π dalec-mediawiki: get last pages from a mediawiki instance
- π dalec-webdav: get lastmodified files from a webdav instance (eg: nextcloud files)
- π° dalec-feedparser: get contents from atom and rss feeds
- π« dalec-imap: get emails from imap instance
- π₯ dalec-mastodon: get toots from a mastodon instance
- πΊ dalec-peertube: get last uploaded videos from a peertube instance
- π΅ dalec-git: get last commits, branches, tags from a git repository
- π± dalec-github: get issues, pull-requests, activity from github
- π¦ dalec-twitter: get tweets from twitter
- π dalec-youtube: get last uploaded videos from youtube
- π₯ dalec-imdb: get last movies from imdb
If you are using Django older than 3.1, the JSONField is provided from
django-jsonfield-backport.
For 3.1+, you MUST use a DB supporting the official
django's JSONField
.
You SHOULD NOT install this app but you SHOULD install one (or more) of it's children (see ). eg:
pip install dalec-gitlab dalec-nextcloud
Then, add dalec
, dalec_prime
and dalec's children to INSTALLED_APPS
in settings.py
:
# settings.py
INSTALLED_APPS = [
# β¦
"dalec",
"dalec_prime", # if you want to use your own Content model, don't add it
"dalec_gitlab",
"dalec_nextcloud",
# β¦
]
And in your urls.py
:
# urls.py
url_patterns = [
...
re_path("^dalec/", include("dalec.urls")),
...
]
Each dalec's child app will probably need some specific configuration to retrieve external contents (eg: token or login/password). Please refer to this dalec's child app configuration section first.
Now your dalec's child app is configured, you can display it's X last contents somewhere in a
template by using the templatetag dalec
:
{% load dalec %}
{% dalec app content_type [channel=None] [channel_object=None] [template=None] [ordered_by=None] %}
real examples:
Retrieves last gitlab issues for a specific user:
{% dalec "gitlab" "issue" channel="user" channel_object="doctor-who" %}
Retrieves recent gitlab event for a group:
{% dalec "gitlab" "event" channel="group" channel_object='42' %}
Retrieves recent gitlab event for a project:
{% dalec "gitlab" "event" channel="project" channel_object='443' %}
Retrieves recent gitlab issues for a project:
{% dalec "gitlab" "issue" channel="project" channel_object='404' %}
Retrieves recent gitlab issues for multiple projects:
{% dalec "gitlab" "issue" channel="project" channel_objects='["42","443"]' %}
Retrieves recent gitlab issues for multiple projects and order them by descending
issue internal ID (default is `last_update_dt`):
{% dalec "gitlab" "issue" channel="project" channel_object='42' ordered_by="-iid" %}
An example app is packaged to get a working example which does not require any extra configuration.
- add
dalec_example
,dalec_prime
anddalec
toINSTALLED_APPS
- run migrations
- include dalec.urls inside your project's urls
- add those fragments of code inside the template where you want to display the example:
{% load dalec %}
<h1>Last quarters (very usefull, isn't it ?)</h1>
{% dalec "example" "quarter" %}
<h1>Last updated establishments of french national education</h1>
{% dalec "example" "french_educ" %}
<h1>Last updated establishments of french national education depending of the Academy of Grenoble</h1>
{% dalec "example" "french_educ" channel="academy" channel_object="Grenoble" %}
This app have general settings which can be erased for all of it's children and sometimes by content type.
- General setting format :
DALEC_SOMETHING
- override child version (it's app name, like gitlab for example):
DALEC_GITLAB_SOMETHING
- override content type version (gitlab's issues for example):
DALEC_GITLAB_ISSUE_SOMETHING
- default:
10
- per child app setting: yes
- per child app's content type setting: yes
Set the number of contents to keep by type. Oldest will be purged to keep only the last X contents
of each channel and type.
0
means "no limit".
- default:
True
- per child app setting: yes
- per child app's content type setting: yes
If True
, when an user display a channel contents, an ajax requests is sent to refresh content.
It's usefull if you do not want to use a cron task and/or need to get always the last contents.
- default:
900
- per child app setting: yes
- per child app's content type setting: yes
Number of seconds before an ajax request sends a new query to the instance providing instance.
- default:
"dalec_prime.Content"
- per child app setting: no
- per child app's content type setting: no
Concrete model to use to store contents. If you do not want to use the default one,
you should not add dalec.prime
in INSTALLED_APPS
to avoid to load a useless model
and have an empty table in your data base.
- default:
"dalec_prime.FetchHistory"
- per child app setting: no
- per child app's content type setting: no
Same as DALEC_CONTENT_MODEL
but for the FetchHistory
model.
- default:
None
- per child app setting: yes
- per child app's content type setting: no
Name of the (S)CSS framework you use on your website. It changes the default templates used to
display contents. Templates are priorized in this order (css_framework
versions only used if
you set a value to DALEC_CSS_FRAMEWORK
):
dalec/%(app)s/%(tpl)s-list.html
: only if you use a specific template, see templatetagdalec
dalec/%(app)s/%(css_framework)s/%(content_type)s-%(channel)s-list.html
dalec/%(app)s/%(content_type)s-%(channel)s-list.html
dalec/%(app)s/%(css_framework)s/%(content_type)s-list.html
dalec/%(app)s/%(content_type)s-list.html
dalec/%(app)s/%(css_framework)s/list.html
dalec/%(app)s/list.html
dalec/default/%(css_framework)s/list.html
dalec/default/list.html
Supported valued are:
None
: only dalec classes and data will be added. HTML elements are sementics. Templates are the default ones.
Future supported values could be:
- materialize
- bulma
- bootstrap
- semantic-ui
No styles are included inside dalec who must remains pure with no feelings.
But some SCSS framework may be supported. Please refer to DALEC_CSS_FRAMEWORK
setting.
You should always inherit from the default templates and use defined blocks to customise it.
Each app can have it's own "list" template but if it doesn't, a default one will be used. In priority order:
dalec/<childappname>/<contenttype>-<channel>-list.html
dalec/<childappname>/<contenttype>-list.html
dalec/<childappname>/list.html
dalec/default/list.html
Each content types can have it's own template. Those filenames will be tried:
dalec/<childappname>/<contenttype>-<channel>-item.html
dalec/<childappname>/<contenttype>-item.html
dalec/<childappname>/item.html
dalec/default/item.html
For "gitlab" app, "issue" content type and "project" channel we will try :
dalec/gitlab/issue-project-item.html
dalec/gitlab/issue-item.html
dalec/gitlab/item.html
dalec/default/item.html
Model used to store contents is defined by the setting DALEC_CONTENT_MODEL
which has the
default value "dalec_prime.Content"
.
If you want to use your own model, in your settings.py
:
- remove
dalec.prime
fromINSTALLED_APPS
- set the setting
DALEC_CONTENT_MODEL
with<yourapp>.<yourModel>
If you want to add a specific external source, you just have to extends dalec.proxy.Proxy
and override it's _fetch
method.
To create a dalec child (a proper way), you should create a new django app with the name pattern
dalec_<yourExternalSourceUname>
Because I'm a developper
A Dalek which have a concept of Blasphemy can not be a sane Dalek! https://youtu.be/6ThpkjDgdvY?t=162
The Daleks are a fictional extraterrestrial race of mutants principally portrayed in the British science fiction television programme Doctor Who. Name (and logo) of this django app is directly related to them.
This project was made possible thanks to the
Open Space Maker Federation whose goal is to open
up the world of space infrastructure to as many people as possible.
They need boards to aggregate contents from different sources (gitlab, discourseβ¦).
We (Webu) didn't find any applications which fit our needs,
so we create a new one and released it under the MIT licence.