Permalink
Browse files

More notes

  • Loading branch information...
dzhus committed Apr 5, 2012
1 parent 12ce688 commit 2208daf6a016669bb0ea31e406c13c7681f8470a
View
@@ -9,7 +9,10 @@
collection of fields with certain extra annotations. Every filled
form («instance of model») has unique ID when stored in Redis.
- Models must be defined prior to usage with special syntax.
+ Models must be defined prior to usage with special syntax, which may
+ also be requested by client code to build interface for models
+ (using JavaScript templating, for example).
+
Transparent mode is supported in which model definitions are not
checked, but permissions engine is unavailable as well. Certain
transformations may be applied to model definition by server and
View
@@ -1,6 +1,35 @@
name: snaplet-redson
version: 0.1.0.0
synopsis: CRUD for JSON data with Redis storage
+
+description: This snaplet provides HTTP API to /c/reate, /r/ead,
+ /u/pdate and /d/elete JSON objects sent by client
+ and stored in Redis key-value cache. CRUD methods
+ are mapped to HTTP `POST`, `GET`, `PUT` and
+ `DELETE`. Valid objects are described using model
+ definition syntax, which includes information on
+ fields and permissions. The snaplet supports
+ role-based user permissions system as implemented
+ by Snap authentication. Model definitions may
+ also be used by browser JavaScript to provide
+ interface to create or edit objects.
+
+ There is a permission-less transparent mode,
+ WebSocket create/delete notifications and
+ timeline method to serve information about
+ recently added objects. Ad-hoc search is
+ implemented in Redis and provided via snaplet
+ route.
+
+ There's a "snapless" part of the package, which
+ implements Snap-agnostic Redis CRUD operations
+ for key-value pair collections and may be used
+ for tools which operate with storage directly
+ without using web framework.
+
+ More of usage documentation is contained in
+ <https://github.com/dzhus/snaplet-redson/blob/master/README.org>
+
homepage: https://github.com/dzhus/snaplet-redson/
bug-reports: https://github.com/dzhus/snaplet-redson/issues/
license: BSD3
View
@@ -473,7 +473,18 @@ routes = [ (":model/timeline", method GET timeline)
------------------------------------------------------------------------------
--- | Connect to Redis and set routes.
+-- | Initialize Redson. AuthManager from parent snaplet is required.
+--
+-- Connect to Redis, read configuration and set routes.
+--
+-- > appInit :: SnapletInit MyApp MyApp
+-- > appInit = makeSnaplet "app" "App with Redson" Nothing $
+-- > do
+-- > r <- nestSnaplet "_" redson $ redsonInit auth
+-- > s <- nestSnaplet "session" session $ initCookieSessionManager
+-- > sesKey "_session" sessionTimeout
+-- > a <- nestSnaplet "auth" auth $ initJsonFileAuthManager defAuthSettings
+-- > return $ MyApp r s a
redsonInit :: Lens b (Snaplet (AuthManager b))
-> SnapletInit b (Redson b)
redsonInit topAuth = makeSnaplet
@@ -2,7 +2,8 @@
{-|
-Snap-agnostic low-level CRUD operations.
+Snap-agnostic low-level CRUD operations. No model definitions are used
+on this level. Instead, objects must be
This module may be used for batch uploading of database data.
@@ -184,6 +184,7 @@ instance FromJSON Application where
parseJSON _ = error "Could not parse application entry"
+-- | A named group of fields.
type Groups = M.Map B.ByteString [Field]
@@ -197,8 +198,8 @@ groupFieldName :: FieldName
groupFieldName parent field = B.concat [parent, "_", field]
--- | Replace all model fields having `group` type with actual group
--- fields.
+-- | Replace all model fields having `groupName` annotation with
+-- actual group fields.
spliceGroups :: Groups -> Model -> Model
spliceGroups groups model =
let

0 comments on commit 2208daf

Please sign in to comment.