From 6ea91c3b0e99ca36a370c420a30df65f2a7ecf16 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Wed, 24 Apr 2019 09:09:50 -0400 Subject: [PATCH] Revert "Snipt -> Siftie, first pass." This reverts commit c12e294599bbd4164feae0f6637f519a7b02eb48. --- README.md | 10 ++-- accounts/models.py | 4 +- accounts/templates/stats.html | 2 +- app.json | 6 +-- blogs/middleware.py | 12 ++--- .../templates/blogs/themes/default/base.html | 2 +- blogs/templates/blogs/themes/default/rss.xml | 6 +-- media/js/src/modules/partials/blogging.html | 2 +- settings.py | 37 ++++++-------- snipts/management/commands/import_snipts.py | 11 ++-- snipts/models.py | 35 ++++++------- snipts/templates/snipts/embed.html | 4 +- snipts/templates/snipts/list.html | 8 +-- .../snipts/snipt-edit-js-template.html | 2 +- snipts/templates/snipts/snipt-list.html | 2 +- snipts/tests.py | 50 +++++++++---------- teams/migrations/0002_team_email.py | 6 +-- teams/templates/teams/for-teams-complete.html | 2 +- teams/templates/teams/for-teams.html | 8 +-- teams/templates/teams/team-members.html | 2 +- templates/add-snipt.html | 2 +- templates/base.html | 4 +- templates/profile.html | 6 +-- templates/registration/activation_email.txt | 2 +- .../registration/activation_email_subject.txt | 2 +- .../registration/password_reset_email.html | 2 +- templates/rss.xml | 10 ++-- 27 files changed, 110 insertions(+), 129 deletions(-) diff --git a/README.md b/README.md index 7cd9259..8781944 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Siftie Snippets +# Snipt ## Running locally @@ -31,9 +31,9 @@ ## Automatic deploy to Heroku -You can click the button below to automatically deploy Siftie Snippets to Heroku. +You can click the button below to automatically deploy Snipt to Heroku. -[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/siftie/snippets) +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/nicksergeant/snipt) ## Manual deploy to Heroku @@ -49,8 +49,8 @@ You can click the button below to automatically deploy Siftie Snippets to Heroku ## Updating your Heroku instance after an automatic deploy -- `git clone https://github.com/siftie/snippets` -- `cd snippets` +- `git clone https://github.com/nicksergeant/snipt` +- `cd snipt` - `git checkout heroku` - `heroku git:remote -a ` - `git push heroku heroku:master` diff --git a/accounts/models.py b/accounts/models.py index 53f4810..dd06338 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -97,11 +97,11 @@ class UserProfile(models.Model): # Otherwise, if they have blog posts, use their Snipt blog URL. elif self.get_blog_posts(): - url = "https://{}.snippets.siftie.com/".format(self.user.username) + url = 'https://{}.snipt.net/'.format(self.user.username) # Otherwise, use their regular Snipt profile page. else: - url = "https://snippets.siftie.com/{}/".format(self.user.username) + url = 'https://snipt.net/{}/'.format(self.user.username) return url diff --git a/accounts/templates/stats.html b/accounts/templates/stats.html index 4a078f9..39c7e83 100644 --- a/accounts/templates/stats.html +++ b/accounts/templates/stats.html @@ -18,7 +18,7 @@ - + diff --git a/app.json b/app.json index 17a6662..c8242e0 100644 --- a/app.json +++ b/app.json @@ -1,12 +1,12 @@ { - "name": "Siftie Snippets", + "name": "Snipt", "description": "Code snippets for teams and individuals.", "keywords": [ "snipt", "code snippets" ], - "website": "https://snippets.siftie.com", - "repository": "https://github.com/siftie/snippets", + "website": "https://snipt.net", + "repository": "https://github.com/nicksergeant/snipt", "logo": "https://snipt.s3.amazonaws.com/logo.png", "success_url": "/", "scripts": { diff --git a/blogs/middleware.py b/blogs/middleware.py index 5583c75..643ad33 100644 --- a/blogs/middleware.py +++ b/blogs/middleware.py @@ -8,14 +8,12 @@ class BlogMiddleware: def process_request(self, request): request.blog_user = None - host = request.META.get("HTTP_HOST", "") - host_s = host.replace("www.", "").split(".") + host = request.META.get('HTTP_HOST', '') + host_s = host.replace('www.', '').split('.') - if ( - host != "snippets.siftie.com" - and host != "snipt.localhost" - and host != "local.snippets.siftie.com" - ): + if host != 'snipt.net' and \ + host != 'snipt.localhost' and \ + host != 'local.snipt.net': if len(host_s) > 2: if host_s[1] == "snipt": diff --git a/blogs/templates/blogs/themes/default/base.html b/blogs/templates/blogs/themes/default/base.html index 5d2be0b..32aade7 100644 --- a/blogs/templates/blogs/themes/default/base.html +++ b/blogs/templates/blogs/themes/default/base.html @@ -76,7 +76,7 @@ {% endif %} diff --git a/blogs/templates/blogs/themes/default/rss.xml b/blogs/templates/blogs/themes/default/rss.xml index bd3c810..3571af1 100644 --- a/blogs/templates/blogs/themes/default/rss.xml +++ b/blogs/templates/blogs/themes/default/rss.xml @@ -1,9 +1,9 @@ - + {% firstof request.blog_user.profile.blog_title request.blog_user.username %} {% firstof request.blog_user.profile.blog_title request.blog_user.username %} - {% if request.blog_user.profile.get_primary_blog_domain %}http://{{ request.blog_user.profile.blog_domain }}/?rss{% else %}https://{{ request.blog_user.username }}.snippets.siftie.com/?rss{% endif %} + {% if request.blog_user.profile.get_primary_blog_domain %}http://{{ request.blog_user.profile.blog_domain }}/?rss{% else %}https://{{ request.blog_user.username }}.snipt.net/?rss{% endif %} {% for snipt in snipts %} {{ snipt.title }} @@ -11,7 +11,7 @@ {% for tag in snipt.tags.all %}{{ tag }}{% if not forloop.last %}, {% endif %}{% endfor %} {{ snipt.created|date:"r" }} - siftie-snippets-com-{{ snipt.id }} + snipt-net-{{ snipt.id }} {% endfor %} diff --git a/media/js/src/modules/partials/blogging.html b/media/js/src/modules/partials/blogging.html index 58e1577..979d17a 100644 --- a/media/js/src/modules/partials/blogging.html +++ b/media/js/src/modules/partials/blogging.html @@ -18,7 +18,7 @@
- Like 'snipt.nicksergeant.com' or 'nicksergeant.com' (without quotes). Set your CNAME to `snippets.siftie.com` or A-record to `96.126.110.160`. You can use multiple domains here: separate each domain with a space. The first domain will be your primary domain. All other domains will redirect to your primary domain. + Like 'snipt.nicksergeant.com' or 'nicksergeant.com' (without quotes). Set your CNAME to `snipt.net` or A-record to `96.126.110.160`. You can use multiple domains here: separate each domain with a space. The first domain will be your primary domain. All other domains will redirect to your primary domain.
diff --git a/settings.py b/settings.py index d1f68f8..7b41443 100644 --- a/settings.py +++ b/settings.py @@ -8,29 +8,22 @@ if "DATABASE_URL" in os.environ: ABSOLUTE_URL_OVERRIDES = {"auth.user": lambda u: "/%s/" % u.username} ACCOUNT_ACTIVATION_DAYS = 0 -ADMINS = (("Siftie", "team@siftie.com"),) -ALLOWED_HOSTS = ["*"] -AUTH_PROFILE_MODULE = "accounts.UserProfile" -AUTHENTICATION_BACKENDS = ("utils.backends.EmailOrUsernameModelBackend",) +ADMINS = (('Nick Sergeant', 'nick@snipt.net'),) +ALLOWED_HOSTS = ['*'] +AUTH_PROFILE_MODULE = 'accounts.UserProfile' +AUTHENTICATION_BACKENDS = ('utils.backends.EmailOrUsernameModelBackend',) BASE_PATH = os.path.dirname(__file__) CSRF_COOKIE_SECURE = True if "USE_SSL" in os.environ else False CORS_ORIGIN_ALLOW_ALL = True -DEBUG = True if "DEBUG" in os.environ else False -DEFAULT_FROM_EMAIL = os.environ.get("POSTMARK_EMAIL", "team@siftie.com") -EMAIL_BACKEND = "postmark.django_backend.EmailBackend" -# HAYSTACK_CONNECTIONS = { -# "default": { -# "ENGINE": "haystack.backends.whoosh_backend.WhooshEngine", -# "PATH": os.environ.get("WHOOSH_PATH", "./.whoosh_index"), -# "STORAGE": "file", -# } -# } -# HAYSTACK_SIGNAL_PROCESSOR = "haystack.signals.RealtimeSignalProcessor" -INTERNAL_IPS = ("127.0.0.1",) -LANGUAGE_CODE = "en-us" -LOGIN_REDIRECT_URL = "/login-redirect/" -LOGIN_URL = "/login/" -LOGOUT_URL = "/logout/" +DEBUG = True if 'DEBUG' in os.environ else False +DEFAULT_FROM_EMAIL = os.environ.get('POSTMARK_EMAIL', 'support@snipt.net') +EMAIL_BACKEND = 'postmark.django_backend.EmailBackend' +HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' +INTERNAL_IPS = ('127.0.0.1',) +LANGUAGE_CODE = 'en-us' +LOGIN_REDIRECT_URL = '/login-redirect/' +LOGIN_URL = '/login/' +LOGOUT_URL = '/logout/' MANAGERS = ADMINS MEDIA_ROOT = os.path.join(BASE_PATH, "media/uploads") MEDIA_URL = "/media/uploads/" @@ -52,7 +45,7 @@ SECRET_KEY = os.environ.get("SECRET_KEY", "changeme") SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") SECURE_SSL_REDIRECT = True if "USE_SSL" in os.environ else False SEND_BROKEN_LINK_EMAILS = False -SERVER_EMAIL = os.environ.get("POSTMARK_EMAIL", "team@siftie.com") +SERVER_EMAIL = os.environ.get('POSTMARK_EMAIL', 'support@snipt.net') SESSION_COOKIE_AGE = 15801100 SESSION_COOKIE_SECURE = True if "USE_SSL" in os.environ else False SITE_ID = 1 @@ -65,7 +58,7 @@ STATICFILES_STORAGE = "whitenoise.django.GzipManifestStaticFilesStorage" STATIC_ROOT = os.path.join(BASE_PATH, "static") STATIC_URL = "/static/" TASTYPIE_CANNED_ERROR = """There was an error with your request. The site - developers have a record of this error, please email team@siftie.com and + developers have a record of this error, please email api@snipt.net and we'll help you out.""" TEMPLATES = [ diff --git a/snipts/management/commands/import_snipts.py b/snipts/management/commands/import_snipts.py index 03120b3..2a04e1f 100644 --- a/snipts/management/commands/import_snipts.py +++ b/snipts/management/commands/import_snipts.py @@ -8,13 +8,8 @@ import requests def get_snipts(api_key, from_username, url=None, snipts=[]): - path = ( - url - or "/api/private/snipt/?limit=50&api_key={}&username={}&format=json".format( - api_key, from_username - ) - ) - res = requests.get("https://snippets.siftie.com" + path) + path = url or '/api/private/snipt/?limit=50&api_key={}&username={}&format=json'.format(api_key, from_username) + res = requests.get('https://snipt.net' + path) json = res.json() print( @@ -34,7 +29,7 @@ def get_snipts(api_key, from_username, url=None, snipts=[]): class Command(BaseCommand): - help = u"Import snipts from Siftie Snippets." + help = u"Import snipts from snipt.net." def add_arguments(self, parser): parser.add_argument("api_key", nargs="+", type=str) diff --git a/snipts/models.py b/snipts/models.py index 074b5c8..bafcaee 100644 --- a/snipts/models.py +++ b/snipts/models.py @@ -83,13 +83,12 @@ class Snipt(models.Model): if self.lexer == "markdown": self.stylized = markdown(self.code, "default") - # Snippet embeds - for match in re.findall("\[\[(\w{32})\]\]", self.stylized): - self.stylized = self.stylized.replace( - "[[" + str(match) + "]]", - """ + # Snipt embeds + for match in re.findall('\[\[(\w{32})\]\]', self.stylized): + self.stylized = self.stylized.replace('[[' + str(match) + ']]', + """
""".format( match, match @@ -134,10 +133,10 @@ class Snipt(models.Model): ), ) - # Parse usernames - for match in re.findall("@(\w+) ", self.stylized): + # Parse Snipt usernames + for match in re.findall('@(\w+) ', self.stylized): - # Try and get the user by username. + # Try and get the Snipt user by username. user = get_object_or_None(User, username=match) if user: @@ -228,9 +227,8 @@ class Snipt(models.Model): self.user.profile.blog_domain.split(" ")[0], self.slug ) else: - return u"https://{}.snippets.siftie.com/{}/".format( - self.user.username.replace("_", "-"), self.slug - ) + return u'https://{}.snipt.net/{}/'.format( + self.user.username.replace('_', '-'), self.slug) if self.custom_slug: return u"/{}/".format(self.custom_slug) @@ -248,9 +246,8 @@ class Snipt(models.Model): self.user.profile.blog_domain.split(" ")[0], self.slug ) else: - return u"https://{}.snippets.siftie.com/{}/".format( - self.user.username, self.slug - ) + return u'https://{}.snipt.net/{}/'.format( + self.user.username, self.slug) if self.public: return u"/{}/{}/".format(self.user.username, self.slug) @@ -277,9 +274,9 @@ class Snipt(models.Model): def get_embed_url(self): if settings.DEBUG: - root = "http://local.snippets.siftie.com" + root = 'http://local.snipt.net' else: - root = "https://snippets.siftie.com" + root = 'https://snipt.net' return "{}/embed/{}/".format(root, self.key) @@ -311,7 +308,7 @@ class Snipt(models.Model): class SniptLogEntry(models.Model): - """An individual log entry for a snippet changeset.""" + """An individual log entry for a Snipt changeset.""" user = models.ForeignKey(User, on_delete=models.CASCADE) snipt = models.ForeignKey(Snipt, on_delete=models.CASCADE) @@ -328,7 +325,7 @@ class SniptLogEntry(models.Model): class SniptSecureView(models.Model): - """A single view to a secure snippet.""" + """A single view to a secure snipt.""" user = models.ForeignKey(User, on_delete=models.CASCADE) snipt = models.ForeignKey(Snipt, on_delete=models.CASCADE) diff --git a/snipts/templates/snipts/embed.html b/snipts/templates/snipts/embed.html index a7b83dd..982a685 100644 --- a/snipts/templates/snipts/embed.html +++ b/snipts/templates/snipts/embed.html @@ -1,2 +1,2 @@ -{% if 'snipt' in request.GET %}document.addEventListener('DOMContentLoaded', function() { document.getElementById('snipt-embed-{{ snipt.key }}').innerHTML = '
{% for line in lines %}{{ line|safe }}\n{% endfor %}
'; }); -{% else %}document.open();document.writeln('
');{% for line in lines %}document.writeln('{{ line|safe }}');{% endfor %}document.writeln('');document.writeln('
');document.close();{% endif %} +{% if 'snipt' in request.GET %}document.addEventListener('DOMContentLoaded', function() { document.getElementById('snipt-embed-{{ snipt.key }}').innerHTML = '
{% for line in lines %}{{ line|safe }}\n{% endfor %}
'; }); +{% else %}document.open();document.writeln('
');{% for line in lines %}document.writeln('{{ line|safe }}');{% endfor %}document.writeln('');document.writeln('
');document.close();{% endif %} diff --git a/snipts/templates/snipts/list.html b/snipts/templates/snipts/list.html index 5688bc5..e6cd5af 100644 --- a/snipts/templates/snipts/list.html +++ b/snipts/templates/snipts/list.html @@ -27,10 +27,10 @@ {% empty %}
{% if request.user == user and not request.user.is_active and not public %} - Welcome! Please activate your account to create your first snippet. + Welcome! Please activate your account to create your first snipt. {% else %} {% if request.user == user and request.user.is_authenticated %} - Welcome! Create your first snippet by clicking "Add Snippet" above. + Welcome! Create your first snipt by clicking "Add Snipt" above. {% else %} No snipts to show here. Sorry! {% endif %} @@ -44,10 +44,10 @@ {% empty %}
{% if request.user == user and not request.user.is_active and not public %} - Welcome! Please activate your account to create your first snippet. + Welcome! Please activate your account to create your first snipt. {% else %} {% if request.user == user and request.user.is_authenticated %} - Welcome! Create your first snippet by clicking "Add Snippet" above. + Welcome! Create your first snipt by clicking "Add Snipt" above. {% else %} No snipts to show here. Sorry! {% endif %} diff --git a/snipts/templates/snipts/snipt-edit-js-template.html b/snipts/templates/snipts/snipt-edit-js-template.html index 5863055..6303a80 100644 --- a/snipts/templates/snipts/snipt-edit-js-template.html +++ b/snipts/templates/snipts/snipt-edit-js-template.html @@ -70,7 +70,7 @@ Private snipts do not appear in the public listing, but are accessible via the direct URL.
- Public snipts are accessible by all Siftie Snippets users and appear in the public listing. + Public snipts are accessible by all Snipt.net users and appear in the public listing.
SnippetSnipt Views Favs