From f9cb8805e1f55efa862e888b8fd381e45269927a Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Fri, 2 May 2014 12:52:18 +1200 Subject: [PATCH 1/3] API Error page support for Security controller errors --- _config/config.yml | 5 ++++- .../ErrorPageControllerExtension.php | 17 +++++++++++++++++ tests/model/ErrorPageTest.php | 14 +++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 code/controllers/ErrorPageControllerExtension.php diff --git a/_config/config.yml b/_config/config.yml index b1b1fd8e..8b91fc39 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -1,3 +1,6 @@ LeftAndMain: extensions: - - LeftAndMainPageIconsExtension \ No newline at end of file + - LeftAndMainPageIconsExtension +Security: + extensions: + - ErrorPageControllerExtension diff --git a/code/controllers/ErrorPageControllerExtension.php b/code/controllers/ErrorPageControllerExtension.php new file mode 100644 index 00000000..1d7b87c2 --- /dev/null +++ b/code/controllers/ErrorPageControllerExtension.php @@ -0,0 +1,17 @@ +assertEquals($response->getStatusCode(), '403'); $this->assertNotNull($response->getBody(), 'We have body text from the error page'); } -} \ No newline at end of file + + public function testSecurityError() { + // Generate 404 page + $page = $this->objFromFixture('ErrorPage', '404'); + $page->publish('Stage', 'Live'); + + // Test invalid action + $response = $this->get('Security/nosuchaction'); + $this->assertEquals($response->getStatusCode(), '404'); + $this->assertNotNull($response->getBody()); + $this->assertContains('text/html', $response->getHeader('Content-Type')); + } +} From 3162d0e66486d76823f97aa4f9575a76a33f7a81 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 1 May 2014 16:34:30 +1200 Subject: [PATCH 2/3] API Update ErrorPage to respect new HTTP Error codes --- code/model/ErrorPage.php | 2 ++ lang/en.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/code/model/ErrorPage.php b/code/model/ErrorPage.php index 9291dbba..c0118997 100644 --- a/code/model/ErrorPage.php +++ b/code/model/ErrorPage.php @@ -201,6 +201,8 @@ class ErrorPage extends Page { 415 => _t('ErrorPage.415', '415 - Unsupported Media Type'), 416 => _t('ErrorPage.416', '416 - Request Range Not Satisfiable'), 417 => _t('ErrorPage.417', '417 - Expectation Failed'), + 422 => _t('ErrorPage.422', '422 - Unprocessable Entity'), + 429 => _t('ErrorPage.429', '429 - Too Many Requests'), 500 => _t('ErrorPage.500', '500 - Internal Server Error'), 501 => _t('ErrorPage.501', '501 - Not Implemented'), 502 => _t('ErrorPage.502', '502 - Bad Gateway'), diff --git a/lang/en.yml b/lang/en.yml index e73b0e75..0bc207c9 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -200,6 +200,8 @@ en: 415: '415 - Unsupported Media Type' 416: '416 - Request Range Not Satisfiable' 417: '417 - Expectation Failed' + 422: '422 - Unprocessable Entity' + 429: '429 - Too Many Requests' 500: '500 - Internal Server Error' 501: '501 - Not Implemented' 502: '502 - Bad Gateway' From bae95805dd53bc6beacee261e256a1709a776980 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Tue, 6 May 2014 17:42:29 +1200 Subject: [PATCH 3/3] Updated translation masters --- javascript/lang/nb.js | 45 +++++++++++++++++++++++++++++++++++++++++++ lang/nb.yml | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 javascript/lang/nb.js diff --git a/javascript/lang/nb.js b/javascript/lang/nb.js new file mode 100644 index 00000000..66356a07 --- /dev/null +++ b/javascript/lang/nb.js @@ -0,0 +1,45 @@ +// This file was generated by GenerateJavaScriptI18nTask from javascript/lang/src/nb.js. +// See https://github.com/silverstripe/silverstripe-buildtools for details +if(typeof(ss) == 'undefined' || typeof(ss.i18n) == 'undefined') { + if(typeof(console) != 'undefined') console.error('Class ss.i18n not defined'); +} else { + ss.i18n.addDictionary('nb', { + "CMSMAIN.ALERTCLASSNAME": "Sidetypen vil bare bli oppdatert når siden blir lagret", + "CMSMain.RollbackToVersion": "Vil du virkelig rulle tilbake til versjon #%s av denne siden?", + "CMSMAIN.CANTADDCHILDREN": "You can't add children to the selected node", + "CMSMAIN.PUBLISHINGPAGES": "Publiserer sider ...", + "CMSMAIN.SELECTMOREPAGES": "Du har valgt %s sider.\n\nVil du virkelig utføre denne handlingen?", + "CMSMAIN.SAVING": "lagrer ...", + "CMSMAIN.ERRORDELETINGPAGES": "Feil ved sletting av sider", + "URLSEGMENT.Edit": "Rediger", + "CMSMAIN.WARNINGSAVEPAGESBEFOREADDING": "Du må lagre siden før du kan legge til undersider.", + "CMSMAIN.PUBLISHING": "Publiserer ...", + "CMSMAIN.URLSEGMENTVALIDATION": "URLs can only be made up of letters, digits and hyphens.", + "URLSEGMENT.Cancel": "Avbryt", + "Tree.ShowAsList": "Vis undersider som en liste", + "CMSMAIN.ERRORREVERTING": "Error reverting to live content", + "Tree.ThisPageOnly": "Bare denne siden", + "CMSMain.ConfirmRestoreFromLive": "Vil du virkelig kopiere den publiserte siden til utkastsiden?", + "CMSMAIN.ERRORPUBLISHING": "Feil ved publisering av sider", + "CMSMAIN.ERRORADDINGPAGE": "Feil ved opprettelse av side", + "AssetTableField.REALLYDELETE": "Vil du virkelig slette de merkede filene?", + "CMSMAIN.RESTORING": "Gjenoppretter ...", + "AssetTableField.MOVING": "Flytter %s file(r)", + "Tree.EditPage": "Rediger", + "URLSEGMENT.OK": "OK", + "CMSMAIN.ERRORUNFILTER": "Unfiltered tree", + "CMSMAIN.FILTEREDTREE": "Filtered tree to only show changed pages", + "AssetAdmin.ConfirmDelete": "Vil du virkelig slette denne mappen og alle filer som ligger i den?", + "AssetAdmin.BATCHACTIONSDELETECONFIRM": "Vil du virkelig slette %s mapper?", + "CMSMAIN.AddSearchCriteria": "Legg til kriterie", + "Tree.Duplicate": "Dupliser", + "Tree.ThisPageAndSubpages": "Denne siden og undersider", + "WidgetAreaEditor.TOOMANY": "Beklager, du har for mange \"widgets\" i dette området", + "CMSMAIN.DELETINGPAGES": "Sletter sider ...", + "Folder.Name": "Mappenavn", + "CMSMAIN.REALLYDELETEPAGES": "Vil du virkelig slette de %s merkede sidene?", + "CMSMAIN.SELECTONEPAGE": "Vennligst velg minst én side.", + "Tree.AddSubPage": "Legg til ny side her", + "CMSMAIN.ERRORFILTERPAGES": "Could not filter tree to only show changed pages
%s" +}); +} \ No newline at end of file diff --git a/lang/nb.yml b/lang/nb.yml index 723b2a45..0bb90fdd 100644 --- a/lang/nb.yml +++ b/lang/nb.yml @@ -3,7 +3,7 @@ nb: ADDFILES: 'Legg til filer' ActionAdd: 'Legg til mappe' AppCategoryArchive: Arkiv - AppCategoryAudio: Audio + AppCategoryAudio: Lyd AppCategoryDocument: Dokument AppCategoryFlash: Flash AppCategoryImage: Bilde