This commit is contained in:
pika 2025-03-30 20:32:22 +02:00
parent 539d6a6416
commit f939933a7c
9 changed files with 62 additions and 59 deletions

Binary file not shown.

View file

@ -108,6 +108,17 @@ def create_app(config_name='development'):
except ImportError as e:
print(f"Could not import API blueprint: {e}")
# Register template filters - IMPORTANT FOR MARKDOWN FILTER
from app.core.template_filters import bp as filters_bp
app.register_blueprint(filters_bp)
# Register template filters directly if the blueprint method doesn't work
from app.core.template_filters import markdown_filter, ip_network_filter, ip_address_filter, get_ip_network
app.jinja_env.filters['markdown'] = markdown_filter
app.jinja_env.filters['ip_network'] = ip_network_filter
app.jinja_env.filters['ip_address'] = ip_address_filter
app.jinja_env.globals['get_ip_network'] = get_ip_network
# Create database tables
with app.app_context():
try:

Binary file not shown.

View file

@ -103,79 +103,37 @@
<div class="col-md-8">
<!-- Applications -->
<div class="card">
<div class="card-header d-flex align-items-center">
<div class="card-header">
<h3 class="card-title">Applications</h3>
<div class="ms-auto">
<a href="{{ url_for('dashboard.app_new', server_id=server.id) }}" class="btn btn-sm btn-primary">
<i class="ti ti-plus me-1"></i> Add Application
<div class="card-actions">
<a href="{{ url_for('dashboard.app_new', server_id=server.id) }}" class="btn btn-primary">
<span class="ti ti-plus me-2"></span> Add Application
</a>
</div>
</div>
<div class="card-body">
{% if server.apps %}
<div class="accordion" id="applicationAccordion">
<div class="row row-cards">
{% for app in server.apps %}
<div class="accordion-item">
<h2 class="accordion-header" id="heading{{ app.id }}">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
data-bs-target="#collapse{{ app.id }}" aria-expanded="false" aria-controls="collapse{{ app.id }}">
<span class="me-2">{{ app.name }}</span>
<div class="col-md-6 col-lg-4">
<div class="card">
<div class="card-body">
<h3 class="card-title">
<a href="{{ url_for('dashboard.app_view', app_id=app.id) }}">{{ app.name }}</a>
</h3>
{% if app.ports %}
<div class="ms-auto d-flex">
<div class="mt-2">
<span class="badge bg-blue me-1">Ports:</span>
{% for port in app.ports %}
<span class="badge bg-primary me-1">{{ port.port_number }}/{{ port.protocol }}</span>
<span class="badge bg-azure me-1">{{ port.port_number }}/{{ port.protocol }}</span>
{% endfor %}
</div>
{% endif %}
</button>
</h2>
<div id="collapse{{ app.id }}" class="accordion-collapse collapse" aria-labelledby="heading{{ app.id }}"
data-bs-parent="#applicationAccordion">
<div class="accordion-body">
<div class="d-flex justify-content-end mb-2">
<a href="{{ url_for('dashboard.app_edit', app_id=app.id) }}"
class="btn btn-sm btn-outline-primary me-2">
<i class="ti ti-edit"></i> Edit
</a>
<button type="button" class="btn btn-sm btn-outline-danger"
onclick="confirmDeleteApp({{ app.id }}, '{{ app.name }}')">
<i class="ti ti-trash"></i> Delete
</button>
</div>
<!-- Ports -->
{% if app.ports %}
<div class="mb-3">
<h5>Ports</h5>
<div class="table-responsive">
<table class="table table-vcenter table-sm">
<thead>
<tr>
<th>Port</th>
<th>Protocol</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{% for port in app.ports %}
<tr>
<td>{{ port.port_number }}</td>
<td>{{ port.protocol }}</td>
<td>{{ port.description }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
<!-- Documentation -->
{% if app.documentation %}
<div class="mt-3">
<h5>Documentation</h5>
<div class="markdown-body">
{{ app.documentation|markdown }}
{{ app.documentation|markdown|safe }}
</div>
</div>
{% else %}

28
config.py Normal file
View file

@ -0,0 +1,28 @@
import os
class Config:
"""Base config."""
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-key-placeholder')
SQLALCHEMY_TRACK_MODIFICATIONS = False
WTF_CSRF_ENABLED = True
SESSION_COOKIE_SECURE = False # Set to True in production with HTTPS
class DevelopmentConfig(Config):
"""Development config."""
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', 'sqlite:///app.db')
SQLALCHEMY_ECHO = True
class ProductionConfig(Config):
"""Production config."""
DEBUG = False
TESTING = False
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL', 'sqlite:///app.db')
SESSION_COOKIE_SECURE = True
REMEMBER_COOKIE_SECURE = True
class TestingConfig(Config):
"""Testing config."""
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
WTF_CSRF_ENABLED = False

BIN
instance/app.db Normal file

Binary file not shown.

10
wsgi.py
View file

@ -1,7 +1,13 @@
import os
from app import create_app
# Create application instance - production
# Set the environment variable for database URL if needed
# os.environ['DATABASE_URL'] = 'your_production_database_url'
# Create a production application
app = create_app('production')
if __name__ == '__main__':
app.run()
# This is only used for development
# In production, a WSGI server would import this file
app.run(host='0.0.0.0', port=5000)