From 89e9154499f67fd8c63e1098b3e50b317c690dd0 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 5 May 2014 12:22:52 +0200 Subject: custom error pages for 404 and 500 errors --- config/application.rb | 2 ++ config/routes.rb | 3 +++ 2 files changed, 5 insertions(+) (limited to 'config') diff --git a/config/application.rb b/config/application.rb index 2c9c55a..1077198 100644 --- a/config/application.rb +++ b/config/application.rb @@ -91,5 +91,7 @@ module LeapWeb ## see initializers/customization.rb ## config.paths['app/views'].unshift "config/customization/views" + + config.exceptions_app = self.routes end end diff --git a/config/routes.rb b/config/routes.rb index 745b97d..f92c704 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,9 @@ LeapWeb::Application.routes.draw do root :to => "home#index" get '(:locale)' => 'home#index', :locale => MATCH_LOCALE, :as => 'home' + match '/404' => 'errors#not_found' + match '/500' => 'errors#server_error' + scope "(:locale)", :locale => MATCH_LOCALE, :controller => 'pages', :action => 'show' do get 'privacy-policy', :as => 'privacy_policy' get 'terms-of-service', :as => 'terms_of_service' -- cgit v1.2.3 From 97e30cc136a72092abba19f1b601ad9d5ebd5257 Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 5 May 2014 12:29:21 +0200 Subject: i18n for error pages --- config/locales/en.yml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'config') diff --git a/config/locales/en.yml b/config/locales/en.yml index cebf075..899d659 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,10 +1,19 @@ en: + home: Home privacy_policy: Privacy Policy terms_of_service: Terms of Service pricing: Pricing about: About Us contact: Contact + + not_found_title: Page not found. + not_found_subtitle: "The page you were looking for doesn't exist." + not_found_lead: "You may have mistyped the address or the page may have moved." + server_error_title: Ouch! + server_error_subtitle: We ran into a server error. + server_error_lead: The problem has been logged and we will look into it. no_such_thing: "No such %{thing}." + thing_was_successfully_created: "%{thing} was successfully created." create_thing: "Create %{thing}" -- cgit v1.2.3 From b298cea527f74f682d24defee360e0f45f47d125 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 6 May 2014 09:50:46 +0200 Subject: little bit of documentation --- config/application.rb | 1 + config/routes.rb | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'config') diff --git a/config/application.rb b/config/application.rb index 1077198..8555f48 100644 --- a/config/application.rb +++ b/config/application.rb @@ -92,6 +92,7 @@ module LeapWeb ## config.paths['app/views'].unshift "config/customization/views" + # handle http errors ourselves config.exceptions_app = self.routes end end diff --git a/config/routes.rb b/config/routes.rb index f92c704..9e0b72d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,6 +6,10 @@ LeapWeb::Application.routes.draw do root :to => "home#index" get '(:locale)' => 'home#index', :locale => MATCH_LOCALE, :as => 'home' + # + # HTTP Error Handling + # instead of the default error pages use the errors controller and views + # match '/404' => 'errors#not_found' match '/500' => 'errors#server_error' -- cgit v1.2.3 From 71dcf3f4e5d423b78b47f675297fc98b28ef3442 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 15 May 2014 11:17:47 +0200 Subject: SmtpCertsController, routes and tests --- config/routes.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/routes.rb b/config/routes.rb index 745b97d..ff2d2cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -26,6 +26,7 @@ LeapWeb::Application.routes.draw do resources :users, :only => [:create, :update, :destroy, :index] resources :messages, :only => [:index, :update] resource :cert, :only => [:show] + resource :smtp_cert, :only => [:show] resource :service, :only => [:show] end -- cgit v1.2.3 From 00d5adc90ccadc7f4a2a0d54a5a31a1ad02f05be Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 26 May 2014 09:31:36 +0200 Subject: change from GET to POST for certs We create them. let's reflect that in the verb. --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'config') diff --git a/config/routes.rb b/config/routes.rb index ff2d2cc..2853fbd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -25,8 +25,8 @@ LeapWeb::Application.routes.draw do delete "logout" => "sessions#destroy", :as => "logout" resources :users, :only => [:create, :update, :destroy, :index] resources :messages, :only => [:index, :update] - resource :cert, :only => [:show] - resource :smtp_cert, :only => [:show] + resource :cert, :only => [:show, :create] + resource :smtp_cert, :only => [:create] resource :service, :only => [:show] end -- cgit v1.2.3 From 730e31017109994c24db431fde12f575ed5c1467 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 20 May 2014 09:13:25 +0200 Subject: FlashResponder will automagically add flash messages --- config/initializers/i18n.rb | 4 ++++ config/locales/en.yml | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'config') diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index c277a22..b209d00 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -8,3 +8,7 @@ MATCH_LOCALE = /(#{I18n.available_locales.join('|')})/ # I18n.available_locales is always an array of symbols, but for comparison with # params we need it to be an array of strings. LOCALES_STRING = I18n.available_locales.map(&:to_s) + +# enable using the cascade option +# see svenfuchs.com/2011/2/11/organizing-translations-with-i18n-cascade-and-i18n-missingtranslations +I18n::Backend::Simple.send(:include, I18n::Backend::Cascade) diff --git a/config/locales/en.yml b/config/locales/en.yml index 899d659..a7a76a8 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,4 +1,10 @@ en: + flash: + success: "%{resource} was successfully saved." + create: + success: "%{resource} was successfully created." + update: + success: "%{resource} was successfully updated." home: Home privacy_policy: Privacy Policy terms_of_service: Terms of Service -- cgit v1.2.3 From c10f9311678ff2183443bc03e153b30d3b68ff74 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 20 May 2014 13:09:59 +0200 Subject: Controller#flash_for instead of FlashResponder FlashResponder added a flash before responding. However at the point of responding objects have already been saved. So there is no way to test if they were changed. Now instead we can call flash_for resource before resource.save and it will add the flash messages only if the resource was actually changed. --- config/initializers/add_controller_methods.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/initializers/add_controller_methods.rb b/config/initializers/add_controller_methods.rb index f572ecb..03e8393 100644 --- a/config/initializers/add_controller_methods.rb +++ b/config/initializers/add_controller_methods.rb @@ -1,4 +1,5 @@ ActiveSupport.on_load(:application_controller) do include ControllerExtension::Authentication include ControllerExtension::TokenAuthentication + include ControllerExtension::Flash end -- cgit v1.2.3 From 19bce0f114180f355f0df367cf6d21bd957734a6 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 22 May 2014 14:57:29 +0200 Subject: tickets: structure i18n --- config/locales/flash.en.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 config/locales/flash.en.yml (limited to 'config') diff --git a/config/locales/flash.en.yml b/config/locales/flash.en.yml new file mode 100644 index 0000000..7ad28f8 --- /dev/null +++ b/config/locales/flash.en.yml @@ -0,0 +1,10 @@ +en: + flash: + success: "%{resource} was successfully saved." + error: "%{resource} could not be saved." + create: + success: "%{resource} was successfully created." + error: "%{resource} could not be created." + update: + success: "%{resource} was successfully updated." + error: "%{resource} could not be updated." -- cgit v1.2.3 From 4085e3fabef6427cd3f8be9b61c209bd82eaa595 Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 24 May 2014 10:33:31 +0200 Subject: navigation works with empty locale selected Just in case some translation keys are not present things should still work and make sense. So translation keys should be picked in a meaningful way and scoped rather than prefixed. For example overview.account will turn into "Account" if no translation is present while "overview_account" will turn into "Overview Account". We usually want the former. --- config/locales/en.yml | 33 +-------------------------------- config/locales/footer.en.yml | 7 +++++++ config/locales/generic.en.yml | 4 ++++ config/locales/home.en.yml | 7 +++++++ config/locales/users.en.yml | 15 +++++++-------- 5 files changed, 26 insertions(+), 40 deletions(-) create mode 100644 config/locales/footer.en.yml create mode 100644 config/locales/generic.en.yml create mode 100644 config/locales/home.en.yml (limited to 'config') diff --git a/config/locales/en.yml b/config/locales/en.yml index a7a76a8..feac53b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,17 +1,7 @@ en: - flash: - success: "%{resource} was successfully saved." - create: - success: "%{resource} was successfully created." - update: - success: "%{resource} was successfully updated." home: Home - privacy_policy: Privacy Policy - terms_of_service: Terms of Service - pricing: Pricing - about: About Us - contact: Contact + example_email: 'user@domain.org' not_found_title: Page not found. not_found_subtitle: "The page you were looking for doesn't exist." not_found_lead: "You may have mistyped the address or the page may have moved." @@ -19,8 +9,6 @@ en: server_error_subtitle: We ran into a server error. server_error_lead: The problem has been logged and we will look into it. no_such_thing: "No such %{thing}." - - thing_was_successfully_created: "%{thing} was successfully created." create_thing: "Create %{thing}" overview: "Overview" @@ -40,22 +28,3 @@ en: changes_saved: "Changes saved successfully." are_you_sure: "Are you sure? This change cannot be undone." - download_client: "Download Bitmask" - client_info: "The Bitmask application allows you to use %{provider} services." - all_downloads_info: "It is available for %{clients}." - other_downloads_info: "Bitmask is also available for %{clients}." - login_info: "Log in to change your account settings, create support tickets, and manage payments." - signup_info: "Get a user account via this website. We recommend registering via the Bitmask application instead unless you are only using Bitmask for Android." - welcome: "Welcome to %{provider}." - get_help: "Get Help" - help_info: "Can't login? Create a new support ticket anonymously." - example_email: 'user@domain.org' - os: - linux32: "Linux (32 bit)" - linux64: "Linux (64 bit)" - linux: "GNU/Linux" - windows: "Windows" - android: "Android" - osx: "Mac OS" - other: "(not available for your OS)" - diff --git a/config/locales/footer.en.yml b/config/locales/footer.en.yml new file mode 100644 index 0000000..65f8ab2 --- /dev/null +++ b/config/locales/footer.en.yml @@ -0,0 +1,7 @@ +en: + # layout/footer + privacy_policy: Privacy Policy + terms_of_service: Terms of Service + pricing: Pricing + about: About Us + contact: Contact diff --git a/config/locales/generic.en.yml b/config/locales/generic.en.yml new file mode 100644 index 0000000..dce6d93 --- /dev/null +++ b/config/locales/generic.en.yml @@ -0,0 +1,4 @@ +en: + signup: "Sign Up" + login: "Log In" + cancel: "Cancel" diff --git a/config/locales/home.en.yml b/config/locales/home.en.yml new file mode 100644 index 0000000..4fdbfc2 --- /dev/null +++ b/config/locales/home.en.yml @@ -0,0 +1,7 @@ +en: + welcome: "Welcome to %{provider}." + download_bitmask: "Download Bitmask" + + login_info: "Log in to change your account settings, create support tickets, and manage payments." + signup_info: "Get a user account via this website. We recommend registering via the Bitmask application instead unless you are only using Bitmask for Android." + support_info: "Can't login? Create a new support ticket anonymously." diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index 0ca5a73..3f4fbed 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -2,9 +2,6 @@ en: account_settings: "Account Settings" logout: "Logout" none: "None" - signup: "Sign Up" - cancel: "Cancel" - login: "Log In" username: "Username" password: "Password" change_password: "Change Password" @@ -42,11 +39,13 @@ en: # # overview # - overview_welcome: "Welcome %{username}." - overview_intro: "From this user control panel, you can:" - overview_tickets: "Create and check support tickets." - overview_email: "Modify email settings." - overview_account: "Destroy your account." + users: + overview: + welcome: "Welcome %{username}." + intro: "From this user control panel, you can:" + tickets: "Create and check support tickets." + email: "Modify email settings." + account: "Destroy your account." # # rails -- cgit v1.2.3 From bbeb4b629dc38d82b3b3200706dd25b8def8892e Mon Sep 17 00:00:00 2001 From: Azul Date: Sat, 24 May 2014 13:39:10 +0200 Subject: sorting translation keys some --- config/locales/en.yml | 30 ------------------------------ config/locales/errors.en.yml | 11 +++++++++++ config/locales/generic.en.yml | 21 +++++++++++++++++++++ config/locales/home.en.yml | 1 + config/locales/simple_form.en.yml | 4 ++-- config/locales/users.en.yml | 4 ++-- 6 files changed, 37 insertions(+), 34 deletions(-) delete mode 100644 config/locales/en.yml create mode 100644 config/locales/errors.en.yml (limited to 'config') diff --git a/config/locales/en.yml b/config/locales/en.yml deleted file mode 100644 index feac53b..0000000 --- a/config/locales/en.yml +++ /dev/null @@ -1,30 +0,0 @@ -en: - home: Home - - example_email: 'user@domain.org' - not_found_title: Page not found. - not_found_subtitle: "The page you were looking for doesn't exist." - not_found_lead: "You may have mistyped the address or the page may have moved." - server_error_title: Ouch! - server_error_subtitle: We ran into a server error. - server_error_lead: The problem has been logged and we will look into it. - no_such_thing: "No such %{thing}." - create_thing: "Create %{thing}" - - overview: "Overview" - user_control_panel: "user control panel" - - created: "Created" - created_by_on: "Created by %{user} on %{time}" - updated: "Updated" - - none: "None" - unknown: "Unknown" - admin: "Admin" - anonymous: "Anonymous" - save: "Save" - add: "Add" - remove: "Remove" - changes_saved: "Changes saved successfully." - are_you_sure: "Are you sure? This change cannot be undone." - diff --git a/config/locales/errors.en.yml b/config/locales/errors.en.yml new file mode 100644 index 0000000..93feab1 --- /dev/null +++ b/config/locales/errors.en.yml @@ -0,0 +1,11 @@ +en: + errors: + title: + not_found: Page not found. + server_error: Ouch! + subtitle: + not_found: "The page you were looking for doesn't exist." + server_error: We ran into a server error. + text: + not_found: "You may have mistyped the address or the page may have moved." + server_error: The problem has been logged and we will look into it. diff --git a/config/locales/generic.en.yml b/config/locales/generic.en.yml index dce6d93..14dafac 100644 --- a/config/locales/generic.en.yml +++ b/config/locales/generic.en.yml @@ -1,4 +1,25 @@ en: signup: "Sign Up" login: "Log In" + logout: "Log Out" + cancel: "Cancel" + + created: "Created" + created_by_on: "Created by %{user} on %{time}" + updated: "Updated" + + none: "None" + unknown: "Unknown" + admin: "Admin" + anonymous: "Anonymous" + save: "Save" + add: "Add" + remove: "Remove" + changes_saved: "Changes saved successfully." + are_you_sure: "Are you sure? This change cannot be undone." + + example_email: 'user@domain.org' + + no_such_thing: "No such %{thing}." + create_thing: "Create %{thing}" diff --git a/config/locales/home.en.yml b/config/locales/home.en.yml index 4fdbfc2..c3cdfb1 100644 --- a/config/locales/home.en.yml +++ b/config/locales/home.en.yml @@ -1,4 +1,5 @@ en: + home: Home welcome: "Welcome to %{provider}." download_bitmask: "Download Bitmask" diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 5d0c675..4b35883 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -29,8 +29,8 @@ en: helpers: submit: user: - create: "Sign up" + create: "Sign Up" update: "Save" session: - create: "Log in" + create: "Log In" diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index 3f4fbed..0375174 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -1,7 +1,7 @@ en: + overview: "Overview" + user_control_panel: "user control panel" account_settings: "Account Settings" - logout: "Logout" - none: "None" username: "Username" password: "Password" change_password: "Change Password" -- cgit v1.2.3 From 8ca32588c969ee9eca986da8cf1de92b39ce3576 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 27 May 2014 17:52:26 +0200 Subject: move users key into layouts scope so it does not conflict with users scope --- config/locales/users.en.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/locales/users.en.yml b/config/locales/users.en.yml index 0375174..f0fcb3d 100644 --- a/config/locales/users.en.yml +++ b/config/locales/users.en.yml @@ -1,5 +1,6 @@ en: - overview: "Overview" + layouts: + users: "Users" user_control_panel: "user control panel" account_settings: "Account Settings" username: "Username" -- cgit v1.2.3