
gittech. site
for different kinds of informations and explorations.
YAML-Powered URL and Shell Command Shortener
Published at
Jan 16, 2025
Main Article
Yamlink
A fast, lightweight URL mapping and redirection system that dynamically manages URL shortcuts through YAML configuration files. Perfect for creating and managing custom URL shorteners for internal tools, documentation, or any web resources.
Description
Yamlink solves the common challenge of managing and accessing numerous URLs within an organization or personal workflow by:
- Creating human-readable shortcuts for complex URLs
- Supporting hierarchical URL organization through YAML
- Providing real-time configuration updates without service restart
- Offering both CLI and server components for flexible usage
Installation
Prerequisites
- Go 1.22.4 or higher
- Make (optional, for using Makefile commands)
Build from Source
# Clone the repository git clone https://github.com/NishantJoshi00/yamlink cd yamlink # Build the binaries go build ./cmd/yamlink # Server component go build ./cmd/shelinks # CLI component
Install System-wide (Optional)
# Move binaries to system path sudo mv yamlink /usr/local/bin/ sudo mv shelinks /usr/local/bin/
Usage
Server Mode (yamlink)
Create Configuration Files
# config.yaml host: localhost port: 8080 map_file: map.yaml refresh_interval: 5 # seconds
# map.yaml github: profile: https://github.com/NishantJoshi00 docs: - https://docs.example.com
Start the Server
CONFIG_FILE=config.yaml ./yamlink
Access URLs
- Visit
http://localhost:8080/github/profile
- Visit
http://localhost:8080/docs/0
- Visit
CLI Mode (shelinks)
Set up Configuration
# ~/.shelinks.yaml gs: git status gp: git push
Use in Shell
# For ZSH source scripts/init.zsh /path/to/shelinks ~/.shelinks.yaml # For Fish source scripts/init.fish /path/to/shelinks ~/.shelinks.yaml
Use Shortcuts
s/gs # Expands to 'git status' s/gp # Expands to 'git push'
Features
- Dynamic URL Mapping: Support for nested URL structures up to 3 levels deep
- Real-time Updates: Configuration changes are automatically detected and applied
- Multiple Access Methods:
- Server mode for web-based access
- CLI mode for shell integration
- Flexible Configuration:
- Support for both single URLs and arrays of URLs
- Custom refresh intervals for configuration updates
- Shell Integration: Native support for zsh and fish shells
- Logging: Structured JSON logging with configurable log levels
Contributing Guidelines
- Issue First: Create or find an issue before starting work
- Issue Tags: Use descriptive tags:
- [BUG] for bug reports
- [FEATURE] for feature requests
- [DOCS] for documentation improvements
- Work Assignment: Don't work on issues already assigned to others
- Testing: Ensure all tests pass by running
make test
- Code Style: Follow Go standard formatting guidelines
License
This project is licensed under the MIT License - see the LICENSE file for details.