Checkpoint, configuration can now be done through DB and the site. Server settings are still on the file system
This commit is contained in:
@ -115,6 +115,42 @@
|
||||
.delete-btn:hover {
|
||||
background-color: #ff1a1a;
|
||||
}
|
||||
.config-section {
|
||||
margin: 2rem 0;
|
||||
padding: 1rem;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
.config-editor fieldset {
|
||||
margin-bottom: 1.5rem;
|
||||
border: 1px solid #ddd;
|
||||
padding: 1rem;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.config-editor legend {
|
||||
font-weight: bold;
|
||||
padding: 0 0.5rem;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
.form-group input,
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 0.5rem;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
.form-group textarea {
|
||||
font-family: monospace;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -173,8 +209,55 @@
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="config-section">
|
||||
<h2>Configuration</h2>
|
||||
<div class="config-editor">
|
||||
<form id="configForm">
|
||||
|
||||
|
||||
<!-- Appearance -->
|
||||
<fieldset>
|
||||
<legend>Appearance</legend>
|
||||
<div class="form-group">
|
||||
<label for="appearance.accent_color">Accent Color:</label>
|
||||
<input style="min-height: 2rem;" type="color" id="appearance.accent_color" name="appearance.accent_color" value="{{ config.appearance.accent_color }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="appearance.site_title">Site Title:</label>
|
||||
<input type="text" id="appearance.site_title" name="appearance.site_title" value="{{ config.appearance.site_title }}">
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<!-- About Section -->
|
||||
<fieldset>
|
||||
<legend>About</legend>
|
||||
<div class="form-group">
|
||||
<label for="about.name">Name:</label>
|
||||
<input type="text" id="about.name" name="about.name" value="{{ config.about.name }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="about.location">Location:</label>
|
||||
<input type="text" id="about.location" name="about.location" value="{{ config.about.location }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="about.profile_image">Profile Image Path:</label>
|
||||
<input type="text" id="about.profile_image" name="about.profile_image" value="{{ config.about.profile_image }}">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="about.bio">Bio (Markdown):</label>
|
||||
<textarea id="about.bio" name="about.bio" rows="4">{{ config.about.bio }}</textarea>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Save Configuration</button>
|
||||
</form>
|
||||
</div>
|
||||
<div class="config-history-link" style="margin-top: 1rem;">
|
||||
<a href="{{ url_for('config_history') }}">View Configuration History</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<script nonce="{{ g.csp_nonce }}">
|
||||
function makeEditable(element) {
|
||||
const value = element.textContent;
|
||||
const input = document.createElement('input');
|
||||
@ -250,6 +333,38 @@
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById('configForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = {};
|
||||
const inputs = e.target.querySelectorAll('input, textarea');
|
||||
|
||||
inputs.forEach(input => {
|
||||
formData[input.name] = input.value;
|
||||
});
|
||||
|
||||
try {
|
||||
const response = await fetch('/admin/update_config', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(formData)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
alert('Configuration saved successfully');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('Error saving configuration: ' + result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('Error saving configuration: ' + error);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
Reference in New Issue
Block a user