|
1 |
| -#This is intended as a temporary solution while dependencies on other apps are |
2 |
| -#resolved. We are migrating world locations to a taxonomy based model but the |
3 |
| -#following problems have arisen that this approach temporarily solves: |
4 |
| -# |
5 |
| -# * we require world locations to be associated with content in Whitehall |
6 |
| -# for email subscriptions to work so we can't just get rid of them |
7 |
| -# * we also need them as not all content will be part of the taxonomy |
8 |
| -# (e.g. news about the country) |
9 |
| -# * the taxon will take the base path (/world/<country-slug>) and so the |
10 |
| -# WorldLocation can't occupy that |
11 |
| -# * we need to redirect old /government/world/<country-slug> urls to the new |
12 |
| -# taxon but if we leave WorldLocation with that path it will a) overwrite |
13 |
| -# the redirect route every time it is updated and b) we'll be knowingly |
14 |
| -# linking to a redirect |
15 |
| -# |
16 |
| -#A slightly better solution will be for Whitehall to retrieve the taxon path from |
17 |
| -#publishing API and send that with the world location link as an additional field |
18 |
| -#in the links. We'll need the taxonomy to exist in order to implement this. This |
19 |
| -#will still require frontend code to know about the links but will be similar |
20 |
| -#to prior art we have for some links to be affected by elements with `detail`. |
21 |
| - |
22 | 1 | class WorldLocationBasePath
|
23 |
| - EXCEPTIONAL_CASES = { |
24 |
| - "Democratic Republic of Congo" => "democratic-republic-of-congo", |
25 |
| - "South Georgia and the South Sandwich Islands" => "south-georgia-and-the-south-sandwich-islands", |
26 |
| - "St Pierre & Miquelon" => "st-pierre-miquelon" |
27 |
| - }.freeze |
28 |
| - |
29 | 2 | class << self
|
30 | 3 | def for(world_location_link)
|
31 | 4 | base_path = world_location_link["base_path"]
|
32 | 5 | title = world_location_link["title"]
|
33 | 6 | return base_path if base_path.present?
|
34 | 7 |
|
35 |
| - slug = EXCEPTIONAL_CASES[title] || title.parameterize |
| 8 | + slug = title.parameterize |
36 | 9 |
|
37 | 10 | "/world/#{slug}/news"
|
38 | 11 | end
|
|
0 commit comments