Skip to content

Commit

Permalink
Better Facebook sign-in button.
Browse files Browse the repository at this point in the history
  • Loading branch information
akoprow committed Mar 12, 2012
1 parent f44cba6 commit 6368c16
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
Binary file added resources/img/facebook_signin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions resources/style.css
Expand Up @@ -22,6 +22,9 @@
.search-pubDate {
color: dimgrey;
}
.userbox {
float: right;
}
.username {
color: lime;
}
Expand Down
11 changes: 3 additions & 8 deletions src/facebook.opa
Expand Up @@ -65,14 +65,9 @@ Please re-run your application with: --fb-config option")

xhtml =
login_url = FBA.user_login_url([], redirect)
WBootstrap.Button.make(
{ button:
<img style="width:18px; height:18px; vertical-align:top;" title="Facebook" src="https://opalang.org/sso/img/fb-icon.png" alt="Connect with Facebook" />
<span>Facebook</>
, callback: function(_) { Client.goto(login_url) }
},
[]
)
<a onclick={function (_) { Client.goto(login_url) }}>
<img src="resources/img/facebook_signin.png" />
</>

function login(token) {
match (FBA.get_token_raw(token, redirect)) {
Expand Down
14 changes: 7 additions & 7 deletions src/webshell.opa
Expand Up @@ -60,9 +60,7 @@ function login_box() {
function block(content) {
<h3 style="float: right">{content}</>
}
login =
prompt = <a>You can sign in with:</>
block(<>{prompt}{FacebookConnect.xhtml}</>)
login = <>{FacebookConnect.xhtml}</>
logout =
function do_logout(_) {
Login.set_current_user({guest})
Expand All @@ -71,10 +69,12 @@ function login_box() {
name = <a>{Login.get_current_user_name()}</>
button = WBootstrap.Button.make({ button: <>Logout</>, callback: do_logout}, [])
block(<>{button}{name}</>)
match (Login.get_current_user()) {
case {guest}: login
default: logout
}
content =
match (Login.get_current_user()) {
case {guest}: login
default: logout
}
<span class=userbox>{content}</>
}

function page() {
Expand Down

0 comments on commit 6368c16

Please sign in to comment.