Hi everyone,
Seb asked me a while ago to list the changes I did to the "core Alaveteli"
from the AsktheEU theme, in order to see whether we can make the core app a
bit more flexible to cover some of them.
I'm including all the changes from the theme, even if some are obvious and
already documented, just to be thorough. I'm ordering them from the basic
to the hack-ish (monkey-patching classes when I couldn't find a
'documented' plugin extension mechanism in Rails 2.x).
1. Branded the site by overriding existing views as explained in the
Themes doc [1]. Since we support multiple languages we have four versions
of each view template: index.rhtml, index.de.rhtml...
2. Added a number of custom states by modifying lib/customstates.rb; this
is explained in the Themes doc already [1].
3. In order to override some files in the lib/ folder (see next two
points), we have to add the theme lib/ folder the LOAD_PATH, as shown in
[2].
4. Replaced default public body categories - which are defined in a .rb
file in lib/ - with EU ones. [3]
5. There's now a mechanism in the base Alaveteli to add custom routes,
which were needed for a few extra help pages and a new listing page. The
theme routes are added to lib/config/custom-routes.rb [4]
6. We had to ammend the email footers and templates because of legalese,
wording or references to FOI (which is UK-specific, and had to be replaced
by 'access to information'). Note that just adding view template files in
the right location as in point 1 will have _no_ effect. This patch is
needed [5].
7. We needed small changes to two controller actions (to have the blog
items in the homepage, for example), so I had to patch two controllers [6].
8. For i18n, some of the English strings from Transifex had to be
ammended, mostly because they refer to FOI and a few times because
AccessInfo didn't like the particular wording. This was sorted by having
FastGetText use two linked repositories [7]: first it checks the app.po
file from the theme, where some English strings are overriden [8], and if
nothing is found it falls back to the core Alaveteli app.po.
Also, some of the custom pages introduced by the theme - like the all-new
homepage - had text that needed i18n; this was also handled through this
mechanism.
There were just a few strings to i18n, so the app.po files were created by
hand, and no Transifex project was really needed. However, overriding the
base English strings like this is not easy to maintain, since it has to be
done by a developer; ideally we would set up something in Transifex so Core
English gets translated _by translators/editors_ to "AsktheEU English" for
example. Haven't thought much about whether it's possible.
9. Finally, we had to monkey patch some model classes [9] in order to a)
get rid of FOI references in the law name, b) add an intro paragraph to the
default letter, while ignoring it in the search snippets and c) not allow
FOI officers to reply through the website, as AccessInfo wasn't sure this
was safe in the EU case because of the email domain names.
And that's it. :) Oh, well, there are a bunch of CSS tweaks too, some of
them hiding a few links here and there, but that's quite straightforward.
Any question, just let me know. And if I missed some simpler way I'd love
to hear.
/david
[1]: https://github.com/sebbacon/alaveteli/blob/master/doc/THEMES.md
[2]:
https://github.com/dcabo/asktheeu-theme/blob/master/lib/alavetelithem...
[3]:
https://github.com/dcabo/asktheeu-theme/blob/master/lib/lib/public_bo...
[4]:
https://github.com/dcabo/asktheeu-theme/blob/master/lib/lib/config/cu...
[5]:
https://github.com/dcabo/asktheeu-theme/blob/master/lib/patch_mailer_...
[6]:
https://github.com/dcabo/asktheeu-theme/blob/master/lib/controller_pa...
[7]:
https://github.com/dcabo/asktheeu-theme/blob/master/lib/gettext_setup.rb
[8]:
https://github.com/dcabo/asktheeu-theme/blob/master/locale-theme/en/a...
[9]:
https://github.com/dcabo/asktheeu-theme/blob/master/lib/model_patches.rb