update custom many title
parent
3ef0f533b3
commit
9156bdc436
39
app.py
39
app.py
|
|
@ -13,6 +13,7 @@ from flask_talisman import Talisman
|
||||||
import glob
|
import glob
|
||||||
import csv
|
import csv
|
||||||
import uuid
|
import uuid
|
||||||
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
@ -27,6 +28,16 @@ STATIC_DIR = os.environ.get('STATIC_DIR', 'static')
|
||||||
TEMPLATES_DIR = os.environ.get('TEMPLATES_DIR', 'templates')
|
TEMPLATES_DIR = os.environ.get('TEMPLATES_DIR', 'templates')
|
||||||
TOKENS_FILE = os.environ.get('TOKENS_FILE', 'tokens.csv')
|
TOKENS_FILE = os.environ.get('TOKENS_FILE', 'tokens.csv')
|
||||||
|
|
||||||
|
# Get application titles from environment variables
|
||||||
|
APP_BAR_TITLE = os.environ.get('APP_BAR_TITLE', 'C Programming Learning System')
|
||||||
|
COPYRIGHT_TEXT = os.environ.get('COPYRIGHT_TEXT', 'C Programming Learning System © 2025')
|
||||||
|
PAGE_TITLE_SUFFIX = os.environ.get('PAGE_TITLE_SUFFIX', 'C Programming Learning System')
|
||||||
|
|
||||||
|
# Log the values to ensure they are loaded correctly
|
||||||
|
print(f"APP_BAR_TITLE: {APP_BAR_TITLE}")
|
||||||
|
print(f"COPYRIGHT_TEXT: {COPYRIGHT_TEXT}")
|
||||||
|
print(f"PAGE_TITLE_SUFFIX: {PAGE_TITLE_SUFFIX}")
|
||||||
|
|
||||||
# Security configuration using Talisman
|
# Security configuration using Talisman
|
||||||
Talisman(app,
|
Talisman(app,
|
||||||
force_https=False, # Set to True if using SSL
|
force_https=False, # Set to True if using SSL
|
||||||
|
|
@ -449,6 +460,11 @@ def render_markdown_content(file_path):
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def index():
|
def index():
|
||||||
"""Main page showing all lessons"""
|
"""Main page showing all lessons"""
|
||||||
|
print("Index function called") # Logging for debugging
|
||||||
|
print(f"APP_BAR_TITLE value: {APP_BAR_TITLE}") # Logging for debugging
|
||||||
|
print(f"COPYRIGHT_TEXT value: {COPYRIGHT_TEXT}") # Logging for debugging
|
||||||
|
print(f"PAGE_TITLE_SUFFIX value: {PAGE_TITLE_SUFFIX}") # Logging for debugging
|
||||||
|
|
||||||
# Get token from session or request (for now, we'll pass it in the template context)
|
# Get token from session or request (for now, we'll pass it in the template context)
|
||||||
token = request.args.get('token', '') # This would typically come from session after login
|
token = request.args.get('token', '') # This would typically come from session after login
|
||||||
|
|
||||||
|
|
@ -480,7 +496,23 @@ def index():
|
||||||
for lesson in lessons:
|
for lesson in lessons:
|
||||||
print(f"Lesson: {lesson['title']}, completed: {lesson.get('completed', 'N/A')}") # Logging for debugging
|
print(f"Lesson: {lesson['title']}, completed: {lesson.get('completed', 'N/A')}") # Logging for debugging
|
||||||
|
|
||||||
return render_template('index.html', lessons=lessons, home_content=home_content, token=token, progress=progress)
|
try:
|
||||||
|
result = render_template('index.html',
|
||||||
|
lessons=lessons,
|
||||||
|
home_content=home_content,
|
||||||
|
token=token,
|
||||||
|
progress=progress,
|
||||||
|
app_bar_title=APP_BAR_TITLE,
|
||||||
|
copyright_text=COPYRIGHT_TEXT,
|
||||||
|
page_title_suffix=PAGE_TITLE_SUFFIX)
|
||||||
|
print("Template rendered successfully")
|
||||||
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error rendering template: {str(e)}")
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
# Return a simple error page
|
||||||
|
return f"Error rendering template: {str(e)}"
|
||||||
|
|
||||||
@app.route('/lesson/<filename>')
|
@app.route('/lesson/<filename>')
|
||||||
def lesson(filename):
|
def lesson(filename):
|
||||||
|
|
@ -552,7 +584,10 @@ int main() {
|
||||||
lesson_completed=lesson_completed,
|
lesson_completed=lesson_completed,
|
||||||
prev_lesson=prev_lesson,
|
prev_lesson=prev_lesson,
|
||||||
next_lesson=next_lesson,
|
next_lesson=next_lesson,
|
||||||
ordered_lessons=ordered_lessons)
|
ordered_lessons=ordered_lessons,
|
||||||
|
app_bar_title=APP_BAR_TITLE,
|
||||||
|
copyright_text=COPYRIGHT_TEXT,
|
||||||
|
page_title_suffix=PAGE_TITLE_SUFFIX)
|
||||||
|
|
||||||
@app.route('/compile', methods=['POST'])
|
@app.route('/compile', methods=['POST'])
|
||||||
def compile_code():
|
def compile_code():
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,10 @@ services:
|
||||||
- ../.env
|
- ../.env
|
||||||
|
|
||||||
# production
|
# production
|
||||||
command: gunicorn --config gunicorn.conf.py app:app
|
# command: gunicorn --config gunicorn.conf.py app:app
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
# command: python app.py
|
command: python app.py
|
||||||
|
|
||||||
elemes-ts:
|
elemes-ts:
|
||||||
image: docker.io/tailscale/tailscale:latest
|
image: docker.io/tailscale/tailscale:latest
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
Flask==2.3.3
|
Flask==2.3.3
|
||||||
markdown==3.5
|
markdown==3.5
|
||||||
gunicorn==21.2.0
|
gunicorn==21.2.0
|
||||||
flask-talisman==1.1.0
|
flask-talisman==1.1.0
|
||||||
|
python-dotenv==1.0.0
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>C Programming Learning System</title>
|
<title>{{ page_title_suffix }}</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
<link rel="stylesheet" href="{{ url_for('send_static', path='style.css') }}">
|
<link rel="stylesheet" href="{{ url_for('send_static', path='style.css') }}">
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" href="/">
|
<a class="navbar-brand" href="/">
|
||||||
<i class="fas fa-code"></i> C Programming Learning System
|
<i class="fas fa-code"></i> {{ app_bar_title }}
|
||||||
</a>
|
</a>
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<form class="d-flex" id="token-form" style="display: flex; align-items: center;">
|
<form class="d-flex" id="token-form" style="display: flex; align-items: center;">
|
||||||
|
|
@ -28,8 +28,6 @@
|
||||||
<div class="container mt-4">
|
<div class="container mt-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<h1 class="mb-4">C Programming Learning System</h1>
|
|
||||||
|
|
||||||
<!-- Home content rendered from markdown -->
|
<!-- Home content rendered from markdown -->
|
||||||
<div class="home-content mb-5">
|
<div class="home-content mb-5">
|
||||||
{{ home_content | safe }}
|
{{ home_content | safe }}
|
||||||
|
|
@ -76,7 +74,7 @@
|
||||||
|
|
||||||
<footer class="footer mt-5 py-4 bg-light">
|
<footer class="footer mt-5 py-4 bg-light">
|
||||||
<div class="container text-center">
|
<div class="container text-center">
|
||||||
<span class="text-muted">C Programming Learning System © 2025</span>
|
<span class="text-muted">{{ copyright_text }}</span>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|
@ -359,4 +357,4 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>{{ lesson_title }} - C Programming Learning System</title>
|
<title>{{ lesson_title }} - {{ page_title_suffix }}</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="navbar-brand" href="/">
|
<a class="navbar-brand" href="/">
|
||||||
<i class="fas fa-code"></i> C Programming Learning System
|
<i class="fas fa-code"></i> {{ app_bar_title }}
|
||||||
</a>
|
</a>
|
||||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
|
||||||
<span class="navbar-toggler-icon"></span>
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
|
@ -207,7 +207,7 @@
|
||||||
|
|
||||||
<footer class="footer mt-5 py-4 bg-light">
|
<footer class="footer mt-5 py-4 bg-light">
|
||||||
<div class="container text-center">
|
<div class="container text-center">
|
||||||
<span class="text-muted">C Programming Learning System © 2025</span>
|
<span class="text-muted">{{ copyright_text }}</span>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue