Skip to content

Commit

Permalink
Merge branch 'master' into background-jobs-cli-management
Browse files Browse the repository at this point in the history
  • Loading branch information
kaplanelad authored Dec 11, 2024
2 parents bd917bc + 6ca216d commit a417f42
Show file tree
Hide file tree
Showing 38 changed files with 792 additions and 149 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ backtrace_printer = { version = "1.3.0" }
# cli
clap = { version = "4.4.7", features = ["derive"], optional = true }
colored = "2"
reqwest = { version = "0.12.7", features = [
"charset",
"http2",
"json",
"macos-system-configuration",
"rustls-tls",
], default-features = false }


sea-orm = { version = "1.1.0", features = [
Expand Down
4 changes: 2 additions & 2 deletions docs-site/config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The URL the site will be built for
base_url = "https://loco.rs"
title = "Loco"
description = "Loco is a productivity-first web and service framework in Rust"
title = "Loco.rs - Productivity-first Rust Fullstack Web Framework"
description = "Loco.rs is like Ruby on Rails for Rust. Use it to quickly build and deploy Rust based apps from zero to production."


# Whether to automatically compile all Sass files in the sass directory
Expand Down
2 changes: 1 addition & 1 deletion docs-site/content/casts/003-scaffolding-crud-with-html.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ id = "EircfwF8c0E"

Reference material for this episode:

* Loco.rs docs: [routes in controllers](https://loco.rs/docs/getting-started/scaffold/)
* Loco.rs docs: [routes in controllers](https://loco.rs/docs/the-app/controller/#routes-in-controllers)
* The [SaaS starter](https://loco.rs/docs/starters/saas/)
* The [REST API starter](https://loco.rs/docs/starters/rest-api/)
8 changes: 4 additions & 4 deletions docs-site/content/casts/005-testing-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ id = "485JlLA-T6U"

Reference material for this episode:

* Loco.rs docs: [routes in controllers](https://loco.rs/docs/the-app/task/)
* The [SaaS starter](https://loco.rs/docs/starters/saas/)
* The [REST API starter](https://loco.rs/docs/starters/rest-api/)
* The [Lightweight starter](https://loco.rs/docs/starters/service/)
* Loco.rs docs: [routes in controllers](https://loco.rs/docs/processing/task/)
* The [SaaS starter](https://loco.rs/docs/getting-started/starters/#saas-starter)
* The [REST API starter](https://loco.rs/docs/getting-started/starters/#rest-api-starter)
* The [Lightweight starter](https://loco.rs/docs/getting-started/starters/#lightweight-service-starter)
2 changes: 1 addition & 1 deletion docs-site/content/casts/006-mailers.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ id = "ieGeihxLGC8"

Reference material for this episode:

* Loco.rs docs: [Mailers](https://loco.rs/docs/the-app/mailers/)
* Loco.rs docs: [Mailers](https://loco.rs/docs/processing/mailers/)
32 changes: 13 additions & 19 deletions docs-site/content/docs/getting-started/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,7 @@ pub async fn list(State(ctx): State<AppContext>) -> Result<Response> {
}

pub async fn add(State(ctx): State<AppContext>, Json(params): Json<Params>) -> Result<Response> {
let mut item = ActiveModel {
..Default::default()
};
let mut item: ActiveModel = Default::default();
params.update(&mut item);
let item = item.insert(&ctx.db).await?;
format::json(item)
Expand Down Expand Up @@ -586,7 +584,7 @@ pub fn routes() -> Routes {
.add("/", post(add))
.add("/:id", get(get_one))
.add("/:id", delete(remove))
.add("/:id", post(update))
.add("/:id", patch(update))
}
```
Expand Down Expand Up @@ -678,7 +676,7 @@ pub fn routes() -> Routes {
// .add("/", get(list))
// .add("/:id", get(get_one))
// .add("/:id", delete(remove))
// .add("/:id", post(update))
// .add("/:id", patch(update))
}
```
Expand Down Expand Up @@ -855,9 +853,7 @@ Go back to `src/controllers/comments.rs` and take a look at the `add` function:
```rust
pub async fn add(State(ctx): State<AppContext>, Json(params): Json<Params>) -> Result<Response> {
let mut item = ActiveModel {
..Default::default()
};
let mut item: ActiveModel = Default::default();
params.update(&mut item);
let item = item.insert(&ctx.db).await?;
format::json(item)
Expand All @@ -872,16 +868,14 @@ async fn add(
State(ctx): State<AppContext>,
Json(params): Json<Params>,
) -> Result<Response> {
// we only want to make sure it exists
let _current_user = crate::models::users::Model::find_by_pid(&ctx.db, &auth.claims.pid).await?;

// next, update
// homework/bonus: make a comment _actually_ belong to user (user_id)
let mut item = ActiveModel {
..Default::default()
};
params.update(&mut item);
let item = item.insert(&ctx.db).await?;
format::json(item)
// we only want to make sure it exists
let _current_user = crate::models::users::Model::find_by_pid(&ctx.db, &auth.claims.pid).await?;

// next, update
// homework/bonus: make a comment _actually_ belong to user (user_id)
let mut item: ActiveModel = Default::default();
params.update(&mut item);
let item = item.insert(&ctx.db).await?;
format::json(item)
}
```
2 changes: 1 addition & 1 deletion docs-site/content/docs/the-app/controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ middlewares:

`Loco` also allow us to apply [layers](https://docs.rs/tower/latest/tower/trait.Layer.html) to specific handlers or
routes.
For more information on handler and route based middleware, refer to the [middleware](/docs/the-app/middlewares)
For more information on handler and route based middleware, refer to the [middleware](/docs/the-app/controller/#middleware)
documentation.


Expand Down
66 changes: 61 additions & 5 deletions docs-site/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,74 @@
<!DOCTYPE html>
<html lang="{{ config.extra.language_code | default(value=" en-US") }}" >
<head>
{% if page.extra.meta %}
<!-- the meta data config goes here -->
{% for data in page.extra.meta %}
<meta
{% for key, value in data%}
{% if key == "property" and value == "og:title"%}
{% set_global page_has_og_title = true -%}
{% endif %}
{% if key == "property" and value == "og:description"%}
{% set_global page_has_og_description = true -%}
{% endif %}
{% if key == "name" and value == "description"%}
{% set_global page_has_description = true -%}
{% endif %}
{{ key }}="{{ value }}"
{% endfor %}
/>
{% endfor %}
{% endif %}

{# Site title #}
{% set current_path = current_path | default(value="/") %}
{% if current_path == "/" %}
<title>
{{ config.title | default(value="Home") }}
</title>

{% else %}
<title>
{% if page.title %} {{ page.title ~ " - Loco.rs" }}
{% elif section.title %} {{ section.title ~ " - Loco.rs" }}
{% elif config.title %} {{ config.title }}
{% else %} Post ~ " - Loco.rs" {% endif %}
</title>

{% if not page_has_og_title %}
<meta property="og:title" content="{% if page.title -%}{{ page.title }}{% elif config.title -%}{{ config.title }}{% else -%}Post{% endif %} - Loco.rs" />
<meta property="og:title" content="{% if page.title -%}{{ page.title }}{% elif config.title -%}{{ config.title }}{% else -%}Post{% endif %} - Loco.rs">
<meta name="twitter:title" content="{% if page.title -%}{{ page.title }}{% elif config.title -%}{{ config.title }}{% else -%}Post{% endif %} - Loco.rs">
{% endif %}
{% endif %}


{% if not page_has_og_description %}
{% if page.description %}
<meta property="og:description" content="{{ page.description }}" />
{% elif config.description %}
<meta property="og:description" content="{{ config.description }}" />
{% endif %}
{% endif %}

{% if not page_has_description %}
{% if page.description %}
<meta name="description" content="{{ page.description }}" />
{% elif config.description %}
<meta name="description" content="{{ config.description }}" />
{% endif %}
{% endif %}


<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<meta property="description" content="Loco.rs is like Ruby on Rails for Rust. Use it to quickly build and deploy Rust based apps from zero to production.">
<meta property="og:description" content="Loco.rs is like Ruby on Rails for Rust. Use it to quickly build and deploy Rust based apps from zero to production.">
<meta property="og:title" content="Loco.rs - Rust Web Framework">
<meta property="og:description" content="Loco.rs is like Ruby on Rails for Rust. Use it to quickly build and deploy Rust based apps from zero to production.">

<meta property="og:image" content="https://loco.rs/[email protected]">

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Loco.rs - Rust Web Framework">
<meta name="twitter:description" content="Loco.rs is like Ruby on Rails for Rust. Use it to quickly build and deploy Rust based apps from zero to production.">
<meta name="twitter:image" content="https://loco.rs/[email protected]">

Expand Down
Loading

0 comments on commit a417f42

Please sign in to comment.