diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7c68b07 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# https://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000..b79b995 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,19 @@ +--- +name: Bug report +about: Report an issue +title: "" +labels: bug +assignees: "" +--- + +**Describe the bug** +A clear and concise description of the bug. + +**To Reproduce** +A minimal code example (preferably a runnable example on [Try PureScript](https://try.purescript.org)!) or steps to reproduce the issue. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/change-request.md b/.github/ISSUE_TEMPLATE/change-request.md new file mode 100644 index 0000000..a2ee685 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/change-request.md @@ -0,0 +1,21 @@ +--- +name: Change request +about: Propose an improvement to this library +title: "" +labels: "" +assignees: "" +--- + +**Is your change request related to a problem? Please describe.** +A clear and concise description of the problem. + +Examples: + +- It's frustrating to have to [...] +- I was looking for a function to [...] + +**Describe the solution you'd like** +A clear and concise description of what a good solution to you looks like, including any solutions you've already considered. + +**Additional context** +Add any other context about the change request here. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..c47a263 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: PureScript Discourse + url: https://discourse.purescript.org/ + about: Ask and answer questions here. + - name: Functional Programming Slack + url: https://functionalprogramming.slack.com + about: For casual chat and questions (use https://fpchat-invite.herokuapp.com to join). diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..d8780f7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,11 @@ +**Description of the change** +Clearly and concisely describe the purpose of the pull request. If this PR relates to an existing issue or change proposal, please link to it. Include any other background context that would help reviewers understand the motivation for this PR. + +--- + +**Checklist:** + +- [ ] Added the change to the changelog's "Unreleased" section with a link to this PR and your username +- [ ] Linked any existing issues or proposals that this pull request should close +- [ ] Updated or added relevant documentation in the README and/or documentation directory +- [ ] Added a test for the contribution (if applicable) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6b0550f --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up a PureScript toolchain + uses: purescript-contrib/setup-purescript@main + + - name: Cache PureScript dependencies + uses: actions/cache@v2 + with: + key: ${{ runner.os }}-spago-${{ hashFiles('**/*.dhall') }} + path: | + .spago + output + + - name: Install dependencies + run: spago install + + - name: Build source + run: spago build --no-install --purs-args '--censor-lib --strict' + + - name: Run tests + run: spago test --no-install diff --git a/.gitignore b/.gitignore index 207bbb2..3456264 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,13 @@ -/.* -!/.gitignore -!/.github -!/.travis.yml +.* +!.gitignore +!.github +!.editorconfig -# Dependencies -bower_components -node_modules - -# Generated files output -dce-output generated-docs - -# Lockfiles +bower_components +node_modules package-lock.json -*.lock # Extra files public/test.js diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6da455e..0000000 --- a/.travis.yml +++ /dev/null @@ -1,23 +0,0 @@ -language: node_js -dist: trusty -sudo: required -node_js: stable -env: - - PATH=$HOME/purescript:$PATH -install: - - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest)) - - curl --location --output $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz - - tar -xvf $HOME/purescript.tar.gz -C $HOME/ - - chmod a+x $HOME/purescript - - npm install -g bower - - npm install - - bower install --production -script: - - npm run -s build - - bower install - - npm run -s test -after_success: - - >- - test $TRAVIS_TAG && - echo $GITHUB_TOKEN | pulp login && - echo y | pulp publish --no-push diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..195c9a8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,100 @@ +# Changelog + +Notable changes to this project are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +Breaking changes (😱!!!): + +New features: + +Bugfixes: + +Other improvements: + +## [v9.0.1](https://github.com/purescript-contrib/purescript-routing/releases/tag/v9.0.1) - 2020-02-09 + +- Bug fix: `param` will now remove `Query` from the internal state once all parameters have been consumed, allowing `end` to be used to disallow further parameters. + +## [v9.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v9.0.0) - 2019-03-12 + +- Updated dependencies + +## [v8.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v8.0.0) - 2018-05-28 + +- Updates for 0.12 and `Effect`. +- Removed `Match` class. + +## [v7.1.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v7.1.0) - 2018-03-22 + +- Added matcher for `NonEmptyString` +- Re-exported `Routing.Match.Class` matchers from `Routing.Match` +- Added `Routing.PushState` module for using the browser's `pushState` interface instead of hash routing. + +## [v7.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v7.0.0) - 2018-01-28 + +- Removes FFI +- Removes Aff functions +- Adds general `foldHashes` +- Removes `hashChanged` +- Changes the way `matches` works (filters failures) + +@natefaubion + +## [v6.1.2](https://github.com/purescript-contrib/purescript-routing/releases/tag/v6.1.2) - 2017-10-18 + +- Fix for parsing of URI-encoded path segments without query fragments + +## [v6.1.1](https://github.com/purescript-contrib/purescript-routing/releases/tag/v6.1.1) - 2017-10-10 + +- Fixed behaviour of query parsing so that everything past the first `?` is parsed as a query string + +## [v6.1.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v6.1.0) - 2017-10-03 + +- Added `Eq` and `Ord` instances for `RoutePart` (@coot) + +## [v6.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v6.0.0) - 2017-09-23 + +- Updated for `purescript-aff` v4.x +- Altered parsing to capture query params without a trailing `/` #37 +- Added `optionalMatch` + +All updates courtesy of @coot + +## [v5.1.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v5.1.0) - 2017-04-21 + +- Added `end` combinator @throughnothing + +## [v5.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v5.0.0) - 2017-04-10 + +- Updates for PureScript 0.11 (@coot) + +## [v4.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v4.0.0) - 2017-02-22 + +- Renamed `matchHash` and `matchHash'` to `match` and `matchWith` + +## [v3.1.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v3.1.0) - 2017-02-18 + +- Added support for matching integers in paths (@menelaos) + +## [v3.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v3.0.0) - 2016-11-03 + +- Updated for PureScript 0.10 + +## [v2.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v2.0.0) - 2016-07-31 + +- Updated dependencies + +## [v1.0.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v1.0.0) - 2016-07-04 + +Updated for PureScript 0.9 and core libraries 1.0. + +## [v0.4.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v0.4.0) - 2016-03-13 + +- Updated to latest `purescript-aff` + +## [v0.2.1](https://github.com/purescript-contrib/purescript-routing/releases/tag/v0.2.1) - 2015-12-16 + +## [v0.2.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v0.2.0) - 2015-09-23 + +## [v0.1.0](https://github.com/purescript-contrib/purescript-routing/releases/tag/v0.1.0) - 2015-07-10 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9d54ef4 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing to Routing + +Thanks for your interest in contributing to `routing`! We welcome new contributions regardless of your level of experience or familiarity with PureScript. + +Every library in the Contributors organization shares a simple handbook that helps new contributors get started. With that in mind, please [read the short contributing guide on purescript-contrib/governance](https://github.com/purescript-contrib/governance/blob/main/contributing.md) before contributing to this library. diff --git a/README.md b/README.md index 49be2e1..e53fb88 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,44 @@ -# purescript-routing +# Routing -[![Latest release](http://img.shields.io/github/release/purescript-contrib/purescript-routing.svg)](https://github.com/purescript-contrib/purescript-routing/releases) -[![Build status](https://travis-ci.org/purescript-contrib/purescript-routing.svg?branch=master)](https://travis-ci.org/purescript-contrib/purescript-routing) +[![CI](https://github.com/purescript-contrib/purescript-routing/workflows/CI/badge.svg?branch=main)](https://github.com/purescript-contrib/purescript-routing/actions?query=workflow%3ACI+branch%3Amain) +[![Release](https://img.shields.io/github/release/purescript-contrib/purescript-routing.svg)](https://github.com/purescript-contrib/purescript-routing/releases) +[![Pursuit](https://pursuit.purescript.org/packages/purescript-routing/badge)](https://pursuit.purescript.org/packages/purescript-routing) +[![Maintainer: garyb](https://img.shields.io/badge/maintainer-garyb-teal.svg)](https://github.com/garyb) +[![Maintainer: thomashoneyman](https://img.shields.io/badge/maintainer-thomashoneyman-teal.svg)](https://github.com/thomashoneyman) Client side routing library. ## Installation -```shell -bower install purescript-routing +Install `routing` with [Spago](https://github.com/purescript/spago): + +```sh +spago install routing ``` -# Module documentation +## Quick start + +The [guide](GUIDE.md) provides an overview of library's usage and implementation. + +## Documentation + +`routing` documentation is stored in a few places: + +1. Module documentation is [published on Pursuit](https://pursuit.purescript.org/packages/purescript-routing). +2. Written documentation is kept in the [docs directory](./docs). +3. Usage examples can be found in [the test suite](./test). + +If you get stuck, there are several ways to get help: + +- [Open an issue](https://github.com/purescript-contrib/purescript-routing/issues) if you have encountered a bug or problem. +- [Search or start a thread on the PureScript Discourse](https://discourse.purescript.org) if you have general questions. You can also ask questions in the `#purescript` and `#purescript-beginners` channels on the [Functional Programming Slack](https://functionalprogramming.slack.com) ([invite link](https://fpchat-invite.herokuapp.com/)). + +## Contributing + +You can contribute to `routing` in several ways: + +1. If you encounter a problem or have a question, please [open an issue](https://github.com/purescript-contrib/purescript-routing/issues). We'll do our best to work with you to resolve or answer it. -- The [guide](GUIDE.md) provides an overview of library's usage and implementation. +2. If you would like to contribute code, tests, or documentation, please [read the contributor guide](./CONTRIBUTING.md). It's a short, helpful introduction to contributing to this library, including development instructions. -- Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-routing). +3. If you have written a library, tutorial, guide, or other resource based on this package, please share it on the [PureScript Discourse](https://discourse.purescript.org)! Writing libraries and learning resources are a great way to help this library succeed. diff --git a/bower.json b/bower.json index d729be5..d11c70b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "purescript-routing", - "homepage": "https://github.com/slamdata/purescript-routing", + "homepage": "https://github.com/purescript-contrib/purescript-routing", "authors": [ "Maxim Zimaliev " ], @@ -12,7 +12,7 @@ "license": "Apache-2.0", "repository": { "type": "git", - "url": "git://github.com/slamdata/purescript-routing.git" + "url": "https://github.com/slamdata/purescript-routing.git" }, "ignore": [ "**/.*", diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..f51e647 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,3 @@ +# Routing Documentation + +This directory contains documentation for `routing`. If you are interested in contributing new documentation, please read the [contributor guidelines](../CONTRIBUTING.md) and [What Nobody Tells You About Documentation](https://documentation.divio.com) for help getting started. diff --git a/package.json b/package.json index 50e6ab1..f029ee0 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,10 @@ { "private": true, "scripts": { - "clean": "rimraf output && rimraf .pulp-cache", - "build": "pulp build -- --censor-lib --strict", - "test": "pulp test", - "test:browser": "pulp build -I test -m Test.Browser --to test/dist/bundle.js", + "test:browser": "spago bundle-app -m Test.Browser --to test/dist/bundle.js", "test:serve": "static test" }, "devDependencies": { - "node-static": "^0.7.11", - "pulp": "^14.0.0", - "purescript-psa": "^0.7.3", - "rimraf": "^3.0.2" + "node-static": "^0.7.11" } } diff --git a/packages.dhall b/packages.dhall new file mode 100644 index 0000000..80f5fe6 --- /dev/null +++ b/packages.dhall @@ -0,0 +1,4 @@ +let upstream = + https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20201007/packages.dhall sha256:35633f6f591b94d216392c9e0500207bb1fec42dd355f4fecdfd186956567b6b + +in upstream diff --git a/spago.dhall b/spago.dhall new file mode 100644 index 0000000..fef4177 --- /dev/null +++ b/spago.dhall @@ -0,0 +1,25 @@ +{ name = "routing" +, dependencies = + [ "aff" + , "assert" + , "console" + , "control" + , "effect" + , "either" + , "foldable-traversable" + , "generics-rep" + , "globals" + , "integers" + , "lists" + , "maybe" + , "prelude" + , "psci-support" + , "record" + , "semirings" + , "tuples" + , "validation" + , "web-html" + ] +, packages = ./packages.dhall +, sources = [ "src/**/*.purs", "test/**/*.purs" ] +}