summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <yuval@y3xz.com>2015-06-09 18:53:48 +0300
committerYuval Adam <yuval@y3xz.com>2015-06-09 18:53:48 +0300
commit58b4bc50d64ea8b664a2f023eb5889c640ec9a0f (patch)
tree0da99fe5743fa3ddae1a921b8425caedcd860cc3
parentd0d37fb74d1509934dea97eff3ed2f3c87098286 (diff)
Login, logout and simple routing
-rw-r--r--.meteor/packages1
-rw-r--r--.meteor/versions8
-rw-r--r--client/button.js25
-rw-r--r--client/colors.css40
-rw-r--r--client/colors.html16
-rw-r--r--client/templates/layout.html5
-rw-r--r--client/templates/login.html4
-rw-r--r--client/templates/main.html3
-rw-r--r--client/templates/one.html3
-rw-r--r--client/templates/two.html3
-rw-r--r--lib/router.js7
11 files changed, 70 insertions, 45 deletions
diff --git a/.meteor/packages b/.meteor/packages
index 3b138b8..bd191b3 100644
--- a/.meteor/packages
+++ b/.meteor/packages
@@ -10,3 +10,4 @@ insecure
bozhao:accounts-instagram
service-configuration
accounts-ui-unstyled
+iron:router
diff --git a/.meteor/versions b/.meteor/versions
index 08eb9bf..0eeae57 100644
--- a/.meteor/versions
+++ b/.meteor/versions
@@ -21,6 +21,14 @@ htmljs@1.0.4
http@1.1.0
id-map@1.0.3
insecure@1.0.3
+iron:controller@1.0.8
+iron:core@1.0.8
+iron:dynamic-template@1.0.8
+iron:layout@1.0.8
+iron:location@1.0.9
+iron:middleware-stack@1.0.9
+iron:router@1.0.9
+iron:url@1.0.9
jquery@1.11.3_2
json@1.0.3
launch-screen@1.0.2
diff --git a/client/button.js b/client/button.js
index 8dc64a5..bc3828b 100644
--- a/client/button.js
+++ b/client/button.js
@@ -1,13 +1,20 @@
-Session.setDefault('counter', 0);
+Template.layout.events({
+ 'click .logout': function (event) {
+ Meteor.logout();
+ Router.go('login');
+ }
+})
-Template.hello.helpers({
- counter: function () {
- return Session.get('counter');
+Template.login.events({
+ 'click .login-instagram': function (event) {
+ Meteor.loginWithInstagram({}, function (err) {
+ if (err)
+ Session.set('errorMessage', err.reason || 'Unknown error');
+ });
+ return false;
}
});
-Template.hello.events({
- 'click button': function () {
- Session.set('counter', Session.get('counter') + 1);
- }
-}); \ No newline at end of file
+Accounts.onLogin(function() {
+ Router.go('one');
+});
diff --git a/client/colors.css b/client/colors.css
index c18dec8..db0e6f8 100644
--- a/client/colors.css
+++ b/client/colors.css
@@ -1,39 +1,39 @@
/* Base styles */
-#login-buttons-instagram {
+.login-instagram {
font-size: 1.2em;
font-family: sans-serif;
color:#333;
text-shadow:1px 1px #fff;
text-decoration: none;
- display:inline-block;
+ display:inline-block;
padding:0.5em 1.75em 0.5em 1em;
border-radius: 0.25em;
background: #f8f8f8;
border:1px solid #ccc;
border-right:0.25em solid #00558D; /* blue stripe */
position: relative;
- margin:0 0 1px;
+ margin:0 0 1px;
}
-#login-buttons-instagram:before, #login-buttons-instagram:after {
+.login-instagram:before, .login-instagram:after {
content:'';
display:block;
position: absolute;
}
/* Add Stripes */
-#login-buttons-instagram:before {
+.login-instagram:before {
width:0.25em;
height: 100%;
- background:#FBB03B; /* yellow stripe */
- border-left:0.25em solid #D4145A; /* red stripe */
- border-right:0.25em solid #00A99D; /* green stripe */
+ background:#FBB03B; /* yellow stripe */
+ border-left:0.25em solid #D4145A; /* red stripe */
+ border-right:0.25em solid #00A99D; /* green stripe */
top:0;
right:0;
}
/* Add Hightlights */
-#login-buttons-instagram:after {
+.login-instagram:after {
width:100%;
height: 100%;
top: 0;
@@ -54,7 +54,7 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#59ffffff', e
/* Animate - Fade */
-#login-buttons-instagram, #login-buttons-instagram:before {
+.login-instagram, .login-instagram:before {
-webkit-transition-property: background, border;
-webkit-transition: 0.1s ease-in;
-moz-transition-property: background, border;
@@ -67,21 +67,21 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#59ffffff', e
}
/* Hover / Focus */
-#login-buttons-instagram:hover, #login-buttons-instagram:focus {
+.login-instagram:hover, .login-instagram:focus {
background: #fff;
}
-#login-buttons-instagram:hover {
+.login-instagram:hover {
border-right:0.25em solid #09c;
}
-#login-buttons-instagram:hover:before {
- background:#fc6; /* yellow stripe */
- border-left:0.25em solid #f06; /* red stripe */
- border-right:0.25em solid #0cc; /* green stripe */
+.login-instagram:hover:before {
+ background:#fc6; /* yellow stripe */
+ border-left:0.25em solid #f06; /* red stripe */
+ border-right:0.25em solid #0cc; /* green stripe */
}
-#login-buttons-instagram:hover:after {
+.login-instagram:hover:after {
background: -moz-linear-gradient(top, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.1) 49%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.05) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0.25)), color-stop(49%,rgba(255,255,255,0.1)), color-stop(50%,rgba(255,255,255,0)), color-stop(100%,rgba(0,0,0,0.05)));
background: -webkit-linear-gradient(top, rgba(255,255,255,0.25) 0%,rgba(255,255,255,0.1) 49%,rgba(255,255,255,0) 50%,rgba(0,0,0,0.05) 100%);
@@ -93,6 +93,6 @@ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#40ffffff', e
}
/* Active */
-#login-buttons-instagram:active {
- margin:1px 0 0;
-} \ No newline at end of file
+.login-instagram:active {
+ margin:1px 0 0;
+}
diff --git a/client/colors.html b/client/colors.html
deleted file mode 100644
index d679971..0000000
--- a/client/colors.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<head>
- <title>colors</title>
-</head>
-
-<body>
- <h1>Welcome to Meteor!</h1>
-
- {{> loginButtons}}
-
- {{> hello}}
-</body>
-
-<template name="hello">
- <button>Click Me</button>
- <p>You've pressed the button {{counter}} times.</p>
-</template>
diff --git a/client/templates/layout.html b/client/templates/layout.html
new file mode 100644
index 0000000..b9678a3
--- /dev/null
+++ b/client/templates/layout.html
@@ -0,0 +1,5 @@
+<template name="layout">
+ <h1>Colors</h1>
+ <button class="logout">logout</button>
+{{> yield}}
+</template>
diff --git a/client/templates/login.html b/client/templates/login.html
new file mode 100644
index 0000000..1f42513
--- /dev/null
+++ b/client/templates/login.html
@@ -0,0 +1,4 @@
+<template name="login">
+ <h2>Welcome</h2>
+ <button class="login-instagram">Sign in with Instagram</button>
+</template>
diff --git a/client/templates/main.html b/client/templates/main.html
new file mode 100644
index 0000000..afd997f
--- /dev/null
+++ b/client/templates/main.html
@@ -0,0 +1,3 @@
+<head>
+ <title>Colors</title>
+</head>
diff --git a/client/templates/one.html b/client/templates/one.html
new file mode 100644
index 0000000..740ade0
--- /dev/null
+++ b/client/templates/one.html
@@ -0,0 +1,3 @@
+<template name="one">
+ <h1>one</h1>
+</template>
diff --git a/client/templates/two.html b/client/templates/two.html
new file mode 100644
index 0000000..4e46932
--- /dev/null
+++ b/client/templates/two.html
@@ -0,0 +1,3 @@
+<template name="two">
+ <h1>two</h1>
+</template>
diff --git a/lib/router.js b/lib/router.js
new file mode 100644
index 0000000..30c3814
--- /dev/null
+++ b/lib/router.js
@@ -0,0 +1,7 @@
+Router.configure({
+ layoutTemplate: 'layout'
+});
+
+Router.route('/', {name: 'login'});
+Router.route('/one', {name: 'one'});
+Router.route('/two', {name: 'two'});