{"id":16062382,"url":"https://github.com/a-chacon/rails-url-shortener","last_synced_at":"2025-08-01T16:09:25.715Z","repository":{"id":38939779,"uuid":"479548147","full_name":"a-chacon/rails-url-shortener","owner":"a-chacon","description":"RailsUrlShortener is a lightweight Rails engine for short URLs. Ip logger capabilities too.","archived":false,"fork":false,"pushed_at":"2025-07-20T21:09:24.000Z","size":155,"stargazers_count":18,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-28T12:09:56.924Z","etag":null,"topics":["ip-logger","rails","ruby","url-shortener"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a-chacon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-04-08T21:51:55.000Z","updated_at":"2025-07-20T21:09:04.000Z","dependencies_parsed_at":"2025-05-08T13:48:11.361Z","dependency_job_id":null,"html_url":"https://github.com/a-chacon/rails-url-shortener","commit_stats":{"total_commits":46,"total_committers":1,"mean_commits":46.0,"dds":0.0,"last_synced_commit":"d803ad0f261eab5624fc2539307bdf6fc892fecb"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/a-chacon/rails-url-shortener","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-chacon%2Frails-url-shortener","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-chacon%2Frails-url-shortener/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-chacon%2Frails-url-shortener/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-chacon%2Frails-url-shortener/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a-chacon","download_url":"https://codeload.github.com/a-chacon/rails-url-shortener/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-chacon%2Frails-url-shortener/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268257238,"owners_count":24221054,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ip-logger","rails","ruby","url-shortener"],"created_at":"2024-10-09T04:40:28.773Z","updated_at":"2025-08-01T16:09:25.692Z","avatar_url":"https://github.com/a-chacon.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![Ruby on Rails CI](https://github.com/a-chacon/rails-url-shortener/actions/workflows/rubyonrails.yml/badge.svg)](https://github.com/a-chacon/rails-url-shortener/actions/workflows/rubyonrails.yml)\n![Gem Version](https://img.shields.io/gem/v/rails_url_shortener)\n\n![GitHub License](https://img.shields.io/github/license/a-chacon/rails_url_shortener)\n\n# RailsUrlShortener\n\nRailsUrlShortener is a small Rails engine that provides your app with short URL functionality and IP logging capabilities - like having your own Bitly service. By default, RailsUrlShortener saves all visits to your links for future analysis or other interesting uses.\n\nWhy give your data to a third-party app when you can manage it yourself?\n\nYou can see a **demo project** of what you can do with this engine [HERE](https://paso.fly.dev/).\n\n## Key Features\n\nHere are some of the things you can do with RailsUrlShortener:\n\n* Generate unique keys for links\n* Provide a controller method that finds, saves request information, and performs a 301 redirect to the original URL\n* Associate short links with models in your app\n* Save browser, system, and IP data from each request\n* Create temporary short links using the expires_at option\n* Get IP data from a third-party service\n\n## Installation\n\nFollow these steps to install and configure RailsUrlShortener:\n\n1. Add this line to your application's Gemfile:\n\n```ruby\ngem \"rails_url_shortener\"\n```\n\n2. Install the gem by running:\n\n```bash\nbundle install\n```\n\n3. Install and run the migrations:\n\n```bash\nbin/rails rails_url_shortener:install:migrations db:migrate\n```\n\n4. Generate the initializer for configuration:\n\n```bash\nrails generate rails_url_shortener\n```\n\n## Usage\n\n1. Mount the engine\n\nMount the engine on your app adding the next code on your config/routes.rb:\n\n**If you want to mount this on the root of your app, this should be on the bottom of your routes file.**\n\n```ruby\nmount RailsUrlShortener::Engine, at: \"/\"\n\n```\n\n2. Generate the short link\n\nAnd generate the short links like you want:\n\n* Using the helper method, this return the ready short link.\n\n```ruby\nshort_url(\"https://www.github.com/a-chacon/rails-url-shortener\")\n```\n\n* Or model method, this return the object built. So you can save this on a variable, extract the key and build the short link by your own:\n\n```ruby\nRailsUrlShortener::Url.generate(\"https://www.github.com/a-chacon/rails-url-shortener\")\n```\n\n3. Share the short link\n\n**Then share the short link to your users or wherever you want.**\n\n## Deeper\n\nFull params for the short_url helper:\n\n```ruby\nshort_url(url, owner: nil, key: nil, expires_at: nil, category: nil, url_options: {})\n```\n\nWhere:\n\n* **url**: The long URL to be shortened\n* **owner**: A model from your app to associate with the URL\n* **key**: A custom key for the short URL (optional)\n* **expires_at**: Expiration datetime (after which the redirect won't work)\n* **category**: A tag for categorizing the link\n* **url_options**: Options for the URL generator (e.g., subdomain or protocol)\n\nThe `generate` model method accepts the same parameters except for `url_options`:\n\n```ruby\nRailsUrlShortener::Url.generate(url, owner: nil, key: nil, expires_at: nil, category: nil)\n```\n\n### Data Collection\n\nBy default, the engine saves all requests made to your short URLs. You can use this data for analytics or IP logging. To access the data:\n\n1. Get visits for a specific URL:\n\n```ruby\nRailsUrlShortener::Url.find_by_key(\"key\").visits\n```\n\n2. Get all visits:\n\n```ruby\nRailsUrlShortener::Visit.all\n```\n\nEach Visit is associated with an Ipgeo model that contains information about the IP address:\n\n```ruby\nRailsUrlShortener::Visit.first.ipgeo\n```\n\n### IP Data Collection\n\nWhen a Visit record is created, a background job is enqueued to fetch IP data from the [ip-api.com](https://ip-api.com/) service and create an Ipgeo record. This uses the free endpoint, which has a limit of 45 different IPs per minute. If you expect higher traffic, you'll need to implement an alternative solution.\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nThe gem is available as open source under the terms of the [GPL-3.0 License](https://www.github.com/a-chacon/rails-url-shortener/blob/main/LICENSE).\n\nby: [a-chacon](https://a-chacon.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-chacon%2Frails-url-shortener","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa-chacon%2Frails-url-shortener","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-chacon%2Frails-url-shortener/lists"}