codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

feat: improve commit-history list on mobile #2

Merged
pat-s merged 28 commits from feat/mobile-commit-view into main 2025-06-02 17:01:03 +00:00
Owner
  • Transform the "Date" column from Semantic UI into a flexible Tailwind-based column which only takes up the remaining space
  • Reduce the "Author" column to 15% width
  • Reduce many padding values
  • Add a linebreak after the avatar image
  • Add a linebreak after the date specifier
  • Pretty wrap author names and commit-summary
  • Use javascript to override the logic for displaying dates: now using a consistent abbreviated version (e.g. 3d, 1w, 2mo) instead of lengthy descriptions like "two days ago"

Screenshot

Old New
image image

Time Abbreviation Feature

Overview

This feature adds abbreviated time display functionality to Forgejo's commit list interface, providing a more compact representation of timestamps while maintaining full tooltip information.

Implementation

Backend Changes

A new function TimeSinceAbbreviated has been added to the DateUtils template utility in modules/templates/util_date.go:

  • Function: TimeSinceAbbreviated(time any) template.HTML
  • Purpose: Generates abbreviated relative time strings with tooltip support
  • Returns: HTML span element with abbreviated text and full timestamp tooltip

Template Changes

Updated templates/repo/commits_list.tmpl to:

  • Use DateUtils.TimeSinceAbbreviated instead of DateUtils.TimeSince
  • Maintain responsive layout (stacked on small screens, horizontal on large screens)
  • Keep center alignment for the date column header and values
  • Remove fixed width from date column to allow flexible sizing
  • Redistribute column widths (message column expanded from 8 to 11 units)

UI Layout Changes

  1. Author Column:

    • Avatar and username stack vertically on small screens
    • Side-by-side layout on large screens (≥768px)
    • Left-aligned content
  2. Date/Actions Column:

    • Merged timestamp and action buttons into single column
    • Stacked layout on small screens with abbreviated timestamps
    • Horizontal layout on large screens
    • Center-aligned content
    • Flexible width that adapts to content size (auto-sizing)

Time Abbreviation Format

The feature converts standard relative time strings to abbreviated versions:

Duration Range Abbreviation Example
Seconds s 30s ago
Minutes m 5m ago
Hours h 3h ago
Days d 2d ago
Months mo 1mo ago
Years y 1y ago
Future in Xs in 5m

Features

  • Tooltip Support: Hovering over abbreviated time shows full timestamp
  • Responsive Design: Layout adapts to screen size
  • Accessibility: Maintains semantic HTML structure
  • Backward Compatible: Doesn't affect existing TimeSince usage elsewhere
  • Flexible Column Width: Date column automatically sizes to fit content, optimizing space usage
  • Improved Space Utilization: Message column gets more space while date column uses minimum required width

Testing

Comprehensive tests added in modules/templates/util_date_test.go covering:

  • All time duration ranges
  • Past and future times
  • Null/zero value handling
  • Tooltip content verification

Files Modified

  1. modules/templates/util_date.go - Added TimeSinceAbbreviated function
  2. templates/repo/commits_list.tmpl - Updated to use abbreviated time display and flexible column width
  3. modules/templates/util_date_test.go - Added comprehensive tests
  4. web_src/css/repo.css - Added CSS rules for auto-sizing date column
- Transform the "Date" column from Semantic UI into a flexible Tailwind-based column which only takes up the remaining space - Reduce the "Author" column to 15% width - Reduce many padding values - Add a linebreak after the avatar image - Add a linebreak after the date specifier - Pretty wrap author names and commit-summary - Use javascript to override the logic for displaying dates: now using a consistent abbreviated version (e.g. 3d, 1w, 2mo) instead of lengthy descriptions like "two days ago" # Screenshot | Old | New | |---------|---------| | ![image](/attachments/8bd3b547-b63d-444c-9a6b-a6d73b12b55a) | ![image](/attachments/bf5ae06a-35d6-42ae-8ca8-433477d21fb5) | # Time Abbreviation Feature ## Overview This feature adds abbreviated time display functionality to Forgejo's commit list interface, providing a more compact representation of timestamps while maintaining full tooltip information. ## Implementation ### Backend Changes A new function `TimeSinceAbbreviated` has been added to the `DateUtils` template utility in `modules/templates/util_date.go`: - **Function**: `TimeSinceAbbreviated(time any) template.HTML` - **Purpose**: Generates abbreviated relative time strings with tooltip support - **Returns**: HTML span element with abbreviated text and full timestamp tooltip ### Template Changes Updated `templates/repo/commits_list.tmpl` to: - Use `DateUtils.TimeSinceAbbreviated` instead of `DateUtils.TimeSince` - Maintain responsive layout (stacked on small screens, horizontal on large screens) - Keep center alignment for the date column header and values - Remove fixed width from date column to allow flexible sizing - Redistribute column widths (message column expanded from 8 to 11 units) ### UI Layout Changes 1. **Author Column**: - Avatar and username stack vertically on small screens - Side-by-side layout on large screens (≥768px) - Left-aligned content 2. **Date/Actions Column**: - Merged timestamp and action buttons into single column - Stacked layout on small screens with abbreviated timestamps - Horizontal layout on large screens - Center-aligned content - Flexible width that adapts to content size (auto-sizing) ## Time Abbreviation Format The feature converts standard relative time strings to abbreviated versions: | Duration Range | Abbreviation | Example | |----------------|--------------|---------| | Seconds | `s` | `30s ago` | | Minutes | `m` | `5m ago` | | Hours | `h` | `3h ago` | | Days | `d` | `2d ago` | | Months | `mo` | `1mo ago` | | Years | `y` | `1y ago` | | Future | `in Xs` | `in 5m` | ## Features - **Tooltip Support**: Hovering over abbreviated time shows full timestamp - **Responsive Design**: Layout adapts to screen size - **Accessibility**: Maintains semantic HTML structure - **Backward Compatible**: Doesn't affect existing TimeSince usage elsewhere - **Flexible Column Width**: Date column automatically sizes to fit content, optimizing space usage - **Improved Space Utilization**: Message column gets more space while date column uses minimum required width ## Testing Comprehensive tests added in `modules/templates/util_date_test.go` covering: - All time duration ranges - Past and future times - Null/zero value handling - Tooltip content verification ## Files Modified 1. `modules/templates/util_date.go` - Added TimeSinceAbbreviated function 2. `templates/repo/commits_list.tmpl` - Updated to use abbreviated time display and flexible column width 3. `modules/templates/util_date_test.go` - Added comprehensive tests 4. `web_src/css/repo.css` - Added CSS rules for auto-sizing date column
pat-s force-pushed feat/mobile-commit-view from bfef3ae495 to 7c2fd08311 2025-05-31 08:07:15 +00:00 Compare
pat-s force-pushed feat/mobile-commit-view from 7c2fd08311 to 327c1c1227 2025-05-31 08:42:38 +00:00 Compare
pat-s force-pushed feat/mobile-commit-view from 327c1c1227 to 2a89fece89 2025-05-31 08:51:32 +00:00 Compare
pat-s force-pushed feat/mobile-commit-view from 2a89fece89 to b60e1a50a3 2025-05-31 09:05:33 +00:00 Compare
pat-s force-pushed feat/mobile-commit-view from b60e1a50a3 to 6d15b878c8 2025-05-31 09:34:50 +00:00 Compare
pat-s force-pushed feat/mobile-commit-view from 6d15b878c8 to aa8d0b139d 2025-05-31 09:36:17 +00:00 Compare
pat-s force-pushed feat/mobile-commit-view from aa8d0b139d to a649eebb34 2025-05-31 09:47:27 +00:00 Compare
pat-s changed title from feat: improved mobile-commit history to feat: improve commit-history list on mobile 2025-06-02 16:02:35 +00:00
pat-s merged commit 86ccaf6eb2 into main 2025-06-02 17:01:03 +00:00
pat-s deleted branch feat/mobile-commit-view 2025-06-02 17:01:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!2
No description provided.