Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jul 2, 2020
2 parents 515de9b + 734f30c commit f964beb
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 36 deletions.
42 changes: 24 additions & 18 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
source "https://rubygems.org"

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

# test
gem 'rake'
gem 'minitest', '~> 5.12'
gem 'minitest-reporters'
gem 'rack'
gem 'i18n'

gem 'oj', require: false # false is for testing with or without it

gem 'rubocop', '~> 0.82.0'
gem 'rubocop-performance', '~> 1.5.0'
gem 'simplecov', require: false
gem 'codecov', :require => false

# development
# gem 'slim'
# gem 'haml'
gem 'puma'

# benchmark/profiling
# gem 'benchmark-ips'
# gem 'kalibera'
# gem 'memory_profiler'
group :test do
gem 'rubocop', '~> 0.82.0'
gem 'rubocop-performance', '~> 1.5.0'
gem 'simplecov', require: false
gem 'codecov', require: false
gem 'minitest'
gem 'minitest-reporters'
end

# docs server
gem "github-pages", '204', group: :jekyll_plugins
gem "github-pages", '206', group: :jekyll_plugins

group :apps do
gem 'sinatra'
gem 'sinatra-contrib'
# gem 'slim'
# gem 'haml'
end

# group :performance do
# benchmark/profiling
# gem 'benchmark-ips'
# gem 'kalibera'
# gem 'memory_profiler'
# end
46 changes: 36 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.3.1)
activesupport (6.0.3.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
Expand All @@ -11,6 +11,7 @@ GEM
public_suffix (>= 2.0.2, < 5.0)
ansi (1.5.0)
ast (2.4.1)
backports (3.18.1)
builder (3.2.4)
codecov (0.1.17)
json
Expand Down Expand Up @@ -39,9 +40,9 @@ GEM
ffi (1.13.1)
forwardable-extended (2.6.0)
gemoji (3.0.1)
github-pages (204)
github-pages (206)
github-pages-health-check (= 1.16.1)
jekyll (= 3.8.5)
jekyll (= 3.8.7)
jekyll-avatar (= 0.7.0)
jekyll-coffeescript (= 1.1.1)
jekyll-commonmark-ghpages (= 0.1.6)
Expand Down Expand Up @@ -80,7 +81,7 @@ GEM
mercenary (~> 0.3)
minima (= 2.5.1)
nokogiri (>= 1.10.4, < 2.0)
rouge (= 3.13.0)
rouge (= 3.19.0)
terminal-table (~> 1.4)
github-pages-health-check (1.16.1)
addressable (~> 2.3)
Expand All @@ -95,7 +96,7 @@ GEM
i18n (0.9.5)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.4)
jekyll (3.8.5)
jekyll (3.8.7)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
Expand Down Expand Up @@ -218,7 +219,11 @@ GEM
builder
minitest (>= 5.0)
ruby-progressbar
multi_json (1.14.1)
multipart-post (2.1.1)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.2)
nokogiri (1.10.9)
mini_portile2 (~> 2.4.0)
octokit (4.18.0)
Expand All @@ -231,14 +236,18 @@ GEM
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (3.1.1)
rack (2.2.2)
puma (4.3.5)
nio4r (~> 2.0)
rack (2.2.3)
rack-protection (2.0.8.1)
rack
rainbow (3.0.0)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.4)
rouge (3.13.0)
rouge (3.19.0)
rubocop (0.82.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
Expand All @@ -252,6 +261,7 @@ GEM
ruby-enum (0.8.0)
i18n
ruby-progressbar (1.10.1)
ruby2_keywords (0.0.2)
rubyzip (2.3.0)
safe_yaml (1.0.5)
sass (3.7.4)
Expand All @@ -266,32 +276,48 @@ GEM
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
sinatra (2.0.8.1)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
sinatra-contrib (2.0.8.1)
backports (>= 2.8.2)
multi_json
mustermann (~> 1.0)
rack-protection (= 2.0.8.1)
sinatra (= 2.0.8.1)
tilt (~> 2.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6)
tilt (2.0.10)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (1.2.7)
thread_safe (~> 0.1)
unicode-display_width (1.7.0)
url (0.3.2)
zeitwerk (2.3.0)
zeitwerk (2.3.1)

PLATFORMS
ruby

DEPENDENCIES
codecov
github-pages (= 204)
github-pages (= 206)
i18n
minitest (~> 5.12)
minitest
minitest-reporters
oj
puma
rack
rake
rubocop (~> 0.82.0)
rubocop-performance (~> 1.5.0)
simplecov
sinatra
sinatra-contrib

BUNDLED WITH
2.1.4
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ Use the official extras, or write your own in just a few lines. Extras add speci
- [materialize](http://ddnexus.github.io/pagy/extras/materialize): Add nav, nav_js and combo_nav_js helpers for the Materialize CSS [pagination component](https://materializecss.com/pagination.html)
- [navs](http://ddnexus.github.io/pagy/extras/navs): Add nav_js and combo_nav_js unstyled helpers
- [semantic](http://ddnexus.github.io/pagy/extras/semantic): Add nav, nav_js and combo_nav_js helpers for the Semantic UI CSS [pagination component](https://semantic-ui.com/collections/menu.html)
- [tailwind](http://ddnexus.github.io/pagy/extras/tailwind): Extra styles for [Tailwind CSS](https://tailwindcss.com)
- [uikit](http://ddnexus.github.io/pagy/extras/uikit): Add nav, nav_js and combo_nav_js helpers for the UIkit [pagination component](https://getuikit.com/docs/pagination)

### Feature Extras
Expand Down
111 changes: 111 additions & 0 deletions apps/basic_app.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Basec self-contained rack/sinatra app
# edit or duplicate this app to experiment with the pagy features

# USAGE: rackup -I lib -o 0.0.0.0 -p 8080 apps/basic_app.ru

# standard bundler using project Gemfile
require 'rubygems'
require 'bundler'
Bundler.require(:default, :apps)

require 'pagy'

# pagy initializer
require 'pagy/extras/navs'
require 'pagy/extras/items'
require 'pagy/extras/trim' if ENV['ENABLE_TRIM']
require 'oj' if ENV['ENABLE_OJ']

# sinatra setup
require "sinatra/base"
require "sinatra/reloader"


# simple array-based collection that acts as standard DB collection
class MockCollection < Array

def initialize(arr=Array(1..1000))
super
@collection = self.clone
end

def offset(value)
@collection = self[value..-1]
self
end

def limit(value)
@collection[0, value]
end

def count(*)
size
end

end

# sinatra application
class PagyApp < Sinatra::Base

configure do
enable :inline_templates
end

configure :development do
register Sinatra::Reloader
end

include Pagy::Backend
include Pagy::Frontend

get '/pagy.js' do
content_type 'application/javascript'
send_file Pagy.root.join('javascripts', 'pagy.js')
end

get '/' do
redirect '/helpers'
end

get '/helpers' do
collection = MockCollection.new
@pagy, _ = pagy(collection)
erb :helpers
end

get '/no-pagy' do
erb :'no-pagy'
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>

@@ helpers
<br>
<%= pagy_nav(@pagy) %>
<br>
<%= pagy_nav_js(@pagy) %>
<br>
<%= pagy_combo_nav_js(@pagy) %>
<br>
<%= pagy_items_selector_js(@pagy) %>

@@ no-pagy
<p>Just a page without pagy</p>
1 change: 1 addition & 0 deletions docs/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ <h1 id="site-title">{{ site.title | default: site.github.repository_name }}
<a href="{{ site.baseurl }}/extras/searchkick"><p class="indent1" {% if page.title == 'Searchkick' %}id="active"{% endif %} >Searchkick</p></a>
<a href="{{ site.baseurl }}/extras/semantic"><p class="indent1" {% if page.title == 'Semantic' %}id="active"{% endif %} >Semantic</p></a>
<a href="{{ site.baseurl }}/extras/support"><p class="indent1" {% if page.title == 'Support' %}id="active"{% endif %} >Support</p></a>
<a href="{{ site.baseurl }}/extras/tailwind"><p class="indent1" {% if page.title == 'Tailwind' %}id="active"{% endif %} >Tailwind</p></a>
<a href="{{ site.baseurl }}/extras/trim"><p class="indent1" {% if page.title == 'Trim' %}id="active"{% endif %} >Trim</p></a>
<a href="{{ site.baseurl }}/extras/uikit"><p class="indent1" {% if page.title == 'UIkit' %}id="active"{% endif %} >UIkit</p></a>
</div>
Expand Down
1 change: 1 addition & 0 deletions docs/extras.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Pagy comes with a few optional extensions/extras:
| `semantic` | Add nav, nav_js and combo_nav_js helpers for the Semantic UI CSS [pagination component](https://semantic-ui.com/collections/menu.html) | [semantic.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/semantic.rb), [documentation](http://ddnexus.github.io/pagy/extras/semantic) |
| `support` | Extra support for features like: incremental, infinite, auto-scroll pagination | [support.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/support.rb), [documentation](http://ddnexus.github.io/pagy/extras/support) |
| `trim` | Remove the `page=1` param from links | [trim.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/trim.rb), [documentation](http://ddnexus.github.io/pagy/extras/trim) |
| `tailwind` | Extra styles for [Tailwind CSS](https://tailwindcss.com) | [documentation](http://ddnexus.github.io/pagy/extras/tailwind) |
| `uikit` | Add nav, nav_js and combo_nav_js helpers for the UIkit [pagination component](https://getuikit.com/docs/pagination) | [uikit.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/uikit.rb), [documentation](http://ddnexus.github.io/pagy/extras/uikit) |

## Synopsis
Expand Down
54 changes: 54 additions & 0 deletions docs/extras/tailwind.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: Tailwind
---
# Tailwind Extra Styles

Tailwind allows to apply styles to any DOM element, so - if you use it - you don't actually need a special extra to produce a different output. You can use the standard unstyled pagy helpers: i.e. the default `pagy_nav` and the `pagy_nav_js`and `pagy_nav_combo_js` provided by the [navs](navs.md) extra, and apply the styles to their classes.

## Synopsis

See the [navs](navs.md) extra if you use `pagy_nav_js` or `pagy_combo_nav_js`.

Copy and customize the following basic rules to apply the styles to the pagy CSS classes:

```scss
.pagy-nav,
.pagy-nav-js,
.pagy-combo-nav-js {
@apply .inline-flex .shadow-md;
}
.pagy-nav.pagination,
.pagy-nav-js.pagination,
.pagy-combo-nav-js.pagination {
@apply .border .border-gray-600 .rounded-sm;
}
.pagy-nav .page,
.pagy-nav-js .page,
.pagy-combo-nav-js .page,
.pagy-combo-nav-js .pagy-combo-input {
@apply .text-gray-700 .border-r .border-gray-600 .px-3 .py-2 .text-sm .leading-tight .font-medium;
}
.pagy-nav .page:hover,
.pagy-nav-js .page:hover {
@apply .text-gray-900;
}
.pagy-nav .disabled,
.pagy-nav-js .disabled,
.pagy-combo-nav-js .disabled {
@apply .cursor-not-allowed;
}
.pagy-nav .active,
.pagy-nav-js .active {
@apply .text-blue-500;
}
.pagy-nav .prev,
.pagy-nav-js .prev,
.pagy-combo-nav-js .prev {
@apply .text-gray-900;
}
.pagy-nav .next,
.pagy-nav-js .next,
.pagy-combo-nav-js .next {
@apply .text-gray-900 .border-r .border-transparent;
}
```

0 comments on commit f964beb

Please sign in to comment.