26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/generators/pagy_infinite_scroll/install/install_generator.rb', line 26
def show_post_install_message
say "\n"
say "Pagy Infinite Scroll installed successfully!", :green
say "\n"
say "Next steps:", :yellow
say " 1. Make sure you have Pagy gem installed: gem 'pagy'"
say "\n"
if using_importmap?
say " 2. Importmap setup (already configured!):", :green
say " - Pin added to config/importmap.rb"
say " - Import added to app/javascript/application.js"
say " - Controller auto-registers with Stimulus on page load"
say " - No manual registration needed!"
elsif using_jsbundling?
say " 2. jsbundling setup:", :yellow
say " Copy the controller to your app:"
say " cp $(bundle show pagy_infinite_scroll)/app/assets/javascripts/pagy_infinite_scroll/infinite_scroll_controller.js app/javascript/controllers/pagy_infinite_scroll_controller.js"
say "\n"
say " Then register in app/javascript/controllers/index.js:"
say " import PagyInfiniteScrollController from './pagy_infinite_scroll_controller'"
say " application.register('pagy-infinite-scroll', PagyInfiniteScrollController)"
say "\n"
say " Finally run: yarn build (or npm run build)"
else
say " 2. Manual setup required", :yellow
say " See documentation for your JavaScript setup"
end
say "\n"
say " 3. Choose your rendering approach:", :yellow
say "\n"
say " Option A: Server-Side Rendering (Simpler - Recommended for most apps)"
say " - Use format.js in controller"
say " - Create .js.erb template with: <%= pagy_infinite_scroll_append '.selector', @pagy, @records %>"
say " - Set data-pagy-infinite-scroll-render-mode-value='js' in view"
say " - No JavaScript customization needed!"
say "\n"
say " Option B: JSON API (Advanced - For APIs/SPAs)"
say " - Use format.json in controller"
say " - Create custom Stimulus controller and override createItemHTML()"
say " - Full control over client-side rendering"
say "\n"
say " 4. See full documentation: https://github.com/hassanharoon86/pagy_infinite_scroll"
say "\n"
end
|