diff --git a/databuild/web/templates.rs b/databuild/web/templates.rs index d48d35e..6fe0c85 100644 --- a/databuild/web/templates.rs +++ b/databuild/web/templates.rs @@ -212,20 +212,12 @@ impl Default for BaseContext { } // ============================================================================= -// Shared Template Components (as Askama macros) +// Template Structure // ============================================================================= // -// Note: Askama's source attribute doesn't support concat! or any other way to -// share template code between structs. So the macro definitions (head, nav, footer) -// are duplicated in each template's source string. This is a limitation of -// proc-macro attribute evaluation order. -// -// Each template defines three Askama macros: -// - head(title): HTML head with CSS styles -// - nav(active, graph_label): Navigation bar -// - footer(): Closing tags -// -// The page-specific content is formatted for readability. +// Templates are file-based and located in databuild/web/templates/. +// Common components (head, nav, footer) are defined as macros in base.html +// and imported by each page template with: {% import "base.html" as base %} // ============================================================================= // Home Page diff --git a/databuild/web/templates/base.html b/databuild/web/templates/base.html new file mode 100644 index 0000000..391430a --- /dev/null +++ b/databuild/web/templates/base.html @@ -0,0 +1,198 @@ +{# + Base template macros for DataBuild dashboard. + Import these in page templates with: {% import "base.html" as base %} + Then call: {% call base::head("Page Title") %}, {% call base::nav(...) %}, {% call base::footer() %} +#} + +{% macro head(title) %} + + + + + + + + + {{ title }} + + + +{% endmacro %} + +{% macro nav(active, graph_label) %} + +
+{% endmacro %} + +{% macro footer() %} +
+ + +{% endmacro %} diff --git a/databuild/web/templates/home.html b/databuild/web/templates/home.html index 1dc79c7..5e60a88 100644 --- a/databuild/web/templates/home.html +++ b/databuild/web/templates/home.html @@ -1,67 +1,7 @@ -{% macro head(title) %} - - - - - - - - {{ title }} - - - -{% endmacro %} +{% import "base.html" as base %} -{% macro nav(active, graph_label) %} - -
- {% endmacro %} - - {% macro footer() %} -
- - -{% endmacro %} - -{% call head("Home - DataBuild") %} -{% call nav("", base.graph_label) %} +{% call base::head("Home - DataBuild") %} +{% call base::nav("", base.graph_label) %}

Dashboard

@@ -80,4 +20,4 @@ -{% call footer() %} +{% call base::footer() %} diff --git a/databuild/web/templates/job_runs/detail.html b/databuild/web/templates/job_runs/detail.html index a4132fb..bb19d2d 100644 --- a/databuild/web/templates/job_runs/detail.html +++ b/databuild/web/templates/job_runs/detail.html @@ -1,77 +1,7 @@ -{% macro head(title) %} - - - - - - - - {{ title }} - - - -{% endmacro %} +{% import "base.html" as base %} -{% macro nav(active, graph_label) %} - -
- {% endmacro %} - - {% macro footer() %} -
- - -{% endmacro %} - -{% call head("Job Run - DataBuild") %} -{% call nav("job_runs", base.graph_label) %} +{% call base::head("Job Run - DataBuild") %} +{% call base::nav("job_runs", base.graph_label) %}

Job Run: {{ job_run.id }}

@@ -88,8 +18,8 @@ {% match job_run.last_heartbeat_at %} - {% when Some with (ts) %}{{ ts }} - {% when None %}- + {% when Some with (ts) %}{{ ts }} + {% when None %}- {% endmatch %}
@@ -124,4 +54,4 @@ {% endif %} -{% call footer() %} +{% call base::footer() %} diff --git a/databuild/web/templates/job_runs/list.html b/databuild/web/templates/job_runs/list.html index a0f60e8..70a7111 100644 --- a/databuild/web/templates/job_runs/list.html +++ b/databuild/web/templates/job_runs/list.html @@ -1,78 +1,7 @@ -{% macro head(title) %} - - - - - - - - {{ title }} - - - -{% endmacro %} +{% import "base.html" as base %} -{% macro nav(active, graph_label) %} - -
- {% endmacro %} - - {% macro footer() %} -
- - -{% endmacro %} - -{% call head("Job Runs - DataBuild") %} -{% call nav("job_runs", base.graph_label) %} +{% call base::head("Job Runs - DataBuild") %} +{% call base::nav("job_runs", base.graph_label) %}

Job Runs

@@ -126,4 +55,4 @@ {% endif %} -{% call footer() %} +{% call base::footer() %} diff --git a/databuild/web/templates/partitions/detail.html b/databuild/web/templates/partitions/detail.html index 554283b..1917d6a 100644 --- a/databuild/web/templates/partitions/detail.html +++ b/databuild/web/templates/partitions/detail.html @@ -1,80 +1,7 @@ -{% macro head(title) %} - - - - - - - - {{ title }} - - - -{% endmacro %} +{% import "base.html" as base %} -{% macro nav(active, graph_label) %} - -
- {% endmacro %} - - {% macro footer() %} -
- - -{% endmacro %} - -{% call head("Partition - DataBuild") %} -{% call nav("partitions", base.graph_label) %} +{% call base::head("Partition - DataBuild") %} +{% call base::nav("partitions", base.graph_label) %}

@@ -97,8 +24,8 @@ {% match partition.last_updated_timestamp %} - {% when Some with (ts) %}{{ ts }} - {% when None %}- + {% when Some with (ts) %}{{ ts }} + {% when None %}- {% endmatch %}

@@ -138,4 +65,4 @@ {% endif %} -{% call footer() %} +{% call base::footer() %} diff --git a/databuild/web/templates/partitions/list.html b/databuild/web/templates/partitions/list.html index 3d37423..cdc602f 100644 --- a/databuild/web/templates/partitions/list.html +++ b/databuild/web/templates/partitions/list.html @@ -1,81 +1,7 @@ -{% macro head(title) %} - - - - - - - - {{ title }} - - - -{% endmacro %} +{% import "base.html" as base %} -{% macro nav(active, graph_label) %} - -
- {% endmacro %} - - {% macro footer() %} -
- - -{% endmacro %} - -{% call head("Partitions - DataBuild") %} -{% call nav("partitions", base.graph_label) %} +{% call base::head("Partitions - DataBuild") %} +{% call base::nav("partitions", base.graph_label) %}

Partitions

@@ -133,4 +59,4 @@ {% endif %} -{% call footer() %} +{% call base::footer() %} diff --git a/databuild/web/templates/wants/detail.html b/databuild/web/templates/wants/detail.html index 333f420..5380abc 100644 --- a/databuild/web/templates/wants/detail.html +++ b/databuild/web/templates/wants/detail.html @@ -1,80 +1,7 @@ -{% macro head(title) %} - - - - - - - - {{ title }} - - - -{% endmacro %} +{% import "base.html" as base %} -{% macro nav(active, graph_label) %} - -
- {% endmacro %} - - {% macro footer() %} -
- - -{% endmacro %} - -{% call head("Want - DataBuild") %} -{% call nav("wants", base.graph_label) %} +{% call base::head("Want - DataBuild") %} +{% call base::nav("wants", base.graph_label) %}

Want: {{ want.want_id }}

@@ -138,4 +65,4 @@
{% endif %} -{% call footer() %} +{% call base::footer() %} diff --git a/databuild/web/templates/wants/list.html b/databuild/web/templates/wants/list.html index 3861e80..b9d5394 100644 --- a/databuild/web/templates/wants/list.html +++ b/databuild/web/templates/wants/list.html @@ -1,81 +1,7 @@ -{% macro head(title) %} - - - - - - - - {{ title }} - - - -{% endmacro %} +{% import "base.html" as base %} -{% macro nav(active, graph_label) %} - -
- {% endmacro %} - - {% macro footer() %} -
- - -{% endmacro %} - -{% call head("Wants - DataBuild") %} -{% call nav("wants", base.graph_label) %} +{% call base::head("Wants - DataBuild") %} +{% call base::nav("wants", base.graph_label) %}

Wants

@@ -124,4 +50,4 @@ {% endif %} -{% call footer() %} +{% call base::footer() %}