Skip to content

Commit

Permalink
now we're cooking with gas
Browse files Browse the repository at this point in the history
  • Loading branch information
al3x committed Apr 19, 2008
1 parent a1bb4d0 commit 504e932
Show file tree
Hide file tree
Showing 11 changed files with 213 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*.pyc
13 changes: 11 additions & 2 deletions app.yaml
@@ -1,8 +1,17 @@
application: helloworld
application: lyricswelove
version: 1
runtime: python
api_version: 1

handlers:
- url: /stylesheets
static_dir: stylesheets

- url: /images
static_dir: images

- url: /javascripts
static_dir: javascripts

- url: /.*
script: lyricswelove.py
script: lyrics.py
Empty file added javascripts/app.js
Empty file.
32 changes: 32 additions & 0 deletions javascripts/jquery-1.2.3.min.js

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions lyrics.py
@@ -0,0 +1,43 @@
from google.appengine.ext import webapp
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext.webapp import template
import models
import os
import wsgiref.handlers

class BetterHandler(webapp.RequestHandler):
def template_path(self, filename):
return os.path.join(os.path.dirname(__file__), 'templates', filename)

def template_values(self, extra_dict=None):
standard_values = {
'user': users.get_current_user(),
'login_url': users.create_login_url('/'),
'logout_url': users.create_logout_url('/'),
}

if extra_dict:
standard_values.update(extra_dict)

return standard_values


class MainPage(BetterHandler):
def get(self):
self.response.out.write(template.render(self.template_path('index.html'), self.template_values()))


class NewLyric(BetterHandler):
def get(self):
self.response.out.write(template.render(self.template_path('new_lyric.html'), self.template_values()))


def main():
application = webapp.WSGIApplication([('/', MainPage),
('/lyric/new', NewLyric)],
debug=True)
wsgiref.handlers.CGIHandler().run(application)

if __name__ == "__main__":
main()
23 changes: 0 additions & 23 deletions lyricswelove.py

This file was deleted.

6 changes: 6 additions & 0 deletions models.py
@@ -0,0 +1,6 @@
from google.appengine.ext import db
from google.appengine.api import users

class Lyric(db.Model):
body = db.TextProperty()
owner = db.UserProperty(required=True)
64 changes: 64 additions & 0 deletions stylesheets/screen.css
@@ -0,0 +1,64 @@
/* elements */
body {
background-color: #fff;
color: #191919;
font-family: Georgia, Times, serif;
margin: 2em 15% 0 15%;
}

a {
color: #0080ff;
text-decoration: none;
}
a:active, a:hover { text-decoration: underline; }

h1 { font-size: 3em; }
h1 a:hover { text-decoration: none; }
h2 { font-size: 2em; }

/* classes */
.lyricform br {
clear: left;
}

.lyricform label, .lyricform input[type=text] {
display: block;
width: 60%;
float: left;
margin-bottom: 10px;
}

.lyricform label {
text-align: right;
width: 150px;
padding-right: 20px;
}

.lyricform textarea {
width: 60%;
height: 200px;
}

.optional {
color: #666;
}


/* ids */

#content {
font-size: 1em;
}

#nav {
float: right;
font-family: Helvetica, sans-serif;
font-size: .9em;
list-style-type: none;
padding: 0;
}

#nav li {
display: inline;
margin-right: 1em;
}
25 changes: 25 additions & 0 deletions templates/base.html
@@ -0,0 +1,25 @@
<html>
<head>
<title>Lyrics We Love</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/screen.css" />
<script type="text/javascript" src="/javascripts/jquery-1.2.3.min.js"></script>
<script type="text/javascript" src="/javascripts/app.js"></script>
</head>
<body>
<ul id="nav">
{% if user %}
<li>{{ user }}</li>
<li><a href="/lyric/new">add a lyric</a></li>
<li><a href="{{ logout_url }}">logout</a></li>
{% else %}
<a href="{{ login_url }}">login</a>
{% endif %}
</ul>

<h1><a href="/">Lyrics We Love</a></h1>

<div id="content">
{% block content %}{% endblock %}
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions templates/index.html
@@ -0,0 +1,5 @@
{% extends "base.html" %}

{% block content %}
<h2>Recent Lyrics</h2>
{% endblock %}
26 changes: 26 additions & 0 deletions templates/new_lyric.html
@@ -0,0 +1,26 @@
{% extends "base.html" %}

{% block content %}
<h2>Share A Lyric</h2>

<form action="/lyric/new" method="post" name="new_lyric_form" class="lyricform">
<label for="lyric">Lyric</label>
<textarea name="body"></textarea>
<br />

<label for="artist">Artist</label>
<input type="text" name="artist" />
<br />

<label for="album" class="optional">Album</label>
<input type="text" name="album" />
<br />

<label for="song">Song</label>
<input type="text" name="song" />
<br />

<label for="submit"></label>
<input type="submit" value="La lala la" />
</form>
{% endblock %}

0 comments on commit 504e932

Please sign in to comment.