Skip to content

Commit e687f90

Browse files
committed
Release v1.0.6: Hello World Plugin & Enhanced Plugin System Testing
- Created Hello World test plugin for plugin system validation - Added middleware-based plugin activation/deactivation system - Implemented visual feedback for plugin status on homepage header - Enhanced plugin discovery and management capabilities - Added plugin template integration with theme system - Tested complete activation/deactivation workflow successfully Plugin Features: - Auto-discovery through plugin.json metadata - Dynamic activation/deactivation via admin interface - Visual homepage header when active (purple gradient banner) - Middleware-based request context injection - Template integration with theme system - Complete plugin lifecycle management Technical Implementation: - Created plugins/hello_world/ with full Django app structure - Added HelloWorldMiddleware for request context - Enhanced MIDDLEWARE configuration for plugin integration - Modified themes/default/base.html for plugin display - Tested activation/deactivation through PluginManager model Testing Results: - Plugin activation: ✅ Shows "Hello World Plugin Active!" banner - Plugin deactivation: ✅ Banner disappears from homepage - Admin integration: ✅ Manageable through Django admin - Auto-discovery: ✅ Automatically detected by plugin system
1 parent 86a5408 commit e687f90

13 files changed

Lines changed: 172 additions & 1 deletion

File tree

.claude/settings.local.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@
2929
"Bash(pip3 install:*)",
3030
"Bash(git add:*)",
3131
"Bash(git commit:*)",
32-
"Bash(git push:*)"
32+
"Bash(git push:*)",
33+
"Bash(git checkout main)",
34+
"Bash(git tag:*)",
35+
"Bash(git fetch:*)",
36+
"Bash(git checkout:*)",
37+
"Bash(dir plugins)",
38+
"Bash(findstr:*)"
3339
],
3440
"deny": [],
3541
"ask": []

config/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def get_active_plugins():
9191
'django.middleware.common.CommonMiddleware',
9292
'django.middleware.csrf.CsrfViewMiddleware',
9393
'django.contrib.auth.middleware.AuthenticationMiddleware',
94+
'plugins.hello_world.middleware.HelloWorldMiddleware', # Hello World plugin middleware
9495
'django.contrib.messages.middleware.MessageMiddleware',
9596
'django.middleware.clickjacking.XFrameOptionsMiddleware',
9697
]

plugins/hello_world/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Hello World Plugin

plugins/hello_world/apps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.apps import AppConfig
2+
3+
4+
class HelloWorldConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'plugins.hello_world'
7+
verbose_name = 'Hello World Plugin'

plugins/hello_world/middleware.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from django.utils.deprecation import MiddlewareMixin
2+
3+
4+
class HelloWorldMiddleware(MiddlewareMixin):
5+
"""Middleware to add hello world plugin status to request context"""
6+
7+
def process_request(self, request):
8+
"""Add hello world plugin status to request"""
9+
try:
10+
from plugins.models import PluginManager
11+
plugin = PluginManager.objects.get(app_name='plugins.hello_world')
12+
request.hello_world_active = plugin.is_active
13+
except:
14+
request.hello_world_active = False
15+
16+
return None

plugins/hello_world/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# No models needed for this simple plugin

plugins/hello_world/plugin.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"name": "Hello World Plugin",
3+
"description": "A simple test plugin that displays 'Hello World' message on the homepage header for testing activation/deactivation.",
4+
"version": "1.0.0",
5+
"app_name": "plugins.hello_world"
6+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{% if plugin %}
2+
<div class="card border-primary mb-3">
3+
<div class="card-header bg-primary text-white">
4+
<i class="fas fa-plug"></i> {{ plugin.name }} v{{ plugin.version }}
5+
{% if is_active %}
6+
<span class="badge bg-success ms-2">Active</span>
7+
{% else %}
8+
<span class="badge bg-secondary ms-2">Inactive</span>
9+
{% endif %}
10+
</div>
11+
<div class="card-body">
12+
<p class="card-text">{{ plugin.description }}</p>
13+
{% if is_active %}
14+
<div class="alert alert-success">
15+
<i class="fas fa-check-circle"></i> Plugin is currently active and running!
16+
</div>
17+
{% else %}
18+
<div class="alert alert-warning">
19+
<i class="fas fa-pause-circle"></i> Plugin is currently inactive.
20+
</div>
21+
{% endif %}
22+
</div>
23+
</div>
24+
{% else %}
25+
<div class="alert alert-danger">
26+
<i class="fas fa-exclamation-triangle"></i> Hello World Plugin not found!
27+
</div>
28+
{% endif %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Template tags for Hello World Plugin
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from django import template
2+
from django.utils.safestring import mark_safe
3+
4+
register = template.Library()
5+
6+
7+
@register.simple_tag
8+
def hello_world_header():
9+
"""Display hello world message in header if plugin is active"""
10+
try:
11+
from plugins.models import PluginManager
12+
plugin = PluginManager.objects.get(app_name='plugins.hello_world')
13+
14+
if plugin.is_active:
15+
return mark_safe('''
16+
<div class="alert alert-info text-center mb-0" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; border-radius: 0;">
17+
<i class="fas fa-rocket"></i>
18+
<strong>Hello World Plugin Active!</strong>
19+
This message appears when the Hello World plugin is activated.
20+
<i class="fas fa-star"></i>
21+
</div>
22+
''')
23+
return ''
24+
except:
25+
return ''
26+
27+
28+
@register.simple_tag
29+
def plugin_status_badge():
30+
"""Display plugin status badge"""
31+
try:
32+
from plugins.models import PluginManager
33+
plugin = PluginManager.objects.get(app_name='plugins.hello_world')
34+
35+
if plugin.is_active:
36+
return mark_safe('<span class="badge bg-success">Hello World Plugin: Active</span>')
37+
else:
38+
return mark_safe('<span class="badge bg-secondary">Hello World Plugin: Inactive</span>')
39+
except:
40+
return mark_safe('<span class="badge bg-danger">Hello World Plugin: Not Found</span>')
41+
42+
43+
@register.inclusion_tag('hello_world/plugin_info.html')
44+
def hello_world_info():
45+
"""Display plugin information"""
46+
try:
47+
from plugins.models import PluginManager
48+
plugin = PluginManager.objects.get(app_name='plugins.hello_world')
49+
return {
50+
'plugin': plugin,
51+
'is_active': plugin.is_active
52+
}
53+
except:
54+
return {
55+
'plugin': None,
56+
'is_active': False
57+
}

0 commit comments

Comments
 (0)