Commit 5c45f4d8 authored by alexandre's avatar alexandre
Browse files

Moved management commands into their own app

parent 22f64984
from django.core.management.base import BaseCommand
from etherpadlite.models import Pad
from django.contrib.sites.models import Site
from django.urls import reverse
from aasniff import AAApp
class Conf(object):
SNIFFERS = [
'HttpSniffer',
'HtmlSniffer',
]
STORE = {
'ENGINE': 'sqlite',
'NAME': 'aasniff.sqlite',
}
class Command(BaseCommand):
args = ''
help = 'Indexes pages'
def handle(self, *args, **options):
HOST = None
if Site.objects.count() > 0:
site = Site.objects.all()[0]
HOST = site.domain
if not HOST:
return "No site domain settings found"
host = u"http://%s" % HOST
app = AAApp(conf=Conf)
for pad in Pad.objects.filter():
url = "{}{}".format(host, reverse('pad-read', kwargs={'mode': 'r', 'slug': pad.display_slug}))
try:
app.index(url)
print(f"indexed {url}")
except:
print(f"fail at indexing {url}")
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class EthertoffRdfindexConfig(AppConfig):
name = 'ethertoff_rdfindex'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
......@@ -33,6 +33,7 @@ ALLOWED_HOSTS = []
INSTALLED_APPS = [
# 'example_theme', ## Add your theme here if any
'ethertoff',
'ethertoff_rdf_index',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment