CottageLabs / website

company graphics and website
0 stars 0 forks source link

Cottage Labs website, powered by Pelican

Generating and previewing the website

Create a virtualenv, if you like.

Install pelican with

pip install pelican pelican-yaml-metadata

Generate content from the project root with the command pelican content We commit the resulting HTML from the build (under output/) into the repo so it can be served immediately from the repo on the server.

Run the server from the project root pelican --listen

For development you can use auto-reload mode so you can see changes immediately in browser: pelican --autoreload --listen

Install sass with e.g. sudo apt install ruby-sass

Generate styles from themes/simple/static/scss

scss main.scss main.css

Generating new pages

To add new project page:

To add any other page:

optional

Pages:

Homepage /

templates:

content:

About Us /about

templates:

content:

Lifecycle Pages:

urls:

templates:

content:

Expertiese Pages:

urls:

templates:

content:

Projects' Pages

urls:

template:

content:

logos:

screenshots:

Projects Browser

urls:

templates:

Themes tags:

see src/themes/simple/templates/partials/_tags.html for slugs and tags' names

Deployment on next.cottagelabs.com

This is managed using git hooks. You'll need the server in your .ssh/config file, and run the following from your local checked-out repo to add the remote:

git remote add next cloo@sauron:next.cottagelabs.com.git

You can only deploy the master branch. To do so, run the following command:

git push next master

i.e. you are pushing master to the remote repo on machine sauron. This will run the hooks, and restart nginx for you to pick up the changes.

Server configuration

Requires a bare git repo on the host, e.g. called next.cottagelabs.com.git. This is created with git init --bare next.cottagelabs.com.git in the home directory.

Create the working tree directory where nginx will serve the files from and fix the permissions:

sudo mkdir /var/www/next.cottagelabs.com
sudo chown www-data:www-data /var/www/next.cottagelabs.com
sudo chmod -R 775 /var/www
sudo usermod -a -G www-data cloo

The post receive hook then needs to be created on the host, by copying deploy/hooks/post-receive to ~/next.cottagelabs.com.git/hooks/post-receive and chmod +x hooks/post-receive on the host. This will allow the script to run on deploy and copy the code to the correct work tree.

Afterwards, replace the copied hook with a symlink to the checked out hook (so you can update the hooks):

ln -sf /var/www/next.cottagelabs.com/deploy/hooks/post-receive hooks/post-receive
chmod +x hooks/post-receive

Deployment on cottagelabs.com

Set up server as above, but with production instead of next, and a host set up for cottagelabs.com:

git remote add production cloo@cl-docker:cottagelabs.com.git
git push production master

Also, use the -production hook which is hardcoded for cottagelabs.com, along with its corresponding nginx config.

SSL Certificates

The nginx config expects an SSL certificate - this should be created via LetsEncrypt / certbot.

To use the nginx config, symlink it within /etc/nginx/sites-available and add a symlink to that one inside /etc/nginx/sites-enabled.

e.g.

sudo ln -s /var/www/next.cottagelabs.com/deploy/nginx/next.cottagelabs.com /etc/nginx/sites-available/next.cottagelabs.com