mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
Clean install with python3
This commit is contained in:
parent
c9657aeb8c
commit
73637ba53d
280
README.txt
280
README.txt
@ -1,59 +1,215 @@
|
|||||||
Troggle is an application for caving expedition data management, originally created for use on Cambridge University Caving Club (CUCC)expeditions and licensed under the GNU Lesser General Public License.
|
Troggle is an application for caving expedition data management,
|
||||||
|
originally created for use on Cambridge University Caving Club (CUCC)expeditions
|
||||||
|
and licensed under the GNU Lesser General Public License.
|
||||||
|
|
||||||
Troggle has been forked into two projects. The original one is maintained by Aron Curtis and is used for Erebus caves. The CUCC variant uses files as the definitive data, not the database and lives at expo.survex.com/troggle.
|
Troggle has been forked into two projects. The original one is maintained by Aron Curtis
|
||||||
|
and is used for Erebus caves. The CUCC variant uses files as the definitive data,
|
||||||
|
not the database and lives at http://expo.survex.com/repositories/troggle/.git/
|
||||||
|
|
||||||
Troggle setup
|
Troggle setup
|
||||||
==========
|
=============
|
||||||
|
1. git clone troggle into correct directory structure
|
||||||
|
2. install pip, django & patch django
|
||||||
|
3. configure django to recognise troggle
|
||||||
|
|
||||||
Python, Django, and Database setup
|
Setting up directories
|
||||||
|
----------------------
|
||||||
|
- create a directory in which you also have the loser/, expoweb/ and drawings/ repositories
|
||||||
|
- git clone (see below) the current latest troggle from the 'python3' git branch into
|
||||||
|
a folder called 'troggle'
|
||||||
|
- all the 4 repos should now be siblings, and also siblings with expofiles/
|
||||||
|
- if you have those repos elsewhere, set up symlinks in the directory above troggle
|
||||||
|
so that troggle thinks they are siblings
|
||||||
|
|
||||||
|
Troggle itself
|
||||||
|
-------------
|
||||||
|
Choose the directory where you will keep troggle, (which must be named "troggle")
|
||||||
|
and git clone troggle into it using the following command:
|
||||||
|
|
||||||
|
git clone git://expo.survex.com/troggle
|
||||||
|
or more reliably
|
||||||
|
git clone ssh://expo@expo.survex.com/home/expo/troggle
|
||||||
|
but you will have to set up the ssh key-exchange with the server to make that work.
|
||||||
|
Key-exchange instructions: http://expo.survex.com/handbook/computing/keyexchange.html
|
||||||
|
|
||||||
|
If you want to work on the source code and be able to commit, your account will need to be
|
||||||
|
added to the troggle project members list. Contact wookey at wookware dot org to get this set up.
|
||||||
|
|
||||||
|
Next, you need to fill in your local settings. Copy localsettingsWSL.py
|
||||||
|
to a new file called localsettings.py and edit it and settings.py to match
|
||||||
|
your machine's file locations.
|
||||||
|
Follow the instructions contained in the file to fill out your settings.
|
||||||
|
|
||||||
|
{ *TO BE FIXED*
|
||||||
|
The localsettings-expo-live.py is the python2.7 settings for the server.
|
||||||
|
These are all very out of date and need fixing:
|
||||||
|
localsettingsubuntu.py
|
||||||
|
localsettingsdocker.py
|
||||||
|
localsettingswindows.py
|
||||||
|
localsettingspotatohut.py
|
||||||
|
}
|
||||||
|
|
||||||
|
Python3, Django, and Database setup
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
Troggle requires Django 1.4 or greater, and any version of Python that works with it.
|
Troggle with python3 requires Django 1.7 .
|
||||||
It is currently (Feb.2020) on django 1.7.11 (1.7.11-1+deb8u5).
|
It is currently (May 2020) on django 1.7.11 (1.7.11-1+deb8u5).
|
||||||
Install Django with the following command:
|
|
||||||
|
|
||||||
sudo apt install python-django (on debian/ubuntu) -- does not work now as we need specific version
|
Read this: https://docs.djangoproject.com/en/3.0/topics/install/
|
||||||
|
|
||||||
requirements.txt:
|
We are installing with python3.
|
||||||
Django==1.7.11
|
[ If you want to use python2.7 you presumably can work it out for yourself.
|
||||||
django-registration==2.1.2
|
You should look at past revisions of this file in git to see what is required.
|
||||||
mysql
|
Also : https://linuxize.com/post/how-to-install-pip-on-ubuntu-20.04/ ]
|
||||||
#imagekit
|
|
||||||
#django-imagekit
|
|
||||||
Image
|
|
||||||
django-tinymce==2.7.0
|
|
||||||
smartencoding
|
|
||||||
unidecode
|
|
||||||
|
|
||||||
Install like this:
|
Install Django using pip, not with apt.
|
||||||
sudo apt install pip # does not work on Ubuntu 20.04 for python 2.7. Have to install from source. Use 18.04
|
Your Linux installation almost certainly already includes python3 and pip3 but
|
||||||
pip install django==1.7
|
in case it doesn't install those like this:
|
||||||
pip install django-tinymce==2.0.1
|
|
||||||
sudo apt install libfreetype6-dev
|
|
||||||
pip install django-registration==2.0
|
|
||||||
pip install unidecode
|
|
||||||
pip install --no-cache-dir pillow==2.7.0 # fails horribly on installing Ubuntu 20.04
|
|
||||||
pip install --no-cache-dir pillow # installs on Ubuntu 20.04 , don't know if it works though
|
|
||||||
|
|
||||||
If you want to use MySQL or Postgresql, download and install them.
|
$ sudo apt update
|
||||||
However, you can also use Django with Sqlite3, which is included in Python and thus requires no extra installation.
|
$ sudo apt dist-upgrade
|
||||||
pip install pygraphviz
|
$ sudo apt install python3
|
||||||
apt install survex
|
$ sudo apt install python3-pip
|
||||||
|
|
||||||
pip install django-extensions
|
Now install django etc.
|
||||||
pip install pygraphviz # fails to install
|
$ sudo pip3 install -r requirements.txt
|
||||||
pip install pyparsing pydot # installs fine
|
|
||||||
django extension graph_models # https://django-extensions.readthedocs.io/en/latest/graph_models.html
|
|
||||||
|
|
||||||
|
where requirements.txt is:
|
||||||
|
Django==1.7
|
||||||
|
django-extensions==2.2.9
|
||||||
|
django-registration==2.0
|
||||||
|
django-tinymce==2.0.1
|
||||||
|
Pillow==7.1.2
|
||||||
|
six==1.14.0
|
||||||
|
Unidecode==1.1.1
|
||||||
|
|
||||||
|
if you don't use sudo it will install them all in ~/.local/
|
||||||
|
and so will only be available for you, not everyone; and
|
||||||
|
the paths won't work to find troggle properly.
|
||||||
|
|
||||||
|
six and Unidecode handle some of the python2-3 conversions
|
||||||
|
and Pillow is an image handling package used to make
|
||||||
|
the prospecting map. tinymce is the wysiwyg in-browser
|
||||||
|
editor.
|
||||||
|
|
||||||
|
$ pip3 list
|
||||||
|
will list all the pip python packages installed.
|
||||||
|
|
||||||
|
[NB we should test whether later verisons of tinymce work.]
|
||||||
|
|
||||||
|
venv option
|
||||||
|
-----------
|
||||||
Or use a python3 virtual environment: (python3.5 not later)
|
Or use a python3 virtual environment: (python3.5 not later)
|
||||||
$ cd troggle
|
$ cd troggle
|
||||||
$ cd ..
|
$ cd ..
|
||||||
$ python3.5 -m venv pyth35d2
|
$ python3.5 -m venv pyth35d2
|
||||||
(creates folder with virtual env)
|
(creates folder with virtual env)
|
||||||
cd pyth35d2
|
$ cd pyth35d2
|
||||||
bin/activate
|
$ source bin/activate
|
||||||
(now install everything - not working yet..)
|
(now install everything )
|
||||||
$ pip install -r requirements.txt
|
$ pip install -r requirements.txt
|
||||||
|
|
||||||
|
This works if you need a specific version of python3
|
||||||
|
but doesn't really work with python2.7 as you also need to obtain
|
||||||
|
an elderly version of pip that will work and use and older virtual
|
||||||
|
environment utility
|
||||||
|
|
||||||
|
Patching the django installation
|
||||||
|
--------------------------------
|
||||||
|
Since django 1.7 out of update-support, and since python3 has progressed against
|
||||||
|
the 2015 version that django1.7 is expecting, you need to patch the django
|
||||||
|
installation after installing. In the troggle folder you will find
|
||||||
|
django-patch/html_parser.py
|
||||||
|
copy this over the installed version of django on your machine:
|
||||||
|
|
||||||
|
$ cd troggle
|
||||||
|
$ sudo cp django-patch/html_parser.py /usr/local/lib/python3.8/dist-packages/django/utils/
|
||||||
|
or
|
||||||
|
$ cp django-patch/html_parser.py ~/.local/lib/python3.8/site-packages/django/utils/
|
||||||
|
if you didn't use sudo when installing everything using pip.
|
||||||
|
|
||||||
|
that's it.
|
||||||
|
|
||||||
|
Testing the django installation
|
||||||
|
-------------------------------
|
||||||
|
Test things by running these commands:
|
||||||
|
$ django-admin --version
|
||||||
|
$ django-admin
|
||||||
|
It should show a list of commands and complain:
|
||||||
|
"..only Django core commands are listed as settings are not properly configured"
|
||||||
|
|
||||||
|
If you get an error when running
|
||||||
|
$ django-admin
|
||||||
|
Then run django-admin like this:
|
||||||
|
python /usr/local/lib/python3.8/dist-packages/django/bin/django-admin.py
|
||||||
|
which should fix the paths. From now on you should be able to run
|
||||||
|
$ django-admin
|
||||||
|
from within any folder on your machine.
|
||||||
|
|
||||||
|
Now do
|
||||||
|
$ cd troggle
|
||||||
|
$ python manage.py
|
||||||
|
|
||||||
|
You should see the same list of commands that you saw with django-admin but wth
|
||||||
|
a lot of extra ones and no complaints. This means it is reading at least some of your
|
||||||
|
settings correctly.
|
||||||
|
|
||||||
|
If you get an error your python sys.path is probably not set correctly yet. Do
|
||||||
|
$ python -m site
|
||||||
|
when you are in your troggle directory to see the list of paths python looks
|
||||||
|
for when it is searching for packages (both django and troggle).
|
||||||
|
Ensure that the path to the troggle/ directory is in the list.
|
||||||
|
It should be at the top, which is where the current working directory is.
|
||||||
|
|
||||||
|
Registering troggle as a django application
|
||||||
|
-------------------------------------------
|
||||||
|
In your troggle directory run
|
||||||
|
$ django-admin
|
||||||
|
and check you got the same output as before.
|
||||||
|
|
||||||
|
Then try
|
||||||
|
$ python manage.py
|
||||||
|
It may not work. But if it does it will
|
||||||
|
now show a superset of the previous output: the [django] commands
|
||||||
|
available but also other options. Run
|
||||||
|
$ python manage.py check
|
||||||
|
$ python manage.py diffsettings
|
||||||
|
This last one shows everything set in global settings, settings and localsettings.
|
||||||
|
Anything different from global settings (django built-in) has '###' appended.
|
||||||
|
|
||||||
|
$ python manage.py test -v 2
|
||||||
|
Tests that it can create a database from all the model files.
|
||||||
|
|
||||||
|
$ python manage.py migrate
|
||||||
|
Tests the uptodateness of your sqlite database.
|
||||||
|
$ python manage.py help migrate
|
||||||
|
explains what this does and gives extra command line options.
|
||||||
|
|
||||||
|
If you got an error traceback with
|
||||||
|
$ python manage.py
|
||||||
|
then the settings registration of troggle with django is incomplete.
|
||||||
|
Delete all your cached .pyc files and try again.
|
||||||
|
You probably have a mistake in your settings.py or localsettings.py files.
|
||||||
|
|
||||||
|
Setting up survex
|
||||||
|
-----------------
|
||||||
|
You need to have survex installed as the command line tools 'cavern' and '3dtopos' are
|
||||||
|
used as part of the survex import process.
|
||||||
|
$ sudo apt install survex
|
||||||
|
|
||||||
|
Setting up tables and importing survey data
|
||||||
|
-------------------------------------------
|
||||||
|
Run
|
||||||
|
$ sudo python databaseReset.py
|
||||||
|
from the troggle directory will give you instructions.
|
||||||
|
|
||||||
|
[ NB Adding a new year/expedition requires adding a column to the
|
||||||
|
folk/folk.csv table - a year doesn't exist until that is done.]
|
||||||
|
|
||||||
|
Database
|
||||||
|
--------
|
||||||
|
If you want to use MySQL or Postgresql, download and install them.
|
||||||
|
However, you can also use Django with sqlite3, which is included in Python and thus requires no extra installation.
|
||||||
|
|
||||||
MariaDB database
|
MariaDB database
|
||||||
----------------
|
----------------
|
||||||
Start it up with
|
Start it up with
|
||||||
@ -74,42 +230,16 @@ $ sudo systemctl restart mysql.service
|
|||||||
$ sudo systemctl stop mysql.service
|
$ sudo systemctl stop mysql.service
|
||||||
$ sudo systemctl start mysql.service
|
$ sudo systemctl start mysql.service
|
||||||
|
|
||||||
Troggle itself
|
|
||||||
-------------
|
|
||||||
Choose a directory where you will keep troggle, and git clone Troggle into it using the following command:
|
|
||||||
|
|
||||||
git clone git://expo.survex.com/troggle
|
|
||||||
or more reliably
|
|
||||||
git clone ssh://expo@expo.survex.com/home/expo/troggle
|
|
||||||
|
|
||||||
|
|
||||||
If you want to work on the source code and be able to commit, your account will need to be added to the troggle project members list. Contact wookey at wookware dot org to get this set up.
|
|
||||||
|
|
||||||
Next, you need to fill in your local settings. Copy either localsettingsubuntu.py or localsettingsserver.py to a new file called localsettings.py. Follow the instructions contained in the file to fill out your settings.
|
|
||||||
|
|
||||||
Setting up survex
|
|
||||||
-----------------
|
|
||||||
You need to have survex installed as the command line 'cavern' is used as part of the survex
|
|
||||||
import process.
|
|
||||||
|
|
||||||
Setting up tables and importing legacy data
|
|
||||||
------------------------------------------
|
|
||||||
Run "sudo python databaseReset.py reset" from the troggle directory.
|
|
||||||
|
|
||||||
|
|
||||||
Once troggle is running, you can also log in and then go to "Import / export" data under "admin" on the menu.
|
|
||||||
|
|
||||||
Adding a new year/expedition requires adding a column to the
|
|
||||||
folk/folk.csv table - a year doesn't exist until that is done.
|
|
||||||
|
|
||||||
|
|
||||||
Running a Troggle server
|
Running a Troggle server
|
||||||
------------------------
|
------------------------
|
||||||
For high volume use, Troggle should be run using a web server like apache. However, a quick way to get started is to use the development server built into Django. This is limited though: directory
|
For high volume use, Troggle should be run using a web server like apache.
|
||||||
redirection needs apache.
|
However, a quick way to get started is to use the development server built into Django.
|
||||||
|
This is limited though: directory redirection needs apache.
|
||||||
To do this, run "python manage.py runserver" from the troggle directory.
|
|
||||||
|
|
||||||
|
To do this, run
|
||||||
|
$ python manage.py runserver 8000 -v 3
|
||||||
|
from the troggle directory. This runs it on port 8000 so you see the website
|
||||||
|
at http://localhost:8000/
|
||||||
|
|
||||||
Running a Troggle server with Apache
|
Running a Troggle server with Apache
|
||||||
------------------------------------
|
------------------------------------
|
||||||
@ -140,3 +270,11 @@ any changed files:
|
|||||||
|
|
||||||
apache2ctl stop
|
apache2ctl stop
|
||||||
apache2ctl start
|
apache2ctl start
|
||||||
|
|
||||||
|
Experimental additions
|
||||||
|
----------------------
|
||||||
|
These are modern tools which help us document how troggle works.
|
||||||
|
|
||||||
|
pip install pygraphviz
|
||||||
|
pip install pyparsing pydot # installs fine
|
||||||
|
django extension graph_models # https://django-extensions.readthedocs.io/en/latest/graph_models.html
|
@ -6,10 +6,6 @@ import timeit
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
import settings
|
import settings
|
||||||
if os.geteuid() == 0:
|
|
||||||
print("This script should be run as expo not root - quitting")
|
|
||||||
exit()
|
|
||||||
|
|
||||||
os.environ['PYTHONPATH'] = settings.PYTHON_PATH
|
os.environ['PYTHONPATH'] = settings.PYTHON_PATH
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')
|
||||||
|
|
||||||
@ -27,6 +23,11 @@ import troggle.logbooksdump
|
|||||||
# NOTE databaseReset.py is *imported* by views_other.py as it is used in the control panel
|
# NOTE databaseReset.py is *imported* by views_other.py as it is used in the control panel
|
||||||
# presented there.
|
# presented there.
|
||||||
|
|
||||||
|
if os.geteuid() == 0:
|
||||||
|
# This protects the server from having the wrong file permissions written on logs and caches
|
||||||
|
print("This script should be run as expo not root - quitting")
|
||||||
|
exit()
|
||||||
|
|
||||||
expouser=settings.EXPOUSER
|
expouser=settings.EXPOUSER
|
||||||
expouserpass=settings.EXPOUSERPASS
|
expouserpass=settings.EXPOUSERPASS
|
||||||
expouseremail=settings.EXPOUSER_EMAIL
|
expouseremail=settings.EXPOUSER_EMAIL
|
||||||
|
132
django-patch/html_parser.py
Normal file
132
django-patch/html_parser.py
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
from django.utils.six.moves import html_parser as _html_parser
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
current_version = sys.version_info
|
||||||
|
|
||||||
|
use_workaround = (
|
||||||
|
(current_version < (2, 7, 3)) or
|
||||||
|
(current_version >= (3, 0) and current_version < (3, 2, 3))
|
||||||
|
)
|
||||||
|
|
||||||
|
#HTMLParseError = _html_parser.HTMLParseError
|
||||||
|
# see http://thefourtheye.in/2015/02/15/python-35-and-django-17s-htmlparseerror/
|
||||||
|
# https://github.com/django/django/commit/b07aa52e8a8e4c7fdc7265f75ce2e7992e657ae9
|
||||||
|
try:
|
||||||
|
HTMLParseError = _html_parser.HTMLParseError
|
||||||
|
except AttributeError:
|
||||||
|
# create a dummy class for Python 3.5+ where it's been removed
|
||||||
|
class HTMLParseError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
if not use_workaround:
|
||||||
|
if current_version >= (3, 4):
|
||||||
|
class HTMLParser(_html_parser.HTMLParser):
|
||||||
|
"""Explicitly set convert_charrefs to be False.
|
||||||
|
|
||||||
|
This silences a deprecation warning on Python 3.4, but we can't do
|
||||||
|
it at call time because Python 2.7 does not have the keyword
|
||||||
|
argument.
|
||||||
|
"""
|
||||||
|
def __init__(self, convert_charrefs=False, **kwargs):
|
||||||
|
_html_parser.HTMLParser.__init__(self, convert_charrefs=convert_charrefs, **kwargs)
|
||||||
|
else:
|
||||||
|
HTMLParser = _html_parser.HTMLParser
|
||||||
|
else:
|
||||||
|
tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*')
|
||||||
|
|
||||||
|
class HTMLParser(_html_parser.HTMLParser):
|
||||||
|
"""
|
||||||
|
Patched version of stdlib's HTMLParser with patch from:
|
||||||
|
http://bugs.python.org/issue670664
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
_html_parser.HTMLParser.__init__(self)
|
||||||
|
self.cdata_tag = None
|
||||||
|
|
||||||
|
def set_cdata_mode(self, tag):
|
||||||
|
try:
|
||||||
|
self.interesting = _html_parser.interesting_cdata
|
||||||
|
except AttributeError:
|
||||||
|
self.interesting = re.compile(r'</\s*%s\s*>' % tag.lower(), re.I)
|
||||||
|
self.cdata_tag = tag.lower()
|
||||||
|
|
||||||
|
def clear_cdata_mode(self):
|
||||||
|
self.interesting = _html_parser.interesting_normal
|
||||||
|
self.cdata_tag = None
|
||||||
|
|
||||||
|
# Internal -- handle starttag, return end or -1 if not terminated
|
||||||
|
def parse_starttag(self, i):
|
||||||
|
self.__starttag_text = None
|
||||||
|
endpos = self.check_for_whole_start_tag(i)
|
||||||
|
if endpos < 0:
|
||||||
|
return endpos
|
||||||
|
rawdata = self.rawdata
|
||||||
|
self.__starttag_text = rawdata[i:endpos]
|
||||||
|
|
||||||
|
# Now parse the data between i+1 and j into a tag and attrs
|
||||||
|
attrs = []
|
||||||
|
match = tagfind.match(rawdata, i + 1)
|
||||||
|
assert match, 'unexpected call to parse_starttag()'
|
||||||
|
k = match.end()
|
||||||
|
self.lasttag = tag = match.group(1).lower()
|
||||||
|
|
||||||
|
while k < endpos:
|
||||||
|
m = _html_parser.attrfind.match(rawdata, k)
|
||||||
|
if not m:
|
||||||
|
break
|
||||||
|
attrname, rest, attrvalue = m.group(1, 2, 3)
|
||||||
|
if not rest:
|
||||||
|
attrvalue = None
|
||||||
|
elif (attrvalue[:1] == '\'' == attrvalue[-1:] or
|
||||||
|
attrvalue[:1] == '"' == attrvalue[-1:]):
|
||||||
|
attrvalue = attrvalue[1:-1]
|
||||||
|
if attrvalue:
|
||||||
|
attrvalue = self.unescape(attrvalue)
|
||||||
|
attrs.append((attrname.lower(), attrvalue))
|
||||||
|
k = m.end()
|
||||||
|
|
||||||
|
end = rawdata[k:endpos].strip()
|
||||||
|
if end not in (">", "/>"):
|
||||||
|
lineno, offset = self.getpos()
|
||||||
|
if "\n" in self.__starttag_text:
|
||||||
|
lineno = lineno + self.__starttag_text.count("\n")
|
||||||
|
offset = (len(self.__starttag_text)
|
||||||
|
- self.__starttag_text.rfind("\n"))
|
||||||
|
else:
|
||||||
|
offset = offset + len(self.__starttag_text)
|
||||||
|
self.error("junk characters in start tag: %r"
|
||||||
|
% (rawdata[k:endpos][:20],))
|
||||||
|
if end.endswith('/>'):
|
||||||
|
# XHTML-style empty tag: <span attr="value" />
|
||||||
|
self.handle_startendtag(tag, attrs)
|
||||||
|
else:
|
||||||
|
self.handle_starttag(tag, attrs)
|
||||||
|
if tag in self.CDATA_CONTENT_ELEMENTS:
|
||||||
|
self.set_cdata_mode(tag) # <--------------------------- Changed
|
||||||
|
return endpos
|
||||||
|
|
||||||
|
# Internal -- parse endtag, return end or -1 if incomplete
|
||||||
|
def parse_endtag(self, i):
|
||||||
|
rawdata = self.rawdata
|
||||||
|
assert rawdata[i:i + 2] == "</", "unexpected call to parse_endtag"
|
||||||
|
match = _html_parser.endendtag.search(rawdata, i + 1) # >
|
||||||
|
if not match:
|
||||||
|
return -1
|
||||||
|
j = match.end()
|
||||||
|
match = _html_parser.endtagfind.match(rawdata, i) # </ + tag + >
|
||||||
|
if not match:
|
||||||
|
if self.cdata_tag is not None: # *** add ***
|
||||||
|
self.handle_data(rawdata[i:j]) # *** add ***
|
||||||
|
return j # *** add ***
|
||||||
|
self.error("bad end tag: %r" % (rawdata[i:j],))
|
||||||
|
# --- changed start ---------------------------------------------------
|
||||||
|
tag = match.group(1).strip()
|
||||||
|
if self.cdata_tag is not None:
|
||||||
|
if tag.lower() != self.cdata_tag:
|
||||||
|
self.handle_data(rawdata[i:j])
|
||||||
|
return j
|
||||||
|
# --- changed end -----------------------------------------------------
|
||||||
|
self.handle_endtag(tag.lower())
|
||||||
|
self.clear_cdata_mode()
|
||||||
|
return j
|
@ -1,78 +0,0 @@
|
|||||||
import sys
|
|
||||||
# link localsettings to this file for use on a Windows 10 machine running WSL1
|
|
||||||
# expofiles on a different drive
|
|
||||||
|
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
|
||||||
'ENGINE': 'django.db.backends.sqlite3', # 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
|
|
||||||
'NAME' : 'troggle.sqlite', # Or path to database file if using sqlite3.
|
|
||||||
'USER' : 'expo', # Not used with sqlite3.
|
|
||||||
'PASSWORD' : 'sekrit', # Not used with sqlite3.
|
|
||||||
'HOST' : '', # Set to empty string for localhost. Not used with sqlite3.
|
|
||||||
'PORT' : '', # Set to empty string for default. Not used with sqlite3.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EXPOUSER = 'expo'
|
|
||||||
EXPOUSERPASS = 'nnn:ggggggr'
|
|
||||||
EXPOUSER_EMAIL = 'philip.sargent@gmail.com'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
REPOS_ROOT_PATH = '/mnt/d/CUCC-Expo/'
|
|
||||||
|
|
||||||
sys.path.append(REPOS_ROOT_PATH)
|
|
||||||
sys.path.append(REPOS_ROOT_PATH + 'troggle')
|
|
||||||
|
|
||||||
PUBLIC_SITE = False
|
|
||||||
|
|
||||||
SURVEX_DATA = REPOS_ROOT_PATH + 'loser/'
|
|
||||||
TUNNEL_DATA = REPOS_ROOT_PATH + 'drawings/'
|
|
||||||
THREEDCACHEDIR = REPOS_ROOT_PATH + 'expowebcache/3d/'
|
|
||||||
|
|
||||||
CAVERN = 'cavern'
|
|
||||||
THREEDTOPOS = '3dtopos'
|
|
||||||
EXPOWEB = REPOS_ROOT_PATH + 'expoweb/'
|
|
||||||
SURVEYS = REPOS_ROOT_PATH
|
|
||||||
#SURVEY_SCANS = REPOS_ROOT_PATH + 'expofiles/'
|
|
||||||
SURVEY_SCANS = '/mnt/f/expofiles/'
|
|
||||||
#FILES = REPOS_ROOT_PATH + 'expofiles'
|
|
||||||
FILES = '/mnt/f/expofiles'
|
|
||||||
|
|
||||||
EXPOWEB_URL = ''
|
|
||||||
SURVEYS_URL = '/survey_scans/'
|
|
||||||
|
|
||||||
PYTHON_PATH = REPOS_ROOT_PATH + 'troggle/'
|
|
||||||
|
|
||||||
URL_ROOT = 'http://127.0.0.1:8000/'
|
|
||||||
#URL_ROOT = "/mnt/d/CUCC-Expo/expoweb/"
|
|
||||||
DIR_ROOT = ''#this should end in / if a value is given
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#MEDIA_URL = URL_ROOT + DIR_ROOT + '/site_media/'
|
|
||||||
MEDIA_URL = '/site_media/'
|
|
||||||
MEDIA_ROOT = REPOS_ROOT_PATH + 'troggle/media/'
|
|
||||||
MEDIA_ADMIN_DIR = '/usr/lib/python2.7/site-packages/django/contrib/admin/media/'
|
|
||||||
|
|
||||||
STATIC_URL = URL_ROOT + 'static/'
|
|
||||||
STATIC_ROOT = DIR_ROOT + '/mnt/d/CUCC-Expo/'
|
|
||||||
|
|
||||||
JSLIB_URL = URL_ROOT + 'javascript/'
|
|
||||||
|
|
||||||
TINY_MCE_MEDIA_ROOT = '/usr/share/tinymce/www/'
|
|
||||||
TINY_MCE_MEDIA_URL = URL_ROOT + DIR_ROOT + '/tinymce_media/'
|
|
||||||
|
|
||||||
TEMPLATE_DIRS = (
|
|
||||||
PYTHON_PATH + "templates",
|
|
||||||
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
|
|
||||||
# Always use forward slashes, even on Windows.
|
|
||||||
# Don't forget to use absolute paths, not relative paths.
|
|
||||||
)
|
|
||||||
|
|
||||||
LOGFILE = PYTHON_PATH + 'troggle.log'
|
|
@ -2,6 +2,6 @@ Django==1.7
|
|||||||
django-extensions==2.2.9
|
django-extensions==2.2.9
|
||||||
django-registration==2.0
|
django-registration==2.0
|
||||||
django-tinymce==2.0.1
|
django-tinymce==2.0.1
|
||||||
|
Pillow==7.1.2
|
||||||
six==1.14.0
|
six==1.14.0
|
||||||
Unidecode==1.1.1
|
Unidecode==1.1.1
|
||||||
Pillow==7.1.2
|
|
||||||
|
74
settings.py
74
settings.py
@ -1,20 +1,28 @@
|
|||||||
import os
|
"""
|
||||||
|
Django settings for troggle project.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/1.7/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/1.7/ref/settings/
|
||||||
|
"""
|
||||||
|
#Imports should be grouped in the following order:
|
||||||
|
|
||||||
|
#1.Standard library imports.
|
||||||
|
#2.Related third party imports.
|
||||||
|
#3.Local application/library specific imports.
|
||||||
|
#4.You should put a blank line between each group of imports.
|
||||||
|
|
||||||
|
import os
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
|
||||||
import django
|
import django
|
||||||
|
|
||||||
print("** importing settings.py")
|
# Note that this builds upon the django system installed
|
||||||
from localsettings import *
|
# global settings in
|
||||||
#inital localsettings call so that urljoins work
|
# django/conf/global_settings.py which is automatically loaded first.
|
||||||
|
# read https://docs.djangoproject.com/en/3.0/topics/settings/
|
||||||
#Imports should be grouped in the following order:
|
|
||||||
|
|
||||||
#Standard library imports.
|
|
||||||
#Related third party imports.
|
|
||||||
#Local application/library specific imports.
|
|
||||||
#You should put a blank line between each group of imports.
|
|
||||||
|
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
@ -28,7 +36,6 @@ ALLOWED_HOSTS = ['expo.survex.com']
|
|||||||
ADMINS = (
|
ADMINS = (
|
||||||
# ('Your Name', 'your_email@domain.com'),
|
# ('Your Name', 'your_email@domain.com'),
|
||||||
)
|
)
|
||||||
|
|
||||||
MANAGERS = ADMINS
|
MANAGERS = ADMINS
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
@ -51,37 +58,14 @@ USE_I18N = True
|
|||||||
USE_L10N = True
|
USE_L10N = True
|
||||||
|
|
||||||
FIX_PERMISSIONS = []
|
FIX_PERMISSIONS = []
|
||||||
NOTABLECAVESHREFS = [ "161", "204", "258", "76", "107", "264" ]
|
|
||||||
|
|
||||||
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
|
|
||||||
# trailing slash.
|
|
||||||
# Examples: "http://foo.com/media/", "/media/".
|
|
||||||
ADMIN_MEDIA_PREFIX = '/troggle/media-admin/'
|
|
||||||
#PHOTOS_ROOT = os.path.join(EXPOWEB, 'mugshot-data')
|
|
||||||
CAVEDESCRIPTIONS = os.path.join(EXPOWEB, "cave_data")
|
|
||||||
ENTRANCEDESCRIPTIONS = os.path.join(EXPOWEB, "entrance_data")
|
|
||||||
|
|
||||||
MEDIA_URL = urllib.parse.urljoin(URL_ROOT , '/site_media/')
|
|
||||||
SURVEYS_URL = urllib.parse.urljoin(URL_ROOT , '/survey_scans/')
|
|
||||||
PHOTOS_URL = urllib.parse.urljoin(URL_ROOT , '/photos/')
|
|
||||||
SVX_URL = urllib.parse.urljoin(URL_ROOT , '/survex/')
|
|
||||||
|
|
||||||
# top-level survex file basename (without .svx)
|
# top-level survex file basename (without .svx)
|
||||||
SURVEX_TOPNAME = "1623"
|
SURVEX_TOPNAME = "1623"
|
||||||
|
|
||||||
DEFAULT_LOGBOOK_PARSER = "Parseloghtmltxt"
|
DEFAULT_LOGBOOK_PARSER = "Parseloghtmltxt"
|
||||||
DEFAULT_LOGBOOK_FILE = "logbook.html"
|
DEFAULT_LOGBOOK_FILE = "logbook.html"
|
||||||
|
# All years since 2010 use the default value for Logbook parser
|
||||||
LOGBOOK_PARSER_SETTINGS = {
|
LOGBOOK_PARSER_SETTINGS = {
|
||||||
"2019": ("2019/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2018": ("2018/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2017": ("2017/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2016": ("2016/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2015": ("2015/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2014": ("2014/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2013": ("2013/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2012": ("2012/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2011": ("2011/logbook.html", "Parseloghtmltxt"),
|
|
||||||
"2010": ("2010/logbook.html", "Parseloghtmltxt"),
|
"2010": ("2010/logbook.html", "Parseloghtmltxt"),
|
||||||
"2009": ("2009/2009logbook.txt", "Parselogwikitxt"),
|
"2009": ("2009/2009logbook.txt", "Parselogwikitxt"),
|
||||||
"2008": ("2008/2008logbook.txt", "Parselogwikitxt"),
|
"2008": ("2008/2008logbook.txt", "Parselogwikitxt"),
|
||||||
@ -114,14 +98,9 @@ SECRET_KEY = 'a#vaeozn0)uz_9t_%v5n#tj)m+%ace6b_0(^fj!355qki*v)j2'
|
|||||||
TEMPLATE_LOADERS = (
|
TEMPLATE_LOADERS = (
|
||||||
'django.template.loaders.filesystem.Loader',
|
'django.template.loaders.filesystem.Loader',
|
||||||
'django.template.loaders.app_directories.Loader',
|
'django.template.loaders.app_directories.Loader',
|
||||||
# 'django.template.loaders.eggs.load_template_source',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if django.VERSION[0] == 1 and django.VERSION[1] < 4:
|
authmodule = 'django.contrib.auth.context_processors.auth'
|
||||||
authmodule = 'django.core.context_processors.auth'
|
|
||||||
else:
|
|
||||||
authmodule = 'django.contrib.auth.context_processors.auth'
|
|
||||||
|
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = ( authmodule, "core.context.troggle_context", )
|
TEMPLATE_CONTEXT_PROCESSORS = ( authmodule, "core.context.troggle_context", )
|
||||||
|
|
||||||
LOGIN_REDIRECT_URL = '/'
|
LOGIN_REDIRECT_URL = '/'
|
||||||
@ -135,15 +114,11 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.redirects',
|
'django.contrib.redirects',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
#'troggle.photologue',
|
|
||||||
#'troggle.reversion',
|
|
||||||
#'django_evolution',
|
|
||||||
'tinymce',
|
'tinymce',
|
||||||
'registration',
|
'registration',
|
||||||
'troggle.profiles',
|
'troggle.profiles',
|
||||||
'troggle.core',
|
'troggle.core',
|
||||||
'troggle.flatpages',
|
'troggle.flatpages',
|
||||||
#'troggle.imagekit',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE_CLASSES = (
|
MIDDLEWARE_CLASSES = (
|
||||||
@ -168,9 +143,6 @@ AUTH_PROFILE_MODULE = 'core.person'
|
|||||||
|
|
||||||
QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]"
|
QM_PATTERN="\[\[\s*[Qq][Mm]:([ABC]?)(\d{4})-(\d*)-(\d*)\]\]"
|
||||||
|
|
||||||
TINYMCE_JS_URL = 'http://debug.example.org/tiny_mce/tiny_mce_src.js'
|
|
||||||
|
|
||||||
#TINYMCE_JS_URL = os.path.join(MEDIA_URL, "tinybibble_mce.js")
|
|
||||||
|
|
||||||
TINYMCE_DEFAULT_CONFIG = {
|
TINYMCE_DEFAULT_CONFIG = {
|
||||||
'plugins': "table,spellchecker,paste,searchreplace",
|
'plugins': "table,spellchecker,paste,searchreplace",
|
||||||
@ -182,5 +154,7 @@ TINYMCE_COMPRESSOR = True
|
|||||||
MAX_LOGBOOK_ENTRY_TITLE_LENGTH = 200
|
MAX_LOGBOOK_ENTRY_TITLE_LENGTH = 200
|
||||||
|
|
||||||
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
||||||
|
|
||||||
from localsettings import *
|
from localsettings import *
|
||||||
|
|
||||||
#localsettings needs to take precedence. Call it to override any existing vars.
|
#localsettings needs to take precedence. Call it to override any existing vars.
|
||||||
|
Loading…
Reference in New Issue
Block a user