slug: Type-safe slugs for Yesod ecosystem

[ bsd3, deprecated, library, web, yesod ] [ Propose Tags ]
Deprecated

Type-safe slugs for Yesod ecosystem.


[Skip to Readme]

Modules

[Index]

Flags

Manual Flags

NameDescriptionDefault
dev

Turn on development settings.

Disabled

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.1.6, 0.1.7
Change log CHANGELOG.md
Dependencies aeson (>=0.8 && <1.5), base (>=4.7 && <5.0), exceptions (>=0.6 && <0.11), http-api-data (>=0.2 && <0.4), path-pieces (>=0.1.5 && <0.3), persistent (>=2.0 && <3.0), QuickCheck (>=2.4 && <3.0), semigroups (>=0.18 && <0.19), text (>=1.0 && <1.3) [details]
License BSD-3-Clause
Author Mark Karpov <markkarpov92@gmail.com>
Maintainer Mark Karpov <markkarpov92@gmail.com>
Revised Revision 4 made by mrkkrp at 2018-06-12T16:14:22Z
Category Web, Yesod
Home page https://github.com/mrkkrp/slug
Bug tracker https://github.com/mrkkrp/slug/issues
Source repo head: git clone https://github.com/mrkkrp/slug.git
Uploaded by mrkkrp at 2017-07-22T08:33:43Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 5226 total (29 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2017-07-22 [all 1 reports]

Readme for slug-0.1.7

[back to package description]

Slug

License BSD3 Hackage Stackage Nightly Stackage LTS Build Status Coverage Status

This is a slug implementation that plays nicely with the Yesod ecosystem. Although it's fairly easy to write this thing, slugs are useful and general enough to be coded once and be used again and again. So this little package eliminates some boilerplate you might find yourself writing.

Quick start

The package provides the data type Slug that is an instance of various type classes, so it can be used with Persistent or as a part of a route. It also works with the aeson package.

The slugs are completely type-safe. When you have a Slug, you can be sure that there is a valid slug inside. Valid slug has the following qualities:

  • it's not empty;

  • it consists only of alpha-numeric groups of characters (words) separated by '-' dashes in such a way that entire slug cannot start or end in a dash and also two dashes in a row cannot be found;

  • every character with defined notion of case is lower-cased.

To use the package with persistent models, just import Web.Slug and add it to model file:

MyEntity
  slug Slug
  …

Use it in route file like this:

/post/#Slug PostR GET

In Haskell code, create slugs from Text with mkSlug and extract their textual representation with unSlug. The following property holds:

mkSlug = mkSlug >=> mkSlug . unSlug

License

Copyright © 2015–2017 Mark Karpov

Distributed under BSD 3 clause license.