Skip to content

Commit 53ba99c

Browse files
authored
Merge pull request #623 from DFID/fix-404-related-routing
Fix 404 related routing
2 parents 3a5201e + bd66ead commit 53ba99c

4 files changed

Lines changed: 53 additions & 28 deletions

File tree

Gemfile.lock

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4-
actionview (6.1.7)
5-
activesupport (= 6.1.7)
4+
actionview (6.1.7.7)
5+
activesupport (= 6.1.7.7)
66
builder (~> 3.1)
77
erubi (~> 1.4)
88
rails-dom-testing (~> 2.0)
99
rails-html-sanitizer (~> 1.1, >= 1.2.0)
10-
activesupport (6.1.7)
10+
activesupport (6.1.7.7)
1111
concurrent-ruby (~> 1.0, >= 1.0.2)
1212
i18n (>= 1.6, < 2)
1313
minitest (>= 5.1)
@@ -16,7 +16,7 @@ GEM
1616
addressable (2.8.1)
1717
public_suffix (>= 2.0.2, < 6.0)
1818
builder (3.2.4)
19-
concurrent-ruby (1.2.2)
19+
concurrent-ruby (1.2.3)
2020
cookiejar (0.3.3)
2121
coveralls (0.8.23)
2222
json (>= 1.8, < 3)
@@ -43,21 +43,21 @@ GEM
4343
eventmachine (>= 1.0.0.beta.4)
4444
em-synchrony (1.0.6)
4545
eventmachine (>= 1.0.0.beta.1)
46-
erubi (1.11.0)
46+
erubi (1.12.0)
4747
eventmachine (1.2.7)
4848
http-accept (1.7.0)
4949
http-cookie (1.0.5)
5050
domain_name (~> 0.5)
5151
http_parser.rb (0.8.0)
52-
i18n (1.12.0)
52+
i18n (1.14.4)
5353
concurrent-ruby (~> 1.0)
5454
json (2.6.3)
5555
kgio (2.11.4)
5656
kramdown (2.4.0)
5757
rexml
58-
loofah (2.19.1)
58+
loofah (2.22.0)
5959
crass (~> 1.0.2)
60-
nokogiri (>= 1.5.9)
60+
nokogiri (>= 1.12.0)
6161
mail (2.8.0)
6262
mini_mime (>= 0.1.1)
6363
net-imap
@@ -67,7 +67,7 @@ GEM
6767
mime-types-data (~> 3.2015)
6868
mime-types-data (3.2022.0105)
6969
mini_mime (1.1.2)
70-
minitest (5.18.0)
70+
minitest (5.22.3)
7171
money (6.16.0)
7272
i18n (>= 0.6.4, <= 2)
7373
multi_json (1.15.0)
@@ -89,16 +89,17 @@ GEM
8989
pony (1.13.1)
9090
mail (>= 2.0)
9191
public_suffix (5.0.1)
92-
racc (1.6.1)
92+
racc (1.7.3)
9393
rack (2.2.6.4)
9494
rack-protection (3.0.5)
9595
rack
9696
rack-test (2.0.2)
9797
rack (>= 1.3)
98-
rails-dom-testing (2.0.3)
99-
activesupport (>= 4.2.0)
98+
rails-dom-testing (2.2.0)
99+
activesupport (>= 5.0.0)
100+
minitest
100101
nokogiri (>= 1.6)
101-
rails-html-sanitizer (1.4.4)
102+
rails-html-sanitizer (1.5.0)
102103
loofah (~> 2.19, >= 2.19.1)
103104
raindrops (0.20.0)
104105
rake (13.0.6)
@@ -147,7 +148,7 @@ GEM
147148
unicorn (6.1.0)
148149
kgio (~> 2.6)
149150
raindrops (~> 0.7)
150-
zeitwerk (2.6.7)
151+
zeitwerk (2.6.13)
151152

152153
PLATFORMS
153154
x86_64-linux
@@ -176,4 +177,4 @@ DEPENDENCIES
176177
rubygems-update
177178
sinatra
178179
sinatra-contrib
179-
unicorn
180+
unicorn

data/countries.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,7 +2395,7 @@
23952395
},
23962396
{
23972397
"code": "LY",
2398-
"name": "Libya",
2398+
"name": "State of Libya",
23992399
"description": "The UK is working in partnership with Libya to achieve prosperity, security and human rights for all. Areas of focus include: \n\u2022 Promoting political processes, participation, and human rights \n\u2022 Progress towards an inclusive political process, leading to a political settlement which reflects the rights and needs of all, including elections, a constitution, reconciliation and transitional justice. Development of a strong, independent media. Human rights embedded throughout Libyan institutions. \n\u2022 Strengthening security, justice and defence \n\u2022 Improved security for Libyans, with access to justice, and border control. Development of capable Ministries of Interior, Justice and Defence. Development of a community-based policing service, a functional criminal justice system and professional armed forces under democratic control. Management of arms and ammunition, and disarmament of militias. \n\u2022 Strengthening governance and strategic communications \n\u2022 Progress towards the establishment of credible public sector institutions with effective leadership, capacity and capability to deliver public services, effective strategic communications and good governance. Effective public financial management. \n\u2022 Diversifying the economy and promoting prosperity \n\u2022 Progress towards an open economy, with increased employment opportunities and reduced reliance on the public sector. Increased incentives for outside investment.",
24002400
"Region": "Middle East & North Africa",
24012401
"iso3c": "LBY",
@@ -2737,7 +2737,7 @@
27372737
},
27382738
{
27392739
"code": "FM",
2740-
"name": "Micronesia",
2740+
"name": "Federated States of Micronesia",
27412741
"description": "",
27422742
"Region": "East Asia & Pacific",
27432743
"iso3c": "FSM",
@@ -4314,7 +4314,7 @@
43144314
},
43154315
{
43164316
"code": "TN",
4317-
"name": "Tunisia",
4317+
"name": "Republic of Tunisia",
43184318
"description": "",
43194319
"Region": "Middle East & North Africa",
43204320
"iso3c": "TUN",

devtracker.rb

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,32 @@ def getCacheData(fileName)
404404
# PROJECTS PAGES
405405
#####################################################################
406406

407+
get '/projects/*' do
408+
wildCardData = params['splat'][0]
409+
if request.url.end_with? ('/summary')
410+
getProgID = wildCardData.gsub('/summary', '')
411+
redirect '/programme/'+getProgID+'/summary'
412+
elsif request.url.end_with? ('/documents')
413+
getProgID = wildCardData.gsub('/documents', '')
414+
redirect '/programme/'+getProgID+'/documents'
415+
elsif request.url.end_with? ('/transactions')
416+
getProgID = wildCardData.gsub('/transactions', '')
417+
redirect '/programme/'+getProgID+'/transactions'
418+
elsif request.url.end_with? ('/components')
419+
getProgID = wildCardData.gsub('/components', '')
420+
redirect '/programme/'+getProgID+'/projects'
421+
elsif request.url.end_with? ('/partners')
422+
getProgID = wildCardData.gsub('/partners', '')
423+
redirect '/programme/'+getProgID+'/partners'
424+
else
425+
getProgID = wildCardData.gsub('/components', '')
426+
redirect '/programme/'+getProgID+'/summary'
427+
end
428+
#redirect '/search_p'
429+
end
430+
407431
# Project summary page
408-
get '/projects/*/summary' do
432+
get '/programme/*/summary' do
409433
n = ERB::Util.url_encode (params['splat'][0]).to_s
410434
#n = sanitize_input(n,"p")
411435
check_if_project_exists(n)
@@ -459,7 +483,7 @@ def getCacheData(fileName)
459483
end
460484

461485
# Project documents page
462-
get '/projects/*/documents/?' do
486+
get '/programme/*/documents/?' do
463487
n = ERB::Util.url_encode (params['splat'][0]).to_s
464488
check_if_project_exists(n)
465489
# get the project data from the API
@@ -476,7 +500,7 @@ def getCacheData(fileName)
476500
end
477501

478502
#Project transactions page
479-
get '/projects/*/transactions/?' do
503+
get '/programme/*/transactions/?' do
480504
n = ERB::Util.url_encode (params['splat'][0]).to_s
481505
check_if_project_exists(n)
482506
# get the project data from the API
@@ -492,7 +516,7 @@ def getCacheData(fileName)
492516
end
493517

494518
#Project transactions page
495-
get '/projects/*/components/?' do
519+
get '/programme/*/projects/?' do
496520
n = ERB::Util.url_encode (params['splat'][0]).to_s
497521
check_if_project_exists(n)
498522
# get the project data from the API
@@ -650,7 +674,7 @@ def getCacheData(fileName)
650674
######################################################################
651675
######################################################################
652676
#Project partners page
653-
get '/projects/*/partners/?' do
677+
get '/programme/*/partners/?' do
654678
n = ERB::Util.url_encode (params['splat'][0]).to_s
655679
check_if_project_exists(n)
656680
# get the project data from the API

views/partials/_projects-header.html.erb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@
6666
6767
<nav class="moj-sub-navigation" aria-label="Sub navigation">
6868
<ul class="moj-sub-navigation__list">
69-
<li class="moj-sub-navigation__item"><a href="/projects/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/summary" id='summary' class="moj-sub-navigation__link" <%= active=="summary" ? "aria-current='page'" : ""%>>Summary</a></li>
70-
<li class="moj-sub-navigation__item"><a href="/projects/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/documents" id='documents' class="moj-sub-navigation__link" <%= active=="documents" ? "aria-current='page'" : ""%>>Documents (<%= project.has_key?('document_link_url') ? project['document_link_url'].count : 0 %>)</a></li>
71-
<li class="moj-sub-navigation__item"><a href="/projects/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/components" id="components" class="moj-sub-navigation__link" <%= active=="components" ? "aria-current='page'" : ""%>>Projects</a></li>
72-
<li style="display: none" class="moj-sub-navigation__item transactions-tab"><a href="/projects/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/transactions" id="transactions" class="moj-sub-navigation__link" <%= active=="transactions" ? "aria-current='page'" : ""%>>Transactions</a></li>
73-
<li style="display: none" class="moj-sub-navigation__item partner-tab"><a href="/projects/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/partners" id="partners" class="moj-sub-navigation__link" <%= active=="partners" ? "aria-current='page'" : ""%>>Partners</a></li>
69+
<li class="moj-sub-navigation__item"><a href="/programme/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/summary" id='summary' class="moj-sub-navigation__link" <%= active=="summary" ? "aria-current='page'" : ""%>>Summary</a></li>
70+
<li class="moj-sub-navigation__item"><a href="/programme/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/documents" id='documents' class="moj-sub-navigation__link" <%= active=="documents" ? "aria-current='page'" : ""%>>Documents (<%= project.has_key?('document_link_url') ? project['document_link_url'].count : 0 %>)</a></li>
71+
<li class="moj-sub-navigation__item"><a href="/programme/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/projects" id="components" class="moj-sub-navigation__link" <%= active=="components" ? "aria-current='page'" : ""%>>Projects</a></li>
72+
<li style="display: none" class="moj-sub-navigation__item transactions-tab"><a href="/programme/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/transactions" id="transactions" class="moj-sub-navigation__link" <%= active=="transactions" ? "aria-current='page'" : ""%>>Transactions</a></li>
73+
<li style="display: none" class="moj-sub-navigation__item partner-tab"><a href="/programme/<%=ERB::Util.url_encode(project['iati_identifier']).to_s%>/partners" id="partners" class="moj-sub-navigation__link" <%= active=="partners" ? "aria-current='page'" : ""%>>Partners</a></li>
7474
</ul>
7575
</nav>
7676
</div>

0 commit comments

Comments
 (0)