diff --git a/app/assets/javascripts/discourse/routes/application_routes.js b/app/assets/javascripts/discourse/routes/application_routes.js index b7a33ab405b..0dcc467aeb6 100644 --- a/app/assets/javascripts/discourse/routes/application_routes.js +++ b/app/assets/javascripts/discourse/routes/application_routes.js @@ -8,6 +8,7 @@ Discourse.Route.buildRoutes(function() { var router = this; // Generate static page routes + // e.g., faq, tos, privacy, login _.each(Discourse.StaticController.PAGES, function (page) { router.route(page, { path: '/' + page }); }); @@ -90,4 +91,7 @@ Discourse.Route.buildRoutes(function() { this.route('invited'); }); + + this.route('signup', {path: '/signup'}); + this.route('login', {path: '/login'}); }); diff --git a/app/assets/javascripts/discourse/routes/login_route.js b/app/assets/javascripts/discourse/routes/login_route.js new file mode 100644 index 00000000000..074efb3803e --- /dev/null +++ b/app/assets/javascripts/discourse/routes/login_route.js @@ -0,0 +1,11 @@ +Discourse.LoginRoute = Discourse.Route.extend({ + beforeModel: function() { + if (!Discourse.SiteSetting.login_required) { + this.transitionTo('discovery.latest').then(function(e) { + Ember.run.next(function() { + e.send('showLogin'); + }); + }); + } + } +}); diff --git a/app/assets/javascripts/discourse/routes/signup_route.js b/app/assets/javascripts/discourse/routes/signup_route.js new file mode 100644 index 00000000000..e6a1b77a0fc --- /dev/null +++ b/app/assets/javascripts/discourse/routes/signup_route.js @@ -0,0 +1,9 @@ +Discourse.SignupRoute = Discourse.Route.extend({ + beforeModel: function() { + this.transitionTo('discovery.latest').then(function(e) { + Ember.run.next(function() { + e.send('showCreateAccount'); + }); + }); + } +}); diff --git a/app/assets/javascripts/discourse/routes/static_route.js b/app/assets/javascripts/discourse/routes/static_route.js index 2099a2fe3ec..fd6092abbbc 100644 --- a/app/assets/javascripts/discourse/routes/static_route.js +++ b/app/assets/javascripts/discourse/routes/static_route.js @@ -26,3 +26,15 @@ _.each(Discourse.StaticController.PAGES, function(page) { }); }); + +Discourse.LoginRoute.reopen({ + beforeModel: function() { + if (!Discourse.SiteSettings.login_required) { + this.transitionTo('discovery.latest').then(function(e) { + Ember.run.next(function() { + e.send('showLogin'); + }); + }); + } + } +}); diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 091cac0856f..44686a477a7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -104,7 +104,7 @@ class ApplicationController < ActionController::Base # from the above rescue_from blocks will fail because that isn't valid json. render status: error, layout: false, text: (error == 404) ? build_not_found_page(error) : message else - render text: build_not_found_page(error, 'no_js') + render text: build_not_found_page(error, current_user ? 'application' : 'no_js') end end diff --git a/app/views/layouts/no_js.html.erb b/app/views/layouts/no_js.html.erb index 871230b50f0..7b86ad3ee7d 100644 --- a/app/views/layouts/no_js.html.erb +++ b/app/views/layouts/no_js.html.erb @@ -24,6 +24,11 @@
+ <% unless current_user %> + + <% end %> diff --git a/app/views/static/login.html.erb b/app/views/static/login.html.erb index 4971cd49c7c..6e840e6e9ab 100644 --- a/app/views/static/login.html.erb +++ b/app/views/static/login.html.erb @@ -1 +1,3 @@ -<%= markdown_content(:login_required_welcome_message) %> +<% if SiteSetting.login_required %> + <%= markdown_content(:login_required_welcome_message) %> +<% end %> diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 13e1a21a0bd..c4a2c9d78d6 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -20,6 +20,7 @@ en: posts: "posts" loading: "Loading" powered_by_html: 'Powered by Discourse, best viewed with JavaScript enabled' + log_in: "Log In" via: "%{username} via %{site_name}" is_reserved: "is reserved" diff --git a/config/routes.rb b/config/routes.rb index 48228066d6a..81b152f2922 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -14,7 +14,7 @@ Discourse::Application.routes.draw do match "/404", to: "exceptions#not_found", via: [:get, :post] mount Sidekiq::Web => "/sidekiq", constraints: AdminConstraint.new - + get "site" => "site#index" resources :forums @@ -155,6 +155,7 @@ Discourse::Application.routes.draw do get "faq" => "static#show", id: "faq" get "tos" => "static#show", id: "tos" get "privacy" => "static#show", id: "privacy" + get "signup" => "list#latest" get "users/search/users" => "users#search_users" get "users/password-reset/:token" => "users#password_reset"