🌐 AI搜索 & 代理 主页
Skip to content

Commit 99bebe2

Browse files
authored
Merge branch 'master' into set-omp-num-threads
2 parents 58e2aec + 5626365 commit 99bebe2

File tree

54 files changed

+1327
-389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1327
-389
lines changed

pgml-dashboard/src/api/cms.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,17 @@ async fn get_careers(
773773
CAREERS.render(&doc_file_path, &canonical, cluster).await
774774
}
775775

776+
#[get("/careers/apply/<title>", rank = 4)]
777+
pub async fn careers_apply(title: PathBuf, cluster: &Cluster) -> Result<ResponseOk, crate::responses::NotFound> {
778+
let layout =
779+
crate::components::layouts::marketing::Base::new("Apply for a career", Some(&cluster)).no_transparent_nav();
780+
781+
let job_title = title.display().to_string().replace("-", " ");
782+
let page = crate::components::pages::careers::Apply::new().job_title(&job_title);
783+
784+
Ok(ResponseOk(layout.render(page)))
785+
}
786+
776787
#[get("/docs/<path..>", rank = 5)]
777788
async fn get_docs(
778789
path: PathBuf,
@@ -876,6 +887,7 @@ pub fn routes() -> Vec<Route> {
876887
blog_landing_page,
877888
docs_landing_page,
878889
careers_landing_page,
890+
careers_apply,
879891
get_blog,
880892
get_blog_asset,
881893
get_careers,

pgml-dashboard/src/components/accordian/accordian_controller.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ export default class extends Controller {
1313
} else {
1414
this.bodies[i].style.maxHeight = this.bodies[i].offsetHeight + "px";
1515
}
16-
}
16+
}
1717
}
1818

19-
2019
titleClick(e) {
2120
let target = e.currentTarget.getAttribute("data-value");
2221
e.currentTarget.classList.add("selected");
2322

2423
let body = document.querySelector(`[data-accordian-target="${target}"]`);
2524
body.classList.add("selected");
2625
body.style.maxHeight = this.heights.get(body) + "px";
27-
26+
2827
for (let i = 0; i < this.bodies.length; i++) {
2928
if (body != this.bodies[i]) {
3029
this.bodies[i].classList.remove("selected");

pgml-dashboard/src/components/cards/newsletter_subscribe/mod.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,34 @@ use sailfish::TemplateOnce;
33

44
#[derive(TemplateOnce, Default)]
55
#[template(path = "cards/newsletter_subscribe/template.html")]
6-
pub struct NewsletterSubscribe {}
6+
pub struct NewsletterSubscribe {
7+
success: Option<bool>,
8+
error_message: Option<String>,
9+
email: Option<String>,
10+
}
711

812
impl NewsletterSubscribe {
913
pub fn new() -> NewsletterSubscribe {
10-
NewsletterSubscribe {}
14+
NewsletterSubscribe {
15+
success: None,
16+
error_message: None,
17+
email: None,
18+
}
19+
}
20+
21+
pub fn success(mut self, success: bool) -> Self {
22+
self.success = Some(success);
23+
self
24+
}
25+
26+
pub fn error_message(mut self, error_message: &str) -> Self {
27+
self.error_message = Some(error_message.to_owned());
28+
self
29+
}
30+
31+
pub fn email(mut self, email: &str) -> Self {
32+
self.email = Some(email.to_owned());
33+
self
1134
}
1235
}
1336

pgml-dashboard/src/components/cards/newsletter_subscribe/newsletter_subscribe.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,17 @@ div[data-controller="cards-newsletter-subscribe"] {
99
background-image: url("/dashboard/static/images/newsletter_subscribe_background_mobile.png");
1010
background-color: #{$pink};
1111
}
12+
13+
.message {
14+
display: none;
15+
16+
&.success, &.error {
17+
display: block;
18+
}
19+
20+
bottom: -3rem;
21+
@include media-breakpoint-up(xl) {
22+
left: 0px;
23+
}
24+
}
1225
}
Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,54 @@
1-
<div data-controller="cards-newsletter-subscribe">
2-
<div class="d-flex flex-column flex-lg-row gap-4 justify-content-center align-items-center newsletter-subscribe-container p-5 rounded-4">
3-
<div class="d-flex flex-column gap-4 text-center text-md-start" style="flex: 4">
4-
<h3>Subscribe to our newsletter. (It’s better than you think)</h3>
5-
<p>No spam. No sales pitches. Just product updates. Keep up with all our articles and news. Join our newsletter and stay up to date!</p>
6-
</div>
1+
<%
2+
use pgml_components::Component;
3+
4+
let success_class = match success {
5+
Some(true) => "success",
6+
Some(false) => "error",
7+
None => ""
8+
};
9+
10+
let message = match success {
11+
Some(true) => "Success".to_string(),
12+
Some(false) => error_message.unwrap_or("Something went wrong".to_string()),
13+
None => String::new()
14+
};
15+
16+
let error_icon = match success {
17+
Some(false) => Component::from(r#"<span class="material-symbols-outlined m-auto pe-2 text-error">warning</span>"#),
18+
_ => Component::from("")
19+
};
720

8-
<form action="/newsletter_subscribe" class="d-flex flex-column justify-content-center align-items-center gap-3 w-100" style="flex: 3" method="post">
9-
<div class="input-group p-1 ps-3 subscribe-input">
10-
<input type="email" class="form-control border-0" placeholder="hootareyou@email.com" name="email" autocomplete="off">
11-
<button type="submit" class="btn btn-primary rounded-2 d-none d-md-block">Subscribe</button>
21+
let email_placeholder = match &email {
22+
Some(email) => email.clone().to_string(),
23+
None => {
24+
let message = match success {
25+
Some(true) => "Add Another Email".to_string(),
26+
_ => "hootareyou@email.com".to_string()
27+
};
28+
message
29+
}
30+
};
31+
%>
32+
33+
<turbo-frame id="newsletter-subscribe-frame">
34+
<div data-controller="cards-newsletter-subscribe">
35+
<div class="d-flex flex-column flex-lg-row gap-5 justify-content-between align-items-center newsletter-subscribe-container py-5 ps-xl-5 px-3 rounded-4">
36+
<div class="d-flex flex-column gap-4 text-center text-md-start w-100">
37+
<h3>Subscribe to our newsletter.<br> (It’s better than you think)</h3>
38+
<p>No spam. No sales pitches. Just product updates. Keep up with all our articles and news. Join our newsletter and stay up to date!</p>
39+
</div>
40+
41+
<div class="d-flex flex-column justify-content-center align-items-xl-end align-items-center gap-3 w-100 position-relative" style="max-width: 27rem;">
42+
<form action="/newsletter_subscribe" class="d-flex flex-lg-row flex-column gap-3 w-100" method="post">
43+
<div class="input-group p-1 ps-3 subscribe-input d-flex flex-row gap-1">
44+
<input type="email" class="form-control border-0" placeholder="<%- email_placeholder %>" name="email" autocomplete="off" <% if email.is_some() {%>value="<%- email.unwrap() %><% } %>">
45+
<%+ error_icon %>
46+
<button type="submit" class="btn btn-primary rounded-2 d-none d-md-block">Subscribe</button>
47+
</div>
48+
<button type="submit" class="btn btn-primary rounded-2 d-md-none mx-auto">Subscribe</button>
49+
</form>
50+
<p class="message <%- success_class %> position-absolute body-small-text"><%- message %></p>
1251
</div>
13-
<button type="submit" class="btn btn-primary rounded-2 d-md-none">Subscribe</button>
14-
</form>
52+
</div>
1553
</div>
16-
</div>
54+
</turbo-frame>

pgml-dashboard/src/components/carousel/carousel_controller.js

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,87 @@
1-
import { Controller } from '@hotwired/stimulus'
1+
import { Controller } from "@hotwired/stimulus";
22

33
export default class extends Controller {
4-
static targets = [
5-
"carousel", "carouselTimer", "template"
6-
]
4+
static targets = ["carousel", "carouselTimer", "template"];
75

86
initialize() {
9-
this.paused = false
10-
this.runtime = 0
7+
this.paused = false;
8+
this.runtime = 0;
119
this.times = 1;
1210
}
1311

1412
connect() {
15-
// dont cycle carousel if it only hase one item.
16-
if ( this.templateTargets.length > 1 ) {
17-
this.cycle()
13+
// dont cycle carousel if it only hase one item.
14+
if (this.templateTargets.length > 1) {
15+
this.cycle();
1816
}
1917
}
2018

2119
changeFeatured(next) {
22-
let current = this.carouselTarget.children[0]
23-
let nextItem = next.content.cloneNode(true)
24-
25-
this.carouselTarget.appendChild(nextItem)
20+
let current = this.carouselTarget.children[0];
21+
let nextItem = next.content.cloneNode(true);
2622

27-
if( current ) {
23+
this.carouselTarget.appendChild(nextItem);
24+
25+
if (current) {
2826
current.style.marginLeft = "-100%";
29-
setTimeout( () => {
30-
this.carouselTarget.removeChild(current)
31-
}, 700)
27+
setTimeout(() => {
28+
this.carouselTarget.removeChild(current);
29+
}, 700);
3230
}
3331
}
3432

3533
changeIndicator(current, next) {
3634
let timers = this.carouselTimerTargets;
3735
let currentTimer = timers[current];
38-
let nextTimer = timers[next]
36+
let nextTimer = timers[next];
3937

40-
if ( currentTimer ) {
41-
currentTimer.classList.remove("timer-active")
42-
currentTimer.style.width = "1rem"
38+
if (currentTimer) {
39+
currentTimer.classList.remove("timer-active");
40+
currentTimer.style.width = "1rem";
41+
}
42+
if (nextTimer) {
43+
nextTimer.style.width = "4rem";
44+
nextTimer.classList.add("timer-active");
4345
}
44-
if( nextTimer) {
45-
nextTimer.style.width = "4rem"
46-
nextTimer.classList.add("timer-active")
47-
}
4846
}
4947

5048
Pause() {
51-
this.paused = true
49+
this.paused = true;
5250
}
5351

5452
Resume() {
55-
this.paused = false
53+
this.paused = false;
5654
}
5755

5856
cycle() {
5957
this.interval = setInterval(() => {
6058
// maintain paused state through entire loop
61-
let paused = this.paused
59+
let paused = this.paused;
6260

63-
let activeTimer = document.getElementsByClassName("timer-active")[0]
64-
if( paused ) {
65-
if( activeTimer ) {
66-
activeTimer.classList.add("timer-pause")
61+
let activeTimer = document.getElementsByClassName("timer-active")[0];
62+
if (paused) {
63+
if (activeTimer) {
64+
activeTimer.classList.add("timer-pause");
6765
}
6866
} else {
69-
if( activeTimer && activeTimer.classList.contains("timer-pause")) {
70-
activeTimer.classList.remove("timer-pause")
67+
if (activeTimer && activeTimer.classList.contains("timer-pause")) {
68+
activeTimer.classList.remove("timer-pause");
7169
}
7270
}
7371

74-
if( !paused && this.runtime % 5 == 0 ) {
75-
let currentIndex = this.times % this.templateTargets.length
76-
let nextIndex = (this.times + 1) % this.templateTargets.length
77-
78-
this.changeIndicator(currentIndex, nextIndex)
79-
this.changeFeatured(
80-
this.templateTargets[nextIndex]
81-
)
82-
this.times ++
72+
if (!paused && this.runtime % 5 == 0) {
73+
let currentIndex = this.times % this.templateTargets.length;
74+
let nextIndex = (this.times + 1) % this.templateTargets.length;
75+
76+
this.changeIndicator(currentIndex, nextIndex);
77+
this.changeFeatured(this.templateTargets[nextIndex]);
78+
this.times++;
8379
}
8480

85-
if( !paused ) {
86-
this.runtime++
81+
if (!paused) {
82+
this.runtime++;
8783
}
88-
}, 1000)
84+
}, 1000);
8985
}
9086

9187
disconnect() {

0 commit comments

Comments
 (0)