This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/routes/static_route.js
Robin Ward ad1a8db956 Support for linking to static pages with hash URLs like #section. Also
refactor of static code to be more idomatic.
2014-04-29 18:01:13 -04:00

33 lines
833 B
JavaScript

/**
The routes used for rendering static content
@class StaticRoute
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.StaticController.PAGES.forEach(function(page) {
Discourse[page.capitalize() + "Route"] = Discourse.Route.extend({
renderTemplate: function() {
this.render('static');
},
beforeModel: function(transition) {
var configKey = Discourse.StaticController.CONFIGS[page];
if (configKey && Discourse.SiteSettings[configKey].length > 0) {
transition.abort();
Discourse.URL.redirectTo(Discourse.SiteSettings[configKey]);
}
},
model: function() {
return Discourse.StaticPage.find(page);
},
setupController: function(controller, model) {
this.controllerFor('static').set('model', model);
}
});
});