From fbe0eab01ca99e99172539ff593839069ea06f11 Mon Sep 17 00:00:00 2001 From: Kelketek Rritaa Date: Sun, 25 May 2014 13:18:00 -0500 Subject: [PATCH] Some consistency improvements with URL overrides. --- .gitignore | 7 ++++++ game/gamesrc/web/examples/__init__.py | 1 + game/gamesrc/web/examples/urls.py | 28 +++++++++++++++++++++ game/gamesrc/web/static_overrides/README.md | 5 ++++ game/gamesrc/web/urls.py | 13 ---------- src/settings_default.py | 11 +++++--- src/web/urls.py | 2 +- 7 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 game/gamesrc/web/examples/__init__.py create mode 100644 game/gamesrc/web/examples/urls.py create mode 100644 game/gamesrc/web/static_overrides/README.md delete mode 100644 game/gamesrc/web/urls.py diff --git a/.gitignore b/.gitignore index 878233d84f..c472b02630 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,10 @@ __pycache__ *.restart *.db3 +# Installation-specific +game/settings.py +game/logs/*.log.* + # Installer logs pip-log.txt @@ -41,3 +45,6 @@ nosetests.xml .mr.developer.cfg .project .pydevproject + +# PyCharm config +.idea diff --git a/game/gamesrc/web/examples/__init__.py b/game/gamesrc/web/examples/__init__.py new file mode 100644 index 0000000000..cdcf9604a4 --- /dev/null +++ b/game/gamesrc/web/examples/__init__.py @@ -0,0 +1 @@ +__author__ = 'kelketek' diff --git a/game/gamesrc/web/examples/urls.py b/game/gamesrc/web/examples/urls.py new file mode 100644 index 0000000000..58754f51c9 --- /dev/null +++ b/game/gamesrc/web/examples/urls.py @@ -0,0 +1,28 @@ +from django.conf.urls import url, include + +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 +# + +# Copy this file into your web directory in gamesrc, and add this line to settings.py: +# ROOT_URLCONF = 'game.gamesrc.web.urls' + +# 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 = [ + # url(r'/desired/url/', view, name='example'), +] + +urlpatterns = patterns + urlpatterns \ No newline at end of file diff --git a/game/gamesrc/web/static_overrides/README.md b/game/gamesrc/web/static_overrides/README.md new file mode 100644 index 0000000000..8640413887 --- /dev/null +++ b/game/gamesrc/web/static_overrides/README.md @@ -0,0 +1,5 @@ +If you want to override one of the static files (such as a CSS or JS file) used by Evennia or a Django app installed in your Evennia project, copy it into this folder, and it will be placed in the static folder when you run: + + python manage.py collectstatic + +Do note you may have to reproduce any preceeding directory structures for the file to end up in the right place. diff --git a/game/gamesrc/web/urls.py b/game/gamesrc/web/urls.py deleted file mode 100644 index 8e76e279c9..0000000000 --- a/game/gamesrc/web/urls.py +++ /dev/null @@ -1,13 +0,0 @@ -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/settings_default.py b/src/settings_default.py index 1f7b79af19..bc1e31d2c0 100644 --- a/src/settings_default.py +++ b/src/settings_default.py @@ -479,8 +479,8 @@ LOCALE_PATHS = ["../locale/"] # development webserver (normally Evennia runs its own server) SERVE_MEDIA = False # The master urlconf file that contains all of the sub-branches to the -# applications. -ROOT_URLCONF = 'game.gamesrc.web.urls' +# applications. Change this to add your own URLs to the website. +ROOT_URLCONF = 'src.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. @@ -497,14 +497,19 @@ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(GAME_DIR, "gamesrc", "web", "static") -# Folders from which static files will be gathered from. +# Directories from which static files will be gathered from. STATICFILES_DIRS = ( + os.path.join(GAME_DIR, "gamesrc", "web", "static_overrides"), os.path.join(SRC_DIR, "web", "static"),) +# 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' # We setup the location of the website template as well as the admin site. TEMPLATE_DIRS = ( + os.path.join(GAME_DIR, "gamesrc", "web", "templates"), os.path.join(SRC_DIR, "web", "templates", ACTIVE_TEMPLATE), os.path.join(SRC_DIR, "web", "templates"),) # List of callables that know how to import templates from various sources. diff --git a/src/web/urls.py b/src/web/urls.py index dd1a654e27..788be59bb3 100755 --- a/src/web/urls.py +++ b/src/web/urls.py @@ -6,8 +6,8 @@ # http://diveintopython.org/regular_expressions/street_addresses.html#re.matching.2.3 # -from django.conf.urls import * from django.conf import settings +from django.conf.urls import url, include from django.contrib import admin from django.views.generic import RedirectView