Skip to content

Commit

Permalink
adding support for google accounts [#4 state:resolved]
Browse files Browse the repository at this point in the history
  • Loading branch information
ericw committed Aug 13, 2008
1 parent 5c69b48 commit a9194d9
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 39 deletions.
6 changes: 3 additions & 3 deletions channel.html
@@ -1,8 +1,8 @@
{% load markup %}
{% include "header.html" %}
<div id="header">
<a id="text-logo" href="/">Onelinr</a> | You are viewing the {{channel.name}} oneliner channel. <a href="http://hobix.com/textile/">Textile</a> is enabled.
{{user_html}}
{{user_html}}
<a id="text-logo" href="/">Onelinr</a> | You are viewing the <em>{{channel.name}}</em> oneliner channel. <a href="http://hobix.com/textile/">Textile</a> is enabled.
<!-- <span id="customizr">
<span id="text-color">
<form>
Expand Down Expand Up @@ -34,7 +34,7 @@
{% for p in posts %}
<li id="oneliner-{{p.post_id}}">

{{p.text|textile}}
<span class="handle">{{p.posted_by.handle}}</span> {{p.text|textile}}
<a href="http://onelinr.com/{{channel.name}}#oneliner-{{p.post_id}}" title="Permalink for this oneliner" class="permalink">#</a>
</li>
{% endfor %}
Expand Down
29 changes: 12 additions & 17 deletions handle.html
@@ -1,18 +1,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<title>Choose a Onelinr handle</title>

<link href="/images/favicon.ico" rel="shortcut icon" />
<link href="/stylesheets/style.css" media="screen, projection" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Choose a Onelinr handle</h1>
<form action="" method="post">
<input type="text" id="handle" name="handle">
<input type="submit" value="Ok">
</form>
</body>
{% include "header.html" %}
<body id="handle-page">
<div id="container">
<h1>Choose a Onelinr handle</h1>
<form action="" method="post">
<input type="text" id="handle" name="handle" value="{{handle}}" />
<div id="handle-buttons">
<input type="submit" value="Ok" /> or <a href="/{{channel}}">Cancel</a>
</div>
</form>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion header.html
Expand Up @@ -3,7 +3,7 @@
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8">

<title>Onelinr Channel: {{channel.name}}</title>
<title>{{page_title}}</title>

<link href="/images/favicon.ico" rel="shortcut icon" />
<link href="/stylesheets/style.css" media="screen, projection" rel="stylesheet" type="text/css" />
Expand Down
2 changes: 1 addition & 1 deletion index.html
@@ -1,7 +1,7 @@
{% include "header.html" %}
<body>
<div id="welcome">
<h1>Onelinr <span>by <a href="http://eric.wahlforss.com/2007/04/06/onelinr/">Eric Wahlforss</a></span></h1>
<h1>Onelinr <span>by <a href="http://eric.wahlforss.com/2007/04/06/onelinr/">Eric Wahlforss</a> &amp; <a href="http://hinkeb.com/">Henrik Berggren</a></span></h1>
<p>At <span class="highlight">Onelinr</span> you can start <em>your own oneliner channel</em> by simply typing <a href="/yours">onelinr.com/yours</a> in the address bar of your browser. Or type here:</p>
<form id="new_channel" method="post" onsubmit="location.href = '/' + $('#channel_name').val();return false;">
<div>
Expand Down
8 changes: 4 additions & 4 deletions index.yaml
Expand Up @@ -33,7 +33,7 @@ indexes:
- name: post_id
direction: desc

# Used once in query history.
# Unused in query history -- copied from input.
- kind: Post
properties:
- name: belongs_to
Expand All @@ -45,18 +45,18 @@ indexes:
- name: belongs_to
- name: post_id

# Used 65 times in query history.
# Unused in query history -- copied from input.
- kind: Post
properties:
- name: date_posted
direction: desc

# Used 6 times in query history.
# Unused in query history -- copied from input.
- kind: Post
properties:
- name: id
direction: desc

# Used 5 times in query history.
# Unused in query history -- copied from input.
- kind: Post
ancestor: yes
20 changes: 12 additions & 8 deletions onelinr.py
Expand Up @@ -44,7 +44,7 @@ def get(self):
channels = Channel.all()
channels.order("-post_count")
channelCloud = renderChannelCloud(channels);
self.response.out.write(template.render('index.html', {'channels':channels,'channelCloud':channelCloud}))
self.response.out.write(template.render('index.html', {'channels':channels,'channelCloud':channelCloud,'page_title':'Onelinr'}))

class ChannelPage(webapp.RequestHandler):

Expand All @@ -70,7 +70,7 @@ def get(self):

user_html = generate_handle_links(google_user, user, self.request)

self.response.out.write(template.render('channel.html', {'channel':channel, 'posts':posts, 'user_html':user_html}))
self.response.out.write(template.render('channel.html', {'channel':channel, 'posts':posts, 'user_html':user_html,'page_title':'Onelinr Channel: ' + channel.name}))

def post(self):
google_user = users.get_current_user()
Expand Down Expand Up @@ -113,12 +113,16 @@ def get(self):
google_user = users.get_current_user()

if not google_user:
self.redirect(users.create_login_url(self.request.uri))
self.redirect(users.create_login_url(self.request.uri))

if get_user(google_user) and self.request.get("c") != "1":
self.redirect("/"+channel_name)
self.redirect("/"+channel_name)
elif get_user(google_user) and self.request.get("c") == "1":
user = get_user(google_user)
logging.info(user.handle)
self.response.out.write(template.render('handle.html',{'page_title':'Onelinr','channel':channel_name,'handle':user.handle}))
else:
self.response.out.write(template.render('handle.html',{}))
self.response.out.write(template.render('handle.html',{'page_title':'Onelinr','channel':channel_name}))

def post(self):
channel_name = url_to_channel_name(self.request.uri)
Expand Down Expand Up @@ -238,13 +242,13 @@ def generate_handle_links(google_user, user, request):
if google_user:
if user:
url = users.create_logout_url(request.uri)
html = "Your handle is <i>"+user.handle+"</i>, <a href='/"+channel_name+"/handle?c=1'>change it</a> or <a href='"+url+"'>Sign out</a>"
html = "<span class='user'>Your handle is <em>"+user.handle+"</em>, <a href='/"+channel_name+"/handle?c=1'>change it</a> or <a href='"+url+"'>Sign out</a></span>"
else:
url = users.create_logout_url(request.uri)
html = "<a href='/"+channel_name+"/handle'>Choose a handle</a> or <a href='"+url+"'>Sign out</a>"
html = "<span class='user'><a href='/"+channel_name+"/handle'>Choose a handle</a> or <a href='"+url+"'>Sign out</a></span>"
else:
url = users.create_login_url("/"+channel_name+"/handle")
html = "<a href='"+url+"'>Sign in</a>"
html = "<span class='user'><a href='"+url+"'>Sign in</a></span>"

return html

Expand Down
10 changes: 9 additions & 1 deletion scripts/application.js
Expand Up @@ -64,7 +64,7 @@ OnelinerManager.prototype = {
},4000);
},
displayOneliner: function(oneliner) {
$('<li id="oneliner-'+oneliner.post_id+'">'+oneliner.text+' <a href="/'+this.channel+'#oneliner-'+oneliner.post_id+'" class="permalink" title="Permalink for this oneliner">#</a></li>')
$('<li id="oneliner-'+oneliner.post_id+'"><span class="handle">'+ oneliner.handle +'</span> '+oneliner.text+' <a href="/'+this.channel+'#oneliner-'+oneliner.post_id+'" class="permalink" title="Permalink for this oneliner">#</a></li>')
.prependTo($('#oneliners'))
.hide()
.fadeIn();
Expand Down Expand Up @@ -95,3 +95,11 @@ $(function(){
//var customizr = new ChannelCustomizr();
}
});

$(function() {
$("#handle-page").each(function() {
var handle = $("#handle")[0];
handle.focus();
handle.select();
});
})
67 changes: 63 additions & 4 deletions stylesheets/style.css
Expand Up @@ -21,6 +21,7 @@ body, p, ol, ul, td {
background-repeat:no-repeat;
background-position : 6px 14px;
padding : 5px 0 0 3%;
border-top: 1px solid #CCCCCC;
}

#oneliner-form #oneliner_value {
Expand All @@ -35,7 +36,7 @@ body, p, ol, ul, td {

#oneliners {
z-index:10;
margin-top:25px;
margin: 25px 0 50px 0;
font-size:36px;
padding:5px; }
#oneliners li {
Expand All @@ -45,6 +46,12 @@ body, p, ol, ul, td {
#oneliners li p {
margin : 0;
font-size:36px;
display: inline;
}

#oneliners li span.handle {
color: #bbb;
padding-right: .0em;
}
#oneliners li .permalink {
font-size:.8em;
Expand Down Expand Up @@ -80,11 +87,12 @@ a:hover { color: #fff; background-color:#000; }
background:#eee;
border-bottom:1px solid #ccc;
margin:0;
padding:3px;
width:100%;
padding: .3em .5%;
width:99%;
position:fixed;
top:0;
left:0;
right: 0;
z-index:100; }

#header #customizr {
Expand All @@ -105,15 +113,24 @@ a:hover { color: #fff; background-color:#000; }
#header #customizr #text-color .value {background:#333;}
#header #customizr #background .value {background:#fff;}

#header .user {
float: right;
}

#welcome {
width:600px;
margin:100px auto;
margin:50px auto;
}

#welcome p {
font-size:26px;
}

#handle-page #container {
width:600px;
margin:50px auto;
}

h1 {
font-size:40px;
font-weight:normal;
Expand Down Expand Up @@ -179,6 +196,48 @@ ul#channel-cloud li {
border-bottom:2px dotted #EC7BF4;
}

#handle {
height:30px;
width:400px;
font-size:26px;
font-family:Georgia, serif;
margin:1em auto 1em auto;
border:0;
border-bottom:2px dotted #EC7BF4;
display: block;
}

#handle-page h1 {
text-align: center;
}

#handle-buttons {
padding: 1em 0 0 0;
text-align : center;
font-size: 20px;
}

#handle-buttons input {
font-size: 20px;
font-family:Georgia, serif;
margin: 0 1em 0 1em;
padding: 0 .6em 0 .6em;
-moz-border-radius : 7px;
-webkit-border-radius : 7px;
border: 1px solid #aaa;
cursor: pointer;
background-color: #eee;
}

#handle-buttons input:hover {
background-color: black;
color: white;
}

#handle-buttons a {
margin-left: 1em;
}

#new_channel {
text-align : center;
width : 600px;
Expand Down

0 comments on commit a9194d9

Please sign in to comment.