Merge branch 'master' of github.com:nicksergeant/snipt
commit
9beb544fc9
|
@ -70,6 +70,10 @@ def blog_post(request, username_or_custom_slug):
|
|||
normal_snipts = normal_snipts.exclude(tags__name__in=['tmp'])
|
||||
normal_snipts = normal_snipts[:3]
|
||||
|
||||
if snipt.user != request.user:
|
||||
snipt.views = snipt.views + 1
|
||||
snipt.save()
|
||||
|
||||
context = {
|
||||
'blog_user': request.blog_user,
|
||||
'detail': True,
|
||||
|
|
4
gk
4
gk
|
@ -1,3 +1,3 @@
|
|||
#!/usr/local/bin/fish
|
||||
#!/bin/bash
|
||||
|
||||
kill (cat .gunicorn.pid)
|
||||
kill `cat .gunicorn.pid`
|
||||
|
|
2
gs
2
gs
|
@ -1,3 +1,3 @@
|
|||
#!/usr/local/bin/fish
|
||||
#!/bin/bash
|
||||
|
||||
gunicorn -c gunicorn.conf.py debug_wsgi:application
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -753,7 +753,7 @@ article.snipt {
|
|||
}
|
||||
}
|
||||
section.code {
|
||||
height: 200px;
|
||||
height: 230px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
z-index: 49;
|
||||
|
@ -806,7 +806,7 @@ article.snipt {
|
|||
border: none;
|
||||
font: normal 12px/16px $Consolas;
|
||||
margin: 0;
|
||||
min-height: 190px;
|
||||
min-height: 220px;
|
||||
overflow-x: auto;
|
||||
padding: 5px;
|
||||
white-space: pre;
|
||||
|
@ -1010,8 +1010,8 @@ article.snipt {
|
|||
}
|
||||
}
|
||||
}
|
||||
section.tags {
|
||||
padding-top: 15px;
|
||||
section.meta {
|
||||
padding-top: 10px;
|
||||
|
||||
h2 {
|
||||
background: transparent url('/static/images/snipt-tags-icon.png') 15px center no-repeat;
|
||||
|
@ -1023,6 +1023,8 @@ article.snipt {
|
|||
margin: 0;
|
||||
|
||||
li {
|
||||
color: #999;
|
||||
font: normal 12px $Helvetica;
|
||||
list-style-type: none;
|
||||
margin: 5px 10px 5px 35px;
|
||||
|
||||
|
@ -1193,6 +1195,20 @@ article.snipt {
|
|||
}
|
||||
}
|
||||
}
|
||||
&.blog-post.favorited {
|
||||
div.container {
|
||||
header {
|
||||
@include vertical-gradient-with-image(url('/static/images/favorited-icon.png') top right no-repeat, #FFF, #F0F4FC);
|
||||
@include inset-box-shadow(0, -1px, 0, #E3E9F5);
|
||||
|
||||
h1 {
|
||||
a {
|
||||
padding-right: 25px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
&.snipt-expand {
|
||||
div.container {
|
||||
section.code {
|
||||
|
|
|
@ -5,7 +5,7 @@ from snipts.models import Favorite, Snipt
|
|||
|
||||
class SniptAdmin(admin.ModelAdmin):
|
||||
readonly_fields = ('user',)
|
||||
list_display = ('title', 'slug', 'user', 'lexer', 'public', 'blog_post', 'created', 'modified', 'publish_date',)
|
||||
list_display = ('title', 'slug', 'views', 'favs', 'user', 'lexer', 'public', 'blog_post', 'created', 'modified', 'publish_date',)
|
||||
list_filter = ('blog_post',)
|
||||
search_fields = ('title', 'slug', 'user__username', 'lexer', 'id', 'key',)
|
||||
ordering = ('-created',)
|
||||
|
|
|
@ -205,6 +205,10 @@ class PrivateSniptResource(ModelResource):
|
|||
bundle.data['tags_list'] = edit_string_for_tags(bundle.obj.tags.all())
|
||||
bundle.data['full_absolute_url'] = bundle.obj.get_full_absolute_url()
|
||||
|
||||
if bundle.data['user'].data['profile']['is_pro']:
|
||||
bundle.data['views'] = bundle.obj.views
|
||||
bundle.data['favs'] = bundle.obj.favs()
|
||||
|
||||
if bundle.data['publish_date']:
|
||||
bundle.data['publish_date'] = date(bundle.data['publish_date'], 'M d, Y \\a\\t h:i A')
|
||||
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding field 'Snipt.views'
|
||||
db.add_column('snipts_snipt', 'views',
|
||||
self.gf('django.db.models.fields.IntegerField')(default=0),
|
||||
keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Deleting field 'Snipt.views'
|
||||
db.delete_column('snipts_snipt', 'views')
|
||||
|
||||
|
||||
models = {
|
||||
'auth.group': {
|
||||
'Meta': {'object_name': 'Group'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||
},
|
||||
'auth.permission': {
|
||||
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
},
|
||||
'auth.user': {
|
||||
'Meta': {'object_name': 'User'},
|
||||
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||
},
|
||||
'contenttypes.contenttype': {
|
||||
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||
},
|
||||
'snipts.favorite': {
|
||||
'Meta': {'object_name': 'Favorite'},
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'snipt': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['snipts.Snipt']"}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||
},
|
||||
'snipts.snipt': {
|
||||
'Meta': {'object_name': 'Snipt'},
|
||||
'blog_post': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'code': ('django.db.models.fields.TextField', [], {}),
|
||||
'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'custom_slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
'embedded': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'key': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
|
||||
'lexer': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
|
||||
'line_count': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
|
||||
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||
'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'publish_date': ('django.db.models.fields.DateTimeField', [], {'null': 'True', 'blank': 'True'}),
|
||||
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '255', 'blank': 'True'}),
|
||||
'stylized': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
|
||||
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'}),
|
||||
'views': ('django.db.models.fields.IntegerField', [], {'default': '0'})
|
||||
},
|
||||
'taggit.tag': {
|
||||
'Meta': {'object_name': 'Tag'},
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100'})
|
||||
},
|
||||
'taggit.taggeditem': {
|
||||
'Meta': {'object_name': 'TaggedItem'},
|
||||
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taggit_taggeditem_tagged_items'", 'to': "orm['contenttypes.ContentType']"}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'object_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
|
||||
'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taggit_taggeditem_items'", 'to': "orm['taggit.Tag']"})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['snipts']
|
|
@ -37,6 +37,8 @@ class Snipt(models.Model):
|
|||
key = models.CharField(max_length=100, blank=True, null=True)
|
||||
public = models.BooleanField(default=False)
|
||||
blog_post = models.BooleanField(default=False)
|
||||
|
||||
views = models.IntegerField(default=0)
|
||||
|
||||
created = models.DateTimeField(auto_now_add=True, editable=False)
|
||||
modified = models.DateTimeField(auto_now=True, editable=False)
|
||||
|
@ -107,6 +109,9 @@ class Snipt(models.Model):
|
|||
def __unicode__(self):
|
||||
return self.title
|
||||
|
||||
def favs(self):
|
||||
return Favorite.objects.filter(snipt=self).count()
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
||||
if self.blog_post:
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<a class="copy" href="#">Copy</a>
|
||||
</li>
|
||||
</ul>
|
||||
<section class="tags">
|
||||
<section class="meta tags">
|
||||
<h2><%= snipt.tags.length %> tag<% if ((snipt.tags.length > 1) || (snipt.tags.length === 0)) { print('s'); } %></h2>
|
||||
<ul>
|
||||
<% for (var i=0; i < snipt.tags.length; i++) { %>
|
||||
|
@ -53,6 +53,14 @@
|
|||
<% } %>
|
||||
</ul>
|
||||
</section>
|
||||
<% if (snipt.user.profile.is_pro) { %>
|
||||
<section class="meta stats">
|
||||
<ul>
|
||||
<li><%= snipt.views %> views</li>
|
||||
<li><%= snipt.favs %> favs</li>
|
||||
</ul>
|
||||
</section>
|
||||
<% } %>
|
||||
</aside>
|
||||
</div>
|
||||
<footer>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
{% endif %}
|
||||
</ul>
|
||||
{% if snipt.tags.all %}
|
||||
<section class="tags">
|
||||
<section class="meta tags">
|
||||
<h2>{{ snipt.tags.all|length }} tag{{ snipt.tags.all|pluralize }}</h2>
|
||||
<ul>
|
||||
{% for tag in snipt.sorted_tags %}
|
||||
|
@ -92,6 +92,16 @@
|
|||
</ul>
|
||||
</section>
|
||||
{% endif %}
|
||||
{% if request.user.profile.is_pro and snipt.user == request.user %}
|
||||
<section class="meta stats">
|
||||
<ul>
|
||||
<li>{{ snipt.views|intcomma }} view{{ snipt.views|pluralize }}
|
||||
{% if not snipt.blog_post %}
|
||||
<li>{{ snipt.favs|intcomma }} fav{{ snipt.favs|pluralize }}
|
||||
{% endif %}
|
||||
</ul>
|
||||
</section>
|
||||
{% endif %}
|
||||
</aside>
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
|
|
@ -46,6 +46,9 @@ def detail(request, username, snipt_slug):
|
|||
if request.GET.get('key') != snipt.key:
|
||||
raise Http404
|
||||
|
||||
snipt.views = snipt.views + 1
|
||||
snipt.save()
|
||||
|
||||
tags = Tag.objects
|
||||
|
||||
if user == request.user:
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
<h6>Current Pro features:</h6>
|
||||
<ul>
|
||||
<li>No advertisements (including Amazon books).</li>
|
||||
<li>Stats on "views" and "favorites" for your snipts.</li>
|
||||
<li>“Pro” badge throughout the site.</li>
|
||||
<li>Custom domain for your <a href="https://blog.snipt.net/announcing-the-sniptnet-blogging-platform/">Snipt blog</a>. Contact <a href="mailto:support@snipt.net">support@snipt.net</a> to set up.</li>
|
||||
<li>You’re <strong>supporting</strong> current and future development. This stuff takes time and money.</li>
|
||||
<li>Custom domain for your <a href="https://blog.snipt.net/announcing-the-sniptnet-blogging-platform/">Snipt blog</a>. Contact <a href="mailto:support@snipt.net">support@snipt.net</a> to set it up.</li>
|
||||
</ul>
|
||||
<h6>Planned Pro features (not in order):</h6>
|
||||
<ul>
|
||||
|
|
Loading…
Reference in New Issue