diff --git a/README.md b/README.md
index b8565bf..cc50fa4 100644
--- a/README.md
+++ b/README.md
@@ -5,6 +5,5 @@ python3 -m venv venv
./venv/bin/pip install -r requirements.txt
./manage.py migrate
./manage.py update_geoip
-./manage.py load_titles
./mange.py runserver
```
diff --git a/app/contact/views.py b/app/contact/views.py
index beb08cb..1437b55 100644
--- a/app/contact/views.py
+++ b/app/contact/views.py
@@ -1,7 +1,7 @@
from django.conf import settings
from django.core.mail import EmailMessage
from django.shortcuts import render
-from app.video.utils import render_to_json_response
+from ..utils import render_to_json_response
from . import forms
from . import models
@@ -11,7 +11,7 @@ def index(request):
form = forms.ContactForm(request.POST)
if form.is_valid():
message = 'From: %s\n\n%s' % (form.cleaned_data['email'], form.cleaned_data['message'])
- subject = 'njp.ma contact message'
+ subject = 'phantas.ma contact message'
from_ = settings.CONTACT_FROM_EMAIL
to = [settings.CONTACT_TO_EMAIL]
msg = EmailMessage(subject, message, from_, to, reply_to=[form.cleaned_data['email']])
diff --git a/app/settings.py b/app/settings.py
index c55fcd8..83cd5d1 100755
--- a/app/settings.py
+++ b/app/settings.py
@@ -39,7 +39,6 @@ INSTALLED_APPS = [
'app',
'app.user',
- 'app.video',
'app.text',
'app.contact',
@@ -145,13 +144,11 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
GEOIP_PATH = BASE_DIR / 'geo'
-DEFAULT_PANDORA_API = "https://archive.njp.ma/api/"
+DEFAULT_PANDORA_API = "https://pad.ma/api/"
TIMELINE_QUERY = {'conditions': []}
-URL_PREFIX = ''
-
-CONTACT_TO_EMAIL = 'contact@njp.ma'
-CONTACT_FROM_EMAIL = 'contact@njp.ma'
+CONTACT_TO_EMAIL = 'contact@phantas.ma'
+CONTACT_FROM_EMAIL = 'contact@phantas.ma'
try:
from .local_settings import *
diff --git a/app/templates/about.html b/app/templates/about.html
deleted file mode 100644
index 41c6c03..0000000
--- a/app/templates/about.html
+++ /dev/null
@@ -1,15 +0,0 @@
-{% extends "base.html" %}
-{% block title %}About{% endblock title %}
-{% block body_class%}body--about animated animated-text{% endblock %}
-{% block main %}
-
-
-{% endblock %}
-
-{% block end %}
-
-
-
-{% endblock %}
diff --git a/app/templates/base.html b/app/templates/base.html
index 6087273..c134405 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -5,7 +5,7 @@
{% block title %}
- njp.ma
+ phantas.ma
{% endblock title %}
@@ -15,14 +15,16 @@
diff --git a/app/templates/edit.html b/app/templates/edit.html
deleted file mode 100644
index 8d368ac..0000000
--- a/app/templates/edit.html
+++ /dev/null
@@ -1,4 +0,0 @@
-{% extends "base.html" %}
-{% block main %}
-some overview page with stuff
-{% endblock %}
diff --git a/app/templates/edit_play.html b/app/templates/edit_play.html
deleted file mode 100644
index 5248d87..0000000
--- a/app/templates/edit_play.html
+++ /dev/null
@@ -1,7 +0,0 @@
-{% extends "base.html" %}
-{% block main %}
-{{ edit.data.title }}
-{% if edit.vimeo_id %}
-
-{% endif %}
-{% endblock %}
diff --git a/app/templates/edits.html b/app/templates/edits.html
deleted file mode 100644
index 8d368ac..0000000
--- a/app/templates/edits.html
+++ /dev/null
@@ -1,4 +0,0 @@
-{% extends "base.html" %}
-{% block main %}
-some overview page with stuff
-{% endblock %}
diff --git a/app/templates/fallback.html b/app/templates/fallback.html
index c8817ae..6dc793c 100644
--- a/app/templates/fallback.html
+++ b/app/templates/fallback.html
@@ -67,12 +67,12 @@
- njp.ma
+ phantas.ma
@@ -81,7 +81,7 @@
document.location.href = '/'
path = document.location.pathname.slice(1)
if (path) {
- document.querySelector('h1').innerHTML = 'njp.ma/' + path
+ document.querySelector('h1').innerHTML = 'phantas.ma/' + path
if (path == 'polis') {
setTimeout(() => {
document.querySelector('h2').innerHTML = 'Oct 30, 2021 – Mar 6, 2022'
diff --git a/app/templates/film.html b/app/templates/film.html
deleted file mode 100644
index 2073b4c..0000000
--- a/app/templates/film.html
+++ /dev/null
@@ -1,120 +0,0 @@
-{% extends "base.html" %}
-{% block head %}
-
-
-
-
-
-
-
-
-
-
-
-
-
-{% endblock head %}
-{% block body_class%}animated{% endblock %}
-{% block main %}
-{% comment %}
-
-
-{% endcomment %}
-
-
-
-
-
-
-
-
- {% for item in film.data.items %}
-
- {% endfor %}
-
-
- {% if film.related_texts.exists %}
-
-
Related Assemblies
- {% for text in film.related_texts %}
-
- {% endfor %}
-
- {% endif %}
-
-
-{% endblock %}
-
-{% block end %}
-
- {% comment %}
-
- {% endcomment %}
-{% endblock %}
diff --git a/app/templates/film_play.html b/app/templates/film_play.html
deleted file mode 100644
index 7e810cf..0000000
--- a/app/templates/film_play.html
+++ /dev/null
@@ -1,13 +0,0 @@
-{% extends "base.html" %}
-{% block main %}
-
-{% endblock %}
-{% block end %}
-
-
-
-{% endblock %}
diff --git a/app/templates/films.html b/app/templates/films.html
deleted file mode 100644
index dad69d7..0000000
--- a/app/templates/films.html
+++ /dev/null
@@ -1,54 +0,0 @@
-{% extends "base.html" %}
-{% block body_class%}animated animated-text{% endblock %}
-{% block main %}
-
-
-
- Filter:
-
- Sort:
-
-
-
- {% for film in films %}
-
- {% endfor %}
-
-
-{% endblock %}
-
-{% block end %}
-
-{% endblock %}
diff --git a/app/templates/index.html b/app/templates/index.html
index 645e82e..6d2613f 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -1,17 +1,16 @@
{% extends "base.html" %}
{% block head %}
-
-
-
+
+
+
-
+
-
-
-
+
+
-
-
+
+
{% endblock head %}
{% block body_class%}animated animated-text body--home{% endblock %}
{% block main %}
@@ -33,11 +32,11 @@
{% endif %}
-
njp.ma
+
Phantas.ma
-
-
-
+ {% for text in texts %}
+
+ {% endfor %}
diff --git a/app/templates/text.html b/app/templates/text.html
index c0f1ac7..806fa03 100644
--- a/app/templates/text.html
+++ b/app/templates/text.html
@@ -4,15 +4,15 @@
-
-
+
+
-
+
@@ -20,7 +20,7 @@
{% endblock head %}
-{% block title %}{{ text.title }} - njp.ma{% endblock title %}
+{% block title %}{{ text.title }} - phantas.ma{% endblock title %}
{% block main %}
{% endblock %}
diff --git a/app/templates/tv.html b/app/templates/tv.html
deleted file mode 100644
index ca9a7a1..0000000
--- a/app/templates/tv.html
+++ /dev/null
@@ -1,5 +0,0 @@
-{% extends "base.html" %}
-{% block title %}TV{% endblock%}
-{% block main %}
-here be TV stuff
-{% endblock %}
diff --git a/app/text/models.py b/app/text/models.py
index 5359e97..6fede36 100644
--- a/app/text/models.py
+++ b/app/text/models.py
@@ -41,7 +41,7 @@ class Text(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
language = models.CharField(choices=LANGUAGE_CHOICES, max_length=8, default='en')
- slug = models.SlugField()
+ slug = models.CharField(max_length=1024)
public = models.BooleanField(default=False)
listed = models.BooleanField("List this item on overview page", default=True)
position = models.IntegerField(default=0)
@@ -50,14 +50,14 @@ class Text(models.Model):
byline = models.TextField(default="", blank=True)
body = models.TextField(default="", blank=True)
- data = models.JSONField(default=dict)
+ data = models.JSONField(default=dict, blank=True)
annotations = models.JSONField(default=dict, blank=True, editable=False)
def __str__(self):
return self.title
def get_absolute_url(self):
- return '/' + settings.URL_PREFIX + 'cuts/' + self.slug
+ return '/' + self.slug
def get_annotations(self):
api = ox.api.signin(settings.DEFAULT_PANDORA_API)
@@ -165,21 +165,11 @@ class Text(models.Model):
super().save(*args, **kwargs)
def json(self):
- from ..video.models import Film
data = {}
data['title'] = self.title
data['byline'] = self.byline
data['body'] = self.body
data['language'] = self.language
- item_id = self.data.get('related')
- if not item_id:
- item_id = self.data.get('item')
- if item_id:
- item = Film.objects.filter(pandora_url=item_id).first()
- if item:
- for key in ('title', 'title_zh', 'director'):
- data['item_' + key] = item.data[key]
- data['item_url'] = item.get_absolute_url()
if isinstance(self.annotations, list) and len(self.annotations) > 0:
data['annotations'] = self.annotations
data.update(self.data)
diff --git a/app/text/views.py b/app/text/views.py
index 9d6331d..8646d4f 100644
--- a/app/text/views.py
+++ b/app/text/views.py
@@ -3,7 +3,6 @@ from django.shortcuts import render, redirect, get_object_or_404
from django.conf import settings
from . import models
-from ..video.views import get_stream_prefix
def fallback(request, slug=''):
if not slug:
@@ -13,26 +12,17 @@ def fallback(request, slug=''):
return render(request, 'fallback.html', context)
def index(request):
- from ..video.models import Film
from ..text.models import Text
context = {}
- context['films'] = Film.objects.filter(public=True).count()
- context['texts'] = Text.objects.filter(public=True, listed=True).count()
- context['stream_prefix'] = get_stream_prefix(request)
- featured = Film.objects.filter(featured=True)
- featured_count = featured.count()
- if featured_count:
- featured = featured[random.randint(0, featured_count - 1)]
- try:
- featured = featured.data['items'][0]['id']
- except:
- featured = None
- context['featured'] = featured
+ context['texts'] = Text.objects.filter(public=True, listed=True).order_by('title')
return render(request, 'index.html', context)
def page(request, slug=''):
+ print('page!!', slug)
context = {}
- if request.user.is_staff:
+ if slug == "":
+ return index(request)
+ elif request.user.is_staff:
page = models.Page.objects.filter(slug=slug).first()
else:
page = models.Page.objects.filter(slug=slug, public=True).first()
@@ -40,7 +30,7 @@ def page(request, slug=''):
context['page'] = page
return render(request, 'page.html', context)
else:
- return render(request, 'fallback.html', context)
+ return text(request, slug)
def about(request):
context = {}
@@ -54,11 +44,11 @@ def texts(request):
return render(request, 'texts.html', context)
def text(request, slug):
+ print('find text', slug)
context = {}
if request.user.is_staff:
context['text'] = get_object_or_404(models.Text, slug=slug)
else:
context['text'] = get_object_or_404(models.Text, slug=slug, public=True)
- context['stream_prefix'] = get_stream_prefix(request)
context['pandora_url'] = settings.DEFAULT_PANDORA_API.replace('/api/', '')
return render(request, 'text.html', context)
diff --git a/app/urls.py b/app/urls.py
index 72b7a80..d42e0cb 100755
--- a/app/urls.py
+++ b/app/urls.py
@@ -17,27 +17,13 @@ from django.contrib import admin
from django.urls import path
from django.conf import settings
-from .video import views as video
from .text import views as text
from .contact.views import index as contact
urlpatterns = [
path('admin/', admin.site.urls),
- #path('pandoraAPI/', video.pandoraAPI, name='pandoraAPI'),
- path(settings.URL_PREFIX + 'videos/', video.films, name='films'),
- path(settings.URL_PREFIX + 'video//play/', video.film_play, name='film_play'),
- path(settings.URL_PREFIX + 'video//', video.film, name='film'),
- path(settings.URL_PREFIX + 'edits/', video.edits, name='edits'),
- path(settings.URL_PREFIX + 'edit//play/', video.edit_play, name='edit_play'),
- path(settings.URL_PREFIX + 'edit//', video.edit, name='edit'),
- path(settings.URL_PREFIX + 'tv/', video.tv, name='tv'),
- path(settings.URL_PREFIX + 'cuts/', text.texts, name='texts'),
- path(settings.URL_PREFIX + 'cuts/', text.text, name='text'),
- #path(settings.URL_PREFIX + 'index-alt/', text.index_alt, name='index_alt'),
- path(settings.URL_PREFIX + 'about/', text.about, name='about'),
- path(settings.URL_PREFIX + 'contact/', contact, name='contact'),
- path(settings.URL_PREFIX + '/', text.page, name='page'),
- path(settings.URL_PREFIX[:-1], text.index, name='index'),
- path('', text.fallback, name='fallback'),
- path('', text.fallback, name='fallback'),
+ path('about/', text.about, name='about'),
+ path('contact/', contact, name='contact'),
+ path('', text.page, name='page'),
+ path('', text.index, name='index'),
]
diff --git a/app/video/utils.py b/app/utils.py
similarity index 100%
rename from app/video/utils.py
rename to app/utils.py
diff --git a/app/video/__init__.py b/app/video/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/app/video/admin.py b/app/video/admin.py
deleted file mode 100644
index e162280..0000000
--- a/app/video/admin.py
+++ /dev/null
@@ -1,27 +0,0 @@
-import logging
-import json
-
-from django.contrib import admin
-from django.db.models import JSONField
-
-from . import models
-from ..widgets import PrettyJSONWidget
-logger = logging.getLogger(__name__)
-
-@admin.decorators.register(models.Film)
-class FilmAdmin(admin.ModelAdmin):
- formfield_overrides = {
- JSONField: {'widget': PrettyJSONWidget}
- }
- list_display = (
- '__str__',
- 'position',
- 'slug',
- 'public',
- )
- list_editable = ['public', 'position']
- list_filter = ['public', 'featured']
-
-#@admin.decorators.register(models.Edit)
-#class EditAdmin(admin.ModelAdmin):
-# pass
diff --git a/app/video/apps.py b/app/video/apps.py
deleted file mode 100644
index 535d17a..0000000
--- a/app/video/apps.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from django.apps import AppConfig
-
-
-class VideoConfig(AppConfig):
- default_auto_field = 'django.db.models.BigAutoField'
- name = 'app.video'
diff --git a/app/video/management/commands/load_titles.py b/app/video/management/commands/load_titles.py
deleted file mode 100644
index 8ca234b..0000000
--- a/app/video/management/commands/load_titles.py
+++ /dev/null
@@ -1,80 +0,0 @@
-from django.core.management.base import BaseCommand
-from django.conf import settings
-import ox
-from ... import models
-
-
-def escape(key):
- return key.replace('%', '%25').replace('&', '%26').replace('_', '%09').replace(' ', '_').replace('<', '%0E').replace('>', '%0F')
-
-def escape_slug(key):
- key = ox.decode_html(key).replace('%', '').replace('&', '-').replace('_', '-').replace(' ', '-').replace('<', '').replace('>', '').lower()
- key = key.replace("'", '').replace('"', '').strip()
- return key
-
-class Command(BaseCommand):
- help = 'import titles from pan.do/ra'
-
- def add_arguments(self, parser):
- parser.add_argument("--api", dest="api", type=str, default=settings.DEFAULT_PANDORA_API),
- parser.add_argument("--group", dest="group", type=str, default='Asian Art Biennial 2021'),
-
- def handle(self, *args, **options):
- api = ox.api.signin(options['api'])
-
- keys = [
- 'id', 'title', 'director', 'summary', 'source', 'sourcedescription', 'date', 'location',
- 'country', 'type', 'year',
- 'duration', 'featuring', 'cinematographer',
- 'hue', 'saturation', 'lightness',
- 'folder', 'folderdescription', 'rightslevel'
- ]
-
- query = {
- 'query': {
- },
- 'keys': ['id'],
- 'sort': [{'key': 'duration', 'operator': '-'}],
- 'range': [0, 1000]
- }
- folders = {}
- for item in api.find(**query)['data']['items']:
- item = api.get(id=item['id'], keys=keys)['data']
- if item['rightslevel'] > 0:
- continue
- if isinstance(item['folder'], list):
- print(item['id'])
-
- if item['folder'] not in folders:
- description = item['folderdescription'] or item.get('summary', '')
- folders[item['folder']] = {
- 'title': item['folder'],
- 'date': item.get('date', ''),
- 'year': item.get('year', ''),
- 'country': item.get('country', []),
- 'featuring': item.get('featuring', []),
- 'type': item['type'],
- 'description': description,
- 'url': api.url.replace('/api/', '/grid/folder==' + escape(ox.decode_html(item['folder']))),
- 'items': [],
- }
-
- del item['folderdescription']
- if 'summary' in item and item['summary'] == folders[item['folder']]['description']:
- item['summary'] = ''
- folders[item['folder']]['items'].append(item)
-
- slugs = []
- for item in folders.values():
- slug = escape_slug(item['title'].split(' / ')[0])
- f, c = models.Film.objects.get_or_create(slug=slug)
- f.pandora_url = item['url']
- for key, value in item.items():
- if key != 'url':
- f.data[{
- }.get(key, key)] = value
- if c:
- f.public = True
- f.save()
- slugs.append(slug)
- models.Film.objects.exclude(slug__in=slugs).delete()
diff --git a/app/video/management/commands/update_geoip.py b/app/video/management/commands/update_geoip.py
deleted file mode 100644
index df78a29..0000000
--- a/app/video/management/commands/update_geoip.py
+++ /dev/null
@@ -1,29 +0,0 @@
-import os
-import re
-
-import ox
-
-from django.core.management.base import BaseCommand
-from django.conf import settings
-
-
-class Command(BaseCommand):
- """
- """
- help = 'update geoip database'
- args = ''
-
- def handle(self, **options):
- force = False
- path = settings.GEOIP_PATH / 'GeoLite2-City.mmdb'
- index = ox.net.read_url('https://db-ip.com/db/download/ip-to-city-lite').decode()
- match = re.compile('href=[\'"](http.*.mmdb.gz)').findall(index)
- if match:
- url = match[0]
- print('download', url)
- ox.net.save_url(url, "%s.gz" % path)
- if os.path.exists(path):
- os.unlink(path)
- os.system('gunzip "%s.gz"' % path)
- else:
- print('failed to download GeoLite2-City.mmdb')
diff --git a/app/video/migrations/0001_initial.py b/app/video/migrations/0001_initial.py
deleted file mode 100644
index 8e1f0f2..0000000
--- a/app/video/migrations/0001_initial.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Generated by Django 3.2.9 on 2021-11-12 09:35
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- initial = True
-
- dependencies = [
- ]
-
- operations = [
- migrations.CreateModel(
- name='Film',
- fields=[
- ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('created', models.DateTimeField(auto_now_add=True)),
- ('modified', models.DateTimeField(auto_now=True)),
- ('slug', models.SlugField()),
- ('public', models.BooleanField(default=False)),
- ('position', models.IntegerField(default=0)),
- ('pandora_url', models.CharField(max_length=1024)),
- ('data', models.JSONField(blank=True, default=dict)),
- ],
- ),
- ]
diff --git a/app/video/migrations/0002_film_featured.py b/app/video/migrations/0002_film_featured.py
deleted file mode 100644
index a788901..0000000
--- a/app/video/migrations/0002_film_featured.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by Django 3.2.9 on 2021-11-22 12:48
-
-from django.db import migrations, models
-
-
-class Migration(migrations.Migration):
-
- dependencies = [
- ('video', '0001_initial'),
- ]
-
- operations = [
- migrations.AddField(
- model_name='film',
- name='featured',
- field=models.BooleanField(default=False),
- ),
- ]
diff --git a/app/video/migrations/__init__.py b/app/video/migrations/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/app/video/models.py b/app/video/models.py
deleted file mode 100644
index 8357530..0000000
--- a/app/video/models.py
+++ /dev/null
@@ -1,83 +0,0 @@
-import logging
-import json
-
-from django.conf import settings
-from django.contrib.auth import get_user_model
-from django.db import models
-from django.db.models import Q
-
-import ox
-
-logger = logging.getLogger(__name__)
-User = get_user_model()
-
-
-class Film(models.Model):
- created = models.DateTimeField(auto_now_add=True)
- modified = models.DateTimeField(auto_now=True)
-
- slug = models.SlugField()
- public = models.BooleanField(default=False)
- featured = models.BooleanField(default=False)
- position = models.IntegerField(default=0)
-
- pandora_url = models.CharField(max_length=1024)
-
- data = models.JSONField(default=dict, blank=True)
-
- def __str__(self):
- return self.data.get('title', self.slug)
-
- def get_absolute_url(self):
- return '/' + settings.URL_PREFIX + 'video/' + self.slug
-
- def related_texts(self):
- from ..text.models import Text
- folder = self.data.get('title')
- if folder:
- return Text.objects.filter(Q(data__folder=folder) | Q(data__related=folder))
-
- def duration_seconds(self):
- duration = 0
- for item in self.data.get('items', []):
- duration += item['duration']
- return duration
-
- def duration(self):
- return ox.format_duration(self.data['duration'] * 1000, verbosity=1, milliseconds=False)
-
- def color_1(self):
- hue = self.data['hue']
- saturation = self.data['saturation'] * 100
- saturation = 70
- lightness = self.data['lightness'] * 100
- return "hsl({}, {}%, {}%)".format(hue, saturation, lightness)
-
- def color_2(self):
- hue = self.data['hue']
- saturation = self.data['saturation'] * 100
- saturation = 70
- lightness = self.data['lightness'] * 50
- return "hsl({}, {}%, {}%)".format(hue, saturation, lightness)
-
- def color_3(self):
- hue = self.data['hue']
- saturation = self.data['saturation'] * 100
- saturation = 70
- lightness = self.data['lightness'] * 110
- return "hsl({}, {}%, {}%)".format(hue, saturation, lightness)
-
- def color_4(self):
- hue = self.data['hue']
- saturation = self.data['saturation'] * 100
- saturation = 70
- lightness = self.data['lightness'] * 80
- return "hsl({}, {}%, {}%)".format(hue, saturation, lightness)
-
- def json(self):
- data = {}
- data['url'] = self.pandora_url
- #data.update(self.data)
- return json.dumps(data)
-
-
diff --git a/app/video/tests.py b/app/video/tests.py
deleted file mode 100644
index 7ce503c..0000000
--- a/app/video/tests.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.test import TestCase
-
-# Create your tests here.
diff --git a/app/video/views.py b/app/video/views.py
deleted file mode 100644
index b99dd9b..0000000
--- a/app/video/views.py
+++ /dev/null
@@ -1,128 +0,0 @@
-import logging
-import json
-from collections import Counter
-
-from django.shortcuts import render, redirect, get_object_or_404
-from django.views.decorators.csrf import csrf_exempt
-from django.conf import settings
-from django.contrib.gis.geoip2 import GeoIP2, GeoIP2Exception
-import ox.geo
-
-from . import models
-
-logger = logging.getLogger(__name__)
-
-stream_prefix_cache = {}
-
-def get_ip(request):
- if 'HTTP_X_FORWARDED_FOR' in request.META:
- ip = request.META['HTTP_X_FORWARDED_FOR'].split(',')[0]
- else:
- ip = request.META['REMOTE_ADDR']
- if ip.startswith('::ffff:'):
- ip = ip[len('::ffff:'):]
- return ip
-
-def get_stream_prefix(request):
- #domain = settings.DEFAULT_PANDORA_API.split('/')[2]
- domain = 'njp.ma'
- prefix = "https://media.v1.%s" % domain
- cdn = {
- 'Eastern Asia': "https://media.v2.%s" % domain,
- 'Southern Asia': "https://media.v2.%s" % domain,
- 'Asia': "https://media.v2.%s" % domain,
- }
- ip = get_ip(request)
- if ip in stream_prefix_cache:
- return stream_prefix_cache[ip]
- try:
- g = GeoIP2()
- country = g.country(ip)
- if country:
- country = ox.get_country_name(country['country_code'])
- info = ox.geo.get_country(country)
- for key in ('name', 'region', 'continent'):
- location = info.get(key)
- #print(location)
- if location in cdn:
- stream_prefix_cache[ip] = cdn[location]
- return cdn[location]
- except:
- logger.error('using default prefix, no geoip data found, run ./mange.py update_geoio', exc_info=True)
- stream_prefix_cache[ip] = prefix
- return prefix
- stream_prefix_cache[ip] = prefix
- return prefix
-
-def films(request):
- context = {}
- context['films'] = models.Film.objects.filter(public=True).order_by('position', 'data__title')
- types = []
- for f in context['films']:
- types += [t.capitalize() for t in f.data['type']]
- types = Counter(types)
- context['types'] = []
- for t in sorted(types):
- context['types'].append({
- 'title': '%s (%s)' % (t, types[t]), 'value': t
- })
-
- context['stream_prefix'] = get_stream_prefix(request)
- context['settings'] = settings
- return render(request, 'films.html', context)
-
-def film(request, slug):
- context = {}
- context['film'] = get_object_or_404(models.Film, slug=slug)
- context['settings'] = settings
- context['stream_prefix'] = get_stream_prefix(request)
- context['pandora_url'] = settings.DEFAULT_PANDORA_API.replace('/api/', '')
- return render(request, 'film.html', context)
-
-def film_play(request, slug, id):
- context = {}
- context['settings'] = settings
- context['config'] = json.dumps({
- 'layer': 'transcripts',
- 'item': id
- })
- context['stream_prefix'] = get_stream_prefix(request)
- context['pandora_url'] = settings.DEFAULT_PANDORA_API.replace('/api/', '')
- return render(request, 'film_play.html', context)
-
-def edits(request):
- context = {}
- context['edits'] = models.Edit.objects.filter(public=True).order_by('created')
- return render(request, 'edits.html', context)
-
-def edit(request, slug):
- context = {}
- context['edit'] = get_object_or_404(models.Edit, slug=slug)
- context['settings'] = settings
- return render(request, 'edit.html', context)
-
-def edit_play(request, slug, lang):
- context = {}
- context['edit'] = get_object_or_404(models.Edit, slug=slug)
- context['lang'] = lang
- context['settings'] = settings
- return render(request, 'edit_play.html', context)
-
-def tv(request):
- context = {}
- context['settings'] = settings
- return render(request, 'tv.html', context)
-
-
-@csrf_exempt
-def pandoraAPI(request):
- import ox
- from .utils import render_to_json_response
- import json
- data = json.loads(request.body.decode())
- print('pandora request', data)
- api = ox.api.signin('https://pad.ma/api/')
- data = getattr(api, data['action'])(**data['data'])
- print('response', data)
- return render_to_json_response(data)
-
diff --git a/etc/nginx/sites-available/njp.ma b/etc/nginx/sites-available/phantas.ma
similarity index 83%
rename from etc/nginx/sites-available/njp.ma
rename to etc/nginx/sites-available/phantas.ma
index 5d892ab..4f2bb3e 100644
--- a/etc/nginx/sites-available/njp.ma
+++ b/etc/nginx/sites-available/phantas.ma
@@ -9,19 +9,19 @@ server {
root /var/www/html;
autoindex off;
}
- rewrite ^/(.*) https://njp.ma/$1 permanent;
+ rewrite ^/(.*) https://phantas.ma/$1 permanent;
}
server {
server_tokens off;
- server_name njp.ma;
+ server_name phantas.ma;
listen 443 ssl http2;
listen [::]:443 ssl http2;
- ssl_trusted_certificate /etc/letsencrypt/live/njp.ma/chain.pem;
- ssl_certificate /etc/letsencrypt/live/njp.ma/fullchain.pem;
- ssl_certificate_key /etc/letsencrypt/live/njp.ma/privkey.pem;
+ ssl_trusted_certificate /etc/letsencrypt/live/phantas.ma/chain.pem;
+ ssl_certificate /etc/letsencrypt/live/phantas.ma/fullchain.pem;
+ ssl_certificate_key /etc/letsencrypt/live/phantas.ma/privkey.pem;
#include /etc/letsencrypt/nginx.conf;
location /favicon.ico {
diff --git a/etc/systemd/system/njpma.service b/etc/systemd/system/phantasma.service
similarity index 50%
rename from etc/systemd/system/njpma.service
rename to etc/systemd/system/phantasma.service
index 3f1c6d4..dc1e32a 100644
--- a/etc/systemd/system/njpma.service
+++ b/etc/systemd/system/phantasma.service
@@ -1,14 +1,14 @@
[Unit]
-Description=njpma
+Description=phantasma
[Service]
Type=simple
Restart=always
User=pandora
Group=pandora
-WorkingDirectory=/srv/njpma
+WorkingDirectory=/srv/phantasma
ExecReload=/bin/kill -HUP $MAINPID
-ExecStart=/srv/njpma/venv/bin/gunicorn app.wsgi:application --reuse-port -b [::]:8080
+ExecStart=/srv/phantasma/venv/bin/gunicorn app.wsgi:application --reuse-port -b [::]:8085
[Install]
WantedBy=multi-user.target