{"id":15010650,"url":"https://github.com/telekid/pine","last_synced_at":"2025-04-09T18:34:25.181Z","repository":{"id":57714034,"uuid":"128964595","full_name":"telekid/pine","owner":"telekid","description":"ClojureScript routing for universal applications","archived":false,"fork":false,"pushed_at":"2018-05-07T01:03:32.000Z","size":63,"stargazers_count":4,"open_issues_count":8,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-23T20:37:14.336Z","etag":null,"topics":["clojure","clojure-library","clojurescript","clojurescript-library","router"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/telekid.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}},"created_at":"2018-04-10T16:36:02.000Z","updated_at":"2020-04-12T22:12:47.000Z","dependencies_parsed_at":"2022-09-26T21:31:12.479Z","dependency_job_id":null,"html_url":"https://github.com/telekid/pine","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telekid%2Fpine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telekid%2Fpine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telekid%2Fpine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/telekid%2Fpine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/telekid","download_url":"https://codeload.github.com/telekid/pine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248088258,"owners_count":21045671,"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":["clojure","clojure-library","clojurescript","clojurescript-library","router"],"created_at":"2024-09-24T19:35:12.363Z","updated_at":"2025-04-09T18:34:25.149Z","avatar_url":"https://github.com/telekid.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pine\n\n**__Note:__ Pine is pre-alpha software. Please don't use it in production.**\n\n[![Clojars Project](https://img.shields.io/clojars/v/telekid/pine.svg)](https://clojars.org/telekid/pine)\n[![CircleCI](https://img.shields.io/circleci/project/github/telekid/pine/master.svg)](https://circleci.com/gh/telekid/pine/tree/master)\n![Last Released](https://img.shields.io/github/last-commit/google/skia.svg)\n\nFor a proof-of-concept re-frame application that makes use of pine, see [Pine App](https://github.com/telekid/pine-app).\n\n## Overview\n\nPine is a ClojureScript router designed for universal applications.\n\n### Motivation\n\nTraditional routers compare URLs against a set of route definitions, and return a single handler (or keyword) when they find a match.\n\nPine works a bit differently. Rather than returning a single match result, Pine returns a Clojure set containing the matched route, _along with all of its ancestors_.\n\nLet's look at an example. Here's a code snippet that defines a few routes in Bidi and then matches against them:\n```clojure\n;; define three routes\n(def routes\n  [\"\" {\"/users\" {\"\" :users\n                 [\"/\" :id] {\"\" :user\n                            \"/delete\" :delete-user}}}])\n                            \n;; match a few routes\nuser\u003e (match-route \"/users\" routes)\n{:handler :users}\n\nuser\u003e (match-route \"/users/123\" routes)\n{:handler :user :route-params {:id 123}}\n\nuser\u003e (match-route \"/users/123/delete\" routes)\n{:handler :delete-user :route-params {:id 123}}\n```\n\nNote that Bidi returns the `:handler` (a keyword in this case) and its associated `:route-params`.\n\nPine's `match-route` function returns some additional information:\n\n```clojure\n;; define three routes\n;; (note: this API is subject to change)\n(def routes [{:route-id :users\n              :test-path \"/users\"\n              :routes [{:route-id :user\n                        :test-path [\"/\" :id]\n                        :routes [{:route-id :delete-user\n                                  :test-path \"/delete\"}]}]}])\n\n;; match a few routes\nuser\u003e (match-route \"/users\" routes)\n{:active #{:users}}\nuser\u003e (match-route \"/users/123\" routes)\n{:active #{:users :user} :params {:user {:id 123}}}\nuser\u003e (match-route \"/users\" routes)\n{:active #{:users :user :delete-user} :params {:user {:id 123}}}\n```\n\nNote that `:active` (Pine's equivalent of Bidi's `:handler`) contains a set of all active routes.\n\n### Why is this helpful?\n\nRetaining ancestors makes certain tasks much easier:\n\n- Automatically showing / hiding components in your view tree based on the current route.\n- Conditionally styling links based upon the \"active\" status of their descendents (a la UI Router's [ui-sref-active](https://ui-router.github.io/ng1/docs/0.4.2/#/api/ui.router.state.directive:ui-sref-active) directive.)\n- Dispatching leave/retain/enter events when transitioning across route tree states.\n\n...and more! I just haven't had a chance to write them all up yet.\n\n\n## Additional Features\n\n- Pine supports bi-directional routing. In other words, it can both generate URLs from an active route and its params, and return a set of active routes and params from a given URL.\n- Routes are defined in data, not code. In larger applications, it should be convenient to store them in an EDN file.\n\n\n## Inspiration\n\nPine borrows heavily from and is inspired by the amazing [Bidi](https://github.com/juxt/bidi) and [UI Router](https://github.com/ui-router/core) libraries.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelekid%2Fpine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftelekid%2Fpine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftelekid%2Fpine/lists"}