{"id":14969820,"url":"https://github.com/jonathanhefner/moar","last_synced_at":"2025-11-11T20:25:49.872Z","repository":{"id":56884140,"uuid":"143503077","full_name":"jonathanhefner/moar","owner":"jonathanhefner","description":"More-style pagination for Rails","archived":false,"fork":false,"pushed_at":"2023-05-14T19:30:23.000Z","size":92,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T14:48:40.968Z","etag":null,"topics":["pagination","rails","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonathanhefner.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-04T06:14:34.000Z","updated_at":"2023-06-29T12:32:02.000Z","dependencies_parsed_at":"2024-08-22T21:34:23.066Z","dependency_job_id":"00813363-a4f6-4e2c-b133-4bd3ff3df997","html_url":"https://github.com/jonathanhefner/moar","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"9375121cf7599a9b3905752c2a8c5cb871c20fd4"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jonathanhefner/moar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Fmoar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Fmoar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Fmoar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Fmoar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonathanhefner","download_url":"https://codeload.github.com/jonathanhefner/moar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonathanhefner%2Fmoar/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263348432,"owners_count":23452885,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pagination","rails","ruby","ruby-on-rails"],"created_at":"2024-09-24T13:42:26.882Z","updated_at":"2025-11-11T20:25:44.841Z","avatar_url":"https://github.com/jonathanhefner.png","language":"Ruby","readme":"# moar\n\nMore-style pagination for Rails.  As an example, consider the following\nstory:\n\n* There are 175 posts in the database.\n* User visits the posts index page; the first 10 posts are listed.\n* User clicks a \"More posts\" link; the next 20 posts are appended to the\n  list (30 total) without refreshing the page.\n* User clicks the \"More posts\" link again; the next 30 posts are\n  appended to the list (60 total) without refreshing the page.\n* User clicks the \"More posts\" link again; the browser navigates to a\n  new page listing the next 60 posts.\n* User clicks a \"More posts\" link; the browser navigates to a new page\n  listing the final 55 posts.  No \"More posts\" link is rendered.\n* At any point the user can manually refresh the page, and the same set\n  of posts will be shown.  Likewise, the page can navigated away from\n  and back to, or bookmarked and returned to later, and the same set of\n  posts will be shown.  (Assuming the database remains unchanged.)\n* If JavaScript is disabled, the first and second \"More posts\" links\n  will simply navigate to a new page listing only the posts that would\n  have been fetched via Ajax.\n\nWith *moar*, this story can be realized using the following code:\n\n```ruby\n## app/controllers/posts_controller.rb\n\nclass PostsController \u003c ApplicationController\n  # Step 1 (optional): set controller-specific pagination increments\n  moar_increments [10, 20, 30]\n\n  def index\n    # Step 2: apply pagination increments\n    @posts = moar(Post).order(:created_at)\n  end\nend\n```\n\n```html+erb\n\u003c!-- app/views/posts/index.html.erb --\u003e\n\n\u003ch1\u003ePosts\u003c/h1\u003e\n\u003cul id=\"list-of-posts\"\u003e\n\u003c% @posts.each do |post| %\u003e\n  \u003cli\u003e\u003c%= link_to post.title, post %\u003e\u003c/li\u003e\n\u003c% end %\u003e\n\u003c/ul\u003e\n\n\u003c!-- Step 3: render pagination link --\u003e\n\u003c%= link_to_more @posts, \"#list-of-posts\" %\u003e\n```\n\nA few things to note:\n\n* No special code is required to perform the fetch and render of\n  incremental paginated results via Ajax.\n* The maximum number of results per page (60, in this example) is the\n  sum of all pagination increments (10 + 20 + 30).\n* The `link_to_more` helper automatically infers the link text (\"More\n  posts\") from the paginated results.  This can be configured; see the\n  [Configuration](#configuration) section below.\n* The second argument of the `link_to_more` helper is a CSS selector\n  which points to the paginated results container element.  Results\n  fetched via Ajax are appended directly to that element, so the\n  selector must point to the rendered results' immediate container.  For\n  example, if the paginated results are rendered as rows in a table, the\n  selector should point to the `\u003ctbody\u003e` element rather than the\n  `\u003ctable\u003e` element.\n* The `link_to_more` helper will render nothing when there are no more\n  paginated results \u0026mdash; no `if` required.\n\nFor complete usage details, see the documentation for\n[`moar_increments`](https://www.rubydoc.info/gems/moar/Moar/Controller/ClassMethods:moar_increments),\n[`moar`](https://www.rubydoc.info/gems/moar/Moar/Controller:moar), and\n[`link_to_more`](https://www.rubydoc.info/gems/moar/Moar/Helper:link_to_more).\n\n\n## Configuration\n\nThe *moar* install generator will create two configuration files in your\nproject directory: \"config/initializers/moar.rb\" and\n\"config/locales/moar.en.yml\".\n\n\"config/initializers/moar.rb\" can be edited to change the default\npagination increments used when `moar_increments` is not called, and to\nchange the query param used to indicate page number.\n\n\"config/locales/moar.en.yml\" can be edited to change the link text\nrendered by `link_to_more`.  Translations listed in this file are\nprovided a `results_name` interpolation argument which contains the\nhumanized translated pluralized downcased name of the relevant model.\nFor example, if the translation string is `\"Need more %{results_name}!\"`\nand the paginated results consist of `CowBell` models, the rendered text\nwill be \"Need more cow bells!\".\n\n\n## Installation\n\nAdd the gem to your Gemfile:\n\n```bash\n$ bundle add moar\n```\n\nAnd run the installation generator:\n\n```bash\n$ rails generate moar:install\n```\n\n\n## Contributing\n\nRun `bin/test` to run the tests.\n\n\n## License\n\n[MIT License](MIT-LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanhefner%2Fmoar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanhefner%2Fmoar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanhefner%2Fmoar/lists"}