Skip to content

Commit

Permalink
Adding trainer and account type to home page.
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelclay committed Oct 17, 2010
1 parent ee0d86f commit 554beb5
Show file tree
Hide file tree
Showing 15 changed files with 137 additions and 89 deletions.
12 changes: 10 additions & 2 deletions apps/reader/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ def index(request):
else:
login_form = LoginForm(prefix='login')
signup_form = SignupForm(prefix='signup')

features = Feature.objects.all()[:3]
feature_form = None
if request.user.is_staff:
feature_form = FeatureForm()

feed_count = 0
train_count = 0
if request.user.is_authenticated():
feed_count = UserSubscription.objects.filter(user=request.user, active=True).count()
train_count = UserSubscription.objects.filter(user=request.user, active=True, is_trained=False, feed__stories_last_month__gte=1).count()

howitworks_page = random.randint(0, 5)
return render_to_response('reader/feeds.xhtml', {
'login_form': login_form,
Expand All @@ -54,6 +60,9 @@ def index(request):
'features': features,
'start_import_from_google_reader': request.session.get('import_from_google_reader', False),
'howitworks_page': howitworks_page,
'feed_count': feed_count,
'train_count': feed_count - train_count,
'account_images': range(1, 4),
}, context_instance=RequestContext(request))

@never_cache
Expand Down Expand Up @@ -558,7 +567,6 @@ def save_feed_order(request):
def get_feeds_trainer(request):
classifiers = []
feed_id = request.POST.get('feed_id')

usersubs = UserSubscription.objects.filter(user=request.user)
if feed_id:
feed = get_object_or_404(Feed, pk=feed_id)
Expand Down
70 changes: 62 additions & 8 deletions media/css/reader.css
Original file line number Diff line number Diff line change
Expand Up @@ -1801,8 +1801,8 @@ a.NB-splash-link:hover {
float: left;
}

.NB-modal .NB-modal-submit input[type=submit],
.NB-modal .NB-modal-submit .NB-modal-submit-button {
.NB-modal-submit input[type=submit],
.NB-modal-submit .NB-modal-submit-button {
border: 1px solid #606060;
font-size: 12px;
padding: 4px 12px;
Expand All @@ -1818,28 +1818,28 @@ a.NB-splash-link:hover {
text-decoration: none;
}

.NB-modal .NB-modal-submit .NB-modal-submit-back {
.NB-modal-submit .NB-modal-submit-back {
background-color: #d5d4dB;
color: #909090;

}
.NB-modal .NB-modal-submit .NB-modal-submit-close {
.NB-modal-submit .NB-modal-submit-close {
background-color: #d5d4dB;
color: #909090;
font-weight: bold;
}
.NB-modal .NB-modal-submit .NB-modal-submit-green {
.NB-modal-submit .NB-modal-submit-green {
background-color: #217412;
font-weight: bold;
color: #FCFCFC;
}

.NB-modal .NB-modal-submit .NB-modal-submit-delete {
.NB-modal-submit .NB-modal-submit-delete {
background-color: #7E020D;
font-weight: bold;
color: #FCFCFC;
}
.NB-modal .NB-modal-submit .NB-disabled {
.NB-modal-submit .NB-disabled {
background-color: #d5d4dB;
color: #909090;
border: 1px solid #A0A0A0;
Expand Down Expand Up @@ -2463,6 +2463,58 @@ background: transparent;
float: right;
}

.NB-account .NB-module .NB-module-account {
position: relative;
min-height: 77px;
margin: 0 0 12px;
}

.NB-account .NB-module .NB-module-account.NB-last {
margin-bottom: 0;
}

.NB-account .NB-module .NB-module-account h3 {
border-bottom: 1px solid #F0F0F0;
padding: 4px 0 0px;
margin: 4px 0 4px 128px;
font-size: 13px;
text-transform: uppercase;
color: #134160;
text-shadow: 1px 1px 0 #E0E0E0;
}

.NB-account .NB-module .NB-module-account .NB-module-account-subtitle {
float: right;
color: #C0C0C0;
text-shadow: none;
margin-right: 12px;
}

.NB-account .NB-module .NB-module-account .NB-module-account-image {
position: absolute;
left: 0;
top: 0;
}

.NB-account .NB-module .NB-module-account .NB-module-account-image img {
width: 100px;
height: 75px;
overflow: hidden;
margin: 0 8px 2px 12px;
border: 1px solid #606060;
-moz-box-shadow: 1px 1px 0 #303030;
-webkit-box-shadow: 1px 1px 0 #303030;
box-shadow: 1px 1px 0 #303030;
}

.NB-account .NB-module .NB-module-account .NB-module-account-title {
margin: 0 0 4px 128px;
}
.NB-account .NB-module .NB-module-account .NB-modal-submit-button {
float: left;
margin: 4px 0 0 0;
}

/* ============ */
/* = Features = */
/* ============ */
Expand Down Expand Up @@ -2500,10 +2552,12 @@ background: transparent;
padding: 4px 8px;
margin: 0;
color: #134160;
text-shadow: 1px 1px 0 #E0E0E0;
font-size: 12px;
font-weight: bold;
line-height: 20px;
white-space: nowrap;
min-width: 100px;
}

.NB-module-features .NB-module-feature.last .NB-module-feature-date {
Expand Down Expand Up @@ -3100,7 +3154,7 @@ background: transparent;
list-style: none;
/* margin: 12px 0;*/
padding: 0;
max-height: 260px;
max-height: 256px;
min-height: 186px;
width: auto;
border: 1px solid #909090;
Expand Down
Binary file added media/img/reader/account_premium_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/img/reader/account_premium_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/img/reader/account_premium_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/img/reader/account_standard_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/img/reader/account_standard_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/img/reader/account_standard_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/img/reader/account_trainer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions media/js/newsblur/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3502,6 +3502,18 @@
self.open_feedchooser_modal();
}
});
$.targetIs(e, { tagSelector: '.NB-module-account-upgrade' }, function($t, $p){
e.preventDefault();
if (!$t.hasClass('NB-disabled')) {
self.open_feedchooser_modal();
}
});
$.targetIs(e, { tagSelector: '.NB-module-account-train' }, function($t, $p){
e.preventDefault();
if (!$t.hasClass('NB-disabled')) {
self.open_trainer_modal();
}
});
$.targetIs(e, { tagSelector: '.task_button_view' }, function($t, $p){
e.preventDefault();
var view;
Expand Down
8 changes: 4 additions & 4 deletions media/js/newsblur/reader_classifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ var classifier = {
$.make('li', [
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/sample_classifier_tag.png', style: 'float: right', width: 135, height: 20 }),
$.make('b', 'You will see a bunch of tags and authors.'),
' Check the features you want to see in stories. If you check too many options, you won\'t filter the good stories from the neutral stories.'
' Check the features you want to see in stories. If you check too many options, you won\'t find the good among the neutral.'
]),
$.make('li', [
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/intelligence_slider_positive.png', style: 'float: right', width: 114, height: 29 }),
Expand All @@ -244,14 +244,14 @@ var classifier = {
$.make('li', [
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/sample_menu.png', style: 'float: right', width: 176, height: 118 }),
$.make('b', 'Stop at any time you like.'),
' You can always come back to this trainer.'
' You can always come back to this.'
]),
$.make('li', [
$.make('b', 'Don\'t worry if you don\'t know what you like right now.'),
' Just skip the site. You can click the ',
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs-up.png', style: 'vertical-align: middle;padding: 0 8px 0 2px', width: 14, height: 20 }),
$.make('img', { src: NEWSBLUR.Globals.MEDIA_URL + '/img/reader/thumbs-down.png', style: 'vertical-align: top; padding: 0', width: 14, height: 20 }),
' buttons next to stories as you read them.'
' buttons as you read stories.'
])
]),
(!NEWSBLUR.Globals.is_authenticated && $.make('div', { className: 'NB-trainer-not-authenticated' }, 'Please create an account and add sites you read. Then you can train them.')),
Expand Down Expand Up @@ -626,7 +626,7 @@ var classifier = {
setTimeout(function() {
self.flags.modal_loaded = true;
$(window).resize();
}, 200);
});
});
},
'onShow': function(dialog) {
Expand Down
2 changes: 1 addition & 1 deletion media/js/newsblur/reader_feedchooser.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ NEWSBLUR.ReaderFeedchooser.prototype = {
},

resize_modal: function(previous_height) {
var height = this.$modal.height() + 24;
var height = this.$modal.height() + 16;
var parent_height = this.$modal.parent().height();
if (height > parent_height && previous_height != height) {
var chooser_height = $('#NB-feedchooser-feeds').height();
Expand Down
78 changes: 48 additions & 30 deletions templates/reader/feeds.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,56 @@
<a href="{% url logout %}?next=/" class="NB-splash-link">Logout</a>
</div>
</h5>
<div class="NB-module-account">
<div class="NB-module-account-image">
{% if user.profile.is_premium %}
<img src="{{ MEDIA_URL }}/img/reader/account_premium_{{ account_images|random }}.jpg" />
{% else %}
<img src="{{ MEDIA_URL }}/img/reader/account_standard_{{ account_images|random }}.jpg" />
{% endif %}
</div>
<h3>
{% if user.profile.is_premium %}
<span class="NB-module-account-subtitle">
{{ feed_count }} site{{ feed_count|pluralize }}
</span>
Premium Account
{% else %}
<span class="NB-module-account-subtitle">
{{ feed_count }} of 64 sites
</span>
Standard Account
{% endif %}
</h3>
<div class="NB-module-account-title">
{% if user.profile.is_premium %}

{% else %}

<div class="NB-modal-submit">
<div class="NB-modal-submit-green NB-modal-submit-button NB-module-account-upgrade">Choose Your 64</div>
</div>
{% endif %}
</div>
</div>
<div class="NB-module-account NB-last">
<div class="NB-module-account-image">
<img src="{{ MEDIA_URL }}/img/reader/account_trainer.jpg" />
</div>
<h3>
<span class="NB-module-account-subtitle">
{{ train_count }} of {{ feed_count }} site{{ feed_count|pluralize }}
</span>
Intelligence Trainer
</h3>
<div class="NB-module-account-title">
<div class="NB-modal-submit">
<div class="NB-modal-submit-green NB-modal-submit-button NB-module-account-train">Train Your Filters</div>
</div>
</div>
</div>
</div>
<!--
<div class="NB-module NB-module-features">
<h5 class="NB-module-header">Intelligence Trainer</h5>

<table class="" cellpadding="0" cellspacing="0">
<tr class="NB-module-feature NB-module-feature-new">
<td class="NB-module-feature-date">Today, August 25th</td>
<td class="NB-module-feature-description">I am aware that approximately 20% of all feeds are failing to fetch and parse. The fix will be coming sometime today or tomorrow.</td>
</tr>
</table>
</div>-->
{% endif %}

<div class="NB-module NB-module-features">
Expand Down Expand Up @@ -237,26 +275,6 @@
{% endif %}
</div>

{% if user.is_authenticated and false %}
<div class="NB-module NB-module-stats">
<h5 class="NB-module-header">
Spread the Love
</h5>

<table class="NB-module-features" cellpadding="0" cellspacing="0">
<tr class="NB-module-feature {% if forloop.last %}last{% endif %}">
<td class="NB-module-feature-description"><a href="http://twitter.com/?status=NewsBlur, an intelligent feed reader, makes me swoon: http://www.newsblur.com."><b>Tweet your support</b></a> <img class="NB-module-feature-arrow" src="{{ MEDIA_URL }}/img/icons/silk/arrow_right.png" /> The more people who use NewsBlur, the more incentive there is to continually improve it. <a href="http://twitter.com/samuelclay">Follow @samuelclay</a> for fun.</td>
</tr>
</table>
{% if user.is_staff %}
<form action="{% url add-feature %}" id="add-feature-form" method="post">
{{ feature_form.description }}
<input type="submit" value="Add feature" />
</form>
{% endif %}
</div>
{% endif %}

</div>


Expand Down
4 changes: 0 additions & 4 deletions urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from django.conf.urls.defaults import *
from django.conf import settings
from apps.reader import views as reader_views
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
url(r'^$', reader_views.index, name='index'),
Expand All @@ -11,8 +9,6 @@
(r'^classifier/', include('apps.analyzer.urls')),
(r'^profile/', include('apps.profile.urls')),
(r'^import/', include('apps.feed_import.urls')),
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root)
)

if settings.DEVELOPMENT:
Expand Down
40 changes: 0 additions & 40 deletions utils/compressed_textfield.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
from base64 import binascii
from django.db import models
from django.utils.text import compress_string
from django.db.models.signals import post_init
from django.utils.encoding import smart_unicode

from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^utils\.compressed_textfield\.StoryField"])
add_introspection_rules([], ["^utils\.compressed_textfield\.CompressedTextField"])

def uncompress_string(s):
'''helper function to reverse django.utils.text.compress_string'''
Expand Down Expand Up @@ -43,38 +38,3 @@ def get_prep_save(self, value):
# print "Post To DB: %s %s" % (len(value), value[:25])

return super(StoryField, self).get_prep_save(value)


class CompressedTextField(models.TextField):
'''transparently compress data before hitting the db and uncompress after fetching'''

def get_db_prep_save(self, value):
if value is not None:
value = compress_string(value)
return models.TextField.get_db_prep_save(self, value)

def _get_val_from_obj(self, obj):
if obj:
return uncompress_string(getattr(obj, self.attname))
else:
return self.get_default()

def post_init(self, instance=None, **kwargs):
value = self._get_val_from_obj(instance)
if value:
setattr(instance, self.attname, value)

def contribute_to_class(self, cls, name):
super(CompressedTextField, self).contribute_to_class(cls, name)
post_init.connect(self.post_init, sender=cls)

def get_internal_type(self):
return "TextField"

def db_type(self):
from django.conf import settings
db_types = {'mysql':'longblob','sqlite3':'blob'}
try:
return db_types[settings.DATABASE_ENGINE]
except KeyError:
raise Exception, '%s currently works only with: %s'%(self.__class__.__name__,','.join(db_types.keys()))

0 comments on commit 554beb5

Please sign in to comment.