Europeana uses Pattern Lab in order to develop its styleguide and maintain its sites’ stylesheets, javascripts, images and markup templates. Apache, Compass and Php are required to run it.
Styleguide development is done on files within the /source/ directory of this project, focused primarily on the files within the /source/_patterns directory. Site assets are generated by executing 'php core/console --generate'
-
Clone this repo into a working directory and
cd
into it -
Build and run the Docker image with:
docker build . -t europeana-styleguide docker run -it -p 8080:80 europeana-styleguide
-
You will now have Pattern Lab running at http://localhost:8080/
- Clone this repo into a working directory under an apache server web root
- Generate and/or update the /source/css/ directory and its css
- initially the /source/css directory does not exist
- assuming that compass has already been installed, from the root of the working directory run
compass compile source/
- Generate and/or update the /public/ directory and its site assets
- initially the /public directory exists, but only with a README document
- from the root of the working directory run
php core/console --generate
- from the root of the working directory run
npm install
- from the root of the working directory run
grunt copy:js_templates
- The web server should serve files from the
public
directory generated or updated in the previous step
The unit tests under source/js/unit-tests can be run with the commands:
npm install
npm test
or alternatively:
npm install
karma start
There are a few differences between the Pattern Lab install at https://github.com/pattern-lab/patternlab-php and the Europeana version of Pattern Lab.
- The styleguide
source
directory already exists. - The sass stylesheets that affect the styleguide and that should be edited live in
source/sass
not insource/css
. - The styleguide has been setup to handle more than one site’s styleguide.
source/sass
contains sub folders for each sitesource/_patterns
contains the additional folderjs_demo
for markup used to demo javascript components
- The
source/css
directory needs to be created and updated withcompass compile source/
before the styleguide is update/re-generated.
The Europeana Pattern Lab maintains a styleguide that’s used by several Europeana sites. The template drop-down on the top-level styleguide page reveals the different views for each site. Page templates for different sites are encouraged to use common components where possible.
A new site is defined by its own folder within source/sass
and a folder in source/_patterns/templates
. The template patterns contain json data that distinguishes the site from other sites in the styleguide. The json data refers to site specifc css and/or js files as well as the json data used to populate the templates with (dummy) content.
- Create a folder in
source/sass
that represents the site- Create a
screen.scss
file in that directory that will compose the styles the site uses
- Create a
- Depending on whether you will add a site specific template or page, create a folder in either
source/_patterns/templates
- Create a mustache template that represents the corresponding template or page
source/_patterns/templates/Search/Search-results-list.mustache
- Create a matching
.json
file that contains site specific asset referencessource/_patterns/templates/Search/Search-results-list.json
css_files
andjs_files
definitions in the json file are arrays of objects that represent the paths to the site specific assetscss_files
takes path and media key/value pairs:"path": "../../css/search/screen.css"
"media": "all"
- The partial at
source/_patterns/atoms/meta/_head.mustache
, if included, will iterate over thecss_files
definition and create corresponding<link>
tags.
js_files
takes path and data_main key/value pairs:"path": "../../js/search/screen.js"
"data_main": "../../js/modules/main/templates/main-collections"
- The partial at
source/_patterns/atoms/meta/_foot.mustache
, if included, will iterate over thejs_files
definition and create corresponding<script>
tags. - As a general rule a site should have a single js entry point (the requirejs config specified by
data_main
) the loading of further javascript should then be handled by requirejs
js_vars
takes name, value and unquoted key/value pairs:"name": "pageName"
"value": "collections/show"
"unquoted": false (optional - used to output raw JSON into a variable)
- As a general rule js_vars should be use sparingly as they translate to global (window) variables in the generated javascript
- Create a mustache template that represents the corresponding template or page
The command:
- grunt watch
should be executed in the project root before commencing development. This will rebuild the styleguide CSS (when sass files are saved), redeploy the scripts (when js files are saved) and recompile the templates (when any file is saved)
This watch script invokes Pattern Lab's build command (php core/console --generate
) but it also handles Europeana-specific styleguide features, such as the separate compilation of scss files that are loaded externally by javascript.
For more details on Europeana's front-end development practice please see the development wiki
- Apache should serve the /public/ directory as the site’s document root.
- Pattern Lab configuration can be adjusted in the /core/config/config.ini.default file.
- If, for any reason, you need to delete all assets from the public directory, you should also delete the /config/config.ini file. The
php core/console --generate
will then re-generate that file and the /public/ directory without error. - Various development test sites will rebuild automatically in response to commits to this repository
- To update the "production" site go here - https://jenkins.eanadev.org/job/styleguide.s3.production/ - and log in if you haven't already and click "build now"
- This site: http://styleguide.europeana.eu/ is built from the develop branch
- The sites under this domain: https://style.europeana.eu/ are built from versions on the master branch
- Make sure that the develop branch has been merged with the master branch before attempting to build the master branch
The PHP version of Pattern Lab is, at its core, a static site generator. It combines platform-agnostic assets, like the Mustache-based patterns and the JavaScript-based viewer, with a PHP-based "builder" that transforms and dynamically builds the Pattern Lab site. By making it a static site generator, Pattern Lab strongly separates patterns, data, and presentation from build logi.cg
An additional Dockerfile is included, optimised for small image size, for publication to a Docker repository and use in production environments.
export VERSION=1.3.9
docker build \
-f Dockerfile.alpine \
-t europeana/styleguide:${VERSION} .
docker run \
-p 8080:80 \
europeana/styleguide:${VERSION}
docker push europeana/styleguide:${VERSION}
Licensed under the EUPL v1.2.
For full details, see LICENSE.md.