8.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Installing gimp-web
These instructions are for building the GIMP website from the git repository.
It is assumed you are already acquainted with git.
If not, please consult

To download a fresh copy of the site (anonymous, read-only) use the following command:

`git clone git://`


12 13
## Meta
There is a series of pages on the site that attempt to address many questions about building and using the new system (Pelican).
Pat David's avatar
Pat David committed
14 15
Refer to these pages for extended information in addition to what is below.

17 18

19 20 21 22
## Short 
The new site is built using the Pelican static site generator, written in Python.
The tools to build and test the site are Python, Pelican, and a couple of modules (Markdown, typogrify).


24 25 26 27 28 29
### Getting the build environment
1. Install Python 2.7.x.
2. Install Pelican (`pip install pelican`).
    Make sure that pip is using Python 2.7.x if you have multiple versions installed.
    There may be a pip2.7 alias on your system.
    You can also use a virtualenv to isolate the required Python environment.
30 31
    Note: last I tested, Pelican 3.7.1 was failing to build the website.
    Older Pelican 3.6.3 worked fine with our code: `pip2 install pelican==3.6.3`
32 33 34 35 36
3. Install some extra components:
    * For Markdown support (required):
        `pip install Markdown`
    * For fancy typography elements with typogrify:
        `pip install typogrify`
37 38 39
    * For geographical information from an IP address (optional for
      plugin `gimp_mirrors`):
        `pip install pygeoip`
40 41 42 43

Further information in greater detail can be found in the Pelican documentation (

44 45 46 47 48 49 50 51 52 53 54 55 56
###  Pelican configuration files (pelicanconf.*)
The main settings file to build the site is pelicanconf.*.

There are three versions in our directory for various needs.

1. - this is the main settings file that coincides to WGO (
2. - this is the settings file for building
3. - this is a settings file tailored for a local build and test environment.

Unless you are monkeying with site-wide build settings, you shouldn't normally have to edit these files.
If you do, please consult schumaml or patdavid before pushing to be sure.

57 58 59 60
### Building the site
Once the few prerequisites are installed, building the site is relatively straightforward.
From the project directory, you can invoke pelican:

`pelican -s`
62 63 64 65 66

This will build the site into a directory called `output`.

If you are writing content or developing the site, there is an option to have pelican watch the directories for file changes and to automatically recompile the site when a change is detected:

`pelican -r -s`
68 69 70 71 72 73 74 75 76 77

### Viewing the site
Python has a built-in simple web server that can be used to serve the site.
From the `output/` directory:

`python -m SimpleHTTPServer`

The site can then be accessed locally at `localhost:8000`.

78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
You can also run any other webserver that you want, of course.
The site files will be available in the `output/` directory.

Note: the python SimpleHTTPServer doesn't serve svg images with the correct mimetype.
To do this, you should add your own mimetype for svg files:

    import SimpleHTTPServer
    import SocketServer
    import mimetypes
    PORT = 8000
    Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
    httpd = SocketServer.TCPServer(("", PORT), Handler)
    print "serving at port", PORT

100 101 102 103 104 105

## Content
The site content source files are located in the folder `content/`.
There is a Pelican plugin that will mimic the hierarchy of the folders as urls.
This allows us to simply add directories to create new url hierarchy structures easily.
107 108 109 110 111 112 113

### Directories
So, `content/about/` will be created as `output/about/index.html`.

If a new directory needs to be added, like `artists/`:

114 115 116
1. Create the directory, and an file directly under it.
2. Add the new directory to the `` file in the variable `PAGE_PATHS`
    This is to make sure that the new directory gets parsed correctly.
117 118 119

### File Formats
#### Text files
121 122 123 124 125 126 127 128
The files can be written using ReStructuredText, Markdown, or HTML.
The latest information for using these formats can be found in the documentation:

The majority of the files here are likely Markdown, as it's what I (Pat David) used.
I wrote a brief cheatsheet of the Markdown format that can be found on the site here:

129 130 131
#### SVG files
The website is served with a strict Content Security Policy, and as a
consequence, inline scripts and styles are ignored by compliant browsers.
Normally according to the specification, SVG included via `<img>` should not apply
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
the policy (, but at least
Firefox does not follow the spec properly right now and all SVG with inlined CSS
end up dark.

Here is the current process to add SVG images with Inkscape and keep the

1. keep the original as `some-file-name.src.svg`;
2. from Inkscape, export it as "Optimized SVG" as `some-file-name.svg`; make
sure that "Convert CSS attributes to XML attributes" option is checked;
3. edit `some-file-name.svg` with a text editor and run a search and replace to
clean the remaining style attributes: %s/style="[^"]*"//g
4. use only the optimized SVG in the website.

Further edits on the images should happen on the source file only, which should
then be re-exported with the above process.

Note: for complicated SVG images, it is possible that some features can only
work with CSS rules though this won't be the likely case for most simple images.
For such cases, there is no perfect solution at the time of writing (except
moving the CSS of every SVG images out as an external file, or setting our web
server to serve SVG images with `style-src 'unsafe-inline'`).
155 156 157 158 159

### Writing a News post
To write a News post, simply include your new post in the `news/` directory.
I have been using `YYYY-MM-DD` as a file naming convention.

160 161
If you want to keep any post assets (images, etc) with the post, you can create a sub-folder + file.
So, to create a new post about LGM:

163 164
1. Create a sub-folder under `news/`: `news/2016-01-12/`
2. Create an file for the post contents `/news/2016-01-12/`.

166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
You can reference these images using the Pelican internal link format ( {filename}.. ).
So if the post has an image `gimp.png` in its directory that you want to reference in the post, you would use:

`<img src='{filename}gimp.png' alt='GIMP' />`

This way Pelican will resolve the actual image location no matter where it ends up.
This is particularly helpful when the post is `Status: draft`.

### Post metadata
There are a few pieces of metadata that should be included in the front-matter of a file.

#### Title
This should be self-explanatory.

182 183 184
#### Date
Use an ISO8601 formatted date, please (
That means, YYYY-MM-DD(Thh:mm:ss-TMZ)

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
Thats, Year (4-digit), Month (2-digit), Day (2-digit), T, hour (2-digit), minute (2-digit), seconds (2-digit), "T", Timezone (T-05:00 for me offset from UTC by 6 hours.

The date field can parse less information, so if you'd rather ignore the time, you can simply use:

`Date: 2016-01-14`

#### Category
We're not currently using the `Category` metadata field, but we might (probably will?) in the future.
So it doesn't hurt to fill it out now.
News posts have been filed as `Category: News`.
Other content should be tagged as appropriate (`Content: Tutorial` for instance).

#### Author(s)
The post authors are listed here.
If there is a single author, you can use the singular:

    `Author: Pat David`

If there are multiple authors, a comma-separated list will work with the plural:

    `Authors: Pat David, Alexandre Prokoudine, Michael Schumacher`

You can use the plural `Authors` with a single person without a problem.

    `Authors: Michael Schumacher`

#### Summary
If the item is a news item, this `Summary` metadata will be what appears on the news index page that lists all the posts.
218 219 220
Also possibly the front page if we decide to include snippets there as well.

If there is no `Summary` metadata tag, then the summayr will be auto-generated from the article contents (up to 255 characters in, auto truncate the last word, and end the contents with ellipses `...`.
221 222 223 224 225

#### Drafts
To mark a news item as a draft, include the `Status: draft` metadata in the head of the file.
It will not appear anywhere other than in the `drafts/` folder until the `Status` metadata is removed or changed to `Status: published`.
Pat David's avatar
Pat David committed
It will also not show up in the RSS/Atom feeds.
227 228