{"id":13508179,"url":"https://github.com/mgwidmann/scrivener_html","last_synced_at":"2025-05-15T18:10:43.160Z","repository":{"id":36637940,"uuid":"40944209","full_name":"mgwidmann/scrivener_html","owner":"mgwidmann","description":"HTML view helpers for Scrivener","archived":false,"fork":false,"pushed_at":"2024-06-06T14:52:39.000Z","size":188,"stargazers_count":125,"open_issues_count":22,"forks_count":210,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-07T23:09:06.331Z","etag":null,"topics":["bootstrap","bulma-css-framework","custom-html","ecto","elixir","elixir-phoenix","foundation","html","materialize","materializecss-framework","pagination-links","scrivener","semantic"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","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/mgwidmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"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":"2015-08-18T01:44:50.000Z","updated_at":"2024-09-30T14:06:04.000Z","dependencies_parsed_at":"2024-01-05T21:55:50.755Z","dependency_job_id":"1b4f7e4c-6d92-4510-9b4b-0235a7af2f18","html_url":"https://github.com/mgwidmann/scrivener_html","commit_stats":{"total_commits":139,"total_committers":36,"mean_commits":3.861111111111111,"dds":0.4676258992805755,"last_synced_commit":"9224d1f3315e47cb13fa1ed403d3985474a58afa"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fscrivener_html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fscrivener_html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fscrivener_html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mgwidmann%2Fscrivener_html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mgwidmann","download_url":"https://codeload.github.com/mgwidmann/scrivener_html/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394724,"owners_count":22063984,"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":["bootstrap","bulma-css-framework","custom-html","ecto","elixir","elixir-phoenix","foundation","html","materialize","materializecss-framework","pagination-links","scrivener","semantic"],"created_at":"2024-08-01T02:00:49.330Z","updated_at":"2025-05-15T18:10:43.142Z","avatar_url":"https://github.com/mgwidmann.png","language":"Elixir","readme":"# Scrivener.Html [![Build Status](https://semaphoreci.com/api/v1/projects/3b1ad27c-8991-4208-94d0-0bae42108482/638637/badge.svg)](https://semaphoreci.com/mgwidmann/scrivener_html)\n\nHelpers built to work with [Scrivener](https://github.com/drewolson/scrivener)'s page struct to easily build HTML output for various CSS frameworks.\n\n## Setup\n\nAdd to `mix.exs`\n\n```elixir\n  # add :scrivener_html to deps\n  defp deps do\n    [\n      # ...\n      {:scrivener_html, \"~\u003e 1.8\"}\n      # ...\n    ]\n  end\n\n  # add :scrivener_html to applications list\n  defp application do\n    [\n      # ...\n      applications: [ ..., :scrivener_html, ... ]\n      # ...\n    ]\n  end\n```\n\nFor use with Phoenix.HTML, configure the `:routes_helper` module in `config/config.exs`\nlike the following:\n\n```elixir\nconfig :scrivener_html,\n  routes_helper: MyApp.Router.Helpers,\n  # If you use a single view style everywhere, you can configure it here. See View Styles below for more info.\n  view_style: :bootstrap\n```\n\nImport to your view.\n\n```elixir\ndefmodule MyApp.UserView do\n  use MyApp.Web, :view\n  import Scrivener.HTML\nend\n```\n\n## Example Usage\n\nUse in your template.\n\n```elixir\n\u003c%= for user \u003c- @page do %\u003e\n   ...\n\u003c% end %\u003e\n\n\u003c%= pagination_links @page %\u003e\n```\n\nWhere `@page` is a `%Scrivener.Page{}` struct returned from `Repo.paginate/2`.\nSo the function in your controller is like:\n\n```elixir\n#  params = %{\"page\" =\u003e _page}\ndef index(conn, params) do\n  page = MyApp.User\n          # Other query conditions can be done here\n          |\u003e MyApp.Repo.paginate(params)\n  render conn, \"index.html\", page: page\nend\n```\n\n### Scopes and URL Parameters\n\nIf your resource has any url parameters to be supplied, you should provide them as the 3rd parameter. For example, given a scope like:\n\n```elixir\nscope \"/:locale\", App do\n  pipe_through [:browser]\n\n  get \"/page\", PageController, :index, as: :pages\n  get \"/pages/:id\", PageController, :show, as: :page\nend\n```\n\nYou would need to pass in the `:locale` parameter and `:path` option like so:\n\n_(this would generate links like \"/en/page?page=1\")_\n\n```elixir\n\u003c%= pagination_links @conn, @page, [\"en\"], path: \u0026pages_path/4 %\u003e\n```\n\nWith a nested resource, simply add it to the list:\n\n_(this would generate links like \"/en/pages/1?page=1\")_\n\n```elixir\n\u003c%= pagination_links @conn, @page, [\"en\", @page_id], path: \u0026page_path/4, action: :show %\u003e\n```\n\n### Query String Parameters\n\nAny additional query string parameters can be passed in as well.\n\n```elixir\n\u003c%= pagination_links @conn, @page, [\"en\"], some_parameter: \"data\" %\u003e\n# Or if there are no URL parameters\n\u003c%= pagination_links @conn, @page, some_parameter: \"data\" %\u003e\n```\n\n### Custom Actions\n\nIf you need to hit a different action other than `:index`, simply pass the action name to use in the url helper.\n\n```elixir\n\u003c%= pagination_links @conn, @page, action: :show %\u003e\n```\n\n### Customizing Output\n\nBelow are the defaults which are used without passing in any options.\n\n```elixir\n\u003c%= pagination_links @conn, @page, [], distance: 5, next: \"\u003e\u003e\", previous: \"\u003c\u003c\", first: true, last: true, view_style: :bootstrap %\u003e\n# Which is the same as\n\u003c%= pagination_links @conn, @page %\u003e\n```\n\nTo prevent HTML escaping (i.e. seeing things like `\u0026lt;` on the page), simply use `Phoenix.HTML.raw/1` for any `\u0026amp;` strings passed in, like so:\n\n```elixir\n\u003c%= pagination_links @conn, @page, previous: Phoenix.HTML.raw(\"\u0026leftarrow;\"), next: Phoenix.HTML.raw(\"\u0026rightarrow;\") %\u003e\n```\n\nTo show icons instead of text, simply render custom html templates, like:\n\n_(this example uses materialize icons)_\n\n```elixir\n# Using Phoenix.HTML's sigil_E for EEx\n\u003c%= pagination_links @conn, @page, previous: ~E(\u003ci class=\"material-icons\"\u003echevron_left\u003c/i\u003e), next: ~E(\u003ci class=\"material-icons\"\u003echevron_right\u003c/i\u003e) %\u003e\n# Or by calling render\n\u003c%= pagination_links @conn, @page, previous: render(\"pagination.html\", direction: :prev), next: render(\"pagination.html\", direction: :next)) %\u003e\n```\n\nThe same can be done for first/last links as well (`v1.7.0` or higher).\n\n_(this example uses materialize icons)_\n\n```elixir\n\u003c%= pagination_links @conn, @page, first: ~E(\u003ci class=\"material-icons\"\u003echevron_left\u003c/i\u003e), last: ~E(\u003ci class=\"material-icons\"\u003echevron_right\u003c/i\u003e) %\u003e\n```\n\n## View Styles\n\nThere are six view styles currently supported:\n\n- `:bootstrap` (the default) This styles the pagination links in a manner that\n  is expected by Bootstrap 3.x.\n- `:bootstrap_v4` This styles the pagination links in a manner that\n  is expected by Bootstrap 4.x.\n- `:foundation` This styles the pagination links in a manner that is expected\n  by Foundation for Sites 6.x.\n- `:semantic` This styles the pagination links in a manner that is expected by\n  Semantic UI 2.x.\n- `:materialize` This styles the pagination links in a manner that\n  is expected by Materialize css 0.x.\n- `:bulma` This styles the pagination links in a manner that is expected by Bulma 0.4.x, using the `is-centered` as a default.\n\n## Extending\n\nFor custom HTML output, see `Scrivener.HTML.raw_pagination_links/2`.\n\nSee `Scrivener.HTML.raw_pagination_links/2` for option descriptions.\n\nScrivener.HTML can be included in your view and then just used with a simple call to `pagination_links/1`.\n\n```elixir\niex\u003e Scrivener.HTML.pagination_links(%Scrivener.Page{total_pages: 10, page_number: 5}) |\u003e Phoenix.HTML.safe_to_string()\n\"\u003cnav\u003e\n  \u003cul class=\\\"pagination\\\"\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=4\\\"\u003e\u0026lt;\u0026lt;\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=1\\\"\u003e1\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=2\\\"\u003e2\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=3\\\"\u003e3\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=4\\\"\u003e4\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"active\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=5\\\"\u003e5\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=6\\\"\u003e6\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=7\\\"\u003e7\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=8\\\"\u003e8\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=9\\\"\u003e9\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=10\\\"\u003e10\u003c/a\u003e\u003c/li\u003e\n    \u003cli class=\\\"\\\"\u003e\u003ca class=\\\"\\\" href=\\\"?page=6\\\"\u003e\u0026gt;\u0026gt;\u003c/a\u003e\u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/nav\u003e\"\n```\n\n## SEO\n\nSEO attributes like `rel` are automatically added to pagination links. In addition, a helper for header `\u003clink\u003e` tags is available (`v1.7.0` and higher) to be placed in the `\u003chead\u003e` tag.\n\nSee `Scrivener.HTML.SEO` documentation for more information.\n","funding_links":[],"categories":["Framework Components"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgwidmann%2Fscrivener_html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmgwidmann%2Fscrivener_html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmgwidmann%2Fscrivener_html/lists"}