interactive intro to open social

architecture: css and html embedded in rust string literals #6

open
opened by zzstoatzz.io

problem#

all css and html templates are embedded as rust string literals in src/templates.rs.

current approach:

pub fn login_page() -> &'static str {
    r#"
<!DOCTYPE html>
<html>
<head>
    <style>
        /* ~300 lines of css */
    </style>
</head>
...
    "#
}

issues#

1. no syntax highlighting#

writing css/html in rust strings = no proper editor support

2. css duplication#

  • similar styles duplicated between login_page() and app_page()
  • css variables defined separately in each template
  • ~700 lines of css total in rust strings

3. template maintenance#

  • hard to edit/preview html
  • rust compilation required for any frontend change
  • can't use standard html/css tooling

4. no separation of concerns#

  • presentation logic mixed with backend code
  • harder to onboard frontend contributors

affected files#

  • src/templates.rs (~990 lines, mostly css/html)

notes#

this is somewhat intentional (simple deployment, no build step), but creates maintenance overhead as app grows.

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xbtmt2zjwlrfegqvch7fboei/sh.tangled.repo.issue/1760151727485420