Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Dan fix head#1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
chillenberger merged 6 commits intomasterfromdan-fix-head
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
turn head into component, remove dead code
  • Loading branch information
@chillenberger
chillenberger committedDec 9, 2023
commitcb56aa36354dbda25eb31e70de1a6c8a23be2351
14 changes: 14 additions & 0 deletionspgml-dashboard/src/components/layouts/extend_head/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
use pgml_components::component;
use sailfish::TemplateOnce;

#[derive(TemplateOnce, Default)]
#[template(path = "layouts/extend_head/template.html")]
pub struct ExtendHead {}

impl ExtendHead {
pub fn new() -> ExtendHead {
ExtendHead {}
}
}

component!(ExtendHead);
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,4 +20,4 @@

<script defer src="https://cdn.plot.ly/plotly-2.11.1.min.js"></script>

<script type="module" defer async src="/dashboard/static/js/libs/sortable-1.12.0.min.js"></script>
<script type="module" defer async src="/dashboard/static/js/libs/sortable-1.12.0.min.js"></script>
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
use pgml_components::component;
use sailfish::TemplateOnce;

#[derive(Clone, Default)]
#[derive(TemplateOnce, Default, Clone)]
#[template(path = "layouts/head/template.html")]
pub struct Head {
pub title: String,
pub description: Option<String>,
Expand All@@ -14,7 +16,7 @@ impl Head {
Head::default()
}

pub fn add_preload(&mut self, preload: &str) ->&mut Self {
pub fn add_preload(mut self, preload: &str) ->Head {
self.preloads.push(preload.to_owned());
self
}
Expand All@@ -38,28 +40,13 @@ impl Head {
Head::new().title("404 - Not Found")
}

pub fn context(mut self, context:String) -> Head {
self.context = context;
pub fn context(mut self, context:&str) -> Head {
self.context = context.to_owned();
self
}
}

#[derive(TemplateOnce, Default, Clone)]
#[template(path = "layout/head.html")]
pub struct DefaultHeadTemplate {
pub head: Head,
}

impl DefaultHeadTemplate {
pub fn new(head: Option<Head>) -> DefaultHeadTemplate {
let head = match head {
Some(head) => head,
None => Head::new(),
};

DefaultHeadTemplate { head }
}
}
component!(Head);

#[cfg(test)]
mod head_tests {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,42 +4,42 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="turbo-cache-control" content="no-cache">
<meta name="author" content="PostgresML">
<title><%=head.title %> – PostgresML</title>
<title><%= title %> – PostgresML</title>

<% ifhead.description.is_some() { %>
<meta name="description" content="<%=head.description.clone().unwrap() %>">
<meta property="og:description" content="<%=head.description.clone().unwrap() %>">
<meta name="twitter:description" content="<%=head.description.clone().unwrap() %>">
<% if description.is_some() { %>
<meta name="description" content="<%= description.clone().unwrap() %>">
<meta property="og:description" content="<%= description.clone().unwrap() %>">
<meta name="twitter:description" content="<%= description.clone().unwrap() %>">
<% } else { %>
<meta name="description" content="Train and deploy models to make online predictions using only SQL, with an open source Postgres extension.">
<meta property="og:description" content="Train and deploy models to make online predictions using only SQL, with an open source Postgres extension.">
<meta name="twitter:description" content="Train and deploy models to make online predictions using only SQL, with an open source Postgres extension.">
<% } %>

<% ifhead.image.is_some() { %>
<meta property="og:image" content="<%=head.image.clone().unwrap() %>">
<meta name="twitter:image" content="<%=head.image.clone().unwrap() %>">
<% if image.is_some() { %>
<meta property="og:image" content="<%= image.clone().unwrap() %>">
<meta name="twitter:image" content="<%= image.clone().unwrap() %>">
<% } else { %>
<meta property="og:image" content="https://postgresml.org/dashboard/static/images/owl_gradient.png">
<meta name="twitter:image" content="https://postgresml.org/dashboard/static/images/owl_gradient.png">
<% } %>

<meta property="og:site_name" content="PostgresML">
<meta property="og:type" content="website">
<meta property="og:title" content="<%=head.title %> – PostgresML">
<meta property="og:title" content="<%= title %> – PostgresML">
<meta property="og:url" content="http://www.postgresML.org">
<meta property="og:locale" content="en_US">

<meta name="twitter:site" content="@postgresml">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="@postgresml">
<meta name="twitter:title" content="<%=head.title %> – PostgresML">
<meta name="twitter:title" content="<%= title %> – PostgresML">

<%-head.context %>
<%- context %>

<link rel="icon" href="/dashboard/static/images/owl.ico">

<% for link inhead.preloads { %>
<% for link in preloads { %>
<link rel="preload" fetchpriority="high" as="image" href=<%= link %> type="image/webp">
<% }; %>

Expand Down
9 changes: 7 additions & 2 deletionspgml-dashboard/src/components/layouts/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
// This file is automatically generated.
// You shouldn't modify it manually.

// src/components/layouts/product
pub mod product;
// src/components/layouts/extend_head
pub mod extend_head;
pub use extend_head::ExtendHead;

// src/components/layouts/head
pub mod head;
pub use head::Head;
View file
Open in desktop

This file was deleted.

View file
Open in desktop

This file was deleted.

6 changes: 0 additions & 6 deletionspgml-dashboard/src/components/layouts/product/mod.rs
View file
Open in desktop

This file was deleted.

2 changes: 1 addition & 1 deletionpgml-dashboard/src/guards.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
use crate::components::layouts::product::extend_head::ExtendHead;
use crate::components::layouts::extend_head::ExtendHead;
use crate::components::sections::footers::marketing_footer::MarketingFooter;
use crate::templates::components::{StaticNav, StaticNavLink};
use once_cell::sync::OnceCell;
Expand Down
13 changes: 5 additions & 8 deletionspgml-dashboard/src/templates/mod.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,9 +14,8 @@ use crate::models;
use crate::utils::tabs;

pub mod docs;
pub mod head;

pubusehead::*;
usecrate::components::layouts::Head;

#[derive(TemplateOnce, Default)]
#[template(path = "content/not_found.html")]
Expand DownExpand Up@@ -47,7 +46,7 @@ impl Layout {
let head = match context.as_ref() {
Some(context) => Head::new()
.title(title)
.context(context.context.head_items.clone()),
.context(&context.context.head_items),
None => Head::new().title(title),
};

Expand DownExpand Up@@ -119,7 +118,7 @@ impl From<Layout> for String {
pub struct WebAppBase<'a> {
pub content: Option<String>,
pub breadcrumbs: Vec<NavLink<'a>>,
pub head:crate::templates::Head,
pub head: Head,
pub dropdown_nav: StaticNav,
pub account_management_nav: StaticNav,
pub upper_left_nav: StaticNav,
Expand All@@ -129,12 +128,10 @@ pub struct WebAppBase<'a> {

impl<'a> WebAppBase<'a> {
pub fn new(title: &str, context: &crate::Context) -> Self {
let mut head = crate::templates::Head::new()
.title(title)
.context(context.head_items.clone());
let head = Head::new().title(title).context(&context.head_items);

WebAppBase {
head: head,
head,
dropdown_nav: context.dropdown_nav.clone(),
account_management_nav: context.account_management_nav.clone(),
upper_left_nav: context.upper_left_nav.clone(),
Expand Down
3 changes: 1 addition & 2 deletionspgml-dashboard/templates/layout/base.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
<%
use crate::components::navigation::navbar::marketing::Marketing as MarketingNavbar;
use crate::templates::head::DefaultHeadTemplate;
%>
<!DOCTYPE html>
<html lang="en-US">

<%+DefaultHeadTemplate::new(Some(head)) %>
<%+ head %>

<body data-bs-theme="dark" data-theme="docs">
<main>
Expand Down
3 changes: 1 addition & 2 deletionspgml-dashboard/templates/layout/web_app_base.html
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,6 @@
};
use crate::components::navigation::navbar::web_app::WebApp as WebAppNavbar;
use crate::components::navigation::left_nav::web_app::WebApp as WebAppLeftNav;
use crate::templates::head::DefaultHeadTemplate;
%>

<%
Expand All@@ -17,7 +16,7 @@

<!DOCTYPE html>
<html lang="en-US">
<%+DefaultHeadTemplate::new(Some(head)) %>
<%+ head %>
<body data-bs-theme="dark" data-theme="product">
<% for component in body_components { %>
<%+ component %>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp