--- layout: page title: Themes --- # Alaveteli's themes
Alaveteli uses themes to make the site look and run differently from the default. Simple changes like colour and logo are relatively easy, but themes can also control more complex things like how the site behaves.
When you customise your Alaveteli site, there is a lot you can change just by editing the [config settings]({{ site.baseurl }}docs/customising/config/). But if you want to change the way the site looks, or add more specific behaviour, you'll need to make a **theme**. You don't need to be a programmer in order to make simple changes, but you will need to be confident enough to copy and change some files. If you're not sure about this, [ask for help](/community/)!Sometimes you may want to change the core templates in a way that would benefit everyone, in which case: great! But please discuss the changes on the mailing list first, make them in a fork of Alaveteli, and then issue a pull request.
config/general.yml
:
THEME_URLS:
- 'git://github.com/mysociety/whatdotheyknow-theme.git'
THEME_URLS
setting allows you to specifiy more than one theme — but
normally you only need one.
lib/themes/yourtheme/lib/views/help/about.html.erb
,
then that will appear instead of the core "about us" file.
### Changing the logo
Alaveteli uses Rails' [asset pipeline](http://guides.rubyonrails.org/asset_pipeline.html)
to convert and compress stylesheets written in
Sass
into minified concatenated CSS. Assets are stored in core Alaveteli under
`app/assets` -- in `fonts`, `images`, `javascripts` and `stylesheets`. The
default theme has corresponding asset directories in `alavetelitheme/assets`
Asset files placed in these directories will override those in the core
directories. As with templates, a file at
lib/themes/yourtheme/assets/images/logo.png
will appear on the
site instead of the logo from `app/assets/images/logo.png`.
### Changing the colour scheme
Alaveteli uses a set of basic
Sass
modules to define the layout for the site on different device sizes, and some
basic styling. These modules are in `app/assets/stylesheets/responsive`. The
colours and fonts are added in the theme -- `alavetelitheme` defines them in
`lib/themes/alavetelitheme/assets/stylesheets/responsive/custom.scss`. Colours
used in the theme are defined as variables at the top of this file and you can
edit them in your version of this file in your own theme.
### Changing other styling
To change other styling, you can add to or edit the styles in
`lib/themes/alavetelitheme/assets/stylesheets/responsive/custom.scss`.
Styles defined here will override those in the sass modules in
`app/assets/stylesheets/responsive` as they will be imported last by
`app/assets/stylesheets/responsive/all.scss`. However, if you want to
substantially change the way a particular part of the site is laid out,
you may want to override one of the core Sass modules. You could override the
layout of the front page, for example, by copying
`app/assets/stylesheets/responsive/_frontpage_layout.scss` to
lib/themes/yourtheme/assets/stylesheets/responsive/_frontpage_layout.scss
and editing it.
You can load extra stylesheets and javascript files by adding them to
lib/themes/yourtheme/lib/views/general/_before_head_end.html.erb
## Adding your own categories for authorities
You should add
categories
for the authorities on your site -- Alaveteli will display the authorities grouped
by categories if you have set any up. Alaveteli uses
tags
to assign authorities to the right categories, but you should add tags anyway
because they are also used by the site's search facility. Together, categories
and tags help your users find the right authority for their request.
You can set all this up using the
admin interface.
See [more about categories and tags]({{ site.baseurl }}docs/running/categories_and_tags/)
for details.
## Customising the request states
As mentioned above, if you can possibly live with the
[default Alaveteli request statuses]({{ site.baseurl }}docs/customising/states/),
it would be good to do so. You can set how many days must pass before
a request is considered "overdue" in the main site config file —
see [`REPLY_LATE_AFTER_DAYS`]({{ site.baseurl }}docs/customising/config/#reply_late_after_days).
If you can't live with the states as they are, there's a very basic way to add
to them (we're working on this, so it will be improved over time). Currently,
there's no easy way to remove any. There is an example of how to do this in the
`alavetelitheme`.
To do add states, create two modules in your theme,
`InfoRequestCustomStates` and `RequestControllerCustomStates`.
`InfoRequestCustomStates` must have these methods:
* `theme_calculate_status`: return a tag to identify the current state of the request
* `theme_extra_states`: return a list of tags which identify the extra states you'd like to support
* `theme_display_status`: return human-readable strings corresponding with these tags
`RequestControllerCustomStates` must have one method:
* `theme_describe_state`: return a notice for the user suitable for
displaying after they've categorised a request; and redirect them to
a suitable next page
When you've added your extra states, you also need to create the following files
in your theme:
* `lib/views/general/_custom_state_descriptions.html.erb`: Descriptions
of your new states, suitable for displaying to end users
* `lib/views/general/_custom_state_transitions_complete.html.erb`:
Descriptions for any new states that you might characterise as
'completion' states, for displaying on the categorisation form that
we ask requestors to fill out
* `lib/views/general/_custom_state_transitions_pending.html.erb`: As
above, but for new states you might characterise as *pending*
states.
You can see examples of these customisations in
[this commit](https://github.com/sebbacon/informatazyrtare-theme/commit/2b240491237bd72415990399904361ce9bfa431d)
for the Kosovan version of Alaveteli, Informata Zyrtare (ignore the
file `_custom_state_transitions.html.erb`, which is
unused).
## Adding new pages in the navigation
You can extend the base routes in Alaveteli by modifying
lib/themes/yourtheme/lib/config/custom-routes.rb
.
The example in `alavetelitheme` adds an extra help page. You can also use this
to override the behaviour of specific pages if necessary.
## Adding or overriding models and controllers
If you need to extend the behaviour of Alaveteli at the controller or model
level, see `alavetelitheme/lib/controller_patches.rb` and
`alavetelitheme/lib/model_patches.rb` for examples.
## Quickly switching between themes
On your
development server,
you can use
[`script/switch-theme.rb`](https://github.com/mysociety/alaveteli/blob/master/script/switch-theme.rb)
to set the current theme if you are working with multiple themes. This can be
useful for switching between the default `alavetelitheme` and your own fork.
## Testing your theme
You can add tests for the changes in functionality that are implemented
in your theme. These use rspec, as does the main Alaveteli test suite.
They should be put in the `spec` directory of your theme. They are run
separately from the main Alaveteli tests by executing the following command in the directory in which Alaveteli is installed (substituting your theme directory for `alavetelitheme`):
bundle exec rspec lib/themes/alavetelitheme/spec
You can see some example tests in the whatdotheyknow-theme.