A little app to serve my photography from my personal website

static assets need to be under photos path for cloudflare tunnel

ericwood.org 5738837c bb4fcfd7

Waiting for spindle ...
+13 -10
+6 -3
src/main.rs
··· 29 29 let reloader = load_templates_dyn(); 30 30 let app_state = Arc::new(AppState { reloader, pool }); 31 31 let app = Router::new() 32 + .nest_service("/photos/assets", ServeDir::new(&env::var("ASSETS_PATH")?)) 33 + .nest_service( 34 + "/photos/thumbnails", 35 + ServeDir::new(&env::var("THUMBNAIL_PATH")?), 36 + ) 37 + .nest_service("/photos/images", ServeDir::new(&env::var("IMAGE_PATH")?)) 32 38 .route("/photos", get(routes::photos::index)) 33 39 .route("/photos/{id}", get(routes::photos::show)) 34 40 .with_state(app_state) 35 - .nest_service("/assets", ServeDir::new(&env::var("ASSETS_PATH")?)) 36 - .nest_service("/thumbnails", ServeDir::new(&env::var("THUMBNAIL_PATH")?)) 37 - .nest_service("/images", ServeDir::new(&env::var("IMAGE_PATH")?)) 38 41 .fallback(handler_404); 39 42 let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); 40 43 axum::serve(listener, app).await?;
+2 -2
templates/layout.jinja
··· 10 10 {% block title %}{% endblock %} 11 11 </title> 12 12 {% block head %}{% endblock %} 13 - <link rel="stylesheet" href="/assets/app.css" /> 13 + <link rel="stylesheet" href="/photos/assets/app.css" /> 14 14 </head> 15 15 <body> 16 16 <div class="container"> ··· 27 27 </header> 28 28 {% block body %}{% endblock %} 29 29 </div> 30 - <script src="/assets/app.js" type="text/javascript"></script> 30 + <script src="/photos/assets/app.js" type="text/javascript"></script> 31 31 </body> 32 32 </html>
+3 -3
templates/photos/index.jinja
··· 1 1 {% extends "layout" %} 2 2 {% block title %}Photos{% endblock %} 3 - {% block head %}<link rel="stylesheet" href="/assets/photos/index.css" />{% endblock %} 3 + {% block head %}<link rel="stylesheet" href="/photos/assets/photos/index.css" />{% endblock %} 4 4 {% block body %} 5 5 <div class="photos__layout"> 6 6 <div class="photos__mobile-nav"> ··· 18 18 data-width="{{ photo.width }}" 19 19 data-height="{{ photo.height }}" 20 20 > 21 - <img src="/thumbnails/{{ photo.id }}.webp"> 21 + <img src="/photos/thumbnails/{{ photo.id }}.webp"> 22 22 </a> 23 23 {% endfor %} 24 24 </div> ··· 92 92 <path id="close-icon" d="M20.7457 3.32851C20.3552 2.93798 19.722 2.93798 19.3315 3.32851L12.0371 10.6229L4.74275 3.32851C4.35223 2.93798 3.71906 2.93798 3.32854 3.32851C2.93801 3.71903 2.93801 4.3522 3.32854 4.74272L10.6229 12.0371L3.32856 19.3314C2.93803 19.722 2.93803 20.3551 3.32856 20.7457C3.71908 21.1362 4.35225 21.1362 4.74277 20.7457L12.0371 13.4513L19.3315 20.7457C19.722 21.1362 20.3552 21.1362 20.7457 20.7457C21.1362 20.3551 21.1362 19.722 20.7457 19.3315L13.4513 12.0371L20.7457 4.74272C21.1362 4.3522 21.1362 3.71903 20.7457 3.32851Z" fill="currentColor"/> 93 93 </defs> 94 94 </svg> 95 - <script src="/assets/photos/index.js" type="text/javascript"></script> 95 + <script src="/photos/assets/photos/index.js" type="text/javascript"></script> 96 96 {% endblock %}
+2 -2
templates/photos/show.jinja
··· 1 1 {% extends "layout" %} 2 2 {% block title %}Photos / View{% endblock %} 3 - {% block head %}<link rel="stylesheet" href="/assets/photos/show.css" />{% endblock %} 3 + {% block head %}<link rel="stylesheet" href="/photos/assets/photos/show.css" />{% endblock %} 4 4 {% block body %} 5 5 <div class="photo__container"> 6 6 <div class="photo__image"> 7 - <img src="/images/{{ photo.filename }}"> 7 + <img src="/photos/images/{{ photo.filename }}"> 8 8 </div> 9 9 <div class="photo__sidebar"> 10 10 <h2>Metadata</h2>