Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
655 changes: 655 additions & 0 deletions API.md

Large diffs are not rendered by default.

159 changes: 129 additions & 30 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,48 @@ The application is designed as a modular, portable web server with database capa
│ Dispatches to
┌───────────────┴───────────────┬──────────────┐
│ │ │
↓ ↓ ↓
┌──────────┐ ┌──────────────┐ ┌──────────┐
│ Board │ │ Admin │ │ Upload │
│ (board.c)│ │ (admin.c) │ │(upload.c)│
│- Threads │ │- Dashboard │ │- Files │
│- Posts │ │- Auth │ │- Storage
└─────┬────┘ └──────┬───────┘ └─────┬────┘
│ │ │
│ Uses │ Uses │ Uses
↓ ↓ ↓
┌──────────────────────────────────────────────────────────┐
│ Database (db.c) │
│ - SQLite connection management │
│ - Query execution
│ - Migrations
└─────────────────────────┬────────────────────────────────┘
┌───────────────┴───────────────┬──────────────┬──────────────
│ │ │
↓ ↓ ↓
┌──────────┐ ┌──────────────┐ ┌──────────┐ ┌──────────┐
│ Board │ │ Admin │ │ Upload │ │ Auth │
│ (board.c)│ │ (admin.c) │ │(upload.c)│ │ (auth.c) │
│- Threads │ │- Dashboard │ │- Files │ │- Sessions│
│- Posts │ │- Management │ │- Storage │ │- Tokens
└─────┬────┘ └──────┬───────┘ └─────┬────┘ └─────┬────┘
│ │ │
│ Uses │ Uses │ Uses │ Uses
↓ ↓ ↓
┌──────────────────────────────────────────────────────────────────
│ Database (db.c)
│ - SQLite connection management
│ - Query execution & prepared statements
│ - Migrations & WAL mode
└─────────────────────────┬────────────────────────────────────────
┌───────────┐
│ SQLite │
│ Database │
└───────────┘

┌──────────────┐
┌─────────┤ Render │
│ │ (render.c) │
│ │- Templating │
│ │- HTML gen │
│ └──────────────┘
└─── Used by all handlers for output
┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ Render │ │ HTML Template│ │ i18n │ │ Kaomoji │
│ (render.c) │ │(html_templ.c)│ │ (i18n.c) │ │ (kaomoji.c) │
│- Templating │ │- Common CSS │ │- Translations│ │- Emoticons │
│- HTML escape │ │- Headers │ │- Languages │ │- Categories │
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘
│ │ │ │
└─────────────────┴─────────────────┴─────────────────┘
Used by all handlers
┌──────────┴──────────┐
│ Utils (utils.c) │
│ - URL decode │
│ - Cookie parsing │
│ - Token generation │
└─────────────────────┘
```

## Module Descriptions
Expand Down Expand Up @@ -287,16 +296,106 @@ typedef struct {
- `upload_parse_multipart()` - Parse multipart/form-data
- `upload_save_file()` - Save file to disk
- `upload_file_free()` - Clean up file structure
- `upload_init()` - Initialize upload directory

**Routes**:
- `POST /upload` - File upload endpoint

**Features** (to implement):
**Features**:
- Multipart form data parsing
- File type validation
- Size limits
- Auto-create upload directory
- Secure file storage
- Virus scanning (optional)

### i18n.c/h - Internationalization Module

**Responsibility**: Multi-language support and translation management

**Key Types**:
```c
typedef enum {
LANG_EN,
LANG_ZH_CN
} language_t;
```

**Key Functions**:
- `i18n_get_language()` - Detect user's preferred language
- `i18n_get()` - Get translated text for a key
- `i18n_get_lang_code()` - Get language code string
- `i18n_get_lang_name()` - Get language display name

**Features**:
- URL parameter detection (`?lang=en`)
- Cookie-based preference (1 year expiry)
- English and Simplified Chinese support
- Easy language switcher UI

### auth.c/h - Authentication Module

**Responsibility**: Session management and authentication

**Key Functions**:
- `auth_is_authenticated()` - Check if user has valid session
- `auth_create_session()` - Create new session token
- `auth_destroy_session()` - Invalidate session

**Features**:
- Session token management
- Database-backed sessions
- Reusable across modules
- Secure random token generation

### utils.c/h - Utility Module

**Responsibility**: Common utility functions

**Key Functions**:
- `url_decode()` - Decode URL-encoded strings
- `get_cookie_value()` - Parse cookie headers
- `generate_random_token()` - Generate secure random tokens

**Features**:
- Reusable utility functions
- URL decoding with safety checks
- Cookie parsing for HTTP headers

### kaomoji.c/h - Kaomoji Module

**Responsibility**: Japanese emoticon data and management

**Key Structures**:
```c
typedef struct {
const char *name;
const char **items;
int count;
} kaomoji_category_t;
```

**Key Functions**:
- `kaomoji_get_categories()` - Get all emoticon categories
- `kaomoji_get_categories_count()` - Get category count

**Features**:
- 12 emoticon categories
- 100+ kaomoji emoticons
- Easy integration with message forms
- Picker UI support

### html_template.c/h - HTML Template Module

**Responsibility**: Common HTML rendering and CSS

**Key Functions**:
- `html_get_common_css()` - Returns Material Design CSS
- `html_render_header()` - Renders HTML document header
- `html_render_footer()` - Renders HTML document footer

**Features**:
- Material Design color scheme
- Responsive breakpoints
- Common CSS in one place
- Reduces HTML duplication

## Data Flow

Expand Down
40 changes: 38 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,43 @@ All notable changes to this project will be documented in this file.

## [Unreleased]

### Added
- **Internationalization (i18n)**
- Multi-language support (English, Simplified Chinese)
- Language detection from URL parameter, cookie, or default
- Language switcher UI in all pages
- Cookie-based language preference (1 year expiry)
- Comprehensive translation system with 50+ translation keys

- **Material Design UI**
- Complete UI redesign following Material Design principles
- Gradient headers with custom color schemes
- Card-based layouts with elevation effects
- Responsive design with mobile/desktop breakpoints
- Touch-friendly buttons (48px min-height)
- Common CSS module for consistent styling

- **Kaomoji Emoticon Picker**
- 12 categories with 100+ Japanese emoticons
- Interactive picker UI in message forms
- Categories: Happy, Excited, Love, Sad, Angry, Confused, Surprised, Cute, Animals, Actions, Objects, Symbols
- One-click insertion into text fields

- **Code Refactoring**
- Extracted `auth.c/h` for authentication and session management
- Extracted `utils.c/h` for common utility functions
- Extracted `kaomoji.c/h` for emoticon data
- Extracted `html_template.c/h` for HTML templates and common CSS
- Reduced code duplication and improved modularity
- Better separation of concerns

### Fixed
- Database ENOENT/Segfault Issues
- **Thread View SIGSEGV Crash**
- Fixed incorrect parameter order in `snprintf()` causing segmentation fault
- Thread pages now load correctly without crashes
- Added test suite to prevent regression

- **Database ENOENT/Segfault Issues**
- Added directory existence checks before database initialization
- Disabled SQLite memory-mapped I/O (`PRAGMA mmap_size=0`) to prevent SIGSEGV on file deletion
- Enabled WAL mode (`PRAGMA journal_mode=WAL`) for better concurrency
Expand All @@ -14,10 +49,11 @@ All notable changes to this project will be documented in this file.
- Auto-create upload directory if it doesn't exist

### Changed
- CI/CD Enhancement
- **CI/CD Enhancement**
- Added automatic GitHub Release creation when new tags are pushed
- Release includes compiled binary (`app.com`) and SHA256 checksums
- Release notes are automatically generated from commits
- Fixed release permissions using `secrets.GITHUB_TOKEN`

### Added
- SQLite3 integration (version 3.46.1)
Expand Down
Loading