Restructured web resources to better manage static files.

This commit is contained in:
Kelketek Rritaa 2014-05-02 22:52:12 -05:00
parent 05c9d67ffc
commit 16bcc3c9f0
25 changed files with 70 additions and 59 deletions

View file

@ -0,0 +1,5 @@
This folder is used by Django's staticfiles application for gathering all static files (CSS, JS, etc) into one place
from the various sources that they might be gathered from.
Do not edit files in this directory. Instead, read up on Django's static file handling to learn how to create Django
apps with their own static files.

13
game/gamesrc/web/urls.py Normal file
View file

@ -0,0 +1,13 @@
from src.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
#
# You can add URLs to your game's website by extending urlpatterns.
#
# 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/

View file

@ -18,6 +18,7 @@ found on http://localhost:8000/webclient.)
""" """
import time import time
import json import json
from hashlib import md5 from hashlib import md5
from twisted.web import server, resource from twisted.web import server, resource
@ -32,7 +33,6 @@ from src.server import session
SERVERNAME = settings.SERVERNAME SERVERNAME = settings.SERVERNAME
ENCODINGS = settings.ENCODINGS ENCODINGS = settings.ENCODINGS
# defining a simple json encoder for returning # defining a simple json encoder for returning
# django data to the client. Might need to # django data to the client. Might need to
# extend this if one wants to send more # extend this if one wants to send more

View file

@ -411,6 +411,8 @@ if WEBSERVER_ENABLED:
web_root = DjangoWebRoot(threads) web_root = DjangoWebRoot(threads)
# point our media resources to url /media # point our media resources to url /media
web_root.putChild("media", static.File(settings.MEDIA_ROOT)) web_root.putChild("media", static.File(settings.MEDIA_ROOT))
# point our static resources to url /static
web_root.putChild("static", static.File(settings.STATIC_ROOT))
web_site = server.Site(web_root, logPath=settings.HTTP_LOG_FILE) web_site = server.Site(web_root, logPath=settings.HTTP_LOG_FILE)
for proxyport, serverport in WEBSERVER_PORTS: for proxyport, serverport in WEBSERVER_PORTS:

View file

@ -480,7 +480,7 @@ LOCALE_PATHS = ["../locale/"]
SERVE_MEDIA = False SERVE_MEDIA = False
# The master urlconf file that contains all of the sub-branches to the # The master urlconf file that contains all of the sub-branches to the
# applications. # applications.
ROOT_URLCONF = 'src.web.urls' ROOT_URLCONF = 'game.gamesrc.web.urls'
# Where users are redirected after logging in via contrib.auth.login. # Where users are redirected after logging in via contrib.auth.login.
LOGIN_REDIRECT_URL = '/' LOGIN_REDIRECT_URL = '/'
# Where to redirect users when using the @login_required decorator. # Where to redirect users when using the @login_required decorator.
@ -493,7 +493,13 @@ MEDIA_URL = '/media/'
# URL prefix for admin media -- CSS, JavaScript and images. Make sure # URL prefix for admin media -- CSS, JavaScript and images. Make sure
# to use a trailing slash. Django1.4+ will look for admin files under # to use a trailing slash. Django1.4+ will look for admin files under
# STATIC_URL/admin. # STATIC_URL/admin.
STATIC_URL = '/media/' STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(GAME_DIR, "gamesrc", "web", "static")
# Folders from which static files will be gathered from.
STATICFILES_DIRS = (
os.path.join(SRC_DIR, "web", "static"),)
# The name of the currently selected web template. This corresponds to the # The name of the currently selected web template. This corresponds to the
# directory names shown in the webtemplates directory. # directory names shown in the webtemplates directory.
ACTIVE_TEMPLATE = 'prosimii' ACTIVE_TEMPLATE = 'prosimii'
@ -540,6 +546,7 @@ INSTALLED_APPS = (
'django.contrib.admin', 'django.contrib.admin',
'django.contrib.admindocs', 'django.contrib.admindocs',
'django.contrib.flatpages', 'django.contrib.flatpages',
'django.contrib.staticfiles',
'src.server', 'src.server',
'src.typeclasses', 'src.typeclasses',
'src.players', 'src.players',
@ -548,7 +555,7 @@ INSTALLED_APPS = (
'src.help', 'src.help',
'src.scripts', 'src.scripts',
'src.web.news', 'src.web.news',
'src.web.website',) 'src.web.webclient')
# The user profile extends the User object with more functionality; # The user profile extends the User object with more functionality;
# This should usually not be changed. # This should usually not be changed.
AUTH_USER_MODEL = "players.PlayerDB" AUTH_USER_MODEL = "players.PlayerDB"

View file

@ -5,9 +5,8 @@ It is imported from the root handler, game.web.urls.py.
from django.conf.urls import * from django.conf.urls import *
urlpatterns = patterns('src.web.news.views', urlpatterns = [
(r'^show/(?P<entry_id>\d+)/$', 'show_news'), url(r'^show/(?P<entry_id>\d+)/$', 'show_news', name="show"),
(r'^archive/$', 'news_archive'), url(r'^archive/$', 'news_archive', name="archive"),
(r'^search/$', 'search_form'), url(r'^search/$', 'search_form', name="search"),
(r'^search/results/$', 'search_results'), url(r'^search/results/$', 'search_results', name="search_results")]
)

View file

Before

Width:  |  Height:  |  Size: 678 KiB

After

Width:  |  Height:  |  Size: 678 KiB

Before After
Before After

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

@ -5,7 +5,7 @@
{% block branding %} {% block branding %}
<h1 id="site-name">{% trans 'Evennia database administration' %} <h1 id="site-name">{% trans 'Evennia database administration' %}
<a href="/">(Back)</a> </h1> <a href="{% url "index" %}">(Back)</a> </h1>
{% endblock %} {% endblock %}
{% block nav-global %}{% endblock %} {% block nav-global %}{% endblock %}

View file

@ -1,3 +1,4 @@
{% load staticfiles %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
@ -8,12 +9,12 @@
<meta name="generator" content="haran" /> <meta name="generator" content="haran" />
{% if sidebar %} {% if sidebar %}
<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/prosimii-screen-alt.css" media="screen" title="Prosimii (Sidebar)" /> <link rel="stylesheet" type="text/css" href="{% static "ev/css/prosimii-screen-alt.css" %}" media="screen" title="Prosimii (Sidebar)" />
{% else %} {% else %}
<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/prosimii-screen.css" media="screen" title="Prosimii" /> <link rel="stylesheet" type="text/css" href="{% static "ev/css/prosimii-screen.css" %}" media="screen" title="Prosimii" />
{% endif %} {% endif %}
<link rel="stylesheet alternative" type="text/css" href="{{MEDIA_URL}}css/prosimii-print.css" media="screen" title="Print Preview" /> <link rel="stylesheet alternative" type="text/css" href="{% static "ev/css/prosimii-print.css" %}" media="screen" title="Print Preview" />
<link rel="stylesheet" type="text/css" href="{{MEDIA_URL}}css/prosimii-print.css" media="print" /> <link rel="stylesheet" type="text/css" href="{% static "ev/css/prosimii-print.css" %}" media="print" />
{% block header_ext %} {% block header_ext %}
{% endblock %} {% endblock %}
@ -34,7 +35,7 @@
</div> </div>
<div class="midHeader"> <div class="midHeader">
<img src="/media/images/evennia_logo_small.png" align='left'/> <h1 class="headerTitle" lang="la">{{game_name}}</h1> <img src="{% static "ev/images/evennia_logo_small.png" %}" align='left'/> <h1 class="headerTitle" lang="la">{{game_name}}</h1>
<div class="headerSubTitle" title="Slogan"> <div class="headerSubTitle" title="Slogan">
<!-- Insert a slogan here if you want --> <!-- Insert a slogan here if you want -->
{{game_slogan}} &nbsp; {{game_slogan}} &nbsp;
@ -45,13 +46,13 @@
<div class="headerLinks"> <div class="headerLinks">
<span class="doNotDisplay">Tools:</span> <span class="doNotDisplay">Tools:</span>
{% if user.is_authenticated %} {% if user.is_authenticated %}
<a href="/accounts/logout/">Log Out &laquo;</a> <a href="{% url 'logout' %}">Log Out &laquo;</a>
<span class="doNotDisplay">|</span> <span class="doNotDisplay">|</span>
Logged in as {{user.username}} &laquo; Logged in as {{user.username}} &laquo;
{% else %} {% else %}
<a href="/accounts/login/">Log In &laquo;</a> <a href="{% url 'login' %}">Log In &laquo;</a>
<span class="doNotDisplay">|</span> <span class="doNotDisplay">|</span>
<a href="/tbi">Register &laquo;</a> <a href="{% url 'to_be_implemented' %}">Register &laquo;</a>
{% endif %} {% endif %}
</div> </div>
</div> </div>
@ -61,9 +62,9 @@
<a href="/">Home</a> | <a href="/">Home</a> |
<a href="https://github.com/evennia/evennia/wiki/Evennia-Introduction/">About</a> | <a href="https://github.com/evennia/evennia/wiki/Evennia-Introduction/">About</a> |
<a href="https://github.com/evennia/evennia/wiki">Documentation</a> | <a href="https://github.com/evennia/evennia/wiki">Documentation</a> |
<a href="/admin/">Admin Interface</a> <a href="{% url 'admin:index' %}">Admin Interface</a>
{% if webclient_enabled %} {% if webclient_enabled %}
| <a href="/webclient">Play Online</a> | <a href="{% url 'webclient:index' %}">Play Online</a>
{% endif %} {% endif %}
</div> </div>
@ -87,7 +88,7 @@
title="Other designs by haran">haran</a>. title="Other designs by haran">haran</a>.
Powered by Powered by
<a href="http://evennia.com">Evennia.</a> <a href="http://evennia.com">Evennia.</a>
<br \> <br />
</span> </span>
</div> </div>
</body> </body>

View file

@ -14,11 +14,11 @@
<p>Welcome to your new installation of <a href="http://evennia.com">Evennia</a>, your friendly <p>Welcome to your new installation of <a href="http://evennia.com">Evennia</a>, your friendly
neighborhood next-generation MUD development system and server. You are looking at Evennia's web neighborhood next-generation MUD development system and server. You are looking at Evennia's web
presence, which can be expanded to a full-fledged site as presence, which can be expanded to a full-fledged site as
needed. Through the <a href="/admin">admin interface</a> you can view and edit the needed. Through the <a href="{% url 'admin:index' %}">admin interface</a> you can view and edit the
database without logging into the game. database without logging into the game.
{% if webclient_enabled %} {% if webclient_enabled %}
You can also connect to the game directly from your browser using our You can also connect to the game directly from your browser using our
<a href='/webclient'>online client</a>!<br></br> <a href="{% url 'webclient:index' %}">online client</a>!<br></br>
{% endif %} {% endif %}
For more info, take your time to For more info, take your time to
peruse our extensive online <a href="https://github.com/evennia/evennia/wiki">documentation</a>. peruse our extensive online <a href="https://github.com/evennia/evennia/wiki">documentation</a>.

View file

@ -24,18 +24,16 @@ admin.autodiscover()
# Setup the root url tree from / # Setup the root url tree from /
urlpatterns = patterns('', urlpatterns = [
# User Authentication # User Authentication
url(r'^accounts/login', 'django.contrib.auth.views.login'), url(r'^accounts/login', 'django.contrib.auth.views.login', name="login"),
url(r'^accounts/logout', 'django.contrib.auth.views.logout'), url(r'^accounts/logout', 'django.contrib.auth.views.logout', name="logout"),
# Front page
url(r'^', include('src.web.website.urls')),
# News stuff # News stuff
# url(r'^news/', include('src.web.news.urls')), # url(r'^news/', include('src.web.news.urls')),
# Page place-holder for things that aren't implemented yet. # Page place-holder for things that aren't implemented yet.
url(r'^tbi/', 'src.web.website.views.to_be_implemented'), url(r'^tbi/', 'src.web.views.to_be_implemented', name='to_be_implemented'),
# Admin interface # Admin interface
url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
@ -44,13 +42,16 @@ urlpatterns = patterns('',
# favicon # favicon
url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico')), url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico')),
# webclient stuff # ajax stuff
url(r'^webclient/', include('src.web.webclient.urls')), url(r'^webclient/', include('src.web.webclient.urls', namespace='webclient', app_name='webclient')),
)
# Front page
url(r'^$', 'src.web.views.page_index', name="index")]
# This sets up the server if the user want to run the Django # This sets up the server if the user want to run the Django
# test server (this should normally not be needed). # test server (this should normally not be needed).
if settings.SERVE_MEDIA: if settings.SERVE_MEDIA:
urlpatterns += patterns('', urlpatterns.extend([
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), 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

@ -33,7 +33,7 @@ def page_index(request):
nplyrs_conn_recent = len(recent_users) or "none" nplyrs_conn_recent = len(recent_users) or "none"
nplyrs = PlayerDB.objects.num_total_players() or "none" nplyrs = PlayerDB.objects.num_total_players() or "none"
nplyrs_reg_recent = len(PlayerDB.objects.get_recently_created_players()) or "none" nplyrs_reg_recent = len(PlayerDB.objects.get_recently_created_players()) or "none"
nsess = len(PlayerDB.objects.get_connected_players()) or "none" nsess = len(PlayerDB.objects.get_connected_players()) or "no one"
nobjs = ObjectDB.objects.all().count() nobjs = ObjectDB.objects.all().count()
nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count() nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count()

View file

@ -1,4 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
{% load staticfiles %}
<html dir="ltr" lang="en"> <html dir="ltr" lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
@ -6,7 +7,7 @@
<title>Evennia web MUD client</title> <title>Evennia web MUD client</title>
<!--CSS style sheet --> <!--CSS style sheet -->
<link rel='stylesheet' type="text/css" media="screen" href="/media/css/webclient.css"> <link rel='stylesheet' type="text/css" media="screen" href="{% static "webclient/css/webclient.css" %}">
<!-- Importing the online jQuery javascript library --> <!-- Importing the online jQuery javascript library -->
<!--script src="http://code.jquery.com/jquery-1.6.1.js" type="text/javascript" charset="utf-8"></script--> <!--script src="http://code.jquery.com/jquery-1.6.1.js" type="text/javascript" charset="utf-8"></script-->
@ -23,14 +24,13 @@
document.write("\<script src=\"/media/javascript/evennia_websocket_webclient.js\" type=\"text/javascript\" charset=\"utf-8\"\>\</script\>")} document.write("\<script src=\"/media/javascript/evennia_websocket_webclient.js\" type=\"text/javascript\" charset=\"utf-8\"\>\</script\>")}
else { else {
<!-- No websocket support in browser. Importing the Evennia ajax webclient component (requires jQuery) --> <!-- No websocket support in browser. Importing the Evennia ajax webclient component (requires jQuery) -->
document.write("\<script src=\"/media/javascript/evennia_ajax_webclient.js\" type=\"text/javascript\" charset=\"utf-8\"\>\</script\>")} document.write("\<script src=\"{% static "webclient/js/evennia_ajax_webclient.js" %}\" type=\"text/javascript\" charset=\"utf-8\"\>\</script\>")}
</script> </script>
{% else %} {% else %}
<!-- websocket not enabled; use ajax --> <!-- websocket not enabled; use ajax -->
<script src="/media/javascript/evennia_ajax_webclient.js" type="text/javascript" charset="utf-8"></script> <script src="/media/javascript/evennia_ajax_webclient.js" type="text/javascript" charset="utf-8"></script>
{% endif %} {% endif %}
</head> </head>
<body> <body>

View file

@ -4,5 +4,5 @@ webpage 'application'.
""" """
from django.conf.urls import * from django.conf.urls import *
urlpatterns = patterns('', urlpatterns = [
url(r'^$', 'src.web.webclient.views.webclient'),) url(r'^$', 'src.web.webclient.views.webclient', name="index")]

View file

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

View file

@ -1,10 +0,0 @@
"""
This structures the (simple) structure of the
webpage 'application'.
"""
from django.conf.urls import *
urlpatterns = patterns('src.web.website.views',
(r'^$', 'page_index'),
)