7 Commits

Author SHA1 Message Date
e177814996 refactor: move label to a new feature
Some checks failed
Frontend CI / build (push) Successful in 1m39s
Auto Comment On PR / add_improve_comment (pull_request) Successful in 17s
PR Title Check / pr-title-check (pull_request) Failing after 16s
2025-10-15 05:31:00 +08:00
24a98f8f70 BLOG-126 Post management (list and create) (#139)
All checks were successful
Frontend CI / build (push) Successful in 6m14s
### Description

- As the title

### Package Changes

_No response_

### Screenshots

|Scenario|Screenshot|
|-|-|
|Posts list|![截圖 2025-10-15 凌晨4.09.28.png](/attachments/c8ad41e8-1065-4249-90e3-977bd36031e8)|
|Empty input|![截圖 2025-10-15 凌晨4.10.12.png](/attachments/c902fdc0-4287-4b5d-9b9e-63dd6a5604a6)|
|Pattern not matched|![截圖 2025-10-15 凌晨4.11.05.png](/attachments/88e4fb1d-6a69-4305-a94c-bd48982bb8a5)|

### Reference

Resolve #126.

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #139
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2025-10-15 04:21:13 +08:00
565df7aace BLOG-125 Get post by sementic ID (#134)
All checks were successful
Frontend CI / build (push) Successful in 1m26s
### Description

#### Backend

- String and interger can be pass as `id` to `GET` `/post/{id}`

- For the posts existed, the default `semantic_id` for them will be `_id`. (e.g. `_1`, `_2`)

- Semantic ID should follow the rules:

  1. It shouldn't be an integer

  1. It should match the pattern: `^[0-9a-zA-Z_\-]+$`

  <br>

  |Semantic ID|Result|Note|
  |-|-|-|
  |12|X|against with `i`|
  |-3|X|against with `i`|
  |3.14|X|against with `ii`|
  |hello world|X|against with `ii`|
  |*EMPTY*|X|against with `ii`|
  |12_34-56|O||

#### Frontend

- The href of post preview card becomes the semantic ID.

### Package Changes

```toml
regex = "1.12.1"
```

### Screenshots

![截圖 2025-10-12 下午6.23.12.png](/attachments/67de1cd7-f584-40ad-9bbd-27f8bf6f1894)

### Reference

Resolves #125.

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #134
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2025-10-12 18:28:58 +08:00
08c5262df6 BLOG-118 Fix to allow nullable published_time to support unpublished posts (#121)
All checks were successful
Frontend CI / build (push) Successful in 1m19s
### Description

This PR updates the application to handle posts that may not have a publication date (e.g., drafts) by making the `published_time` field optional across the entire post feature stack.

This ensures that draft posts can be processed and rendered without causing errors, and prevents search engine metadata from being generated for content that is not yet published.

#### Key Changes:

* **DTO & Schema (`postInfoResponseDto.ts`):**
    * The Zod schema for `PostInfoResponseSchema` has been updated to mark `published_time` as `.nullable()`.
    * The `PostInfoResponseDto` class now correctly handles a `null` value from the API, mapping it to `Date | null`.

* **Domain Entity (`postInfo.ts`):**
    * The core `PostInfo` entity's `publishedTime` property is now typed as `Date | null` to reflect the business logic that a post may be unpublished.

* **View Model (`postInfoViewModel.ts`):**
    * Updated `publishedTime` to be `Date | null`.
    * Added a new `isPublished` boolean getter for convenient conditional logic in the UI.
    * The `formattedPublishedTime` getter now returns `string | null`.
    * Dehydration and rehydration logic (`dehydrate`/`rehydrate`) has been updated to correctly handle the nullable `publishedTime`.

* **UI Component (`PostContentPage.svelte`):**
    * The component now uses the new `isPublished` flag to conditionally render the `<StructuredData>` component for SEO. This ensures that structured data is only included for posts that have been officially published.

### Package Changes

_No response_

### Screenshots

_No response_

### Reference

Resolves #118

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #121
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2025-08-06 21:36:54 +08:00
b953d0bf0d BLOG-109 Fix published_time schema to include offset (#110)
All checks were successful
Frontend CI / build (push) Successful in 1m8s
### Description

Reference: https://zod.dev/api?id=iso-dates#iso-datetimes

- Add `{ offset: true }` as options.

### Package Changes

_No response_

### Screenshots

_No response_

### Reference

Resolves #109

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #110
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2025-08-02 14:55:44 +08:00
a5f66616c4 BLOG-104 Implement CRUD functionality for Posts (#108)
All checks were successful
Frontend CI / build (push) Successful in 1m8s
### Description

This pull request introduces the core functionality for creating and updating posts, completing the backend CRUD operations for the `post` feature. It includes new API endpoints, database schema changes, and corresponding updates across the entire application stack from the database layer to the frontend.

#### Backend API

-   **Added new authenticated endpoints:**
    -   `POST /post`: To create a new post.
    -   `PUT /post/{id}`: To update an existing post.
-   Implemented the full vertical slice for these operations, including:
    -   `CreatePostUseCase` and `UpdatePostUseCase`.
    -   Repository and DB service methods for creating, updating, and associating posts with labels.
    -   Transactional database operations to ensure data integrity when creating/updating posts and their associated labels.

#### Database

-   Added a new migration to include an `"order"` column in the `post_label` table.
-   This column preserves the user-defined order of labels for each post.
-   Queries have been updated to fetch and sort labels based on this new column.

#### API Schema & Documentation

-   Enhanced `utoipa` OpenAPI documentation with more specific formats for data types:
    -   `#[schema(format = Uri)]` for URLs like `preview_image_url`.
    -   `#[schema(format = Email)]` for user emails.
    -   `#[schema(format = DateTime)]` for timestamps.
-   Standardized the `published_time` field to use the RFC3339 string format instead of a numeric timestamp, improving API clarity and interoperability.

#### Frontend

-   Updated the `PostInfoResponseDto` in the frontend to correctly parse the new `DateTime` (ISO string) format for `published_time`.

#### Refactoring

-   Renamed `get_full_post` to a more descriptive `get_post_by_id` across the post feature module for better code clarity.

### Package Changes

```toml
utoipa = { version = "5.4.0", features = [
    "actix_extras",
    "non_strict_integers",
    "url",
] }
```

### Screenshots

_No response_

### Reference

Resolves #104

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #108
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2025-08-02 14:35:27 +08:00
c2462fe537 BLOG-44 Post overall page (#64)
All checks were successful
Frontend CI / build (push) Successful in 1m6s
### Description

- Change the format of color response

  ```json
  {
    "red": 0,
    "green": 255,
    "blue": 128,
    "alpha": 255
  }
  ```

- The relationship between the label's background color and its highlight color is calculated. The method involves first converting the RGB color value to HSL, then decreasing the L (lightness) component, and finally converting it back to RGB.

### Package Changes

```json
{
  "zod": "^4.0.5"
}
```

### Screenshots

|Desktop|Mobile|
|-|-|
|![image.png](/attachments/851450c4-0975-4b66-9bf7-606d0114c03e)|![image.png](/attachments/f263d65c-89e9-4439-8d50-ae92ae9482ac)|

### Reference

Resolves #44

### Checklist

- [x] A milestone is set
- [x] The related issuse has been linked to this branch

Reviewed-on: #64
Co-authored-by: SquidSpirit <squid@squidspirit.com>
Co-committed-by: SquidSpirit <squid@squidspirit.com>
2025-07-24 00:32:20 +08:00