Skip to content

Commit

Permalink
Merge pull request #2 from pietdaniel/refactorings
Browse files Browse the repository at this point in the history
further removal of dead code, general cleaning and grokings
  • Loading branch information
pietdaniel committed May 18, 2014
2 parents 9b92273 + 43ae01b commit 1686398
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 70 deletions.
14 changes: 2 additions & 12 deletions poetification/poetification/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@
https://docs.djangoproject.com/en/1.6/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '))n56hpl-i=2rfm$5ptoiojcbh)b@^h*=p$gwca^=yt4qak$t4'

Expand All @@ -27,7 +22,6 @@
ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
Expand All @@ -52,11 +46,11 @@
GITHUB_APP_ID = os.environ['GITHUB_APP_ID']
GITHUB_API_SECRET = os.environ['GITHUB_API_SECRET']
FACEBOOK_EXTENDED_PERMISSIONS = ['read_stream']
LOGIN_URL = '/login-form/'

# LOGIN_URL = '/login-form/'
LOGIN_REDIRECT_URL = '/complete/'
LOGIN_ERROR_URL = '/login-error/'


SOCIAL_AUTH_DEFAULT_USERNAME = 'new_social_auth_user'
SOCIAL_AUTH_UID_LENGTH = 16
SOCIAL_AUTH_ASSOCIATION_HANDLE_LENGTH = 16
Expand Down Expand Up @@ -95,7 +89,6 @@

# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
Expand All @@ -105,7 +98,6 @@

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'
Expand All @@ -116,10 +108,8 @@

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
STATICFILES_FINDERS = (
Expand Down
22 changes: 6 additions & 16 deletions poetification/webpoet/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,27 @@
from lineutils import *
from nltk_contrib.readability import syllables_en as SE
from collections import defaultdict
# from syllable import *
from poemtypes import *

class PostList(models.Model):
def __init__(self, phrases):
self.lines = [Line.get_line(p) for p in phrases]
self.lines = filter(lambda x: bool(x), self.lines)

self.fhash = None

@staticmethod
def fromFacebookFeed(feed):
# postlist = PostList([msg['message'] for msg in feed])
# return postlist
feeddata = []
# print feed
try:
feeddata = feed['paging']['data']
except:
# print "error"
feeddata = feed['data']
finally:
postlist = []
for msg in feeddata:
try:
# print msg['message']
postlist.append(msg['message'])
except: continue

return PostList(postlist)

@staticmethod
Expand Down Expand Up @@ -66,14 +58,8 @@ def get_line(phrase):
else:
return None


def nsyl(self, word):
return SE.count(word)
# word = RhymeWord.findWord(word)
# if not word:
# return 0
# else:
# return word.syllables

@property
def syllables(self):
Expand Down Expand Up @@ -103,7 +89,6 @@ class RhymeWord(models.Model):
class Meta:
unique_together = ['word', 'syllables', 'rhyme_phoneme']


@staticmethod
def findWord(word):
rw = None
Expand All @@ -126,4 +111,9 @@ def findWord(word):
rw.save()
finally:
return rw







1 change: 0 additions & 1 deletion poetification/webpoet/poemtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def __init__(self, posts):
if (ele.syllables > 4 and ele.syllables < 8):
n.append(ele.text)


if (len(m)+len(n)) < 5:
return #Not a poem!

Expand Down
33 changes: 0 additions & 33 deletions poetification/webpoet/templates/webpoet/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,6 @@
</head>

<body>
<!-- <nav class="navbar navbar-default" role="navigation"> -->
<!-- Brand and toggle get grouped for better mobile display -->
<!-- <div class="navbar-header"> -->
<!-- <button type="button" class="navbar-toggle" data-toggle="collapse" >
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button> -->
<!-- <a class="navbar-brand" href="/home">webpoet</a> -->
<!-- </div> -->

<!-- Collect the nav links, forms, and other content for toggling -->
<!-- <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> -->
<!-- <ul class="nav navbar-nav"> -->
<!-- <li class="{% active request 'home' %}"><a href="/home">Home</a></li> -->
<!-- <li class="{% active request 'poems' %}"><a href="/poems">Poems</a></li> -->
<!-- <li class="{% active request 'new' %}"><a href="/new">New Poem!</a></li> -->
<!-- </ul> -->
<!-- <ul class="nav navbar-nav navbar-right">
<li class="navbar-text">{{ request.user.name }}</li>
<li><a href="/logout">Logout</a></li>
</ul> -->
<!-- </div> --><!-- /.navbar-collapse -->
<!-- </nav> -->
{% block content %}{% endblock %}

<!-- <div class="navbar-bottom"> -->
<!-- <nav class="navbar navbar-default well" role="navigation"> -->
<!-- <ul class="nav navbar-nav pull-left">
<li class="navbar-text pull-left">&copy; YUH</li>
</ul> -->
<!-- </nav> -->
<!-- </div> -->
</body>
</html>
9 changes: 1 addition & 8 deletions poetification/webpoet/templates/webpoet/poem.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
{% load staticfiles %}

{% block content %}
<!-- <div class="panel panel-default"> -->
<!-- <div class="panel-heading"> -->
<!-- <h3 class="panel-title">Web Poems</h3> -->
<!-- </div> -->
<div class="panel-title text-center" style='padding-top:90px'>
<h1 id='poem_title'>POETIFICATION</h1>
<h1 id='poem_title'>RHYMING STATU.US</h1>
</div>


<div class="container">
<div class="row">
<div class="col-lg-4 text-center" style='padding-top:90px'>
Expand All @@ -31,7 +26,5 @@ <h1 id='poem_title'>POETIFICATION</h1>
</div>
</div>


<!-- </div> -->
{% endblock %}

File renamed without changes.
File renamed without changes.

0 comments on commit 1686398

Please sign in to comment.