More work on getting Snippets up.

master
Nick Sergeant 2019-01-21 20:10:10 -05:00
parent c12e294599
commit 94189c216f
12 changed files with 3204 additions and 37 deletions

View File

@ -61,9 +61,12 @@ assets:
> media/js/pro-all.min.js
deploy:
git push heroku
git push dokku
run:
~/.virtualenvs/snipt/bin/python manage.py runserver
sass:
sass --sourcemap=none --watch -t compressed --scss media/css/style.scss:media/css/style.css
sass media/css/style.scss > media/css/style.css
.PHONY: deploy sass
.PHONY: deploy run sass

View File

@ -1,5 +1,23 @@
# Siftie Snippets
## Running locally:
- Clone the repo.
- `cd snippets`
- `python3 -m venv ~/.virtualenvs/snipt`
- `source ~/.virtualenvs/snipt/bin/activate`
- `pip install -r requirements.txt`
- `brew install postgresql`
- `brew services start postgresql`
- `createuser snippets`
- `createdb snippets --owner=snippets`
- `cp settings_local.py-template settings_local.py` // modify if necessary
- `brew install elasticsearch`
- `brew services start elasticsearch`
- `curl -X PUT "localhost:9200/haystack?pretty"`
- `python manage.py update_index` // optional if you have a local DB dump with snippets
- `make run`
## Automatic deploy to Heroku
You can click the button below to automatically deploy Siftie Snippets to Heroku.

View File

@ -45,7 +45,7 @@ class UserProfile(models.Model):
)
# User
user = models.OneToOneField(User)
user = models.OneToOneField(User, on_delete=models.DO_NOTHING)
is_pro = models.BooleanField(default=False)
teams_beta_seen = models.BooleanField(default=False)
teams_beta_applied = models.BooleanField(default=False)

File diff suppressed because one or more lines are too long

View File

@ -58,14 +58,15 @@ $Rockwell: 'Rockwell', 'Courier Bold', Courier, Georgia, Times, 'Times New Roman
border-bottom-right-radius: $bottomRight;
border-bottom-left-radius: $bottomLeft;
}
@mixin vertical-gradient($start: #000, $stop: #FFF) { background: ($start + $stop) / 2;
@mixin vertical-gradient($start: #000, $stop: #FFF) {
background: $start;
background: -webkit-gradient(linear, left top, left bottom, from($start), to($stop));
background: -moz-linear-gradient(center top, $start 0%, $stop 100%);
background: -moz-gradient(center top, $start 0%, $stop 100%);
background: linear-gradient(to bottom, $start 0%, $stop 100%);
}
@mixin vertical-gradient-with-image($image, $start: #000, $stop: #FFF) {
background: ($start + $stop) / 2 $image;
background: $start;
background: $image, -webkit-gradient(linear, left top, left bottom, from($start), to($stop));
background: $image, -moz-linear-gradient(center top, $start 0%, $stop 100%);
background: $image, -moz-gradient(center top, $start 0%, $stop 100%);
@ -163,7 +164,7 @@ header.main {
}
nav.public {
float: left;
width: 435px;
width: 481px;
ul {
margin: 0;

View File

@ -1,6 +1,6 @@
Django==1.10.3
Django==1.11.18
Fabric==1.12.0
PyYAML==3.12
PyYAML==3.13
Pygments==2.1.3
certifi==2016.9.26
dj-database-url==0.4.1
@ -9,13 +9,13 @@ django-annoying==0.10.3
django-cors-headers==1.3.1
django-debug-toolbar==1.3.2
django-extensions==1.7.4
django-haystack==2.5.1
django-haystack==2.8.1
django-markdown-deux==1.0.5
django-registration-redux==1.4
django-storages==1.5.1
django-taggit==0.21.3
django-tastypie==0.13.3
elasticsearch==5.0.0
django-tastypie==0.14
elasticsearch==6.3.1
git+git://github.com/matagus/django-pagination-py3.git#egg=django-pagination
git+git://github.com/nicksergeant/django-templatetag-sugar.git#egg=django-templatetag-sugar
gunicorn==19.6.0
@ -29,5 +29,5 @@ requests==2.11.1
six==1.9.0
smartypants==1.8.6
stripe==1.41.1
urllib3==1.11
urllib3==1.24.1
whitenoise==3.2.2

View File

@ -9,9 +9,9 @@ USE_HTTPS = False
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'snipt',
'USER': 'snipt',
'PASSWORD': 'password',
'NAME': 'snippets',
'USER': 'snippets',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': ''
}

View File

@ -22,11 +22,12 @@ from teams.models import Team
class Snipt(models.Model):
"""An individual Snipt."""
user = models.ForeignKey(User, blank=True, null=True)
user = models.ForeignKey(User, blank=True, null=True, on_delete=models.DO_NOTHING)
last_user_saved = models.ForeignKey(User,
blank=True,
null=True,
related_name='last_user_saved')
related_name='last_user_saved',
on_delete=models.DO_NOTHING)
title = models.CharField(max_length=255, blank=True, null=True,
default='Untitled')
@ -299,8 +300,8 @@ class Snipt(models.Model):
class SniptLogEntry(models.Model):
"""An individual log entry for a snippet changeset."""
user = models.ForeignKey(User)
snipt = models.ForeignKey(Snipt)
user = models.ForeignKey(User, on_delete=models.DO_NOTHING)
snipt = models.ForeignKey(Snipt, on_delete=models.DO_NOTHING)
code = models.TextField()
diff = models.TextField()
@ -316,8 +317,8 @@ class SniptLogEntry(models.Model):
class SniptSecureView(models.Model):
"""A single view to a secure snippet."""
user = models.ForeignKey(User)
snipt = models.ForeignKey(Snipt)
user = models.ForeignKey(User, on_delete=models.DO_NOTHING)
snipt = models.ForeignKey(Snipt, on_delete=models.DO_NOTHING)
created = models.DateTimeField(auto_now_add=True, editable=False)
modified = models.DateTimeField(auto_now=True, editable=False)
@ -328,8 +329,8 @@ class SniptSecureView(models.Model):
class Favorite(models.Model):
snipt = models.ForeignKey(Snipt)
user = models.ForeignKey(User)
snipt = models.ForeignKey(Snipt, on_delete=models.DO_NOTHING)
user = models.ForeignKey(User, on_delete=models.DO_NOTHING)
created = models.DateTimeField(auto_now_add=True, editable=False)
modified = models.DateTimeField(auto_now=True, editable=False)

View File

@ -19,10 +19,10 @@ class Team(models.Model):
email = models.EmailField(max_length=255)
members = models.ManyToManyField(User, related_name='member', blank=True)
name = models.CharField(max_length=30)
owner = models.ForeignKey(User, related_name='owner')
owner = models.ForeignKey(User, related_name='owner', on_delete=models.DO_NOTHING)
slug = models.SlugField(max_length=255, blank=True)
stripe_id = models.CharField(max_length=100, null=True, blank=True)
user = models.OneToOneField(User, blank=True, null=True)
user = models.OneToOneField(User, blank=True, null=True, on_delete=models.DO_NOTHING)
plan = models.CharField(max_length=100, default='snipt-teams-25-monthly',
choices=PLANS, blank=True, null=True)
disabled = models.BooleanField(default=False)

View File

@ -78,7 +78,7 @@
<div class="fields">
<input ng-model="search.query" type="text" class="search-query" name="q"
ng-init="search.query='{{ query|escapejs }}'"
placeholder="Search snipts" id="id_q"
placeholder="Search snippets" id="id_q"
value="{{ query }}" />
</div>
</fieldset>
@ -87,7 +87,7 @@
<ul>
{% if not request.user.is_authenticated %}
<li>
<a href="/public/" {% if '/public/' in request.path or public %} class="active"{% endif %}>Public snipts</a>
<a href="/public/" {% if '/public/' in request.path or public %} class="active"{% endif %}>Public snippets</a>
</li>
<li>
<a href="/login/?next={{ request.path }}" {% if '/login/' in request.path %} class="active"{% endif %}>Log in</a>
@ -99,10 +99,10 @@
{% endif %}
{% else %}
<li>
<a href="/{{ request.user.username }}/" {% if request.user.username in request.path %} class="active"{% endif %}>My snipts</a>
<a href="/{{ request.user.username }}/" {% if request.user.username in request.path %} class="active"{% endif %}>My snippets</a>
</li>
<li>
<a href="/public/" {% if '/public/' in request.path or public %} class="active"{% endif %}>Public snipts</a>
<a href="/public/" {% if '/public/' in request.path or public %} class="active"{% endif %}>Public snippets</a>
</li>
{% block add-snipt %}{% endblock %}
{% endif %}
@ -146,7 +146,7 @@
{% if request.user.profile.has_pro %}
<span class="is-pro">Pro</span>
{% else %}
Siftie Snippets user
Snippets user
{% endif %}
</span>
</span>

View File

@ -26,11 +26,11 @@
<ul>
{% if request.user.is_authenticated %}
<li>
<a href="/{{ request.user.username }}/">My snipts</a>
<a href="/{{ request.user.username }}/">My snippets</a>
</li>
{% endif %}
<li>
<a href="/public/">Public snipts</a>
<a href="/public/">Public snippets</a>
</li>
<li>
<a href="/search/">Search</a>
@ -62,7 +62,7 @@
</div>
</div>
{% if request.user.is_authenticated %}
<a href="/{{ request.user.username }}/" class="button">My snipts</a>
<a href="/{{ request.user.username }}/" class="button">My snippets</a>
{% else %}
<a href="/login/" class="button">Log in</a>
{% endif %}

View File

@ -61,13 +61,13 @@
</a>
</div>
{% if user.username == 'nick' %}
<div class="member-since">Siftie Snippets Founder in {{ user.date_joined|date:"Y" }}</div>
<div class="member-since">Snippets Founder in {{ user.date_joined|date:"Y" }}</div>
{% else %}
<div class="member-since">Member since {{ user.date_joined|date:"Y" }}</div>
{% endif %}
{% if user.profile.get_blog_posts %}
<div class="urls">
Siftie Snippets Blog:
Snippets Blog:
<a href="{{ user.profile.get_user_profile_url }}">
{{ user.profile.get_user_profile_url }}
</a>