2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-21 14:51:51 +00:00
Mirror of Troggle Repo but with issue tracking etc. https://expo.survex.com
Go to file
2024-10-14 21:12:35 +03:00
_deploy Where JS is put 2024-05-09 21:07:52 +03:00
core Error ms inserted 2024-10-14 20:59:01 +03:00
export Fixing new dev machine setup 2023-05-02 14:27:55 +03:00
kmz_icons Start of creating kmz file, with entrance photos and links to expo.survex.com 2023-05-08 01:10:43 +01:00
media link to mugshots 2024-07-22 13:58:55 +02:00
parsers more logbook entries 2024-09-01 22:57:52 +03:00
photomap instrucitons 2023-10-20 18:06:19 +03:00
README capitalisation fix 2023-06-28 20:37:06 +01:00
templates remove date from cave .html files when editing or creating 2024-10-14 21:12:35 +03:00
wiki-archaic rename wiki folder 2021-04-02 15:52:56 +01:00
__init__.py [svn] Initial troggle checkin 2009-05-13 05:13:38 +01:00
.gitignore try again 2024-06-29 12:09:41 +03:00
categories.json static files redone 2020-06-18 21:50:16 +01:00
confusables.json static files redone 2020-06-18 21:50:16 +01:00
databaseReset.py findng variant data on survexblocks and setting wallet *ref 2023-10-26 18:28:59 +03:00
dependencies-check-deptry.txt depry detects uneeded dependencies 2022-09-18 20:28:23 +03:00
deprecations.txt remove // in URLs 2024-02-06 18:52:46 +00:00
dump.py Convert.format() to f-strings with flynt 2022-11-23 10:48:39 +00:00
ERROR.txt fix current year in top menu 2024-04-10 23:25:13 +01:00
index.html auto new year stuff 2024-03-15 01:50:34 +00:00
localsettings2024-02-05.py WHy are these files not committed ont he server? Philip 2024-04-06 15:27:30 +01:00
manage.py reordering import statements using isort 2023-01-19 18:30:05 +00:00
md5bash.sh Much QM re-engineering 2023-03-17 20:01:52 +00:00
modelviz.py reordering import statements using isort 2023-01-19 18:30:05 +00:00
pre-push.sh fixes for WSL1 on new machine 2022-10-27 16:29:11 +01:00
pre-run.sh fixes for WSL1 on new machine 2022-10-27 16:29:11 +01:00
pyproject.toml ran ruff to remove unused imports 2023-01-19 21:20:47 +00:00
README.txt test stuff for Django 5.0a (alpha) 2023-09-26 15:20:59 +03:00
requirements-p11d32.txt annotation on heading 2024-07-22 17:24:57 +02:00
requirements-p11d42.txt setting up fresh venv 2023-09-26 18:32:11 +03:00
requirements-p12d5.txt p12d5 working 2024-02-21 01:26:55 +00:00
requirements.txt Update server requirements for bullseye 2024-04-21 00:00:21 +01:00
reset-django.py ruff removed unused imports 2023-01-19 21:34:09 +00:00
security-warnings.txt fixing paths in settings to be Path() not str() 2023-03-08 18:24:57 +00:00
settings.py fix pointless error messages in tests 2024-08-21 15:48:49 +03:00
TESTOUTPUT.txt fix current year in top menu 2024-04-10 23:25:13 +01:00
url-reverse.txt test revers() function 2023-03-12 16:21:31 +00:00
urls.py comment 2024-07-23 23:43:08 +02:00
venv-trog-d3.sh annotation on heading 2024-07-22 17:24:57 +02:00
venv-trog-d4.sh setting up fresh venv 2023-09-26 18:32:11 +03:00
venv-trog-d5.sh trying python v 3.12 2024-02-21 01:04:54 +00:00
wsgi.py Update URLs to django documn version 2023-02-10 00:05:04 +00:00

Updated 2 May 2023

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 Aaron Curtis 
and was used for Erebus caves in Antarctica. 
The CUCC variant uses files as the definitive data, not the database, and lives at http://expo.survex.com/repositories/troggle/.git/

The versions have diverged markedly, not just in the software but also in the implicit convnetions of how the directory structures of the survex files, the drawings and
the scans are arranged.

For the server setup, see /_deploy/debian/wookey-exposerver-recipe.txt
and see http://expo.survex.com/handbook/troggle/serverconfig.html

Much material which was in this file has been moved to 
http://expo.survex.com/handbook/troggle/serverconfig.html

See copyright notices in
http://expo.survex.com/handbook/computing/contribute.html
and for context see
http://expo.survex.com/handbook/computing/onlinesystems.html 

Troggle setup
=============
0. read the very extensive online documentation and stop reading this README...
well, come back to this README after you have read the HTML pages. Not everything has been transferred.

   http://expo.survex.com/handbook/troggle/troglaptop.html
   http://expo.survex.com/handbook/troggle/serverconfig.html
   http://expo.survex.com/handbook/troggle/trogdangoup.html
   and at troggle/debian/serversetup 
1. set up the ssh key-exchange with the git server so you can clone troggle
   http://expo.survex.com/handbook/computing/keyexchange.html

Setting up directories
----------------------
see  http://expo.survex.com/handbook/troggle/troglaptop.html and 
http://expo.survex.com/handbook/troggle/serverconfig.html

Next, you need to fill in your local settings. Copy _deploy/WSL/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.

{ in _deploy/old/ we have these which are all very out of date:
  localsettings-expo-live.py is the python2.7 settings for the server.
  localsettingsubuntu.py
  localsettingsdocker.py
  localsettingswindows.py
  localsettingspotatohut.py
}

Python3, Django, and Database setup
-----------------------------------
We are now using Django 3.2 and will move to 4.2 in 2024
We are installing with python 3.11 (the server is running 3.9)

Install Django using pip, not with apt, on your test system in a venv.
Conventionally on our main master expo server we install everything that we can as debian packages, not using pip.

[installation instructions removed - now in http://expo.survex.com/handbook/troggle/troglaptop.html ]

[venv description removed - read it in http://expo.survex.com/handbook/troggle/troglaptop.html ]

READ the os-trog.sh script !
READ the venv-trog.sh script !


Automatic Provisioning and Configuration
----------------------------------------
We don't do this - yet.

The most appropriate configuration tools today (2021) appear to be Bolt or Ansible
https://puppet.com/docs/bolt/latest/bolt.html (declarative, local)
https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html (procedural, remote)
https://puppet.com/blog/automating-from-zero-to-something/ 

We don't need anything for the deploy server itself, but we could do with something for setting
up test servers quickly to help get newbie developers up to speed faster. But learning a new tool
creates a barrier in itself. This is one reason most of us don't use Docker.

CSS and media files
-------------------
We are not using the STATICFILES capability.
We are serving css files from troggle/media/.. (see urls.py) 

Plain CSS pages
---------------
When running the test server 
manage.py runserver 0.0.0.0:8000
and without Apache running, we are serving CSS using using this Django 'view':
view_surveys.cssfilessingle 
i.e.
cssfilessingle() in core/view_surveys.py

Setting up survex
-----------------
You need to have survex installed as the command line tools 'cavern' is
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.]


MariaDB database
----------------
Start it up with
$ sudo mysql -u -p
when it will prompt you to type in the password. Get this by reading the settings.py file in use on the server.
then
> CREATE DATABASE troggle;
> use troggle;
> exit;

Note the semicolons.

You can check the status of the db service:
$ sudo systemctl status mysql

You can start and stop the db service with
$ sudo systemctl restart mysql.service
$ sudo systemctl stop mysql.service
$ sudo systemctl start mysql.service

While logged in at a terminal session as expo on expo.survex.,com

$ mysql -h localhost -u expo -p<password>
will get you the MariasDb command prompt: https://www.hostwinds.com/guide/how-to-use-mysql-mariadb-from-command-line/

then (Note the SEMICOLONS !):
>drop database troggle;
>create database troggle;
>quit
Somewhere I have notes for the GRANT PRIVS type runes...

Ah yes:
CREATE DATABASE troggle;
GRANT ALL PRIVILEGES ON troggle.* TO 'expo'@'localhost' IDENTIFIED BY 'somepassword'; FLUSH PRIVILEGES; (at mysql root prompt)

(explained on https://chartio.com/resources/tutorials/how-to-grant-all-privileges-on-a-database-in-mysql/)
(but you need to create the database too)

The GRANT ALL PRIVILEGES  bit requires you to logon in to MariaDB as root. sudo doesn't cut it.
these permissions are set in a different 'info' database which usually is untouched even if database troggle gets creamed.

The 'somepassword' is specified int he localsettings.py file.


PERMISSIONS
https://linuxize.com/post/usermod-command-in-linux/

THIS MAY BE OUT OF DATE - from 2022 we are running Apache as user 'expo' not 'www-data'

so that the online editing system for SVX files works.
The same goes for /expoweb/ files, so that "edit this page" works and the New Cave
and New Entrance forms work.

sudo usermod -a expo expocvs
the expocvs group is used for git 

all the users should be in this group


Running a Troggle server with Apache
------------------------------------
Troggle also needs these aliases to be configured. These are set in 
/home/expo/config/apache/expo.conf
on the expo server.

At least these need setting:
DocumentRoot              /home/expo/expoweb
WSGIScriptAlias        /  /home/expo/troggle/wsgi.py
<Directory /home/expo/troggle>
	<Files wsgi.py>
		Require all granted
	</Files>
</Directory>

the instructions for apache Alias commands are in comments at the end of
the urls.py file.

Unlike the django "manage.py runserver" method, apache requires a restart before it will use
any changed files:

sudo service apache2 restart

Olly's comments 20 July 2020:
olly: looking at /lib/systemd/system/apache2.service suggests so

olly: ExecStart=/usr/sbin/apachectl start
olly: ExecStop=/usr/sbin/apachectl stop
olly: ExecReload=/usr/sbin/apachectl graceful

Additions
---------
The python code has been manually cleaned using the 'black' and 'ruff' lint tools,
and the 'deptry' dependency checker. This needs doing every year or so.
See dependencies-check-deptry.txt

See troggle/pyproject.toml for configurations

Experimental additions
----------------------
These are untried tools which may help us document how troggle works in future.

pip install pygraphviz 
pip install pyparsing pydot # installs fine
django extension graph_models # https://django-extensions.readthedocs.io/en/latest/graph_models.html