Skip to content

Conversation

@PrayagCodes
Copy link

@PrayagCodes PrayagCodes commented Nov 25, 2025

Overview

This PR implements the ability to create web link shortcuts on the desktop, allowing users to save and quickly access frequently visited websites. This feature bridges the gap between the Puter environment and external web resources, making the desktop feel more integrated and functional.

Features

  • Context Menu Integration: Add 'New Link' option to desktop context menu
  • URL Validation: Prompt for URL with validation (must start with 'http://' or 'https://')
  • Smart Filename Generation: Auto-generate filename from URL domain (e.g., 'Github.weblink')
  • Paste-to-Create: Automatic link creation when pasting URLs onto desktop
  • Visual Identification: Display .weblink files with link icon instead of generic file icon
  • Quick Access: Double-click to open URLs in new browser tab with security attributes
  • Persistence: URLs stored in .weblink files persist across sessions
  • Duplicate Prevention: Mechanism to prevent creating multiple files when pasting

Changes Made

Core Functionality

  • src/gui/src/helpers/new_context_menu_item.js: Add 'Web Link' menu item to context menu
  • src/gui/src/helpers.js:
    • Add create_weblink() function for manual link creation
    • Add create_weblink_from_url() function for paste operations
    • Implement duplicate prevention mechanism
  • src/gui/src/keyboard.js: Enhance paste handler to detect and create links from URLs
  • src/gui/src/helpers/item_icon.js: Add icon support for .weblink file extension
  • src/gui/src/helpers/open_item.js: Add special handling to open URLs from .weblink files

Internationalization

  • src/gui/src/i18n/translations/*.js: Add translations to all 38 language files
    • Added keys: web_link, enter_url_for_web_link, url_must_start_with_http, failed_to_open_url, invalid_url_in_weblink, error_reading_weblink

Security Considerations

  • URLs validated before opening (must start with 'http://' or 'https://')
  • window.open() called with opener=null for security (prevents window.opener access)
  • User-friendly error messages for invalid URLs or file reading errors

Technical Details

  • File Format: .weblink files store URLs as plain text
  • Storage: URLs stored persistently in filesystem
  • Duplicate Prevention: Uses _creating_weblink flag to prevent concurrent creation
  • Event Handling: Early event prevention in paste handler to avoid browser defaults

Testing

Manual Test Cases

  1. Create Link via Context Menu

    • Right-click desktop → 'New' → 'Web Link'
    • Enter valid URL (e.g., https://github.com)
    • Verify file created with link icon
    • Double-click to verify URL opens in new tab
  2. Paste URL to Create Link

    • Copy URL from browser
    • Paste onto desktop (Ctrl+V / Cmd+V)
    • Verify single file created (no duplicates)
    • Verify file opens correctly
  3. URL Validation

    • Try creating link with invalid URL
    • Verify error message appears
    • Verify no file is created
  4. Persistence

    • Create web link shortcut
    • Refresh page
    • Verify shortcut still works
  5. Icon Display

    • Create multiple web links
    • Verify all display with link icon

Related Issues

Closes #[issue-number]

Notes

  • The implementation uses plain text files to store URLs, making them easy to read and edit
  • The feature integrates seamlessly with existing file system operations
  • All error messages are internationalized and user-friendly
  • The duplicate prevention mechanism ensures a smooth user experience when pasting URLs

Implement the ability to create web link shortcuts on the desktop,
allowing users to save and quickly access frequently visited websites.
This feature bridges the gap between the Puter environment and external
web resources, making the desktop feel more integrated and functional.

Features:
- Add 'New Link' option to desktop context menu
- Prompt for URL with validation (must start with 'http://' or 'https://')
- Auto-generate filename from URL domain (e.g., 'Github.weblink')
- Automatic link creation when pasting URLs onto desktop
- Display .weblink files with link icon instead of generic file icon
- Double-click to open URLs in new browser tab with security attributes
- Persistent storage of URLs in .weblink files
- Duplicate prevention mechanism for paste operations

Changes:
- src/gui/src/helpers/new_context_menu_item.js: Add 'Web Link' menu item
- src/gui/src/helpers.js: Add create_weblink() and create_weblink_from_url() functions
- src/gui/src/keyboard.js: Enhance paste handler to detect and create links from URLs
- src/gui/src/helpers/item_icon.js: Add icon support for .weblink file extension
- src/gui/src/helpers/open_item.js: Add special handling to open URLs from .weblink files
- src/gui/src/i18n/translations/*.js: Add translations to all 38 language files

Technical details:
- .weblink files store URLs as plain text
- URLs validated before opening (security check)
- window.open() called with opener=null for security
- Duplicate prevention using '_creating_weblink' flag
- Early event prevention in paste handler to avoid browser defaults
Copy link

@israx israx left a comment

Choose a reason for hiding this comment

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

nice job. We are getting close!

@PrayagCodes PrayagCodes requested a review from israx December 6, 2025 08:24
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.

2 participants