Show login button on 404 page. Add routes to show login and signup modals when page/route loads. If logged in and showing 404 page, load ember app.
This commit is contained in:
parent
2a8734f0d5
commit
7f6b2e5563
|
@ -8,6 +8,7 @@ Discourse.Route.buildRoutes(function() {
|
||||||
var router = this;
|
var router = this;
|
||||||
|
|
||||||
// Generate static page routes
|
// Generate static page routes
|
||||||
|
// e.g., faq, tos, privacy, login
|
||||||
_.each(Discourse.StaticController.PAGES, function (page) {
|
_.each(Discourse.StaticController.PAGES, function (page) {
|
||||||
router.route(page, { path: '/' + page });
|
router.route(page, { path: '/' + page });
|
||||||
});
|
});
|
||||||
|
@ -90,4 +91,7 @@ Discourse.Route.buildRoutes(function() {
|
||||||
|
|
||||||
this.route('invited');
|
this.route('invited');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.route('signup', {path: '/signup'});
|
||||||
|
this.route('login', {path: '/login'});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -104,7 +104,7 @@ class ApplicationController < ActionController::Base
|
||||||
# from the above rescue_from blocks will fail because that isn't valid json.
|
# 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
|
render status: error, layout: false, text: (error == 404) ? build_not_found_page(error) : message
|
||||||
else
|
else
|
||||||
render text: build_not_found_page(error, 'no_js')
|
render text: build_not_found_page(error, current_user ? 'application' : 'no_js')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
<div class="title span13">
|
<div class="title span13">
|
||||||
<a href="/"><img src="<%=SiteSetting.logo_url%>" alt="<%=SiteSetting.title%>" id="site-logo"></a>
|
<a href="/"><img src="<%=SiteSetting.logo_url%>" alt="<%=SiteSetting.title%>" id="site-logo"></a>
|
||||||
</div>
|
</div>
|
||||||
|
<% unless current_user %>
|
||||||
|
<div class='panel clearfix'>
|
||||||
|
<a href="/login" class='btn btn-primary btn-small'><%= I18n.t('log_in') %></a>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
<%= markdown_content(:login_required_welcome_message) %>
|
<% if SiteSetting.login_required %>
|
||||||
|
<%= markdown_content(:login_required_welcome_message) %>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -20,6 +20,7 @@ en:
|
||||||
posts: "posts"
|
posts: "posts"
|
||||||
loading: "Loading"
|
loading: "Loading"
|
||||||
powered_by_html: 'Powered by <a href="http://www.discourse.org">Discourse</a>, best viewed with JavaScript enabled'
|
powered_by_html: 'Powered by <a href="http://www.discourse.org">Discourse</a>, best viewed with JavaScript enabled'
|
||||||
|
log_in: "Log In"
|
||||||
|
|
||||||
via: "%{username} via %{site_name}"
|
via: "%{username} via %{site_name}"
|
||||||
is_reserved: "is reserved"
|
is_reserved: "is reserved"
|
||||||
|
|
|
@ -155,6 +155,7 @@ Discourse::Application.routes.draw do
|
||||||
get "faq" => "static#show", id: "faq"
|
get "faq" => "static#show", id: "faq"
|
||||||
get "tos" => "static#show", id: "tos"
|
get "tos" => "static#show", id: "tos"
|
||||||
get "privacy" => "static#show", id: "privacy"
|
get "privacy" => "static#show", id: "privacy"
|
||||||
|
get "signup" => "list#latest"
|
||||||
|
|
||||||
get "users/search/users" => "users#search_users"
|
get "users/search/users" => "users#search_users"
|
||||||
get "users/password-reset/:token" => "users#password_reset"
|
get "users/password-reset/:token" => "users#password_reset"
|
||||||
|
|
Loading…
Reference in New Issue