Skip to content

Commit

Permalink
Added issue template and standalone_app to use as a scaffold for repr…
Browse files Browse the repository at this point in the history
…oducing issues [ci skip]
  • Loading branch information
ddnexus committed May 6, 2021
1 parent c8e41e3 commit f933cd7
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- ISSUES NOT FOLLOWING THIS TEMPLATE MAY GET CLOSED AND DELETED -->

<!-- Check what applies [x] -->

## 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!
118 changes: 118 additions & 0 deletions apps/standalone_app.ru
Original file line number Diff line number Diff line change
@@ -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
<html>
<head>
<script type="application/javascript" src="/pagy.js"></script>
<script type="application/javascript">
window.addEventListener("load", Pagy.init);
</script>
</head>
<body>
<%= yield %>
</body>
</html>


@@ welcome
<h3>Pagy app</h3>
<p>This app runs on Sinatra/Puma</p>


@@ pagy_issue
<h3>Edit this view as you need</h3>
<p>@records</p>
<p><%= @records.join(',') %></p>
<br>
<%= pagy_nav(@pagy) %>
<br>
<%= pagy_nav_js(@pagy) %>
<br>
<%= pagy_combo_nav_js(@pagy) %>
<br>
<%= pagy_items_selector_js(@pagy) %>
2 changes: 1 addition & 1 deletion pagy-on-docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f933cd7

Please sign in to comment.