Skip to content

Commit

Permalink
Fix all sorts of minor issues
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.science.uu.nl/repos/edu.3555003.wiskunded/trunk@124 46e4088a-c2b5-4d24-90db-838aeec2e325
  • Loading branch information
3555003 committed Apr 27, 2011
1 parent c7b610e commit f24a3fa
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 23 deletions.
27 changes: 25 additions & 2 deletions JCU.cabal
Expand Up @@ -41,9 +41,24 @@ Executable jcu
containers >= 0.4,
transformers >= 0.2,
attoparsec >= 0.8.5 && < 0.9,
ListLike >= 3.1 && < 3.2
ListLike >= 3.1 && < 3.2,

extensions: TypeSynonymInstances MultiParamTypeClasses
-- For Snap stuff, until it hits Hackage
cereal >= 0.3 && < 0.4,
syb >= 0.3 && < 0.4,
clientsession >= 0.4.1 && < 0.5,
haskell98 >= 1.1 && < 1.2,
Crypto >= 4.2.3 && < 4.3,
safe >= 0.3 && < 0.4,
compact-string-fix >= 0.3.1 && < 0.4

extensions:
TypeSynonymInstances
, OverloadedStrings
, MultiParamTypeClasses
, FunctionalDependencies
, DeriveDataTypeable
, FlexibleInstances

if flag(development)
cpp-options: -DDEVELOPMENT
Expand All @@ -63,6 +78,14 @@ Executable jcu
-fno-warn-orphans

Library
extensions:
TypeSynonymInstances
, OverloadedStrings
, MultiParamTypeClasses
, FunctionalDependencies
, DeriveDataTypeable
, FlexibleInstances

Build-Depends: base >= 4.0 && < 5.0
Hs-Source-Dirs: src
Exposed-modules: JCU.Prolog.Types, JCU.Prolog.Parser, JCU.Prolog.Prolog,
Expand Down
1 change: 0 additions & 1 deletion resources/static/brunch/src/app/views/home_view.coffee
Expand Up @@ -23,7 +23,6 @@ class exports.HomeView extends Backbone.View
txtAddRule = @$('#txtAddRule')
txtVal = txtAddRule.val()

# TODO: Make this actually work
newRule = new Rule({id: "", rule: txtVal})

if newRule.validate()
Expand Down
40 changes: 24 additions & 16 deletions resources/static/brunch/src/vendor/backbone-master.js
Expand Up @@ -28,11 +28,11 @@
Backbone.VERSION = '0.3.3';

// Require Underscore, if we're on the server, and it's not already present.
var _ = root._ || root.$;
var _ = root._;
if (!_ && (typeof require !== 'undefined')) _ = require('underscore')._;

// For Backbone's purposes, jQuery, Zepto, or Ender owns the `$` variable.
var $ = root.jQuery || root.Zepto || root.$;
// For Backbone's purposes, jQuery or Zepto owns the `$` variable.
var $ = root.jQuery || root.Zepto;

// Runs Backbone.js in *noConflict* mode, returning the `Backbone` variable
// to its previous owner. Returns a reference to this Backbone object.
Expand Down Expand Up @@ -267,15 +267,23 @@
return this;
},

checkResponse : function(resp) {
var ty = typeof(resp);
if (ty && ty != "object") {
throw 'Invalid response received from server. Expected an object, but received a ' + ty;
}
return resp;
},

// Fetch the model from the server. If the server's representation of the
// model differs from its current attributes, they will be overriden,
// triggering a `"change"` event.
fetch : function(options) {
options || (options = {});
var model = this;
var success = options.success;
options.success = function(resp) {
if (!model.set(model.parse(resp), options)) return false;
options.success = function(resp, status, xhr) {
if (!model.set(model.checkResponse(model.parse(resp, xhr), options))) return false;
if (success) success(model, resp);
};
options.error = wrapError(options.error, model, options);
Expand All @@ -290,9 +298,9 @@
if (attrs && !this.set(attrs, options)) return false;
var model = this;
var success = options.success;
options.success = function(resp) {
if (!model.set(model.parse(resp), options)) return false;
if (success) success(model, resp);
options.success = function(resp, status, xhr) {
if (!model.set(model.checkResponse(model.parse(resp, xhr), options))) return false;
if (success) success(model, resp, xhr);
};
options.error = wrapError(options.error, model, options);
var method = this.isNew() ? 'create' : 'update';
Expand Down Expand Up @@ -324,7 +332,7 @@

// **parse** converts a response into the hash of attributes to be `set` on
// the model. The default implementation is just to pass the response along.
parse : function(resp) {
parse : function(resp, xhr) {
return resp;
},

Expand Down Expand Up @@ -514,8 +522,8 @@
options || (options = {});
var collection = this;
var success = options.success;
options.success = function(resp) {
collection[options.add ? 'add' : 'refresh'](collection.parse(resp), options);
options.success = function(resp, status, xhr) {
collection[options.add ? 'add' : 'refresh'](collection.parse(resp, xhr), options);
if (success) success(collection, resp);
};
options.error = wrapError(options.error, collection, options);
Expand All @@ -530,22 +538,22 @@
if (!(model instanceof Backbone.Model)) {
var attrs = model;
model = new this.model(null, {collection: coll});
if (!model.set(attrs)) return false;
if (!model.set(attrs, options)) return false;
} else {
model.collection = coll;
}
var success = options.success;
options.success = function(nextModel, resp) {
options.success = function(nextModel, resp, xhr) {
coll.add(nextModel);
if (success) success(nextModel, resp);
if (success) success(nextModel, resp, xhr);
};
model.save(null, options);
return model;
},

// **parse** converts a response into a list of models to be added to the
// collection. The default implementation is just to pass it through.
parse : function(resp) {
parse : function(resp, xhr) {
return resp;
},

Expand Down Expand Up @@ -730,7 +738,7 @@
};

// Cached regex for cleaning hashes.
var hashStrip = /^#*/;
var hashStrip = /^#*!?/;

// Cached regex for detecting MSIE.
var isExplorer = /msie [\w.]+/;
Expand Down
4 changes: 2 additions & 2 deletions resources/templates/signup.tpl
@@ -1,9 +1,9 @@
<apply template="layout">
<h1>Please login</h1>
<h1>Please Sign Up</h1>
<form method="post" action="/signup">
<table>
<tr>
<td>Username</td><td><input type="text" name="email" /></td>
<td>Email address</td><td><input type="text" name="email" /></td>
</tr>
<tr>
<td>Password</td><td><input type="password" name="password" /></td>
Expand Down
5 changes: 3 additions & 2 deletions src/JCU/Web/Handlers.hs
Expand Up @@ -90,7 +90,7 @@ data FormField = FormField { isRequired :: Bool
-- much better suited for validation than this...
formValidator :: FormValidator
formValidator = [ ("email", FormField True (E.isValid . unpack))
, ("password", FormField True (\xs -> B.length xs > 6)) ]
, ("password", FormField True (\xs -> B.length xs >= 6)) ]

valForm :: Ord k => Map k [ByteString] -> (k, FormField) -> Bool
valForm parms (fld, FormField req val) | fld `member` parms = val $ head (parms ! fld)
Expand All @@ -105,6 +105,7 @@ signupH = do
then do email <- getParam "email"
pwd <- getParam "password"
let u = makeUser email pwd
trace (show u) (return ())
au <- saveAuthUser (authUser u, additionalUserFields u)
case au of
Nothing -> newSignupH
Expand Down Expand Up @@ -148,7 +149,7 @@ addStoredRuleH :: Application ()
addStoredRuleH = do-- TODO restrict forbiddenH $ do
rule <- getRequestBody
trace ("addStoredRuleH: " ++ show rule)
(writeLBS "{}")
(writeLBS "")

checkRulesH :: Application ()
checkRulesH = do-- TODO restrict forbiddenH $ do
Expand Down
1 change: 1 addition & 0 deletions src/JCU/Web/Types.hs
Expand Up @@ -17,6 +17,7 @@ import JCU.Prolog.Parser
data User = User { authUser :: AuthUser
, storedRules :: [ByteString]
, inuseRules :: [ByteString] }
deriving Show

instance ToJSON Rule where
toJSON t = let txt = show t
Expand Down

0 comments on commit f24a3fa

Please sign in to comment.