You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
354 lines
11 KiB
354 lines
11 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Imam Javad API - Swagger UI</title>
|
|
|
|
<!-- Swagger UI CSS -->
|
|
<link rel="stylesheet" type="text/css" href="https://unpkg.com/swagger-ui-dist@4.15.5/swagger-ui.css" />
|
|
|
|
<style>
|
|
:root {
|
|
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
--success-color: #28a745;
|
|
--warning-color: #f39c12;
|
|
--danger-color: #e74c3c;
|
|
--info-color: #17a2b8;
|
|
}
|
|
|
|
/* Fixed Authentication Banner */
|
|
.auth-banner {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
z-index: 9999;
|
|
background: var(--primary-gradient);
|
|
backdrop-filter: blur(10px);
|
|
box-shadow: 0 2px 20px rgba(0,0,0,0.1);
|
|
padding: 15px 20px;
|
|
color: white;
|
|
}
|
|
|
|
.auth-content {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.auth-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 20px;
|
|
}
|
|
|
|
.user-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.user-avatar {
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 50%;
|
|
background: rgba(255,255,255,0.2);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.user-details h4 {
|
|
margin: 0;
|
|
font-size: 0.9rem;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.user-details p {
|
|
margin: 0;
|
|
font-size: 0.8rem;
|
|
opacity: 0.8;
|
|
}
|
|
|
|
.auth-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
background: rgba(255,255,255,0.1);
|
|
padding: 8px 12px;
|
|
border-radius: 20px;
|
|
font-size: 0.8rem;
|
|
}
|
|
|
|
.status-indicator {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--success-color);
|
|
}
|
|
|
|
.auth-actions {
|
|
display: flex;
|
|
gap: 10px;
|
|
}
|
|
|
|
.auth-btn {
|
|
padding: 8px 16px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 0.8rem;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
text-decoration: none;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: rgba(255,255,255,0.2);
|
|
color: white;
|
|
border: 1px solid rgba(255,255,255,0.3);
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: rgba(255,255,255,0.3);
|
|
color: white;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: transparent;
|
|
color: white;
|
|
border: 1px solid rgba(255,255,255,0.3);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: rgba(255,255,255,0.1);
|
|
color: white;
|
|
text-decoration: none;
|
|
}
|
|
|
|
/* Main Content Adjustment */
|
|
body {
|
|
padding-top: 80px;
|
|
}
|
|
|
|
/* Swagger UI Customizations */
|
|
.swagger-ui .topbar {
|
|
display: none;
|
|
}
|
|
|
|
.swagger-ui .info {
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.swagger-ui .info .title {
|
|
color: #2c3e50;
|
|
font-size: 2rem;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
/* Mobile Responsive */
|
|
@media (max-width: 768px) {
|
|
body {
|
|
padding-top: 120px;
|
|
}
|
|
|
|
.auth-content {
|
|
flex-direction: column;
|
|
gap: 15px;
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.auth-info {
|
|
flex-direction: column;
|
|
gap: 10px;
|
|
align-items: flex-start;
|
|
width: 100%;
|
|
}
|
|
|
|
.auth-actions {
|
|
width: 100%;
|
|
justify-content: flex-end;
|
|
}
|
|
|
|
.auth-btn {
|
|
font-size: 0.7rem;
|
|
padding: 6px 12px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
body {
|
|
padding-top: 140px;
|
|
}
|
|
|
|
.auth-banner {
|
|
padding: 10px 15px;
|
|
}
|
|
|
|
.user-details h4 {
|
|
font-size: 0.8rem;
|
|
}
|
|
|
|
.user-details p {
|
|
font-size: 0.7rem;
|
|
}
|
|
}
|
|
|
|
/* Loading Animation */
|
|
.loading-spinner {
|
|
display: inline-block;
|
|
width: 16px;
|
|
height: 16px;
|
|
border: 2px solid rgba(255,255,255,0.3);
|
|
border-radius: 50%;
|
|
border-top-color: white;
|
|
animation: spin 1s ease-in-out infinite;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
/* Custom Swagger Styles */
|
|
.swagger-ui .scheme-container {
|
|
background: #f8f9fa;
|
|
border-radius: 8px;
|
|
padding: 15px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
.swagger-ui .btn.authorize {
|
|
background: var(--primary-gradient);
|
|
border: none;
|
|
color: white;
|
|
}
|
|
|
|
.swagger-ui .btn.authorize:hover {
|
|
background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- Fixed Authentication Banner -->
|
|
<div class="auth-banner">
|
|
<div class="auth-content">
|
|
<div class="auth-info">
|
|
{% if request.session.swagger_user_info %}
|
|
<div class="user-info">
|
|
<div class="user-avatar">
|
|
{{ request.session.swagger_user_info.fullname|first|upper }}
|
|
</div>
|
|
<div class="user-details">
|
|
<h4>{{ request.session.swagger_user_info.fullname }}</h4>
|
|
<p>{{ request.session.swagger_user_info.email }}</p>
|
|
</div>
|
|
</div>
|
|
<div class="auth-status">
|
|
<div class="status-indicator"></div>
|
|
<span>Authenticated</span>
|
|
</div>
|
|
{% else %}
|
|
<div class="auth-status">
|
|
<div class="status-indicator" style="background: var(--warning-color);"></div>
|
|
<span>Not Authenticated</span>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<div class="auth-actions">
|
|
<a href="{% url 'docs-index' %}" class="auth-btn btn-secondary">
|
|
<i class="fas fa-book"></i>
|
|
Documentation
|
|
</a>
|
|
{% if request.session.swagger_user_info %}
|
|
<a href="{% url 'clear-swagger-auth' %}" class="auth-btn btn-primary">
|
|
<i class="fas fa-sign-out-alt"></i>
|
|
Logout
|
|
</a>
|
|
{% else %}
|
|
<a href="{% url 'swagger-token-auth' %}" class="auth-btn btn-primary">
|
|
<i class="fas fa-key"></i>
|
|
Authenticate
|
|
</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Swagger UI Container -->
|
|
<div id="swagger-ui"></div>
|
|
|
|
<!-- Swagger UI JavaScript -->
|
|
<script src="https://unpkg.com/swagger-ui-dist@4.15.5/swagger-ui-bundle.js"></script>
|
|
<script src="https://unpkg.com/swagger-ui-dist@4.15.5/swagger-ui-standalone-preset.js"></script>
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/js/all.min.js"></script>
|
|
|
|
<script>
|
|
window.onload = function() {
|
|
const ui = SwaggerUIBundle({
|
|
url: '{{ swagger_spec_url }}',
|
|
dom_id: '#swagger-ui',
|
|
deepLinking: true,
|
|
presets: [
|
|
SwaggerUIBundle.presets.apis,
|
|
SwaggerUIStandalonePreset
|
|
],
|
|
plugins: [
|
|
SwaggerUIBundle.plugins.DownloadUrl
|
|
],
|
|
layout: "StandaloneLayout",
|
|
requestInterceptor: function(request) {
|
|
// Add authorization header if token exists
|
|
{% if request.session.swagger_token %}
|
|
request.headers['Authorization'] = 'Token {{ request.session.swagger_token }}';
|
|
{% endif %}
|
|
return request;
|
|
},
|
|
responseInterceptor: function(response) {
|
|
// Handle authentication errors
|
|
if (response.status === 401) {
|
|
console.log('Authentication required');
|
|
// Could redirect to auth page or show message
|
|
}
|
|
return response;
|
|
}
|
|
});
|
|
|
|
// Custom styling after UI loads
|
|
setTimeout(function() {
|
|
// Hide default topbar
|
|
const topbar = document.querySelector('.swagger-ui .topbar');
|
|
if (topbar) {
|
|
topbar.style.display = 'none';
|
|
}
|
|
|
|
// Add custom info section
|
|
const infoSection = document.querySelector('.swagger-ui .info');
|
|
if (infoSection && !document.querySelector('.custom-info-added')) {
|
|
const customInfo = document.createElement('div');
|
|
customInfo.className = 'custom-info-added';
|
|
customInfo.innerHTML = `
|
|
<div style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white; padding: 20px; border-radius: 8px; margin-bottom: 20px;">
|
|
<h2 style="margin: 0 0 10px 0;">Imam Javad API</h2>
|
|
<p style="margin: 0; opacity: 0.9;">
|
|
Comprehensive API documentation for the Imam Javad educational platform.
|
|
This API provides access to courses, hadis collections, library resources, and more.
|
|
</p>
|
|
</div>
|
|
`;
|
|
infoSection.parentNode.insertBefore(customInfo, infoSection);
|
|
}
|
|
}, 1000);
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|