up static routes
This commit is contained in:
parent
9cca0e4998
commit
1048f4af45
14 changed files with 2959 additions and 1076 deletions
|
@ -26,6 +26,16 @@ class DemoMainResource:
|
|||
# Set content type to HTML
|
||||
resp.content_type = 'text/html'
|
||||
|
||||
# Load environment variables from .env file for OAuth2 configuration
|
||||
from oedb.utils.db import load_env_from_file
|
||||
load_env_from_file()
|
||||
|
||||
# Get OAuth2 configuration parameters
|
||||
import os
|
||||
client_id = os.getenv("CLIENT_ID", "")
|
||||
client_secret = os.getenv("CLIENT_SECRET", "")
|
||||
client_redirect = os.getenv("CLIENT_REDIRECT", "")
|
||||
|
||||
# Create HTML response with MapLibre map
|
||||
html = """
|
||||
<!DOCTYPE html>
|
||||
|
@ -37,7 +47,9 @@ class DemoMainResource:
|
|||
<script src="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.js"></script>
|
||||
<link href="https://unpkg.com/maplibre-gl@3.0.0/dist/maplibre-gl.css" rel="stylesheet" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||
<link rel="stylesheet" href="/static/demo_styles.css">
|
||||
<script defer src="https://use.fontawesome.com/releases/v5.15.4/js/all.js"></script>
|
||||
<script src="/static/demo_auth.js"></script>
|
||||
<style>
|
||||
body { margin: 0; padding: 0; font-family: Arial, sans-serif; }
|
||||
#map { position: absolute; top: 0; bottom: 0; width: 100%; }
|
||||
|
@ -89,9 +101,41 @@ class DemoMainResource:
|
|||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
|
||||
<!-- Hidden OAuth2 configuration for the JavaScript module -->
|
||||
<input type="hidden" id="osmClientId" value="{client_id}">
|
||||
<input type="hidden" id="osmClientSecret" value="{client_secret}">
|
||||
<input type="hidden" id="osmRedirectUri" value="{client_redirect}">
|
||||
|
||||
<div class="map-overlay">
|
||||
<h2>OpenEventDatabase Demo</h2>
|
||||
<p>This map shows current events from the OpenEventDatabase.</p>
|
||||
|
||||
<!-- Authentication section -->
|
||||
<div id="auth-section" class="auth-section">
|
||||
<h3>OpenStreetMap Authentication</h3>
|
||||
<p>Authenticate with your OpenStreetMap account to include your username in reports.</p>
|
||||
<a href="https://www.openstreetmap.org/oauth2/authorize?client_id={client_id}&redirect_uri={client_redirect}&response_type=code&scope=read_prefs" class="osm-login-btn">
|
||||
<span class="osm-logo"></span>
|
||||
Login with OpenStreetMap
|
||||
</a>
|
||||
<script>
|
||||
// Replace server-side auth section with JavaScript-rendered version if available
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
if (window.osmAuth) {
|
||||
const clientId = document.getElementById('osmClientId').value;
|
||||
const redirectUri = document.getElementById('osmRedirectUri').value;
|
||||
const authSection = document.getElementById('auth-section');
|
||||
|
||||
// Only replace if osmAuth is loaded and has renderAuthSection method
|
||||
if (osmAuth.renderAuthSection) {
|
||||
authSection.innerHTML = osmAuth.renderAuthSection(clientId, redirectUri);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<h3>API Endpoints:</h3>
|
||||
<ul>
|
||||
<li><a href="/" target="_blank">/ - API Information</a></li>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue