File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- ## [ Unreleased ]
1+ ## Changelog.md
22
3- ## [ 0.1.0] - 2026-01-20
43
5- - Initial release
4+ ## 0.1.1
5+ - Rails integration documentation
6+ - Optional Railtie for Rails environments
7+ ## [ 0.1.0] - 2026-01-20
Original file line number Diff line number Diff line change @@ -18,4 +18,45 @@ brew install gd
1818### Gemfile
1919``` bash
2020gem ' imprint'
21- ```
21+ ```
22+
23+
24+
25+ ## Rails integration
26+
27+ Imprint is framework-agnostic, but integrates cleanly with Rails.
28+
29+ ### Routes
30+
31+ Define your own route:
32+
33+ ``` ruby
34+ # config/routes.rb
35+ get ' /imprint/:token' , to: ' imprint#show'
36+ ```
37+ ### Controller
38+
39+ ``` ruby
40+ class ImprintController < ApplicationController
41+ def show
42+ path = Imprint .render_from_token(params[:token ])
43+
44+ return head :not_found unless path
45+
46+ send_file path, type: ' image/png' , disposition: ' inline'
47+ end
48+ end
49+ ```
50+
51+ ### Usage
52+
53+ ``` ruby
54+ token = Imprint .sign(
55+ source: ' /path/to/image.png' ,
56+ watermark: ' CONFIDENTIAL' ,
57+ expires_in: 5 .minutes
58+ )
59+ ```
60+ ``` html
61+ <img src =" /imprint/<%= token.split('/').last %>" />
62+ ```
Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ Gem::Specification.new do |spec|
1010
1111 spec . summary = "Signed, expiring image watermark rendering for Ruby"
1212 spec . description = <<~DESC
13- Imprint is a Ruby library for generating signed, time-limited image renders
14- with dynamic text watermarks. It allows you to securely distribute images
15- using expiring tokens, preventing unauthorized reuse or hotlinking.
13+ Imprint is a Ruby library for generating signed, time-limited image renders
14+ with dynamic text watermarks. It allows you to securely distribute images
15+ using expiring tokens, preventing unauthorized reuse or hotlinking.
1616
17- Imprint works as a pure Ruby library and can optionally integrate with Rails
18- via an isolated engine. Image rendering is powered by the GD graphics library.
19- DESC
17+ Imprint works as a pure Ruby library and can optionally integrate with Rails
18+ via an isolated engine. Image rendering is powered by the GD graphics library.
19+ DESC
2020 spec . homepage = "https://github.com/ggerman/imprint"
2121 spec . license = "MIT"
2222 spec . required_ruby_version = '>= 3.3.0'
Original file line number Diff line number Diff line change 44require 'imprint/signer'
55require 'imprint/renderer'
66require 'imprint/engine' if defined? ( Rails )
7+ require 'imprint/railtie' if defined? ( Rails )
78
89module Imprint
910 def self . sign ( source :, watermark :, expires_in :)
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ module Imprint
4+ module Rails
5+ module Helper
6+ def imprint_image_tag ( token , **)
7+ image_tag (
8+ imprint_render_path ( token : token ) ,
9+ **
10+ )
11+ end
12+ end
13+ end
14+ end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require 'rails/railtie'
4+
5+ module Imprint
6+ class Railtie < Rails ::Railtie
7+ initializer 'imprint.helpers' do
8+ ActiveSupport . on_load ( :action_view ) do
9+ include Imprint ::Rails ::Helper
10+ end
11+ end
12+
13+ initializer 'imprint.configure' do
14+ # Punto de extensión futuro
15+ end
16+ end
17+ end
You can’t perform that action at this time.
0 commit comments