Skip to content

feat: Add support for Postscript files#1399

Merged
yorukot merged 2 commits into
yorukot:mainfrom
jirka-grunt:feat/postscript-file-preview
Apr 28, 2026
Merged

feat: Add support for Postscript files#1399
yorukot merged 2 commits into
yorukot:mainfrom
jirka-grunt:feat/postscript-file-preview

Conversation

@jirka-grunt

@jirka-grunt jirka-grunt commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Postscript files are less common than PDFs these days, but adding their support to Superfile is relatively easy.

Summary by CodeRabbit

  • New Features
    • Added icon support for PostScript (PS) files
    • Added thumbnail preview generation for PostScript (.ps) and Encapsulated PostScript (.eps) files

Allow thumbnail generation for .ps and .eps files via Ghostscript.
Use general document icon as Nerd font doesn't include own PS icon
@coderabbitai

coderabbitai Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added PostScript file format support through an icon configuration entry and a new Ghostscript-based thumbnail generator. The thumbnail generator conditionally activates when Ghostscript is installed and processes .ps or .eps files by executing the gs command to render thumbnails.

Changes

Cohort / File(s) Summary
Icon Configuration
src/config/icon/icon.go
Added icon mapping for .ps file extension with Unicode icon \U000f1517 and orange color #d35400.
Thumbnail Generation
src/pkg/file_preview/thumbnail_generator.go
Added psGenerator backend that detects Ghostscript availability and generates thumbnails from PostScript/EPS files by executing the gs command with safe options, first-page rendering, and JPEG output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A rabbit hops through PostScript lands,
Where Ghostscript weaves its magic hands,
From .ps files, thumbnails bloom,
No more darkness in the gloom! 👻🎨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for Postscript files (.ps and .eps). It directly reflects the primary objective of the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pkg/file_preview/thumbnail_generator.go (1)

129-129: Clarify the resolution comment.

The comment states "Resolution (the same as for pdf)" but the pdfGenerator.generateThumbnail method (lines 87-92) doesn't specify an explicit resolution parameter for pdftoppm. This comment could be misleading.

📝 Suggested clarification
-		"-r150",         // Resolution (the same as for pdf)
+		"-r150",         // Resolution (150 DPI)

or verify and update to:

-		"-r150",         // Resolution (the same as for pdf)
+		"-r150",         // Resolution (matches pdftoppm default of 150 DPI)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pkg/file_preview/thumbnail_generator.go` at line 129, The comment for
"-r150" is misleading because pdfGenerator.generateThumbnail does not explicitly
set pdftoppm resolution; either update the comment to state a concrete meaning
(e.g., "Resolution for image export: 150 DPI") and remove "(the same as for
pdf)", or change pdfGenerator.generateThumbnail to pass the same explicit
resolution (150) to the pdftoppm invocation so both places match; locate the
pdftoppm call in pdfGenerator.generateThumbnail and either add a resolution flag
there or update the "-r150" comment in thumbnail_generator.go to a clear,
accurate description.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/config/icon/icon.go`:
- Line 135: The icon for key "ps" uses an invalid Unicode escape "\U000f1517";
replace it with a valid Nerd Font glyph codepoint (for example U+F15C3) so the
Icon field in the map entry for "ps" contains a renderable Nerd Font glyph;
update the Icon value (the Icon field in the map entry keyed by "ps") to the
correct escape sequence for the chosen codepoint and keep the existing Color
value unchanged.

---

Nitpick comments:
In `@src/pkg/file_preview/thumbnail_generator.go`:
- Line 129: The comment for "-r150" is misleading because
pdfGenerator.generateThumbnail does not explicitly set pdftoppm resolution;
either update the comment to state a concrete meaning (e.g., "Resolution for
image export: 150 DPI") and remove "(the same as for pdf)", or change
pdfGenerator.generateThumbnail to pass the same explicit resolution (150) to the
pdftoppm invocation so both places match; locate the pdftoppm call in
pdfGenerator.generateThumbnail and either add a resolution flag there or update
the "-r150" comment in thumbnail_generator.go to a clear, accurate description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2f9e67b4-55bb-479e-b9e8-48115b6e707d

📥 Commits

Reviewing files that changed from the base of the PR and between 165b342 and 4b888a3.

📒 Files selected for processing (2)
  • src/config/icon/icon.go
  • src/pkg/file_preview/thumbnail_generator.go

Comment thread src/config/icon/icon.go
Comment thread src/pkg/file_preview/thumbnail_generator.go
@yorukot yorukot added pr needs work PR needs work before it can be further reviewed/merged and removed awaiting pr review labels Apr 21, 2026
@yorukot yorukot merged commit 4969aa6 into yorukot:main Apr 28, 2026
7 of 11 checks passed
@yorukot yorukot removed the pr needs work PR needs work before it can be further reviewed/merged label Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants