Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

cotech/website

Repository files navigation

Cooperative Technologists

Requirements

  • PHP >= 5.4
  • Node & NPM
  • Gulp
  • Composer - Install
  • MySQL

Development

  1. Check out this repository

  2. Install the dependencies

  3. From the root run

    composer install
    cd ./web/app/themes/coop-tech-oowp-theme
    composer update
    npm install
    gulp
    
  4. Download a copy of the CoTech database from the CoTech site (you'll need admin permissions)

  5. Load the copy of the database into a local database e.g. mysql -u root cotech_db < cotech_data.sql

  6. Copy ./.env.example to ./.env

  7. Edit ./.env and enter the credentials of your database and the path to your local website

  8. Visit the path you entered in Step 7 e.g. http://localhost/cotech/web

  9. Enjoy playing with your new local copy of the site

Using docker

For an easy to use development environment run we use Docker Compose.

  1. Make sure you have downloaded Docker and have it installed on your machine and running.
  2. On your command line of choice kickstart it all with docker-compose up -d run from inside this directory. You can follow the logs with docker-compose logs -f.
  3. It will take some time, especially for the first run.

Then you can access:

URL Description
localhost:18080 WordPress URL (dev:dev)
localhost:18081 PHPMyAdmin

Images

Images used on the cotech website (go in web/app/uploads) will be downloaded when you first setup your environment. If you want to update them again, you can run:

docker-compose exec assets /download-images.sh --force

Deployment

Changes to the dev branch are automatically applied to the dev site. This works via a crontab which runs a script which checks for changes and if there are any then it runs the update script.

The live site is set up exactly the same way but tracking the master branch.

If the dev site images and database needs syncing from the live site then please contact [email protected] and ask him to run the live2dev Ansible playbook.

Deployment (manual)

Currently the live and dev sites are running on Werbarchitects shared hosting and although SFTP/SSHFS and phpMyAdmin access is to available to any developers who need it (ask [email protected] to add your SSH public keys to the server and to email you the MySQL login details), ssh access is only availabe to Webarchitects sysadmins, see the wiki for the steps to manually update the code.

Querying the WordPress database directly

Even though the format of the WordPress database is pretty horrible you can perform analytics queries on a local copy of the database which can be downloaded from the admin section of the site if you have Admin permissions.

e.g. to get the names and email addresses of co-ops that have not entered a turnover so you can nag them:

SELECT * FROM (
    SELECT post_id,  post_title, meta_value as turnover
    FROM `wp_postmeta` LEFT JOIN wp_posts on post_id = ID
    where meta_key = 'turnover'
    and post_status = 'publish'
    and meta_value = "") as noturnover
LEFT JOIN wp_postmeta on noturnover.post_id = wp_postmeta.post_id
where meta_value REGEXP  '^[^@]+@[^@]+\.[^@]{2,}$'