diff --git a/src/web/website/__init__.py b/game/gamesrc/web/__init__.py similarity index 100% rename from src/web/website/__init__.py rename to game/gamesrc/web/__init__.py diff --git a/game/gamesrc/web/static/README.md b/game/gamesrc/web/static/README.md new file mode 100644 index 0000000000..8ba3d8ff20 --- /dev/null +++ b/game/gamesrc/web/static/README.md @@ -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. \ No newline at end of file diff --git a/game/gamesrc/web/urls.py b/game/gamesrc/web/urls.py new file mode 100644 index 0000000000..8e76e279c9 --- /dev/null +++ b/game/gamesrc/web/urls.py @@ -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/ \ No newline at end of file diff --git a/src/server/portal/webclient.py b/src/server/portal/webclient.py index c5f34558ed..74c32c6a4f 100644 --- a/src/server/portal/webclient.py +++ b/src/server/portal/webclient.py @@ -18,6 +18,7 @@ found on http://localhost:8000/webclient.) """ import time import json + from hashlib import md5 from twisted.web import server, resource @@ -32,7 +33,6 @@ from src.server import session SERVERNAME = settings.SERVERNAME ENCODINGS = settings.ENCODINGS - # defining a simple json encoder for returning # django data to the client. Might need to # extend this if one wants to send more diff --git a/src/server/server.py b/src/server/server.py index bc0f8c3e3a..5e7166ce1e 100644 --- a/src/server/server.py +++ b/src/server/server.py @@ -411,6 +411,8 @@ if WEBSERVER_ENABLED: web_root = DjangoWebRoot(threads) # point our media resources to url /media 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) for proxyport, serverport in WEBSERVER_PORTS: diff --git a/src/settings_default.py b/src/settings_default.py index 9a6d466a52..1f7b79af19 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -480,7 +480,7 @@ LOCALE_PATHS = ["../locale/"] SERVE_MEDIA = False # The master urlconf file that contains all of the sub-branches to the # applications. -ROOT_URLCONF = 'src.web.urls' +ROOT_URLCONF = 'game.gamesrc.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. @@ -493,7 +493,13 @@ MEDIA_URL = '/media/' # URL prefix for admin media -- CSS, JavaScript and images. Make sure # to use a trailing slash. Django1.4+ will look for admin files under # 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 # directory names shown in the webtemplates directory. ACTIVE_TEMPLATE = 'prosimii' @@ -540,6 +546,7 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.flatpages', + 'django.contrib.staticfiles', 'src.server', 'src.typeclasses', 'src.players', @@ -548,7 +555,7 @@ INSTALLED_APPS = ( 'src.help', 'src.scripts', 'src.web.news', - 'src.web.website',) + 'src.web.webclient') # The user profile extends the User object with more functionality; # This should usually not be changed. AUTH_USER_MODEL = "players.PlayerDB" diff --git a/src/web/news/urls.py b/src/web/news/urls.py index 09c4a3b6fe..d0a769531f 100755 --- a/src/web/news/urls.py +++ b/src/web/news/urls.py @@ -5,9 +5,8 @@ It is imported from the root handler, game.web.urls.py. from django.conf.urls import * -urlpatterns = patterns('src.web.news.views', - (r'^show/(?P\d+)/$', 'show_news'), - (r'^archive/$', 'news_archive'), - (r'^search/$', 'search_form'), - (r'^search/results/$', 'search_results'), -) +urlpatterns = [ + url(r'^show/(?P\d+)/$', 'show_news', name="show"), + url(r'^archive/$', 'news_archive', name="archive"), + url(r'^search/$', 'search_form', name="search"), + url(r'^search/results/$', 'search_results', name="search_results")] diff --git a/src/web/media/css/prosimii-print.css b/src/web/static/ev/css/prosimii-print.css similarity index 100% rename from src/web/media/css/prosimii-print.css rename to src/web/static/ev/css/prosimii-print.css diff --git a/src/web/media/css/prosimii-screen-alt.css b/src/web/static/ev/css/prosimii-screen-alt.css similarity index 100% rename from src/web/media/css/prosimii-screen-alt.css rename to src/web/static/ev/css/prosimii-screen-alt.css diff --git a/src/web/media/css/prosimii-screen.css b/src/web/static/ev/css/prosimii-screen.css similarity index 100% rename from src/web/media/css/prosimii-screen.css rename to src/web/static/ev/css/prosimii-screen.css diff --git a/src/web/media/images/LICENCE b/src/web/static/ev/images/LICENCE similarity index 100% rename from src/web/media/images/LICENCE rename to src/web/static/ev/images/LICENCE diff --git a/src/web/media/images/evennia_logo.png b/src/web/static/ev/images/evennia_logo.png similarity index 100% rename from src/web/media/images/evennia_logo.png rename to src/web/static/ev/images/evennia_logo.png diff --git a/src/web/media/images/evennia_logo_small.png b/src/web/static/ev/images/evennia_logo_small.png similarity index 100% rename from src/web/media/images/evennia_logo_small.png rename to src/web/static/ev/images/evennia_logo_small.png diff --git a/src/web/media/images/favicon.ico b/src/web/static/ev/images/favicon.ico similarity index 100% rename from src/web/media/images/favicon.ico rename to src/web/static/ev/images/favicon.ico diff --git a/src/web/templates/admin/base_site.html b/src/web/templates/admin/base_site.html index 578579e79b..0fd56d237a 100644 --- a/src/web/templates/admin/base_site.html +++ b/src/web/templates/admin/base_site.html @@ -5,7 +5,7 @@ {% block branding %}

{% trans 'Evennia database administration' %} - (Back)

+ (Back) {% endblock %} {% block nav-global %}{% endblock %} diff --git a/src/web/templates/prosimii/base.html b/src/web/templates/prosimii/base.html index 76e241dc3f..a0008f2e63 100644 --- a/src/web/templates/prosimii/base.html +++ b/src/web/templates/prosimii/base.html @@ -1,3 +1,4 @@ +{% load staticfiles %} @@ -8,12 +9,12 @@ {% if sidebar %} - + {% else %} - + {% endif %} - - + + {% block header_ext %} {% endblock %} @@ -34,7 +35,7 @@
-

{{game_name}}

+

{{game_name}}

{{game_slogan}}   @@ -45,13 +46,13 @@
@@ -61,9 +62,9 @@ Home | About | Documentation | - Admin Interface + Admin Interface {% if webclient_enabled %} - | Play Online + | Play Online {% endif %}
@@ -87,7 +88,7 @@ title="Other designs by haran">haran. Powered by Evennia. -
+
diff --git a/src/web/templates/prosimii/index.html b/src/web/templates/prosimii/index.html index 2594b742f3..19e69d8238 100644 --- a/src/web/templates/prosimii/index.html +++ b/src/web/templates/prosimii/index.html @@ -14,11 +14,11 @@

Welcome to your new installation of Evennia, your friendly 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 - needed. Through the admin interface you can view and edit the + needed. Through the admin interface you can view and edit the database without logging into the game. {% if webclient_enabled %} You can also connect to the game directly from your browser using our - online client!

+ online client!

{% endif %} For more info, take your time to peruse our extensive online documentation. diff --git a/src/web/urls.py b/src/web/urls.py index 9d9d1844c3..dd1a654e27 100755 --- a/src/web/urls.py +++ b/src/web/urls.py @@ -24,18 +24,16 @@ admin.autodiscover() # Setup the root url tree from / -urlpatterns = patterns('', +urlpatterns = [ # User Authentication - url(r'^accounts/login', 'django.contrib.auth.views.login'), - url(r'^accounts/logout', 'django.contrib.auth.views.logout'), + url(r'^accounts/login', 'django.contrib.auth.views.login', name="login"), + url(r'^accounts/logout', 'django.contrib.auth.views.logout', name="logout"), - # Front page - url(r'^', include('src.web.website.urls')), # News stuff # url(r'^news/', include('src.web.news.urls')), # 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 url(r'^admin/doc/', include('django.contrib.admindocs.urls')), @@ -44,13 +42,16 @@ urlpatterns = patterns('', # favicon url(r'^favicon\.ico$', RedirectView.as_view(url='/media/images/favicon.ico')), - # webclient stuff - url(r'^webclient/', include('src.web.webclient.urls')), -) + # ajax stuff + 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 # test server (this should normally not be needed). if settings.SERVE_MEDIA: - urlpatterns += patterns('', - (r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), - ) + urlpatterns.extend([ + url(r'^media/(?P.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}), + url(r'^static/(?P.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}) + ]) diff --git a/src/web/website/views.py b/src/web/views.py similarity index 99% rename from src/web/website/views.py rename to src/web/views.py index 2ab73c3d19..2126a74c55 100644 --- a/src/web/website/views.py +++ b/src/web/views.py @@ -33,7 +33,7 @@ def page_index(request): nplyrs_conn_recent = len(recent_users) or "none" nplyrs = PlayerDB.objects.num_total_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() nrooms = ObjectDB.objects.filter(db_location__isnull=True).exclude(db_typeclass_path=_BASE_CHAR_TYPECLASS).count() diff --git a/src/web/media/css/webclient.css b/src/web/webclient/static/webclient/css/webclient.css similarity index 100% rename from src/web/media/css/webclient.css rename to src/web/webclient/static/webclient/css/webclient.css diff --git a/src/web/media/javascript/evennia_ajax_webclient.js b/src/web/webclient/static/webclient/js/evennia_webclient.js similarity index 100% rename from src/web/media/javascript/evennia_ajax_webclient.js rename to src/web/webclient/static/webclient/js/evennia_webclient.js diff --git a/src/web/templates/prosimii/webclient.html b/src/web/webclient/templates/webclient.html similarity index 92% rename from src/web/templates/prosimii/webclient.html rename to src/web/webclient/templates/webclient.html index f36839e708..efc1c90dfc 100644 --- a/src/web/templates/prosimii/webclient.html +++ b/src/web/webclient/templates/webclient.html @@ -1,4 +1,5 @@ +{% load staticfiles %} @@ -6,7 +7,7 @@ Evennia web MUD client - + @@ -23,14 +24,13 @@ document.write("\ {% else %} {% endif %} - diff --git a/src/web/webclient/urls.py b/src/web/webclient/urls.py index 03f2595d2e..ba5cdf8186 100644 --- a/src/web/webclient/urls.py +++ b/src/web/webclient/urls.py @@ -4,5 +4,5 @@ webpage 'application'. """ from django.conf.urls import * -urlpatterns = patterns('', - url(r'^$', 'src.web.webclient.views.webclient'),) +urlpatterns = [ + url(r'^$', 'src.web.webclient.views.webclient', name="index")] diff --git a/src/web/website/models.py b/src/web/website/models.py deleted file mode 100644 index 89e59e2200..0000000000 --- a/src/web/website/models.py +++ /dev/null @@ -1,7 +0,0 @@ -# -# Define database entities for the app. -# - -from django.db import models - - diff --git a/src/web/website/urls.py b/src/web/website/urls.py deleted file mode 100644 index 8bb4bd811e..0000000000 --- a/src/web/website/urls.py +++ /dev/null @@ -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'), -)