Skip to content

Commit c36c6ce

Browse files
committed
New hgtv with channels and playlists.
1 parent 6959061 commit c36c6ce

31 files changed

+266
-96
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ build/
1212
dist/
1313
settings.py
1414
.webassets-cache
15+
.sass-cache
1516
nosetests.xml
17+
baseframe-packed.css
18+
baseframe-packed.js

config.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Require any additional compass plugins here.
2+
# Set this to the root of your project when deployed:
3+
http_path = "/"
4+
css_dir = "hgtv/static/css"
5+
sass_dir = "hgtv/static/sass"
6+
images_dir = "hgtv/static/img"
7+
javascripts_dir = "hgtv/static/js"
8+
line_comments = false
9+
# To enable relative paths to assets via compass helper functions. Uncomment:
10+
relative_assets = true

hgtv/__init__.py

+6-19
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,25 @@
55
from flask import Flask
66
from flask.ext.assets import Environment, Bundle
77
from baseframe import baseframe, baseframe_js, baseframe_css
8-
from coaster import configureapp
8+
from coaster.app import configure
99

1010
# First, make an app and config it
1111

1212
app = Flask(__name__, instance_relative_config=True)
13-
configureapp(app, 'HGTV_SETTINGS')
13+
configure(app, 'HGTV_ENV')
14+
1415
# Second, setup baseframe and assets
1516

1617
app.register_blueprint(baseframe)
18+
1719
assets = Environment(app)
1820
js = Bundle(baseframe_js)
19-
css = Bundle(baseframe_css)
21+
css = Bundle(baseframe_css,
22+
'css/hgtv.css')
2023
assets.register('js_all', js)
2124
assets.register('css_all', css)
2225

2326
# Third, after config, import the models and views
2427

2528
import hgtv.models
2629
import hgtv.views
27-
28-
# Fourth, setup admin for the models
29-
30-
from flask.ext import admin
31-
from sqlalchemy.orm import scoped_session, sessionmaker
32-
from hgtv.views.login import lastuser
33-
34-
db_session = scoped_session(sessionmaker(
35-
autocommit=False, autoflush=False,
36-
bind=hgtv.models.db.engine))
37-
38-
admin_blueprint = admin.create_admin_blueprint(
39-
hgtv.models, db_session,
40-
view_decorator=lastuser.requires_permission('siteadmin'))
41-
42-
app.register_blueprint(admin_blueprint, url_prefix='/admin')

hgtv/forms/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from hgtv.forms.playlist import *

hgtv/forms/playlist.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from baseframe.forms import Form
4+
import flask.ext.wtf as wtf
5+
6+
__all__ = ['PlaylistForm']
7+
8+
9+
class PlaylistForm(Form):
10+
title = wtf.TextField('Title', validators=[wtf.Required()])

hgtv/models/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
from flask.ext.sqlalchemy import SQLAlchemy
44
from hgtv import app
5-
from coaster.sqlalchemy import IdMixin, TimestampMixin, BaseMixin, BaseNameMixin
5+
from coaster.sqlalchemy import BaseMixin, BaseNameMixin
66

77
db = SQLAlchemy(app)
88

9-
from hgtv.models.show import *
10-
from hgtv.models.season import *
9+
from hgtv.models.channel import *
1110
from hgtv.models.tag import *
1211
from hgtv.models.user import *
1312
from hgtv.models.video import *

hgtv/models/channel.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from hgtv.models import db, BaseNameMixin
4+
5+
6+
class Channel(db.Model, BaseNameMixin):
7+
__tablename__ = 'channel'
8+
userid = db.Column(db.Unicode(22), nullable=False, unique=True)
9+
featured = db.Column(db.Boolean, default=False, nullable=False)
10+
11+
12+
class Playlist(db.Model, BaseNameMixin):
13+
__tablename__ = 'playlist'
14+
channel_id = db.Column(db.Integer, db.ForeignKey('channel.id'), nullable=False)
15+
channel = db.relationship(Channel, primaryjoin=channel_id == Channel.id,
16+
backref=db.backref('playlists', cascade='all, delete-orphan'))
17+
featured = db.Column(db.Boolean, default=False, nullable=False)
18+
19+
20+
channels_videos = db.Table('channels_videos',
21+
db.Column('channel_id', db.Integer, db.ForeignKey('channel.id'), nullable=False),
22+
db.Column('video_id', db.Integer, db.ForeignKey('video.id'), nullable=False)
23+
)
24+
25+
26+
playlists_videos = db.Table('playlists_videos',
27+
db.Column('playlist_id', db.Integer, db.ForeignKey('playlist.id'), nullable=False),
28+
db.Column('video_id', db.Integer, db.ForeignKey('video.id'), nullable=False)
29+
)

hgtv/models/season.py

-18
This file was deleted.

hgtv/models/show.py

-17
This file was deleted.

hgtv/models/tag.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
# -*- coding: utf-8 -*-
22

3-
from coaster import makename
3+
from coaster import make_name
44
from hgtv.models import db, BaseMixin
55

66
__all__ = ['Tag']
77

8+
89
class Tag(db.Model, BaseMixin):
910
__tablename__ = 'tag'
1011
name = db.Column(db.Unicode(80), unique=True, nullable=False)
1112
title = db.Column(db.Unicode(80), unique=True, nullable=False)
1213

1314
def __repr__(self):
1415
return self.name
15-
16+
1617
@classmethod
1718
def get(cls, title):
1819
tag = cls.query.filter_by(title=title).first()
1920
if tag:
2021
return tag
2122
else:
22-
name = makename(title)
23+
name = make_name(title)
2324
# Is this name already in use? If yes, return it
2425
tag = cls.query.filter_by(name=name).first()
2526
if tag:
@@ -30,9 +31,9 @@ def get(cls, title):
3031
return tag
3132

3233
def rename(self, title):
33-
name = makename(tagname)
34+
name = make_name(title)
3435
if self.query.filter_by(name=name).first() is not None:
35-
raise ValueError, u"Name already in use"
36+
raise ValueError(u"Name already in use")
3637
else:
3738
self.name = name
3839
self.title = title

hgtv/models/video.py

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
#!/usr/bin/env python
22
# -*- coding: iso-8859-15 -*-
33

4-
from hgtv.models import db, BaseMixin
4+
from hgtv.models import db, BaseNameMixin
55
from hgtv.models.tag import tags_videos
6+
from hgtv.models.channel import Channel, channels_videos, playlists_videos
67

78
__all__ = ['Video']
89

9-
class Video(db.Model, BaseMixin):
10+
11+
class Video(db.Model, BaseNameMixin):
1012
__tablename__ = 'video'
11-
name = db.Column(db.Unicode(80), unique=True, nullable=False)
12-
title = db.Column(db.Unicode(80), unique=True, nullable=False)
13-
description = db.Column(db.Text(), nullable=False)
14-
url = db.Column(db.Unicode(80), unique=True, nullable=False)
15-
season_id = db.Column(db.Integer, db.ForeignKey('season.id'), nullable=False)
13+
channel_id = db.Column(db.Integer, db.ForeignKey('channel.id'), nullable=False)
14+
channel = db.relationship(Channel, primaryjoin=channel_id == Channel.id,
15+
backref=db.backref('videos', cascade='all, delete-orphan'))
16+
description = db.Column(db.UnicodeText, nullable=False, default=u'')
17+
url = db.Column(db.Unicode(250), nullable=False)
18+
slides = db.Column(db.Unicode(250), nullable=False, default=u'')
1619

1720
tags = db.relationship('Tag', secondary=tags_videos, backref=db.backref('videos'))
21+
channels = db.relationship('Channel', secondary=channels_videos, backref=db.backref('tagged_videos'))
22+
playlists = db.relationship('Playlist', secondary=playlists_videos, backref=db.backref('videos'))
1823

1924
def __repr__(self):
20-
return self.name
25+
return u'<Video %s>' % self.name

hgtv/static/css/hgtv.css

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#logo {
2+
text-indent: -119988px;
3+
overflow: hidden;
4+
text-align: left;
5+
background-image: url('../img/logo.png?1328964434');
6+
background-repeat: no-repeat;
7+
background-position: 50% 50%;
8+
width: 137px;
9+
height: 75px;
10+
}
11+
12+
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
13+
#logo {
14+
background-image: url('../img/[email protected]?1328994417');
15+
-webkit-background-size: 137px 75px;
16+
}
17+
}

hgtv/static/css/packed.css

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.
File renamed without changes.

hgtv/static/img/[email protected]

11.9 KB
Loading

hgtv/static/sass/hgtv.sass

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import "compass/typography/text/replacement"
2+
3+
#logo
4+
@include replace-text-with-dimensions('logo.png')
5+
6+
@media only screen and (-webkit-min-device-pixel-ratio: 2)
7+
#logo
8+
background-image: image-url('[email protected]')
9+
-webkit-background-size: image-width('logo.png') image-height('logo.png')

hgtv/templates/channel.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{% extends "layout.html" %}
2+
{% block title %}{{ channel.title }}{% endblock %}

hgtv/templates/index.html

+4-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
<title>{% block title %}{{ config['SITE_TITLE'] }}{% endblock %}</title>
44
<meta name="DC.title" content="{{ config['SITE_TITLE'] }}"/>
55
{%- endblock %}
6+
67
{% block content %}
7-
<p>
8-
HasGeek.tv is coming soon.
9-
</p>
10-
{% if g.user %}
11-
<p>
12-
You are logged in!
13-
</p>
14-
{% endif %}
8+
9+
Coming soon.
10+
1511
{% endblock %}

hgtv/templates/playlist.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{% extends "layout.html" %}
2+
{% block title %}Playlist: {{ playlist.title }}{% endblock %}

hgtv/templates/tag.html

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{% extends "layout.html" %}
2+
{% block title %}Videos tagged with {{ channel.title }}{% endblock %}

hgtv/templates/video.html

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% extends "layout.html" %}
2+
{% block headline %}
3+
<h1><a href="/diogo">Diogo Ferreira on CyanogenMod</a> <small>&laquo; <a href="/droidcon">Droidcon</a> <a href="/droidcon/2011">2011</a></small></h1>
4+
<p>Recorded November 2011</p>
5+
{% endblock %}
6+
7+
{% block content %}
8+
9+
<div class="row">
10+
<div class="span6">
11+
<div class="video169">
12+
<iframe src="http://www.youtube.com/embed/rTcFk4L7ux0?wmode=transparent" frameborder="0" allowfullscreen></iframe>
13+
</div>
14+
</div>
15+
<div class="span6">
16+
<div class="video169">
17+
<iframe src="http://www.slideshare.net/slideshow/embed_code/9303960" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
18+
</div>
19+
</div>
20+
</div>
21+
22+
{% endblock %}

hgtv/views/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: utf-8 -*-
22

3-
import os
4-
from flask import send_from_directory
5-
from hgtv import app
6-
73
import hgtv.views.index
84
import hgtv.views.login
5+
import hgtv.views.channel
6+
import hgtv.views.playlist
7+
import hgtv.views.video
8+
import hgtv.views.tag

hgtv/views/channel.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
3+
from flask import render_template
4+
from coaster.views import load_model
5+
6+
from hgtv import app
7+
from hgtv.models import Channel
8+
9+
10+
@app.route('/<channel>/')
11+
@load_model(Channel, {'name': 'channel'}, 'channel')
12+
def channel_view(channel):
13+
return render_template('channel.html', channel=channel)

hgtv/views/index.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
# -*- coding: utf-8 -*-
22

33
import os
4-
from flask import g, send_from_directory, Response, get_flashed_messages, flash, render_template
4+
from flask import send_from_directory, render_template
55
from hgtv import app
66

7+
78
@app.route('/')
89
def index():
910
return render_template('index.html')
10-
resp = []
11-
for category, msg in get_flashed_messages(with_categories=True):
12-
resp.append(u'-- %s: %s --' % (category, msg))
13-
if g.user:
14-
resp.append(u'User: %s' % g.user)
15-
resp.append(u"HasGeek.tv. Come back later.")
16-
return Response(u'\n'.join(resp), mimetype="text/plain")
11+
12+
13+
@app.route('/favicon.ico')
14+
def favicon():
15+
return send_from_directory(os.path.join(app.root_path, 'static', 'img'),
16+
'favicon.ico', mimetype='image/vnd.microsoft.icon')

0 commit comments

Comments
 (0)