Skip to content

Conversation

rochacbruno
Copy link
Owner

@rochacbruno rochacbruno commented Jul 21, 2025

Closes #264
Relates #263

Summary

Update HTML template files to use the url_for function instead of hardcoded asset links for better URL handling and maintainability.

Changes

  • CSS Links: Convert ./static/*.css to {{url_for(path='static/*.css')}}
  • JavaScript Links: Convert ./static/*.js to {{url_for(path='static/*.js')}}
  • RSS/JSON Feeds: Use {% set %} statements with slugify filters then url_for with string concatenation
  • Images: Convert static/avatar-placeholder.png to {{url_for(path='static/avatar-placeholder.png')}}
  • Stream Titles: Use stream_display_name(stream=stream) function for proper display names
  • Whitespace Control: Add {%- and -%} to template set statements

Files Modified

  • example/templates/base.html: Major updates to CSS, JS, RSS, and JSON feed links
  • example/templates/content_authors.html: Avatar placeholder image link
  • example/templates/group_author_avatar.html: Avatar placeholder image link

Technical Details

  • Uses Tera's ~ concatenation operator with proper syntax
  • Maintains dynamic URL generation for feeds with variable content
  • Ensures consistent URL handling across all template files
  • All tests pass and code quality checks successful

This change centralizes URL generation through the url_for function, making the templates more maintainable and ensuring consistent URL handling throughout the application.

- Convert hardcoded CSS, JS, RSS, JSON, and image links to use url_for function
- Use set statements with slugify filters for dynamic feed URLs
- Add proper whitespace control to template set statements
- Update stream titles to use stream_display_name function
- Ensure consistent URL generation across all template files

This improves URL handling and makes the templates more maintainable
by centralizing URL generation through the url_for function.
@rochacbruno rochacbruno merged commit a2f6e93 into main Jul 21, 2025
3 checks passed
@rochacbruno rochacbruno deleted the feat/template-url-for-functions branch July 24, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use url_for function on templates to resolve static files
1 participant