Skip to main content

Simple forum for Alliance Auth

Project description

AA Forum

Version License Python Django pre-commit Code Style: black Discord Checks codecov Contributor Covenant

Simple forum app for Alliance Auth

⚠️ Before you install this module ⚠️

This module needs quite some configuration done before working properly. You need to modify your Apache/Nginx configuration as well as the global URL config of Alliance Auth. So please only install if you know what you're doing/feel comfortable to make these kind of changes. For you own sanity, and mine :-)

Contents

Overview

Features

  • Simple permission system. Only 2 permissions ("has_access" and "can_manage")
  • Simple administration, no maze to click through to get where you wantet to go
  • Categories and boards are sortable via drag and drop in admin view
  • Mass creation of boards with a new categoy
  • Boards can be restricted to 1 or more groups, bards without restrictions are visible for everyone who has access to the forum
  • Child boards (1 Level), which inherit their access restrictions from their parent
  • ckEditor with image upload
  • Unread topics counter as number on the "Forum" link in the left navigation
  • Optional notifications about new topics in a board via Discord webhooks

Screenshots

Forum Index

Forum Index

Topic Overview / Board Index

Topic Overview / Board Index

Topic View

Topic View

Start new Topic (ckEditor)

Start new Topic

Admin View

Admin View

Installation

Important: Please make sure you meet all preconditions before you proceed:

  • AA Forum is a plugin for Alliance Auth. If you don't have Alliance Auth running already, please install it first before proceeding. (see the official AA installation guide or details)
  • AA Forum needs a couple of changes made to your Webserver and Alliance Auth configuration. So make sure you know how to do so. The steps needed will be described in this document, but you need to understand what will be changed.

Step 1 - Install the package

Make sure you are in the virtual environment (venv) of your Alliance Auth installation Then install the latest release directly from PyPi.

pip install aa-forum

Step 2 - Configure Alliance Auth

Settings in /home/allianceserver/myauth/myauth/settings/local.py

This is fairly simple, configure your AA settings (local.py) as follows:

# AA Forum
INSTALLED_APPS += [
    "ckeditor",
    "ckeditor_uploader",
    "aa_forum",  # https://github.com/ppfeufer/aa-forum
]

if "ckeditor" in INSTALLED_APPS:
    import ckeditor.configs

    MEDIA_URL = "/media/"
    MEDIA_ROOT = "/var/www/myauth/media/"

    X_FRAME_OPTIONS = "SAMEORIGIN"

    CKEDITOR_UPLOAD_PATH = "uploads/"
    CKEDITOR_RESTRICT_BY_USER = True
    CKEDITOR_ALLOW_NONIMAGE_FILES = False

    # Editor configuration
    #
    # If you already have this from another app, like `aa-bulletin-board`, you don't
    # need to define this again, just add it to the `CKEDITOR_CONFIGS` dict, see below
    #
    # You can extend and change this to your needs
    # Some of the options are commented out, feel free to play around with them
    ckeditor_default_config = {
        "width": "100%",
        "height": "45vh",
        "youtube_responsive": True,
        "youtube_privacy": True,
        "youtube_related": False,
        "youtube_width": 1920,
        "youtube_height": 1080,
        "extraPlugins": ",".join(
            [
                "uploadimage",
                # "div",
                "autolink",
                # "autoembed",
                # "embedsemantic",
                "clipboard",
                "elementspath",
                # "codesnippet",
                "youtube",
            ]
        ),
        "toolbar": [
            {
                "name": "styles",
                "items": [
                    "Styles",
                    "Format",
                    # "Font",
                    # "FontSize",
                ],
            },
            {
                "name": "basicstyles",
                "items": [
                    "Bold",
                    "Italic",
                    "Underline",
                    "Strike",
                    # "Subscript",
                    # "Superscript",
                    # "-",
                    # "RemoveFormat",
                ],
            },
            {
                "name": "clipboard",
                "items": [
                    # "Cut",
                    # "Copy",
                    # "Paste",
                    # "PasteText",
                    # "PasteFromWord",
                    # "-",
                    "Undo",
                    "Redo",
                ],
            },
            {
                "name": "links",
                "items": [
                    "Link",
                    "Unlink",
                    "Anchor",
                ],
            },
            {
                "name": "insert",
                "items": [
                    "Image",
                    "Youtube",
                    "Table",
                    "HorizontalRule",
                    "Smiley",
                    "SpecialChar",
                    # "PageBreak",
                    # "Iframe",
                ],
            },
            {
                "name": "colors",
                "items": [
                    "TextColor",
                    "BGColor",
                ],
            },
            {
                "name": "document",
                "items": [
                    # "Source",
                    # "-",
                    # "Save",
                    # "NewPage",
                    # "Preview",
                    # "Print",
                    # "-",
                    # "Templates",
                ],
            },
        ],
    }

    # Put it all together
    CKEDITOR_CONFIGS = {
        "default": ckeditor.configs.DEFAULT_CONFIG,
        "aa_forum": ckeditor_default_config,
    }

    # Add the external YouTube plugin
    CKEDITOR_CONFIGS["aa_forum"]["external_plugin_resources"] = [
        (
            "youtube",
            "/static/aa_forum/ckeditor/plugins/youtube/",
            "plugin.min.js",
        )
    ]

Settings in /home/allianceserver/myauth/myauth/urls.py

Now let's move on to editing the global URL configuration of Alliance Auth. To do so, you need to open /home/allianceserver/myauth/myauth/urls.py and change the following block right before the handler definitions:

# URL configuration for cKeditor
from django.apps import apps

if apps.is_installed("ckeditor"):
    from django.contrib.auth.decorators import login_required
    from django.views.decorators.cache import never_cache
    from ckeditor_uploader import views as ckeditor_views

    urlpatterns = [
        re_path(
            r"^upload/", login_required(ckeditor_views.upload), name="ckeditor_upload"
        ),
        re_path(
            r"^browse/",
            never_cache(login_required(ckeditor_views.browse)),
            name="ckeditor_browse",
        ),
    ] + urlpatterns

After this, your urls.py should look similar to this:

from django.urls import include, re_path

from allianceauth import urls

# Alliance auth urls
urlpatterns = [
    re_path(r"", include(urls)),
]

# URL configuration for cKeditor
from django.apps import apps

if apps.is_installed("ckeditor"):
    from django.contrib.auth.decorators import login_required
    from django.views.decorators.cache import never_cache
    from ckeditor_uploader import views as ckeditor_views

    urlpatterns = [
        re_path(
            r"^upload/", login_required(ckeditor_views.upload), name="ckeditor_upload"
        ),
        re_path(
            r"^browse/",
            never_cache(login_required(ckeditor_views.browse)),
            name="ckeditor_browse",
        ),
    ] + urlpatterns

handler500 = "allianceauth.views.Generic500Redirect"
handler404 = "allianceauth.views.Generic404Redirect"
handler403 = "allianceauth.views.Generic403Redirect"
handler400 = "allianceauth.views.Generic400Redirect"

Step 3 - Configure your webserver

Your webserver needs to know from where to serve the uploaded mages of course, so we have to tell it.

Apache

In your vhost configuration you have a line ProxyPassMatch ^/static !, which tells the server where to find all the static files. We are adding a similar line for the media, right below that one.

Add the following right below the static proxy match:

ProxyPassMatch ^/media !

Now we also need to let the server know where to find the media directory we just configured the proxy for. To do so, add a new Alias to your configuration. This can be done right below the already existing Alias for /static:

Alias "/media" "/var/www/myauth/media/"

At last a "Directory" rule is needed as well. Add the following below the already existing Directory rule for the static files:

<Directory "/var/www/myauth/media/">
    Require all granted
</Directory>

So the whole block should now look like this:

ProxyPassMatch ^/static !
ProxyPassMatch ^/media !  # *** NEW proxy rule
ProxyPass / http://127.0.0.1:8000/
ProxyPassReverse / http://127.0.0.1:8000/
ProxyPreserveHost On

Alias "/static" "/var/www/myauth/static/"
Alias "/media" "/var/www/myauth/media/"

<Directory "/var/www/myauth/static/">
    Require all granted
</Directory>

<Directory "/var/www/myauth/media/">
    Require all granted
</Directory>

Restart your Apache webserver.

Nginx

In order to let Nginx know where to find the uploaded files, you need to add a new location rule to the configuration. Add the following right below the definition for your "static" location.

location /media {
    alias /var/www/myauth/media;
    autoindex off;
}

Restart your Nginx webserver.

Step 4 - Finalize the installation

Run static files collection and migrations

python manage.py collectstatic
python manage.py migrate

Restart your supervisor services for Auth

Step 5 - Set up permissions

Now it's time to set up access permissions for your new module. You can do so in your admin backend. Read the Permissions section for more information about the available permissions.

Permissions

ID Description Notes
basic_access Can access the AA-Forum module Grants access to the forum
manage_forum Can manage the AA-Forum module (Categories, topics and messages) Users with this permission can create, edit and delete boards and categories in the "Administration" view. They can also modify and delete messages and topics in the "Forum" view. Users with this permission are not bound by group restrictions and have access to all boards and topics, so choose wisely who is getting this permission.

Changelog

See CHANGELOG.md

Contributing

You want to contribute to this project? That's cool!

Please make sure to read the contribution guidelines (I promise, it's not much, just some basics)

Project details


Release history Release notifications | RSS feed

This version

1.7.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aa_forum-1.7.0.tar.gz (411.7 kB view details)

Uploaded Source

Built Distribution

aa_forum-1.7.0-py3-none-any.whl (452.2 kB view details)

Uploaded Python 3

File details

Details for the file aa_forum-1.7.0.tar.gz.

File metadata

  • Download URL: aa_forum-1.7.0.tar.gz
  • Upload date:
  • Size: 411.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for aa_forum-1.7.0.tar.gz
Algorithm Hash digest
SHA256 77d89ada2d48ac38665175a30fc0b27dd078e3cd783f3bee3d4f9d14cc6974ac
MD5 9c2635947d393f56092437f47f76be12
BLAKE2b-256 c5785a5d54c23c0d49596b20b7095b070b69e84dae1f7815e3583a206e2afe26

See more details on using hashes here.

File details

Details for the file aa_forum-1.7.0-py3-none-any.whl.

File metadata

  • Download URL: aa_forum-1.7.0-py3-none-any.whl
  • Upload date:
  • Size: 452.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for aa_forum-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58e55cedea85a671432e4cc5e75b1ed79cfdf15ef7f47d3bc7259e665f305f3b
MD5 585166bf0608142733ebc81196c2e89b
BLAKE2b-256 02e07ebab497f2fdb98814af6991a02e604deb3e54596ea3b6d2dc52f2f831e7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page