Browse code
Redoing auth
fiddlerwoaroof authored on 11/09/2015 02:40:08
Showing 12 changed files
Showing 12 changed files
- db/functions.sql
- src/marrow/bone.py
- static/css/main.css
- static/js/new/controller.js
- static/parenscript/LoginCtrl.js
- static/parenscript/LoginCtrl.ps
- static/parenscript/RootCtrl.ps
- static/parenscript/a1
- static/parenscript/buildapp
- static/parenscript/models.lisp
- static/parenscript/translator
- static/partials/login.html
... | ... |
@@ -373,14 +373,7 @@ AS $$ |
373 | 373 |
DECLARE |
374 | 374 |
result bigint; |
375 | 375 |
BEGIN |
376 |
- WITH votes_for as ( |
|
377 |
- SELECT |
|
378 |
- DISTINCT ON (link_votes.link_id, link_votes.user_id) |
|
379 |
- vote FROM link_votes INTO result |
|
380 |
- INNER JOIN user_links ON link_votes.link_id=user_links.link_id |
|
381 |
- WHERE user_links.user_id=uid AND link_votes.user_id!=user_links.user_id |
|
382 |
- ORDER BY link_votes.link_id, link_votes.user_id, voted DESC |
|
383 |
- ) SELECT sum(vote) FROM votes_for; |
|
376 |
+ SELECT sum(total_votes(link_id)) INTO result FROM user_links WHERE user_id = uid; |
|
384 | 377 |
IF result IS NULL AND exists(SELECT 1 FROM users WHERE id=uid LIMIT 1) THEN |
385 | 378 |
SELECT 0 INTO result; |
386 | 379 |
END IF; |
... | ... |
@@ -161,8 +161,8 @@ def data(username): |
161 | 161 |
cur.execute("SELECT url, title, posted, linkid, votes from get_bone(%s);", (username,)) |
162 | 162 |
result['marrow'] = [ |
163 | 163 |
dict(id=linkid, url=url,title=title,posted=posted.isoformat(),votes=votes) |
164 |
- for url,title,posted,linkid,votes |
|
165 |
- in cur.fetchall() |
|
164 |
+ for url,title,posted,linkid,votes |
|
165 |
+ in cur.fetchall() |
|
166 | 166 |
] |
167 | 167 |
return json.dumps(result) |
168 | 168 |
|
... | ... |
@@ -331,7 +331,7 @@ main form { |
331 | 331 |
padding: 10px 0; |
332 | 332 |
} |
333 | 333 |
main form input[type="text"] { |
334 |
- width: 315px; |
|
334 |
+ width: 100%; |
|
335 | 335 |
} |
336 | 336 |
|
337 | 337 |
.more-link { |
... | ... |
@@ -357,28 +357,138 @@ main form input[type="text"] { |
357 | 357 |
/* @end */ |
358 | 358 |
|
359 | 359 |
/* @group Login Module */ |
360 |
+#login_form .tab { |
|
361 |
+ text-align: center; |
|
362 |
+ background: white; |
|
363 |
+ position:absolute; |
|
364 |
+ width: 39vw; |
|
365 |
+ height: 39vh; |
|
366 |
+ padding: 3vh 3vw; |
|
367 |
+ margin-left: 13vw; |
|
368 |
+ overflow: hidden; |
|
369 |
+ z-index: 0; |
|
370 |
+ border: 1px solid black; |
|
371 |
+} |
|
360 | 372 |
|
361 |
-#login_form div.message{ |
|
362 |
- position: absolute; |
|
363 |
- background: red; |
|
373 |
+.relCont::after { |
|
374 |
+ content: " "; |
|
375 |
+ clear: both; |
|
376 |
+ overflow: hidden; |
|
377 |
+} |
|
378 |
+ |
|
379 |
+.relCont { |
|
380 |
+ position: relative; |
|
381 |
+} |
|
382 |
+ |
|
383 |
+#login_form .tab.front { |
|
384 |
+ z-index: 1; |
|
385 |
+} |
|
386 |
+ |
|
387 |
+#login_form .message{ |
|
388 |
+ /*position: absolute;*/ |
|
364 | 389 |
width: 100%; |
390 |
+ height: 2em; |
|
365 | 391 |
text-align: center; |
392 |
+ visibility: hidden; |
|
366 | 393 |
} |
367 | 394 |
|
395 |
+#login_form div.error { |
|
396 |
+ background: red; |
|
397 |
+ visibility: visible; |
|
398 |
+} |
|
399 |
+ |
|
400 |
+#login_form button { |
|
401 |
+ bottom: 2em; |
|
402 |
+ min-width: 33%; |
|
403 |
+ margin-top: 1.5em; |
|
404 |
+ padding: 1em; |
|
405 |
+ font-size: 2rem; |
|
406 |
+ color: white; |
|
407 |
+ background: blue; |
|
408 |
+ text-transform: uppercase; |
|
409 |
+ background-image: linear-gradient(transparent, #003 90%); |
|
410 |
+} |
|
411 |
+ |
|
412 |
+#login_form ul, #login_form li { |
|
413 |
+ list-style: none; |
|
414 |
+ display: inline-block; |
|
415 |
+ color: black; |
|
416 |
+} |
|
417 |
+ |
|
418 |
+#login_form ul { |
|
419 |
+ z-index: 2; |
|
420 |
+ margin-bottom: 0px; |
|
421 |
+ width: 33vw; |
|
422 |
+} |
|
423 |
+ |
|
424 |
+#login_form #tab-choice { |
|
425 |
+ margin-left: 13vw; |
|
426 |
+ /*margin-bottom: 2em;*/ |
|
427 |
+} |
|
428 |
+ |
|
429 |
+#login_form input[type=radio] { |
|
430 |
+ display: none; |
|
431 |
+} |
|
432 |
+ |
|
433 |
+#login_form input[type=radio] + label { |
|
434 |
+ font-size: 1.5rem; |
|
435 |
+ cursor: pointer; |
|
436 |
+ border: 1px solid black; |
|
437 |
+ background: #aaa; |
|
438 |
+ padding: 0.25em; |
|
439 |
+ padding-bottom: 0em; |
|
440 |
+ margin-right: 0.5em; |
|
441 |
+ margin-bottom: -3px; |
|
442 |
+ z-index: 5; |
|
443 |
+} |
|
444 |
+ |
|
445 |
+#login_form input[type=radio]:checked + label { |
|
446 |
+ background: white; |
|
447 |
+ border-bottom-color: white; |
|
448 |
+ z-index: 3 |
|
449 |
+} |
|
450 |
+ |
|
451 |
+/* |
|
368 | 452 |
#login_form { |
369 | 453 |
position: absolute; |
370 | 454 |
z-index: 100; |
371 | 455 |
height: 100%; |
372 | 456 |
background: white; |
373 | 457 |
} |
458 |
+*/ |
|
459 |
+ |
|
374 | 460 |
#login_form form { |
375 |
- position: absolute; |
|
376 |
- top: 0; |
|
461 |
+ text-align: center; |
|
462 |
+} |
|
463 |
+ |
|
464 |
+ |
|
465 |
+#login_form div.message{ |
|
466 |
+} |
|
467 |
+ |
|
468 |
+#login_form form { |
|
469 |
+ margin-top: 100px; |
|
470 |
+} |
|
471 |
+ |
|
472 |
+#login_form { |
|
473 |
+ width: 100%; |
|
377 | 474 |
left: 0; |
475 |
+ top: 0; |
|
476 |
+} |
|
477 |
+ |
|
478 |
+#login_form form { |
|
479 |
+ margin-top: 20px; |
|
480 |
+} |
|
481 |
+ |
|
482 |
+#login_form div.message{ |
|
483 |
+ margin-top 10px; |
|
484 |
+} |
|
485 |
+ |
|
486 |
+form input[type="password"] { |
|
378 | 487 |
width: 100%; |
379 |
- text-align: center; |
|
380 | 488 |
} |
381 | 489 |
|
490 |
+ |
|
491 |
+ |
|
382 | 492 |
/* @end */ |
383 | 493 |
|
384 | 494 |
/* @group Form Validation */ |
... | ... |
@@ -464,18 +574,6 @@ main > section { |
464 | 574 |
text-align: right; |
465 | 575 |
padding-right: 5px; |
466 | 576 |
} |
467 |
- |
|
468 |
- #login_form { |
|
469 |
- width: 125%; |
|
470 |
- left: -25%; |
|
471 |
- top: 66px; |
|
472 |
- } |
|
473 |
- #login_form div.message{ |
|
474 |
- top: -33px; |
|
475 |
- } |
|
476 |
- #login_form form { |
|
477 |
- margin-top: 100px; |
|
478 |
- } |
|
479 | 577 |
|
480 | 578 |
} |
481 | 579 |
|
... | ... |
@@ -584,19 +682,6 @@ a.user-settings:hover { |
584 | 682 |
border-top: 1px solid #ddd; |
585 | 683 |
} |
586 | 684 |
|
587 |
- #login_form { |
|
588 |
- width: 100%; |
|
589 |
- left: 0; |
|
590 |
- top: 0; |
|
591 |
- } |
|
592 |
- #login_form form { |
|
593 |
- margin-top: 20px; |
|
594 |
- } |
|
595 |
- #login_form div.message{ |
|
596 |
- margin-top 10px; |
|
597 |
- } |
|
598 |
- form input[type="password"] { |
|
599 |
- } |
|
600 | 685 |
|
601 | 686 |
main::before { |
602 | 687 |
display: block; |
... | ... |
@@ -16,11 +16,13 @@ marrowApp.config(['$routeProvider', |
16 | 16 |
marrowApp.config(['$locationProvider', function($locationProvider) { $locationProvider.html5Mode(true); }]); |
17 | 17 |
|
18 | 18 |
marrowApp.controller('LoginCtrl', function ($scope,$http,$route,$location) { |
19 |
+ $scope.tab = 'login'; |
|
20 |
+ |
|
19 | 21 |
$scope.message = ''; |
20 | 22 |
|
21 | 23 |
var check_login = function () { |
22 |
- injector = angular.injector(['ng']); |
|
23 |
- $http = injector.get('$http'); |
|
24 |
+ var injector = angular.injector(['ng']); |
|
25 |
+ var $http = injector.get('$http'); |
|
24 | 26 |
return $http.get("/api/user/check").success(function(is_loggedon) { |
25 | 27 |
if (is_loggedon.result === true) { |
26 | 28 |
angular.element(document.body).addClass('is-logged-on'); |
27 | 29 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,31 @@ |
1 |
+var test = angular.module(test, ngroute()); |
|
2 |
+test.controller('LoginCtrl', function ($scope) { |
|
3 |
+ $scope.tab = 'login'; |
|
4 |
+ $scope.message = ''; |
|
5 |
+ function check_login() { |
|
6 |
+ var injector26 = angular.injector('ng'()); |
|
7 |
+ var $http = injector26.get('$http'); |
|
8 |
+ return $http.get('/api/user/check')(null).success(function (is_loggedon) { |
|
9 |
+ return is_loggedon.result === true ? angular.element(document.body).addclass('is-logged-on') : null; |
|
10 |
+ }); |
|
11 |
+ }; |
|
12 |
+ check_login().success(function (is_loggedon) { |
|
13 |
+ return is_loggedon.result ? $location.url('/') : null; |
|
14 |
+ }); |
|
15 |
+ $scope.newuser = function () { |
|
16 |
+ var username27 = $scope.username; |
|
17 |
+ var password28 = $scope.password; |
|
18 |
+ var postobj = { 'username' : username27, 'password' : password28 }; |
|
19 |
+ return $http.post('/api/user/add')(postobj).success(function (is_l) { |
|
20 |
+ return is_l.result === true ? $location.url('/') : ($scope.message = added_user.message); |
|
21 |
+ }); |
|
22 |
+ }; |
|
23 |
+ return $scope.login = function () { |
|
24 |
+ var username29 = $scope.username; |
|
25 |
+ var password30 = $scope.password; |
|
26 |
+ return $http.post('/api/user/login')({ 'username' : username29, 'password' : password30 }).success(function (login_succeeded) { |
|
27 |
+ var el = angular.element(document.queryselector('#login_form')); |
|
28 |
+ return login_succeeded.status === true ? $location.url('/') : ($scope.message = login_succeeded.message)(); |
|
29 |
+ }); |
|
30 |
+ }; |
|
31 |
+}); |
0 | 32 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,37 @@ |
1 |
+(def-module login-module '("ngRoute")) |
|
2 |
+(defcontroller login-module "LoginCtrl" ($http) |
|
3 |
+ (scope-var tab "login") |
|
4 |
+ (scope-var message "") |
|
5 |
+ |
|
6 |
+ (defun check_login () |
|
7 |
+ (ng-ajax get "/api/user/check" nil is_loggedon |
|
8 |
+ (if (eql (@ is_loggedon result) T) |
|
9 |
+ (chain angular |
|
10 |
+ (element (@ document body)) |
|
11 |
+ (add-class "is-logged-on"))) |
|
12 |
+ nil)) |
|
13 |
+ |
|
14 |
+ (chain (check_login) |
|
15 |
+ (success |
|
16 |
+ (lambda (is_loggedon) |
|
17 |
+ (if (@ is_loggedon result) |
|
18 |
+ (chain $location (url "/"))) |
|
19 |
+ nil))) |
|
20 |
+ |
|
21 |
+ (scope-function newuser () |
|
22 |
+ (with-slots (username password) $scope |
|
23 |
+ (let* ((postObj (create :username username :password password))) |
|
24 |
+ (ng-ajax post "/api/user/add" postObj is_l |
|
25 |
+ (if (eql (@ is_l result) T) |
|
26 |
+ (chain $location (url "/")) |
|
27 |
+ (setf ($s message) (@ added_user message))) |
|
28 |
+ nil)))) |
|
29 |
+ |
|
30 |
+ (scope-function login () |
|
31 |
+ (with-slots (username password) $scope |
|
32 |
+ (ng-ajax post "/api/user/login" (create :username username :password password) login_succeeded |
|
33 |
+ (let ((el (select->element "#login_form"))) |
|
34 |
+ (if (eql (@ login_succeeded status) T) |
|
35 |
+ (chain $location (url "/")) |
|
36 |
+ (scope-var message (@ login_succeeded message))) |
|
37 |
+ nil))))) |
0 | 38 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,71 @@ |
1 |
+(def-module root-module '("ngRoute")) |
|
2 |
+(defcontroller root-module "RootCtrl" ($http $location $route -subscribed-to -bone-service -user-service) |
|
3 |
+ (scope-var url "") |
|
4 |
+ (scope-var title "") |
|
5 |
+ |
|
6 |
+ (scope-function toggle-subscribe (txt) |
|
7 |
+ (let ((post-obj (create :from ($s bone section-title) :to ($s bone section-title))) |
|
8 |
+ (promise nil)) |
|
9 |
+ (if ($s i-follow follows) |
|
10 |
+ (setf promise (chain $http (post "/api/bones/unsubscribe" post-obj))) |
|
11 |
+ (setf promise (chain $http (post "/api/bones/subscribe" post-obj)))) |
|
12 |
+ |
|
13 |
+ (chain promise (success (lambda (result) |
|
14 |
+ (let ((result (chain JSON (parse result)))) |
|
15 |
+ (if result |
|
16 |
+ (setf ($s i-follow follows) |
|
17 |
+ (not ($s i-follow follows)))))))))) |
|
18 |
+ |
|
19 |
+ (setf ($s bone) (create :section-title "" :marrow '())) |
|
20 |
+ (setf ($s friends) (create :data '())) |
|
21 |
+ |
|
22 |
+ (scope-function update () |
|
23 |
+ (setf config (create :params (if ($s args) |
|
24 |
+ ($s args) |
|
25 |
+ (create)))) |
|
26 |
+ ((@ ($s (getendpoint |
|
27 |
+ service-params |
|
28 |
+ (lambda (data) |
|
29 |
+ (setf ($s bone section-title) (@ data section-title)) |
|
30 |
+ (setf ($s bone marrow) (@ data marrow)) |
|
31 |
+ (setf ($s bone i-follow) (chain -User-Service (follows (create :user ($s bone section-title))))) |
|
32 |
+ nil))) |
|
33 |
+ $promise then) ($s _update))) |
|
34 |
+ |
|
35 |
+ (chain -user-service (check |
|
36 |
+ (lambda (is_loggedon) |
|
37 |
+ (if (eql (@ is_loggedon result) t) |
|
38 |
+ (chain angular (element (@ document body)) |
|
39 |
+ (addClass "is-logged-on")) |
|
40 |
+ (chain $location (url "/login"))) |
|
41 |
+ |
|
42 |
+ (chain scope (update)))))) |
|
43 |
+ |
|
44 |
+(defcontroller marrow-app "RandomMarrowCtrl" ($controller $http $location $route -subscribed-to -bone-service -user-service) |
|
45 |
+ (scope-function _update ()) |
|
46 |
+ (scope-var getendpoint (@ -bone-service random)) |
|
47 |
+ (chain angular (extend this ($controller "RootCtrl" (create :$scope $scope))))) |
|
48 |
+ |
|
49 |
+(defcontroller marrow-app "SubscriptionCtrl" ($controller $http $location $route -subscribed-to -bone-service -user-service) |
|
50 |
+ (scope-function uncheck-others (list) |
|
51 |
+ (loop for n in list |
|
52 |
+ if (and (/= n "all") (eql (elt list n) F)) |
|
53 |
+ do (setf (elt list n) F))) |
|
54 |
+ |
|
55 |
+ (scope-var friend (chain Object (create nil))) |
|
56 |
+ (setf ($s friend all) t) |
|
57 |
+ |
|
58 |
+ (scope-function up-vote (bone-item) |
|
59 |
+ (let ((api-call (if (eql (@ bone-item my-vote) 0) |
|
60 |
+ (@ -bone-service vote_up) |
|
61 |
+ (@ -bone-service vote_down)))) |
|
62 |
+ (chain (api-call (create :url (@ bone-item url))) |
|
63 |
+ $promise |
|
64 |
+ (then (lambda (r) |
|
65 |
+ (if (@ r success) |
|
66 |
+ (setf (@ bone-item votes) (@ r votes)) |
|
67 |
+ (setf (@ bone-item my-vote) (@ r my-vote))) |
|
68 |
+ nil)) |
|
69 |
+ (then ($s _update))))) |
|
70 |
+ |
|
71 |
+ ) |
0 | 72 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,72 @@ |
1 |
+var rootModule = angular.module('rootModule', ['ngRoute']); |
|
2 |
+rootModule.controller('RootCtrl', ['$scope', '$http', '$location', '$route', 'SubscribedTo', 'BoneService', 'UserService', function ($scope, $http, $location, $route, SubscribedTo, BoneService, UserService) { |
|
3 |
+ $scope.url = ''; |
|
4 |
+ $scope.title = ''; |
|
5 |
+ $scope.toggleSubscribe = function (txt) { |
|
6 |
+ var postObj = { 'from' : $scope.bone.sectionTitle, 'to' : $scope.bone.sectionTitle }; |
|
7 |
+ var promise = null; |
|
8 |
+ if ($scope.iFollow.follows) { |
|
9 |
+ promise = $http.post('/api/bones/unsubscribe', postObj); |
|
10 |
+ } else { |
|
11 |
+ promise = $http.post('/api/bones/subscribe', postObj); |
|
12 |
+ }; |
|
13 |
+ return promise.success(function (result) { |
|
14 |
+ var result1 = json.parse(result); |
|
15 |
+ return result1 ? ($scope.iFollow.follows = !$scope.iFollow.follows) : null; |
|
16 |
+ }); |
|
17 |
+ }; |
|
18 |
+ $scope.bone = { 'section-title' : '', 'marrow' : [] }; |
|
19 |
+ $scope.friends = { 'data' : [] }; |
|
20 |
+ $scope.update = function () { |
|
21 |
+ config = { 'params' : $scope.args ? $scope.args : { } }; |
|
22 |
+ return $scope.getendpoint(serviceParams, function (data) { |
|
23 |
+ $scope.bone.sectionTitle = data.sectionTitle; |
|
24 |
+ $scope.bone.marrow = data.marrow; |
|
25 |
+ $scope.bone.iFollow = UserService.follows({ 'user' : $scope.bone.sectionTitle }); |
|
26 |
+ return null; |
|
27 |
+ }).$promise.then($scope._update); |
|
28 |
+ }; |
|
29 |
+ UserService.check(function (is_loggedon) { |
|
30 |
+ if (is_loggedon.result === true) { |
|
31 |
+ angular.element(document.body).addclass('is-logged-on'); |
|
32 |
+ } else { |
|
33 |
+ $location.url('/login'); |
|
34 |
+ }; |
|
35 |
+ return scope.update(); |
|
36 |
+ }); |
|
37 |
+ return null; |
|
38 |
+}]); |
|
39 |
+marrowApp.controller('RandomMarrowCtrl', ['$scope', '$controller', '$http', '$location', '$route', 'SubscribedTo', 'BoneService', 'UserService', function ($scope, $controller, $http, $location, $route, SubscribedTo, BoneService, UserService) { |
|
40 |
+ $scope._update = function () { |
|
41 |
+ return null; |
|
42 |
+ }; |
|
43 |
+ $scope.getendpoint = BoneService.random; |
|
44 |
+ angular.extend(this, $controller('RootCtrl', { '$scope' : $scope })); |
|
45 |
+ return null; |
|
46 |
+}]); |
|
47 |
+marrowApp.controller('SubscriptionCtrl', ['$scope', '$controller', '$http', '$location', '$route', 'SubscribedTo', 'BoneService', 'UserService', function ($scope, $controller, $http, $location, $route, SubscribedTo, BoneService, UserService) { |
|
48 |
+ $scope.uncheckOthers = function (list) { |
|
49 |
+ var _js3 = list.length; |
|
50 |
+ for (var _js2 = 0; _js2 < _js3; _js2 += 1) { |
|
51 |
+ var n = list[_js2]; |
|
52 |
+ if (n !== 'all' && list[n] === false) { |
|
53 |
+ list[n] = false; |
|
54 |
+ }; |
|
55 |
+ }; |
|
56 |
+ }; |
|
57 |
+ $scope.friend = object.create(null); |
|
58 |
+ $scope.friend.all = true; |
|
59 |
+ $scope.upVote = function (boneItem) { |
|
60 |
+ var apiCall = boneItem.myVote === 0 ? BoneService.vote_up : BoneService.vote_down; |
|
61 |
+ return apiCall({ 'url' : boneItem.url }).$promise.then(function (r) { |
|
62 |
+ if (r.success) { |
|
63 |
+ boneItem.votes = r.votes; |
|
64 |
+ } else { |
|
65 |
+ boneItem.myVote = r.myVote; |
|
66 |
+ }; |
|
67 |
+ return null; |
|
68 |
+ }).then($scope._update); |
|
69 |
+ }; |
|
70 |
+ return null; |
|
71 |
+}]); |
|
72 |
+ |
2 | 75 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,59 @@ |
1 |
+(ql:quickload :parenscript) |
|
2 |
+ |
|
3 |
+(defpackage :angular |
|
4 |
+ (:use :parenscript :cl) |
|
5 |
+ (:export main)) |
|
6 |
+ |
|
7 |
+(in-package :angular) |
|
8 |
+(use-package :parenscript) |
|
9 |
+ |
|
10 |
+(defmacro+ps scope-var (name value) |
|
11 |
+ `(setf ($s ,name) ,value)) |
|
12 |
+ |
|
13 |
+(defmacro+ps scope-function (name arguments &body body) |
|
14 |
+ `(scope-var ,name (lambda ,arguments |
|
15 |
+ ,@body))) |
|
16 |
+ |
|
17 |
+; The name of the angular module |
|
18 |
+(defvar *ang-module* nil) |
|
19 |
+ |
|
20 |
+ |
|
21 |
+(defmacro+ps $s (&rest values) `(chain $scope ,@values)) |
|
22 |
+ |
|
23 |
+(defmacro+ps def-module (name dependencies) |
|
24 |
+ `(progn (var ,name ((@ angular module) ,(symbol-to-js-string name) ,dependencies)))) |
|
25 |
+ |
|
26 |
+(defun build-lambda (dependencies body) |
|
27 |
+ `(list ,@(mapcar #'symbol-to-js-string dependencies) |
|
28 |
+ (lambda ,(loop for x in dependencies |
|
29 |
+ collect x) |
|
30 |
+ ,@body |
|
31 |
+ nil))) |
|
32 |
+ |
|
33 |
+(defmacro+ps select-> (selector) |
|
34 |
+ `(chain document (query-selector ,selector))) |
|
35 |
+ |
|
36 |
+(defmacro+ps select->element (selector) |
|
37 |
+ `(chain angular (element (select-> ,selector)))) |
|
38 |
+ |
|
39 |
+(defmacro+ps defcontroller (angmodule name dependencies &body body) |
|
40 |
+ (let ((dependencies (cons '$scope dependencies))) |
|
41 |
+ `(chain ,angmodule (controller ,name ,(build-lambda dependencies body))))) |
|
42 |
+ |
|
43 |
+(defmacro+ps ng-ajax (mthd endpoint data resultS &body callback) |
|
44 |
+ `(chain $http |
|
45 |
+ (,mthd ,endpoint ,data) |
|
46 |
+ (success (lambda (,resultS) |
|
47 |
+ ,@callback)))) |
|
48 |
+ |
|
49 |
+(defun translate-file (infile outfile) |
|
50 |
+ (let ((*JS-TARGET-VERSION* 1.9)) |
|
51 |
+ (with-open-file (o outfile :direction :output) |
|
52 |
+ (with-open-file (i infile :direction :input) |
|
53 |
+ (write-line (ps-compile-file i) o))))) |
|
54 |
+ |
|
55 |
+(defun main (args) |
|
56 |
+ (in-package :angular) |
|
57 |
+ (apply #'translate-file (cdr args))) |
|
58 |
+ |
|
59 |
+ |
... | ... |
@@ -1,10 +1,31 @@ |
1 | 1 |
<div id="login_form"> |
2 |
- <form> |
|
3 |
- <div class="message">{{message}}</div> |
|
4 |
- <input type="text" ng-model="username" placeholder="Username" /> |
|
5 |
- <input type="password" ng-model="password" placeholder="Password" /> |
|
6 |
- <button ng-click="login()">Log In</button> |
|
7 |
- <button ng-click="newuser()">Add User</button> |
|
8 |
- </form> |
|
2 |
+ <div class="message" ng-class="{'error': message !== ''}">{{message}}</div> |
|
3 |
+ <ul id="tab-choice"> |
|
4 |
+ <li> |
|
5 |
+ <input type="radio" value="login" ng-model="tab" name="choose-tab" id="chLogin" /> |
|
6 |
+ <label for="chLogin">Login</label> |
|
7 |
+ </li> |
|
8 |
+ <li> |
|
9 |
+ <input type="radio" value="adduser" ng-model="tab" name="choose-tab" id="chAdduser" /> |
|
10 |
+ <label for="chAdduser">Sign Up</label> |
|
11 |
+ </li> |
|
12 |
+ </ul> |
|
13 |
+ <div class="relCont"> |
|
14 |
+ <div class="tab" ng-class="{front: tab === 'adduser'}"> |
|
15 |
+ <form> |
|
16 |
+ <input type="text" ng-model="username" placeholder="Username" /><br /> |
|
17 |
+ <input type="password" ng-model="password" placeholder="Password" /><br /> |
|
18 |
+ <input type="password" ng-model="confirm" placeholder="Confirm Password" /><br /> |
|
19 |
+ <button ng-click="newuser()">Sign Up</button> |
|
20 |
+ </form> |
|
21 |
+ </div> |
|
22 |
+ <div class="tab" ng-class="{front: tab === 'login'}"> |
|
23 |
+ <form ng-submit="login()" method="POST"> |
|
24 |
+ <input type="text" ng-model="username" placeholder="Username" /><br /> |
|
25 |
+ <input type="password" ng-model="password" placeholder="Password" /><br /> |
|
26 |
+ <button type="submit">Log In</button> |
|
27 |
+ </form> |
|
28 |
+ </div> |
|
29 |
+ </div> |
|
9 | 30 |
</div> |
10 | 31 |
|