Reshuffling the Evennia package into the new template paradigm.
This commit is contained in:
parent
2846e64833
commit
2b3a32e447
371 changed files with 17250 additions and 304 deletions
0
lib/web/utils/__init__.py
Normal file
0
lib/web/utils/__init__.py
Normal file
16
lib/web/utils/apache_wsgi.conf
Normal file
16
lib/web/utils/apache_wsgi.conf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import os, sys
|
||||
|
||||
# Calculate the path based on the location of the WSGI script.
|
||||
web_dir = os.path.dirname(os.path.dirname(__file__))
|
||||
workspace = os.path.dirname(os.path.dirname(web_dir))
|
||||
|
||||
sys.path.insert(0, workspace)
|
||||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'game.settings'
|
||||
import django.core.handlers.wsgi
|
||||
|
||||
_application = django.core.handlers.wsgi.WSGIHandler()
|
||||
# This handles apps mounted in places other than the root mount point
|
||||
def application(environ, start_response):
|
||||
environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
|
||||
return _application(environ, start_response)
|
||||
18
lib/web/utils/backends.py
Normal file
18
lib/web/utils/backends.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from django.contrib.auth.backends import ModelBackend
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
class CaseInsensitiveModelBackend(ModelBackend):
|
||||
"""
|
||||
By default ModelBackend does case _sensitive_ username authentication, which isn't what is
|
||||
generally expected. This backend supports case insensitive username authentication.
|
||||
"""
|
||||
def authenticate(self, username=None, password=None):
|
||||
User = get_user_model()
|
||||
try:
|
||||
user = User.objects.get(username__iexact=username)
|
||||
if user.check_password(password):
|
||||
return user
|
||||
else:
|
||||
return None
|
||||
except User.DoesNotExist:
|
||||
return None
|
||||
45
lib/web/utils/evennia_modpy_apache.conf
Normal file
45
lib/web/utils/evennia_modpy_apache.conf
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
|
||||
# WARNING: mod_python is no longer the recommended way to run Evennia's
|
||||
# web front end. This file is no longer actively maintained and may
|
||||
# no longer work. We suggest using mod_wsgi unless absolutely necessary.
|
||||
|
||||
# Add this vhost file to your Apache sites-enabled directory, typically found
|
||||
# at /etc/apache2/sites-enabled. You'll need to go through and change the
|
||||
# /home/evennia to point to the correct home directory, and the evennia
|
||||
# subdir must be under that home directory.
|
||||
|
||||
# A NOTE ON IMAGES/CSS: These files must be handled separately from the actual
|
||||
# dynamic content which is interpreted by Python. You may host these static
|
||||
# images/css from the same server or a different one. The static media
|
||||
# is served from /home/evennia/evennia/media. The easiest way to serve
|
||||
# this stuff is by either hosting them remotely or symlinking
|
||||
# the media directory into an existing Apache site's directory.
|
||||
|
||||
# A NOTE ON ADMIN IMAGES/CSS: You'll need to create a symlink called
|
||||
# 'amedia' under the media directory if you want to use the admin interface.
|
||||
# This can be found in the Django package in your Python path. For example,
|
||||
# the default is: /usr/lib/python2.4/site-packages/django/contrib/admin/media/
|
||||
# although your location may vary.
|
||||
<VirtualHost *>
|
||||
# Set ServerName and ServerAdmin appropriately
|
||||
ServerName evennia.somewhere.com
|
||||
ServerAdmin someone@somewhere.com
|
||||
DocumentRoot /home/evennia/evennia
|
||||
|
||||
<Directory "/home/evennia/evennia">
|
||||
SetHandler python-program
|
||||
PythonHandler django.core.handlers.modpython
|
||||
PythonPath "['/home/evennia/evennia'] + sys.path"
|
||||
SetEnv DJANGO_SETTINGS_MODULE settings
|
||||
PythonDebug On
|
||||
</Directory>
|
||||
|
||||
Alias /media/ "/home/evennia/evennia/media/"
|
||||
<Directory "/home/evennia/evennia/media/">
|
||||
SetHandler None
|
||||
</Directory>
|
||||
|
||||
<LocationMatch "\.(jpg|gif|png|css)$">
|
||||
SetHandler None
|
||||
</LocationMatch>
|
||||
</VirtualHost>
|
||||
51
lib/web/utils/evennia_wsgi_apache.conf
Normal file
51
lib/web/utils/evennia_wsgi_apache.conf
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<VirtualHost *>
|
||||
# This is an example mod_wsgi apache2 vhost. There are a number of
|
||||
# things you'll need to change. They are commented below. Make sure
|
||||
# you read and understand the stuff below.
|
||||
|
||||
# Copy this file to your apache2 vhosts directory before editing.
|
||||
# This file is merely a template. The vhost directory is usually
|
||||
# something like /etc/apache2/sites-enabled/.
|
||||
|
||||
# You'll want to replace the following with your domain info.
|
||||
ServerName dev.evennia.com
|
||||
ServerAlias www.dev.evennia.com
|
||||
#
|
||||
## BEGIN EVENNIA WEB CONFIG
|
||||
#
|
||||
# evennia_web is just an internal name for mod_wsgi and may be left
|
||||
# The user and group options are the user and the group that the
|
||||
# python code will be executed under. This user must have permissions
|
||||
# to the evennia source.
|
||||
WSGIDaemonProcess evennia_web user=evennia group=evennia threads=25
|
||||
WSGIProcessGroup evennia_web
|
||||
|
||||
# This needs to be changed to the appropriate path on your django
|
||||
# install. It serves admin site media.
|
||||
# For Python 2.6, this is:
|
||||
# /usr/lib/python2.6/dist-packages/django/contrib/admin/media/
|
||||
Alias /media/amedia/ "/usr/lib/python2.5/site-packages/django/contrib/admin/media/"
|
||||
<Directory "/usr/lib/python2.5/site-packages/django/contrib/admin/media">
|
||||
Order allow,deny
|
||||
Options Indexes
|
||||
Allow from all
|
||||
IndexOptions FancyIndexing
|
||||
</Directory>
|
||||
|
||||
# Media Directory. This needs to be set to your equivalent path.
|
||||
Alias /media/ "/home/evennia/evennia/game/web/media/"
|
||||
<Directory "/home/evennia/evennia/game/web/media">
|
||||
Order allow,deny
|
||||
Options Indexes FollowSymLinks
|
||||
Allow from all
|
||||
IndexOptions FancyIndexing
|
||||
</Directory>
|
||||
|
||||
|
||||
# WSGI Config File. You'll need to update this path as well.
|
||||
WSGIScriptAlias / /home/evennia/evennia/game/web/utils/apache_wsgi.conf
|
||||
|
||||
#
|
||||
## END EVENNIA WEB CONFIG
|
||||
#
|
||||
</VirtualHost>
|
||||
52
lib/web/utils/general_context.py
Normal file
52
lib/web/utils/general_context.py
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#
|
||||
# This file defines global variables that will always be
|
||||
# available in a view context without having to repeatedly
|
||||
# include it. For this to work, this file is included in
|
||||
# the settings file, in the TEMPLATE_CONTEXT_PROCESSORS
|
||||
# tuple.
|
||||
#
|
||||
|
||||
from django.conf import settings
|
||||
from src.utils.utils import get_evennia_version
|
||||
|
||||
# Determine the site name and server version
|
||||
|
||||
try:
|
||||
GAME_NAME = settings.SERVERNAME.strip()
|
||||
except AttributeError:
|
||||
GAME_NAME = "Evennia"
|
||||
SERVER_VERSION = get_evennia_version()
|
||||
|
||||
|
||||
# Setup lists of the most relevant apps so
|
||||
# the adminsite becomes more readable.
|
||||
|
||||
PLAYER_RELATED = ['Players']
|
||||
GAME_ENTITIES = ['Objects', 'Scripts', 'Comms', 'Help']
|
||||
GAME_SETUP = ['Permissions', 'Config']
|
||||
CONNECTIONS = ['Irc', 'Imc2']
|
||||
WEBSITE = ['Flatpages', 'News', 'Sites']
|
||||
|
||||
|
||||
# The main context processor function
|
||||
WEBCLIENT_ENABLED = settings.WEBCLIENT_ENABLED
|
||||
WEBSOCKET_CLIENT_ENABLED = settings.WEBSOCKET_CLIENT_ENABLED
|
||||
WSURL = "%s:%s" % (settings.WEBSOCKET_CLIENT_URL, settings.WEBSOCKET_CLIENT_PORT)
|
||||
|
||||
def general_context(request):
|
||||
"""
|
||||
Returns common Evennia-related context stuff, which
|
||||
is automatically added to context of all views.
|
||||
"""
|
||||
return {
|
||||
'game_name': GAME_NAME,
|
||||
'game_slogan': SERVER_VERSION,
|
||||
'evennia_userapps': PLAYER_RELATED,
|
||||
'evennia_entityapps': GAME_ENTITIES,
|
||||
'evennia_setupapps': GAME_SETUP,
|
||||
'evennia_connectapps': CONNECTIONS,
|
||||
'evennia_websiteapps':WEBSITE,
|
||||
"webclient_enabled" : WEBCLIENT_ENABLED,
|
||||
"websocket_enabled" : WEBSOCKET_CLIENT_ENABLED,
|
||||
"websocket_url" : WSURL
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue