Cleaned up the web folder to make two separate 'apps'-webclient and website, each with their own static and template dirs. Also merged the prosimii template files into the website template folder. This will make it clearer how to override, since the static/template_override dirs will now look like website/static/... etc rather than using the template names, of which we only ever have used one anyway.

This commit is contained in:
Griatch 2016-01-23 21:56:07 +01:00
parent 5ea9d100d9
commit 4fd06b8976
23 changed files with 91 additions and 100 deletions

View file

@ -83,14 +83,14 @@ STATIC_ROOT = os.path.join(GAME_DIR, "web", "static")
# Directories from which static files will be gathered from.
STATICFILES_DIRS = (
os.path.join(GAME_DIR, "web", "static_overrides"),
os.path.join(EVENNIA_DIR, "web", "static"),)
os.path.join(EVENNIA_DIR, "web", "website", "static"),)
# We setup the location of the website template as well as the admin site.
TEMPLATE_DIRS = (
os.path.join(GAME_DIR, "web", "template_overrides", ACTIVE_TEMPLATE),
os.path.join(GAME_DIR, "web", "template_overrides"),
os.path.join(EVENNIA_DIR, "web", "templates", ACTIVE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "templates"),)
os.path.join(EVENNIA_DIR, "web", "website", "templates", ACTIVE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "website", "templates"),)
# The secret key is randomly seeded upon creation. It is used to sign
# Django's cookies. Do not share this with anyone. Changing it will

View file

@ -1,25 +1,18 @@
"""
Url definition file to redistribute incoming URL requests to django
views. Search the Django documentation for "URL dispatcher" for more
help.
"""
from django.conf.urls import url, include
# default evennia patterns
from evennia.web.urls import urlpatterns
#
# File that determines what each URL points to. This uses _Python_ regular
# expressions, not Perl's.
#
# See:
# http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3
#
# Add your own URL patterns to the patterns variable below, and then change
#
# These are Django URL patterns, so you should look up how to use these at
# https://docs.djangoproject.com/en/1.6/topics/http/urls/
# Follow the full Django tutorial to learn how to create web views for Evennia.
# https://docs.djangoproject.com/en/1.6/intro/tutorial01/
patterns = [
# eventual custom patterns
custom_patterns = [
# url(r'/desired/url/', view, name='example'),
]
urlpatterns = patterns + urlpatterns
# this is used by Django.
urlpatterns = custom_patterns + urlpatterns

View file

@ -568,7 +568,7 @@ LOCALE_PATHS = [os.path.join(EVENNIA_DIR, "locale/")]
SERVE_MEDIA = False
# The master urlconf file that contains all of the sub-branches to the
# applications. Change this to add your own URLs to the website.
ROOT_URLCONF = 'web.urls' #src.web.urls?
ROOT_URLCONF = 'web.urls'
# Where users are redirected after logging in via contrib.auth.login.
LOGIN_REDIRECT_URL = '/'
# Where to redirect users when using the @login_required decorator.
@ -585,22 +585,22 @@ STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(GAME_DIR, "web", "static")
# Directories from which static files will be gathered.
# Location of static data to overload the defaults from
# evennia/web/webclient and evennia/web/website's static/ dirs.
STATICFILES_DIRS = (
os.path.join(GAME_DIR, "web", "static_overrides"),
os.path.join(EVENNIA_DIR, "web", "static"),)
os.path.join(GAME_DIR, "web", "static_overrides"),)
# Patterns of files in the static directories. Used here to make sure that
# its readme file is preserved but unused.
STATICFILES_IGNORE_PATTERNS = ('README.md',)
# The name of the currently selected web template. This corresponds to the
# directory names shown in the webtemplates directory.
ACTIVE_TEMPLATE = 'prosimii'
# directory names shown in the templates directory.
ACTIVE_TEMPLATE = 'website'
# We setup the location of the website template as well as the admin site.
TEMPLATE_DIRS = (
os.path.join(GAME_DIR, "web", "template_overrides", ACTIVE_TEMPLATE),
os.path.join(GAME_DIR, "web", "template_overrides"),
os.path.join(EVENNIA_DIR, "web", "templates", ACTIVE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "templates"),)
os.path.join(EVENNIA_DIR, "web", "website", "templates", ACTIVE_TEMPLATE),
os.path.join(EVENNIA_DIR, "web", "website", "templates"),)
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
@ -634,12 +634,12 @@ TEMPLATE_CONTEXT_PROCESSORS = (
# refer to app models and perform DB syncs.
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.sites',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.flatpages',
'django.contrib.sites',
'django.contrib.staticfiles',
'evennia.utils.idmapper',
'evennia.server',
@ -649,6 +649,7 @@ INSTALLED_APPS = (
'evennia.comms',
'evennia.help',
'evennia.scripts',
'evennia.web.website',
'evennia.web.webclient')
# The user profile extends the User object with more functionality;
# This should usually not be changed.

58
evennia/web/urls.py Executable file → Normal file
View file

@ -6,63 +6,19 @@
# http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3
#
from django.conf import settings
from django.conf.urls import url, include
from django.contrib import admin
from django.views.generic import RedirectView
## fix to resolve lazy-loading bug
## https://code.djangoproject.com/ticket/10405#comment:11
#from django.db.models.loading import cache as model_cache
#if not model_cache.loaded:
# model_cache.get_models()
# loop over all settings.INSTALLED_APPS and execute code in
# files named admin.py in each such app (this will add those
# models to the admin site)
admin.autodiscover()
# Setup the root url tree from /
urlpatterns = [
# User Authentication
url(r'^accounts/login', 'django.contrib.auth.views.login', name="login"),
url(r'^accounts/logout', 'django.contrib.auth.views.logout', name="logout"),
# Front page (note that we shouldn't specify namespace here since we will
# not be able to load django-auth/admin stuff (will probably work in Django>1.9)
url(r'^', include('evennia.web.website.urls')),#, namespace='website', app_name='website')),
# Page place-holder for things that aren't implemented yet.
url(r'^tbi/', 'evennia.web.views.to_be_implemented', name='to_be_implemented'),
# Admin interface
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# favicon
url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico', permanent=False)),
# ajax stuff
# webclient
url(r'^webclient/', include('evennia.web.webclient.urls', namespace='webclient', app_name='webclient')),
# Front page
url(r'^$', 'evennia.web.views.page_index', name="index"),
# Django original admin page. Make this URL is always available, whether
# we've chosen to use Evennia's custom admin or not.
url(r'django_admin/', 'evennia.web.views.admin_wrapper', name="django_admin")]
if settings.EVENNIA_ADMIN:
urlpatterns += [
# Our override for the admin.
url('^admin/$', 'evennia.web.views.evennia_admin', name="evennia_admin"),
# Makes sure that other admin pages get loaded.
url(r'^admin/', include(admin.site.urls))]
else:
# Just include the normal Django admin.
urlpatterns += [url(r'^admin/', include(admin.site.urls))]
# This sets up the server if the user want to run the Django
# test server (this should normally not be needed).
if settings.SERVE_MEDIA:
urlpatterns.extend([
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT})
])
# favicon
url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico', permanent=False))
]

View file

@ -1,7 +0,0 @@
#
# Define database entities for the app.
#
from django.db import models

View file

@ -0,0 +1 @@
# The Evennia default website.

View file

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Before After
Before After

View file

@ -9,12 +9,12 @@
<meta name="generator" content="haran" />
{% if sidebar %}
<link rel="stylesheet" type="text/css" href="{% static "evennia_general/css/prosimii-screen-alt.css" %}" media="screen" title="Prosimii (Sidebar)" />
<link rel="stylesheet" type="text/css" href="{% static "website/css/prosimii-screen-alt.css" %}" media="screen" title="Prosimii (Sidebar)" />
{% else %}
<link rel="stylesheet" type="text/css" href="{% static "evennia_general/css/prosimii-screen.css" %}" media="screen" title="Prosimii" />
<link rel="stylesheet" type="text/css" href="{% static "website/css/prosimii-screen.css" %}" media="screen" title="Prosimii" />
{% endif %}
<link rel="stylesheet alternative" type="text/css" href="{% static "evennia_general/css/prosimii-print.css" %}" media="screen" title="Print Preview" />
<link rel="stylesheet" type="text/css" href="{% static "evennia_general/css/prosimii-print.css" %}" media="print" />
<link rel="stylesheet alternative" type="text/css" href="{% static "website/css/prosimii-print.css" %}" media="screen" title="Print Preview" />
<link rel="stylesheet" type="text/css" href="{% static "website/css/prosimii-print.css" %}" media="print" />
{% block header_ext %}
{% endblock %}
@ -35,7 +35,7 @@
</div>
<div class="midHeader">
<img src="{% static "evennia_general/images/evennia_logo.png" %}" align='left'/> <h1 class="headerTitle" lang="la">{{game_name}}</h1>
<img src="{% static "website/images/evennia_logo.png" %}" align='left'/> <h1 class="headerTitle" lang="la">{{game_name}}</h1>
<div class="headerSubTitle" title="Slogan">
<!-- Insert a slogan here if you want -->
{{game_slogan}} &nbsp;
@ -66,7 +66,7 @@
{% if webclient_enabled %}
| <a href="{% url 'webclient:index' %}">Play Online</a>
{% endif %}
</div>
</div>
@ -83,10 +83,10 @@
<div id="footer">
<span class="doNotPrint">
Template design by
Template design by
<a href="http://www.oswd.org/designs/search/designer/id/3013/"
title="Other designs by haran">haran</a>.
Powered by
title="Other designs by haran">haran</a>.
Powered by
<a href="http://evennia.com">Evennia.</a>
<br />
</span>

View file

@ -0,0 +1,47 @@
"""
This structures the website.
"""
from django.conf import settings
from django.contrib import admin
from django.conf.urls import url, include
# loop over all settings.INSTALLED_APPS and execute code in
# files named admin.py in each such app (this will add those
# models to the admin site)
admin.autodiscover()
urlpatterns = [
url(r'^$', 'evennia.web.website.views.page_index', name="index"),
url(r'^tbi/', 'evennia.web.website.views.to_be_implemented', name='to_be_implemented'),
# User Authentication
url(r'^accounts/login', 'django.contrib.auth.views.login', name="login"),
url(r'^accounts/logout', 'django.contrib.auth.views.logout', name="logout"),
# Django original admin page. Make this URL is always available, whether
# we've chosen to use Evennia's custom admin or not.
url(r'django_admin/', 'evennia.web.website.views.admin_wrapper', name="django_admin"),
# Admin docs
url(r'^admin/doc/', include('django.contrib.admindocs.urls'))
]
if settings.EVENNIA_ADMIN:
urlpatterns += [
# Our override for the admin.
url('^admin/$', 'evennia.web.website.views.evennia_admin', name="evennia_admin"),
# Makes sure that other admin pages get loaded.
url(r'^admin/', include(admin.site.urls))]
else:
# Just include the normal Django admin.
urlpatterns += [url(r'^admin/', include(admin.site.urls))]
# This sets up the server if the user want to run the Django
# test server (this should normally not be needed).
if settings.SERVE_MEDIA:
urlpatterns.extend([
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT})
])

View file

@ -53,7 +53,7 @@ def page_index(request):
"num_others": nothers or "no"
}
return render(request, 'evennia_general/index.html', pagevars)
return render(request, 'website/index.html', pagevars)
def to_be_implemented(request):
@ -66,7 +66,7 @@ def to_be_implemented(request):
"page_title": "To Be Implemented...",
}
return render(request, 'evennia_general/tbi.html', pagevars)
return render(request, 'website/tbi.html', pagevars)
@staff_member_required
@ -75,7 +75,7 @@ def evennia_admin(request):
Helpful Evennia-specific admin page.
"""
return render(
request, 'evennia_general/evennia_admin.html', {
request, 'website/evennia_admin.html', {
'playerdb': PlayerDB})