From f933cd7c2ff47ebeaf635c3a1ff4a88a440f0278 Mon Sep 17 00:00:00 2001 From: Domizio Demichelis Date: Thu, 6 May 2021 16:34:00 +0700 Subject: [PATCH] Added issue template and standalone_app to use as a scaffold for reproducing issues [ci skip] --- .github/ISSUE_TEMPLATE.md | 30 ++++++++ apps/standalone_app.ru | 118 ++++++++++++++++++++++++++++++ pagy-on-docker/docker-compose.yml | 2 +- 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 apps/standalone_app.ru diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..02fa255e8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,30 @@ + + + + +## Prerequisites + +- [ ] I researched through the [documentation](https://ddnexus.github.io/pagy/), the [pagy issues](https://github.com/ddnexus/pagy/issues) and a known Search Engine, and there is no reference/report about this problem +- [ ] I am aware that questions or feature requests should not be filed as a Github Issue (for questions/requests/discussions I will use the [pagy live support](https://gitter.im/ruby-pagy/Lobby)) +- [ ] I did install/upgraded to the latest version of pagy (or the latest `3.*` for pagy legacy) +- [ ] I am providing at least one the following support in order to reproduce the issue: + - [ ] plain ruby file that can run as `ruby my-problem.rb` and shows this issue + - [ ] single file standalone app using the [standalone_app.rb](https://github.com/ddnexus/pagy/blob/master/apps/standalone_app.rb) as a scaffold and edited to show this issue + - [ ] link of my own branch forked from the [pagy-rails app](https://github.com/benkoshy/pagy-rails), containing the code that shows this issue + - [ ] link of the downloadable docker image that shows this issue (e.g. @ dockerhub.com) + +## Description + +### Ruby/Rails/Sinatra/ Version + +... + +### Issue Details + +... + +### Steps to use the support and reproduce the issue + +... + +Thank you! diff --git a/apps/standalone_app.ru b/apps/standalone_app.ru new file mode 100644 index 000000000..2a73f77f9 --- /dev/null +++ b/apps/standalone_app.ru @@ -0,0 +1,118 @@ +# frozen_string_literal: true + +# Self-contained sinatra app usable to easily reproduce any pagy issue + +# USAGE: rerun -- rackup -o 0.0.0.0 -p 8080 apps/basic_app.ru + +# Available at http://0.0.0.0:8080 + +require "bundler/inline" + +# edit this gemfile declaration as you need +# and ensure to use gems updated to the latest versions +gemfile true do + source "https://rubygems.org" + gem 'oj' + gem 'rack' + gem 'rake' + gem 'pagy' + gem 'rerun' + gem 'puma' + gem 'sinatra' + gem 'sinatra-contrib' +end +puts "Pagy::VERSION: #{Pagy::VERSION}" + +# edit this section adding/removing the extras and Pagy::VARS as you need +# pagy initializer +require 'pagy/extras/navs' +require 'pagy/extras/items' +require 'pagy/extras/trim' +Pagy::VARS[:trim] = false # opt-in trim + +# sinatra setup +require 'sinatra/base' + +class PagyApp < Sinatra::Base + + # sinatra application + enable :inline_templates + + include Pagy::Backend # rubocop:disable Style/MixinUsage + # edit this section adding your own helpers as you need + helpers do + include Pagy::Frontend + end + + get '/pagy.js' do + content_type 'application/javascript' + send_file Pagy.root.join('javascripts', 'pagy.js') + end + + get '/' do + erb :welcome + end + + # edit this action as you need + get '/pagy_issue' do + collection = MockCollection.new + @pagy, @records = pagy(collection) + erb :pagy_issue # template available in the __END__ section as @@ pagy_issue + end +end + +# simple array-based collection that acts as standard DB collection +# use it as a simple way to get a collection that acts as a AR scope, but without any DB +# Or use ActiveRecord if you prefer +class MockCollection < Array + def initialize(arr=Array(1..1000)) + super + @collection = clone + end + def offset(value) + @collection = self[value..] + self + end + def limit(value) + @collection[0, value] + end + def count(*) + size + end +end + +run PagyApp + +__END__ + +@@ layout + + + + + + + <%= yield %> + + + + +@@ welcome +

Pagy app

+

This app runs on Sinatra/Puma

+ + +@@ pagy_issue +

Edit this view as you need

+

@records

+

<%= @records.join(',') %>

+
+<%= pagy_nav(@pagy) %> +
+<%= pagy_nav_js(@pagy) %> +
+<%= pagy_combo_nav_js(@pagy) %> +
+<%= pagy_items_selector_js(@pagy) %> diff --git a/pagy-on-docker/docker-compose.yml b/pagy-on-docker/docker-compose.yml index 4611e7ccb..dc8bb7760 100644 --- a/pagy-on-docker/docker-compose.yml +++ b/pagy-on-docker/docker-compose.yml @@ -35,7 +35,7 @@ services: environment: - COVERAGE_REPORT ports: - - "1234:1234" # RubyMine debugger +# - "1234:1234" # RubyMine debugger - "4567:4567" # default sinatra e2e/app.rb - "8080:8080" # should you run the rackup apps/base_app.ru command: rerun "test/e2e/app.rb -o 0.0.0.0"