CoTech WordPress

From CoTech
Jump to navigation Jump to search

At the CoTech Hack 2018 we switched to a static site generator for the CoTech site, the following page is now out of date, please see Website for current information.

There is a static HTML copy of the WordPress site available here:


Help documentation for the site at www.coops.tech the code for which is hosted on GitHub.

Login

You can login to the site here:

And if you don't have your password you can reset it here:

Linking to the site

There are a couple of logos you can use to link to the site:

For more sizes and a SVG version see the Logos page.

You can also link to the site using a sub-domain, for example:

Add a technology

Please check that there isn't already an existing technology, we don't need Python twice!

To add a technology to the site first find a high quality, high resolution logo for the technology, ideally a SVG (but only upload SVG Logos to the wiki for future use, the WordPress site needs png images) so you can turn it into a big image, for example 640px by 640px (this was written when it was assumed there was some server side image resizing, but there isn't so this size suggestion should probably be revised down, see the #Wishlist below), set the background to transparent and make sure it is square by editing the canvas size and then export it as a PNG file (don't upload jpeg's or gif's). If you need an application to edit images then try GIMP the GNU Image Manipulation Program.

Then go to Technology -> Add New and add the title and then Add image and Uploaded Files -> Select Files, edit the Title if needs be and then Select the image. Then on the right hand of the technology page there is a Connected Co-Ops -> Create connections link to pick the co-ops which use the technology by searching and clicking on their names and finally click Publish to save the new technology.

Add a service

Please check that there isn't already an existing service, then find a suitable logo, it needs to be a 512x512px PNG with a transparent background with a FFC531 foreground, apart from that the instructions for adding a technology (see above) apply.

Adding users

To add a coop user either contact Outlandish to ask them to use the web interface to add an editor or ask chrisc in the Slack channel to add an editor via ssh and wp-cli:

sudo -i
su - cotech -s /bin/bash
source .bashrc
cd sites/web
wp user list
export WP_USER="login"
export WP_NAME="Example Co-op"
export WP_USER_EMAIL="example@example.org"
WP_USER_PASSWD=$(pwgen -n 16 1); echo "${WP_USER_PASSWD}" ; export "${WP_USER_PASSWD}"
wp user create "${WP_USER}" "${WP_USER_EMAIL}" --role=editor --user_pass="${WP_USER_PASSWD}" --display_name="${WP_NAME}" --send-email

Changing passwords

If you have forgotten your password you can reset it via the lost password form on the dev site and when the site has been made live the lost password form on the live site, or ask chrisc in the Slack channel to change it via ssh and wp-cli:

sudo -i
su - cotech -s /bin/bash
source .bashrc
cd sites/web
wp user list
export WP_USER="example"
WP_USER_PASSWD=$(pwgen -n 16 1); echo "${WP_USER_PASSWD}" ; export "${WP_USER_PASSWD}"
wp user update "${WP_USER}" --user_pass="${WP_USER_PASSWD}"

Changing email address

Using wp-cli, get a list of the users:

sudo -i
su - cotech -s /bin/bash
source .bashrc
cd sites/web
wp user list

Note the ID of the user you want to update and then:

export WP_ID="X"
export WP_EMAIL="example@example.org"
wp user update "${WP_ID}" --user_email="${WP_EMAIL}"

The user can then reset their password using their email address and the wp-login.php page.

Site Images

Use the WordPress editor interface to upload images and if you need to download a full set of images then this daily crontab:

# m h  dom mon dow   command
01 09 * * * cd ~/sites/web ; tar -zcf cotech-images.tgz app/uploads/

Generates this ~40Mb TGZ https://www.coops.tech/cotech-images.tgz that you can download if you need a full set of site images.

Development using Docker

Debian Stretch dev env

If your workstation / laptop is running Debian 9.0 AKA Stretch then the following will get you up and running:

Install Docker and Docker Compose

See the official instructions or follow this (note the usermod command to add your user account to the docker group, this is missing from the official docs):

sudo -i
apt update
apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common docker-compose
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
apt-key fingerprint 0EBFCD88 
# Check for: DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
echo "deb https://download.docker.com/linux/debian stretch stable" > /etc/apt/sources.list.d/docker.list
apt update ; apt install docker-ce
usermod -a -G docker ${SUDO_USER}
grep ^docker /etc/group 

Note that the above installs docker-compose 1.8 from Stretch, if a newer version is needed see the Install Docker Compose page.

Or use the Ansible Playbooks on git.coop.

Checkout the code

Use ssh to checkout the code if you want to commit changes, you don't want to be root when doing this:

mkdir ~/cotech ; cd ~/cotech
git clone git@github.com:cotech/website.git

Start Docker

Note that if you are in a terminal emulator that was opened before you were added to the docker group then you will get an error (ERROR: Couldn't connect to Docker daemon at http+docker://localunixsocket - is it running?), so do the following in a new terminal session and again this shouldn't be done as root:

cd ~/cotech/website
docker-compose up -d

And you should now be able to browse the site at http://localhost:18080/

Updating the code

The code for the site is available on GitHub:

In the repo

The code is hosted at GitHub, check it out and switch to the dev branch:

git clone git@github.com:cotech/website.git
cd website
git checkout dev

Then update composer.json, for example:

-   "johnpbloch/wordpress": "4.5.3",
+   "johnpbloch/wordpress": "4.7.2",

Then updated the `composer.lock` file by running:

composer update

Then git commit:

git commit -a

Any changes committed to the dev branch will be automatically applied to the the dev site via this bash script which is run via cron every 5 mins.

See also Nicks notes on composer.

On the server

The live site and dev site automatically update every 5 mins from the master and dev branches in the git repo, so generally you shouldn't need ssh access to the server -- if someothing goes wrong and needs fixing ask chrisc in slack.

Ansible live2dev Playbook

See this playbook which uses the files, templates and runs the the tasks here to populate the dev site with data (uploads and the database)

Notes

The WordPress site has been build using Bedrock, see the documentation and especially the documentation for the environment file, .env, this is where the database settings, map API keys etc are and the directory structure.

The variables SERVER_NAME, HTTP_HOST and REQUEST_SCHEME had to be added to .env to prevent errors when running wp-cli.

The .htaccess file is provisioned via Ansible.

You might also need to add a auth token to ~/.composer/auth.json if you hit the GitHub rate limits.

Wishlist

All the issues that were here have been moved to issues at GitHub.