Skip to content
Permalink
Browse files

Sort languages; remove checker feature

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 26, 2016
1 parent af35ffc commit e52cd5047975387aba12a9b67e8d7aa6221c58b6
@@ -109,7 +109,7 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
STATICFILES_DIRS = []
STATIC_URL = '/static/'
STATIC_ROOT = '/srv/users.getnikola.com/static'

@@ -2,7 +2,7 @@
from .models import Language

def make_choices():
return [(l.code, l.name) for l in Language.objects.all()]
return [(l.code, l.name) for l in Language.objects.all().order_by('name')]

class AddForm(forms.Form):
title = forms.CharField(label="Title", max_length=100)
File renamed without changes.
File renamed without changes.
@@ -4,7 +4,6 @@
from django.utils.html import format_html
from django.http import JsonResponse, HttpResponseNotFound
from .models import Site, Language
from .checker import gencheck
from .forms import AddForm

MENU = (
@@ -56,7 +55,7 @@ def lang(request, **filters):


def langlist(request):
group_members = list(Language.objects.filter(display_country=True))
group_members = list(Language.objects.filter(display_country=True).order_by('name'))
groups = {}
for l in group_members:
if l.language_code in groups:
@@ -169,10 +168,7 @@ def check(request):

def api_check(request):
"""Check API."""
if 'url' in request.GET:
return JsonResponse(gencheck(request.GET['url']))
else:
return JsonResponse({"type": "error", "data": "No URL specified. Please remember this is not a random web proxy."})
return JsonResponse({"type": "error", "data": "This service has been disabled. Please see https://users.getnikola.com/ for a helper script."})


def tos(request):

This file was deleted.

This file was deleted.

@@ -1,22 +1,24 @@
{% extends "base.html" %}
{% load staticfiles %}
{% block content %}
<form class="form-horizontal" id="check-form">
<div class="form-group">
<label class="control-label col-lg-2" for="check-url">URL</label>
<div class="col-lg-5">
<input type="url" class="form-control" name="url" id="check-url" placeholder="URL" maxlength="256" required>
<span class="help-block">URL of the site to check.</span>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-5">
<button type="submit" class="btn btn-primary">Check this site</button>
</div>
</div>
<div id="check-output"></div>
</form>
{% endblock %}
{% block extra_js %}
<script src="{% static "check.min.js" %}"></script>
<div>
<p>This feature has been disabled. If you want to test a site, use the following Python program:</p>
<pre class="code python"><a name="rest_code_871104a093764d779132a78f4d157c8d-1"></a><span class="kn">import</span> <span class="nn">requests</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-2"></a>
<a name="rest_code_871104a093764d779132a78f4d157c8d-3"></a><span class="n">url</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">"URL to check: "</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-4"></a><span class="k">if</span> <span class="ow">not</span> <span class="n">url</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">'/rss.xml'</span><span class="p">):</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-5"></a> <span class="n">url</span> <span class="o">+=</span> <span class="s2">"/rss.xml"</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-6"></a><span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-7"></a><span class="n">patterns</span> <span class="o">=</span> <span class="p">[(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;https://getnikola.com/&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v7.6.1+'</span><span class="p">),</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-8"></a> <span class="p">(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;http://getnikola.com/&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v7.0.0-v7.6.0'</span><span class="p">),</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-9"></a> <span class="p">(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;Nikola &lt;http://getnikola.com/&gt;&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v6.3.0-v6.4.0'</span><span class="p">),</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-10"></a> <span class="p">(</span><span class="n">b</span><span class="s1">'&lt;generator&gt;nikola&lt;/generator&gt;'</span><span class="p">,</span> <span class="s1">'Nikola v6.2.1 or older'</span><span class="p">]</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-11"></a><span class="n">result</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-12"></a><span class="k">for</span> <span class="n">pattern</span><span class="p">,</span> <span class="n">description</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">patterns</span><span class="p">):</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-13"></a> <span class="k">if</span> <span class="n">pattern</span> <span class="ow">in</span> <span class="n">r</span><span class="o">.</span><span class="n">content</span><span class="p">:</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-14"></a> <span class="k">print</span><span class="p">(</span><span class="n">description</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-15"></a> <span class="nb">exit</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-16"></a><span class="k">print</span><span class="p">(</span><span class="s2">"Not a Nikola site"</span><span class="p">)</span>
<a name="rest_code_871104a093764d779132a78f4d157c8d-17"></a><span class="nb">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
</pre>
</div>
{% endblock %}

0 comments on commit e52cd50

Please sign in to comment.
You can’t perform that action at this time.