evewiki 0.0.1.dev1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. evewiki-0.0.1.dev1/LICENSE +21 -0
  2. evewiki-0.0.1.dev1/PKG-INFO +121 -0
  3. evewiki-0.0.1.dev1/README.md +91 -0
  4. evewiki-0.0.1.dev1/evewiki/__init__.py +6 -0
  5. evewiki-0.0.1.dev1/evewiki/admin.py +16 -0
  6. evewiki-0.0.1.dev1/evewiki/app_settings.py +5 -0
  7. evewiki-0.0.1.dev1/evewiki/apps.py +9 -0
  8. evewiki-0.0.1.dev1/evewiki/auth_hooks.py +35 -0
  9. evewiki-0.0.1.dev1/evewiki/forms.py +29 -0
  10. evewiki-0.0.1.dev1/evewiki/migrations/0001_initial.py +190 -0
  11. evewiki-0.0.1.dev1/evewiki/migrations/__init__.py +0 -0
  12. evewiki-0.0.1.dev1/evewiki/models/__init__.py +0 -0
  13. evewiki-0.0.1.dev1/evewiki/models/logs.py +15 -0
  14. evewiki-0.0.1.dev1/evewiki/models/page_versions.py +48 -0
  15. evewiki-0.0.1.dev1/evewiki/models/pages.py +249 -0
  16. evewiki-0.0.1.dev1/evewiki/models/settings.py +35 -0
  17. evewiki-0.0.1.dev1/evewiki/tasks.py +12 -0
  18. evewiki-0.0.1.dev1/evewiki/templates/evewiki/base.html +11 -0
  19. evewiki-0.0.1.dev1/evewiki/templates/evewiki/help.html +16 -0
  20. evewiki-0.0.1.dev1/evewiki/templates/evewiki/index.html +363 -0
  21. evewiki-0.0.1.dev1/evewiki/templates/evewiki/page.html +98 -0
  22. evewiki-0.0.1.dev1/evewiki/templates/evewiki/page_delete.html +41 -0
  23. evewiki-0.0.1.dev1/evewiki/templates/evewiki/page_tree.html +10 -0
  24. evewiki-0.0.1.dev1/evewiki/templates/evewiki/sidebar.html +5 -0
  25. evewiki-0.0.1.dev1/evewiki/tests/__init__.py +0 -0
  26. evewiki-0.0.1.dev1/evewiki/tests/test_tasks.py +11 -0
  27. evewiki-0.0.1.dev1/evewiki/urls.py +15 -0
  28. evewiki-0.0.1.dev1/evewiki/views.py +149 -0
  29. evewiki-0.0.1.dev1/pyproject.toml +77 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ryan Cunning
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: evewiki
3
+ Version: 0.0.1.dev1
4
+ Summary: Wiki plugin app for Alliance Auth.
5
+ Author-email: Ryan Cunning <ryan.cunning@gmail.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Classifier: Environment :: Web Environment
9
+ Classifier: Framework :: Django
10
+ Classifier: Framework :: Django :: 4.0
11
+ Classifier: Framework :: Django :: 4.2
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Topic :: Internet :: WWW/HTTP
21
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
22
+ License-File: LICENSE
23
+ Requires-Dist: allianceauth>=3
24
+ Project-URL: Changelog, https://gitlab.com/cunningdesigns/aa-wiki/-/blob/main/CHANGELOG.md
25
+ Project-URL: Documentation, https://gitlab.com/cunningdesigns/aa-wiki
26
+ Project-URL: Homepage, https://gitlab.com/cunningdesigns/aa-wiki
27
+ Project-URL: Source, https://gitlab.com/cunningdesigns/aa-wiki
28
+ Project-URL: Tracker, https://gitlab.com/cunningdesigns/aa-wiki/-/issues
29
+
30
+ # aa-wiki
31
+
32
+ Wiki plugin for [AllianceAuth](https://gitlab.com/allianceauth/allianceauth) to curate content.
33
+
34
+ ## Features
35
+
36
+ - Create and organise pages in a hierarchical structure using `slugs`
37
+ - Supports markdown with both rich and raw editing modes
38
+ - Version History
39
+ - Event logging
40
+ - Restrict content by user's `groups` and/or `states`
41
+
42
+ ## Permissions
43
+
44
+ Users need to have at least `basic_access` interactions with the application
45
+
46
+ | Name | Description |
47
+ |-----------------------|----------------------------------------------------------|
48
+ | `basic_access` | Basic access to load content |
49
+ | `editor_access` | Grant the necessary controls and access to edit content |
50
+
51
+
52
+ ## Settings
53
+
54
+ List of settings that can be modified for the application
55
+ You can alter them by adding a record to the `Settings` section/table in the `evewiki` section of the Admin site
56
+
57
+ | Name | Description | Default |
58
+ |-------------------------------|--------------------------------------------------------------------------------------------------|---------|
59
+ | `hierarchy_max_display_depth` | Limit the depth of the tree for the hierarchy on the main display | 10 |
60
+ | `max_versions` | No one has infinite disk space, a sensible limit which can be modified to clear down the history | 1000 |
61
+
62
+ ## Installation
63
+
64
+ *Assumes setup of AA as per the [documentation](https://allianceauth.readthedocs.io/en/latest/installation-containerized/docker.html)*
65
+ Final folder structure would look like
66
+ ```plaintext
67
+ aa-dev
68
+ ├─ aa-docker
69
+ └─ aa-wiki
70
+
71
+ ```
72
+
73
+ Traverse into the `aa-dev` folder and clone the repo
74
+ ```bash
75
+ git clone https://gitlab.com/cunningdesigns/aa-wiki.git
76
+ ```
77
+
78
+ Traverse to `../aa-docker` folder
79
+
80
+ Bind-mount the plugin-folder in `aa-docker/docker-compose.yml`
81
+ ```yaml
82
+ x-allianceauth-base:
83
+ volumes:
84
+ - ../aa-wiki:/home/allianceauth/evewiki
85
+ ```
86
+
87
+ ___
88
+ *there has to be a better way*
89
+ > Replace `aa-wiki/evewiki/views.py` with content from [example plugin](https://gitlab.com/ErikKalkoken/allianceauth-example-plugin/-/blob/master/example/views.py?ref_type=heads)
90
+
91
+ > Comment out lines 11,12 & 14 on `aa-wiki/evewiki/urls.py`
92
+ ___
93
+
94
+ Start the containers (may require sudo)
95
+ ```bash
96
+ docker compose --env-file=.env up -d
97
+ ```
98
+
99
+ Open a terminal in the gunicorn container, initiate the plugin install
100
+ ```bash
101
+ docker compose exec allianceauth_gunicorn bash
102
+ pip install -e ../evewiki
103
+ ```
104
+
105
+ add `evewiki` to `aa-docker/conf/local.py`
106
+
107
+ Apply migrations and exit
108
+ ```bash
109
+ python manage.py migrate
110
+ ```
111
+
112
+ restart AA
113
+ ```bash
114
+ docker compose restart allianceauth_gunicorn
115
+ ```
116
+
117
+ ___
118
+ *there has to be a better way*
119
+ > Remember to undo the modifications to `evewiki/evewiki/views.py` & `evewiki/evewiki/urls.py`
120
+ ___
121
+
@@ -0,0 +1,91 @@
1
+ # aa-wiki
2
+
3
+ Wiki plugin for [AllianceAuth](https://gitlab.com/allianceauth/allianceauth) to curate content.
4
+
5
+ ## Features
6
+
7
+ - Create and organise pages in a hierarchical structure using `slugs`
8
+ - Supports markdown with both rich and raw editing modes
9
+ - Version History
10
+ - Event logging
11
+ - Restrict content by user's `groups` and/or `states`
12
+
13
+ ## Permissions
14
+
15
+ Users need to have at least `basic_access` interactions with the application
16
+
17
+ | Name | Description |
18
+ |-----------------------|----------------------------------------------------------|
19
+ | `basic_access` | Basic access to load content |
20
+ | `editor_access` | Grant the necessary controls and access to edit content |
21
+
22
+
23
+ ## Settings
24
+
25
+ List of settings that can be modified for the application
26
+ You can alter them by adding a record to the `Settings` section/table in the `evewiki` section of the Admin site
27
+
28
+ | Name | Description | Default |
29
+ |-------------------------------|--------------------------------------------------------------------------------------------------|---------|
30
+ | `hierarchy_max_display_depth` | Limit the depth of the tree for the hierarchy on the main display | 10 |
31
+ | `max_versions` | No one has infinite disk space, a sensible limit which can be modified to clear down the history | 1000 |
32
+
33
+ ## Installation
34
+
35
+ *Assumes setup of AA as per the [documentation](https://allianceauth.readthedocs.io/en/latest/installation-containerized/docker.html)*
36
+ Final folder structure would look like
37
+ ```plaintext
38
+ aa-dev
39
+ ├─ aa-docker
40
+ └─ aa-wiki
41
+
42
+ ```
43
+
44
+ Traverse into the `aa-dev` folder and clone the repo
45
+ ```bash
46
+ git clone https://gitlab.com/cunningdesigns/aa-wiki.git
47
+ ```
48
+
49
+ Traverse to `../aa-docker` folder
50
+
51
+ Bind-mount the plugin-folder in `aa-docker/docker-compose.yml`
52
+ ```yaml
53
+ x-allianceauth-base:
54
+ volumes:
55
+ - ../aa-wiki:/home/allianceauth/evewiki
56
+ ```
57
+
58
+ ___
59
+ *there has to be a better way*
60
+ > Replace `aa-wiki/evewiki/views.py` with content from [example plugin](https://gitlab.com/ErikKalkoken/allianceauth-example-plugin/-/blob/master/example/views.py?ref_type=heads)
61
+
62
+ > Comment out lines 11,12 & 14 on `aa-wiki/evewiki/urls.py`
63
+ ___
64
+
65
+ Start the containers (may require sudo)
66
+ ```bash
67
+ docker compose --env-file=.env up -d
68
+ ```
69
+
70
+ Open a terminal in the gunicorn container, initiate the plugin install
71
+ ```bash
72
+ docker compose exec allianceauth_gunicorn bash
73
+ pip install -e ../evewiki
74
+ ```
75
+
76
+ add `evewiki` to `aa-docker/conf/local.py`
77
+
78
+ Apply migrations and exit
79
+ ```bash
80
+ python manage.py migrate
81
+ ```
82
+
83
+ restart AA
84
+ ```bash
85
+ docker compose restart allianceauth_gunicorn
86
+ ```
87
+
88
+ ___
89
+ *there has to be a better way*
90
+ > Remember to undo the modifications to `evewiki/evewiki/views.py` & `evewiki/evewiki/urls.py`
91
+ ___
@@ -0,0 +1,6 @@
1
+ """Wiki plugin app for Alliance Auth."""
2
+
3
+ # pylint: disable = invalid-name
4
+ default_app_config = "evewiki.apps.EveWikiConfig"
5
+
6
+ __version__ = "0.0.1.dev1"
@@ -0,0 +1,16 @@
1
+ """Admin site."""
2
+
3
+ from django.contrib import admin
4
+
5
+ from .models.logs import Log
6
+ from .models.page_versions import PageVersion
7
+ from .models.pages import Page
8
+ from .models.settings import Setting
9
+
10
+ # from django.contrib import admin
11
+
12
+ # Register your models for the admin site here.
13
+ admin.site.register(Page)
14
+ admin.site.register(Setting)
15
+ admin.site.register(PageVersion)
16
+ admin.site.register(Log)
@@ -0,0 +1,5 @@
1
+ """App settings."""
2
+
3
+ from django.conf import settings
4
+
5
+ EXAMPLE_SETTING_ONE = getattr(settings, "EXAMPLE_SETTING_ONE", None)
@@ -0,0 +1,9 @@
1
+ from django.apps import AppConfig
2
+
3
+ from . import __version__
4
+
5
+
6
+ class EveWikiConfig(AppConfig):
7
+ name = "evewiki"
8
+ label = "evewiki"
9
+ verbose_name = f"evewiki v{__version__}"
@@ -0,0 +1,35 @@
1
+ from django.utils.translation import gettext_lazy as _
2
+
3
+ from allianceauth import hooks
4
+ from allianceauth.services.hooks import MenuItemHook, UrlHook
5
+
6
+ from . import urls
7
+
8
+
9
+ class EveWikiMenuItem(MenuItemHook):
10
+ """This class ensures only authorized users will see the menu entry"""
11
+
12
+ def __init__(self):
13
+ # setup menu entry for sidebar
14
+ MenuItemHook.__init__(
15
+ self,
16
+ _("wiki"),
17
+ "fas fa-tree fa-fw",
18
+ "evewiki:index",
19
+ navactive=["evewiki:"],
20
+ )
21
+
22
+ def render(self, request):
23
+ if request.user.has_perm("evewiki.basic_access"):
24
+ return MenuItemHook.render(self, request)
25
+ return ""
26
+
27
+
28
+ @hooks.register("menu_item_hook")
29
+ def register_menu():
30
+ return EveWikiMenuItem()
31
+
32
+
33
+ @hooks.register("url_hook")
34
+ def register_urls():
35
+ return UrlHook(urls, "evewiki", r"^evewiki/")
@@ -0,0 +1,29 @@
1
+ from django import forms
2
+
3
+ from .models.pages import Page
4
+
5
+
6
+ class PageForm(forms.ModelForm):
7
+
8
+ # Customised ddl inferring additional context via text-indentation
9
+ parent = forms.ChoiceField(
10
+ choices=Page.list(),
11
+ required=False,
12
+ label="Path",
13
+ help_text=Page._meta.get_field("parent").help_text,
14
+ )
15
+
16
+ class Meta:
17
+ model = Page
18
+ fields = ["title", "parent", "slug", "priority", "states", "groups"]
19
+
20
+ def clean(self):
21
+ """
22
+ Django needs a little help to turn the custom `parent` field back into a model.
23
+ """
24
+ cleaned_data = super().clean()
25
+ parent_id = cleaned_data["parent"]
26
+ cleaned_data["parent"] = (
27
+ Page.objects.get(pk=int(parent_id)) if parent_id else None
28
+ )
29
+ return cleaned_data
@@ -0,0 +1,190 @@
1
+ # Generated by Django 4.2.21 on 2025-05-27 00:35
2
+
3
+ import django.db.models.deletion
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+
9
+ initial = True
10
+
11
+ dependencies = [
12
+ ("auth", "0012_alter_user_first_name_max_length"),
13
+ ("authentication", "0024_alter_userprofile_language"),
14
+ ]
15
+
16
+ operations = [
17
+ migrations.CreateModel(
18
+ name="General",
19
+ fields=[
20
+ (
21
+ "id",
22
+ models.AutoField(
23
+ auto_created=True,
24
+ primary_key=True,
25
+ serialize=False,
26
+ verbose_name="ID",
27
+ ),
28
+ ),
29
+ ],
30
+ options={
31
+ "permissions": (
32
+ ("basic_access", "Can access this app"),
33
+ ("editor_access", "Can edit this app"),
34
+ ),
35
+ "managed": False,
36
+ "default_permissions": (),
37
+ },
38
+ ),
39
+ migrations.CreateModel(
40
+ name="Log",
41
+ fields=[
42
+ (
43
+ "id",
44
+ models.AutoField(
45
+ auto_created=True,
46
+ primary_key=True,
47
+ serialize=False,
48
+ verbose_name="ID",
49
+ ),
50
+ ),
51
+ ("user", models.TextField(blank=True, default="", null=True)),
52
+ ("action", models.TextField(blank=True, default="", null=True)),
53
+ ("details", models.TextField(blank=True, default="", null=True)),
54
+ ("created", models.DateTimeField(auto_now_add=True)),
55
+ ],
56
+ ),
57
+ migrations.CreateModel(
58
+ name="Page",
59
+ fields=[
60
+ (
61
+ "id",
62
+ models.AutoField(
63
+ auto_created=True,
64
+ primary_key=True,
65
+ serialize=False,
66
+ verbose_name="ID",
67
+ ),
68
+ ),
69
+ (
70
+ "title",
71
+ models.CharField(
72
+ help_text="Required: Displayed above content and in menu",
73
+ max_length=255,
74
+ ),
75
+ ),
76
+ (
77
+ "slug",
78
+ models.CharField(
79
+ help_text="Required: Indentifier for path and links",
80
+ max_length=255,
81
+ ),
82
+ ),
83
+ (
84
+ "priority",
85
+ models.IntegerField(
86
+ default=10,
87
+ help_text="Required: Sort order for pages on the same path",
88
+ ),
89
+ ),
90
+ ("content", models.TextField(blank=True, default="", null=True)),
91
+ (
92
+ "groups",
93
+ models.ManyToManyField(
94
+ blank=True,
95
+ default=None,
96
+ help_text="Optional: Restrict Page to specific Groups",
97
+ related_name="+",
98
+ to="auth.group",
99
+ verbose_name="groups",
100
+ ),
101
+ ),
102
+ (
103
+ "parent",
104
+ models.ForeignKey(
105
+ blank=True,
106
+ help_text="Required: Oragnise page hierarchy",
107
+ null=True,
108
+ on_delete=django.db.models.deletion.PROTECT,
109
+ related_name="children",
110
+ to="evewiki.page",
111
+ ),
112
+ ),
113
+ (
114
+ "states",
115
+ models.ManyToManyField(
116
+ blank=True,
117
+ default=None,
118
+ help_text="Optional: Restrict Page to specific States",
119
+ related_name="+",
120
+ to="authentication.state",
121
+ verbose_name="states",
122
+ ),
123
+ ),
124
+ ],
125
+ ),
126
+ migrations.CreateModel(
127
+ name="Setting",
128
+ fields=[
129
+ (
130
+ "id",
131
+ models.AutoField(
132
+ auto_created=True,
133
+ primary_key=True,
134
+ serialize=False,
135
+ verbose_name="ID",
136
+ ),
137
+ ),
138
+ (
139
+ "hierarchy_max_display_depth",
140
+ models.IntegerField(
141
+ default=10,
142
+ help_text="Limit the depth of the tree for the hierarchy on the main display",
143
+ ),
144
+ ),
145
+ (
146
+ "max_versions",
147
+ models.IntegerField(
148
+ default=1000,
149
+ help_text="No one has infinite disk space, a sensible limit which can be modified to clear down the history",
150
+ ),
151
+ ),
152
+ ],
153
+ ),
154
+ migrations.CreateModel(
155
+ name="PageVersion",
156
+ fields=[
157
+ (
158
+ "id",
159
+ models.AutoField(
160
+ auto_created=True,
161
+ primary_key=True,
162
+ serialize=False,
163
+ verbose_name="ID",
164
+ ),
165
+ ),
166
+ ("content", models.TextField(blank=True, default="", null=True)),
167
+ ("created", models.DateTimeField(auto_now_add=True)),
168
+ (
169
+ "page",
170
+ models.ForeignKey(
171
+ blank=True,
172
+ help_text="Page being edited",
173
+ null=True,
174
+ on_delete=django.db.models.deletion.SET_NULL,
175
+ to="evewiki.page",
176
+ ),
177
+ ),
178
+ (
179
+ "user",
180
+ models.ForeignKey(
181
+ blank=True,
182
+ help_text="User editing the page",
183
+ null=True,
184
+ on_delete=django.db.models.deletion.SET_NULL,
185
+ to="authentication.userprofile",
186
+ ),
187
+ ),
188
+ ],
189
+ ),
190
+ ]
File without changes
File without changes
@@ -0,0 +1,15 @@
1
+ from django.db import models
2
+
3
+
4
+ class Log(models.Model):
5
+ """
6
+ No relationships just a log.
7
+ """
8
+
9
+ user = models.TextField(default="", blank=True, null=True)
10
+
11
+ action = models.TextField(default="", blank=True, null=True)
12
+
13
+ details = models.TextField(default="", blank=True, null=True)
14
+
15
+ created = models.DateTimeField(auto_now_add=True)
@@ -0,0 +1,48 @@
1
+ from django.db import models
2
+
3
+ from allianceauth.authentication.models import UserProfile
4
+
5
+ from .pages import Page
6
+ from .settings import Setting
7
+
8
+
9
+ class PageVersion(models.Model):
10
+ """
11
+ Previous edits have value
12
+ """
13
+
14
+ page = models.ForeignKey(
15
+ Page,
16
+ on_delete=models.SET_NULL,
17
+ null=True,
18
+ blank=True,
19
+ help_text="Page being edited",
20
+ )
21
+
22
+ user = models.ForeignKey(
23
+ UserProfile,
24
+ on_delete=models.SET_NULL,
25
+ null=True,
26
+ blank=True,
27
+ help_text="User editing the page",
28
+ )
29
+
30
+ content = models.TextField(default="", blank=True, null=True)
31
+
32
+ created = models.DateTimeField(auto_now_add=True)
33
+
34
+ def save(self, *args, **kwargs):
35
+ """
36
+ Clean up old versions when saving
37
+ """
38
+ super().save(*args, **kwargs)
39
+ if self.page_id:
40
+ # Get the IDs of old versions to delete
41
+ settings = Setting.get_settings()
42
+ old_version_ids = list(
43
+ PageVersion.objects.filter(page=self.page)
44
+ .order_by("-created")
45
+ .values_list("id", flat=True)[settings.max_versions :]
46
+ )
47
+ if old_version_ids:
48
+ PageVersion.objects.filter(id__in=old_version_ids).delete()