routes.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. Router.onBeforeAction('loading');
  2. Router.configure({
  3. loadingTemplate: 'loading'
  4. });
  5. Router.route("/", {
  6. template: "home"
  7. });
  8. Router.route("/login", {
  9. template: "login"
  10. });
  11. Router.route("/signup", {
  12. template: "register"
  13. });
  14. Router.route("/terms", {
  15. template: "terms"
  16. });
  17. Router.route("/api", {
  18. template: "api"
  19. });
  20. Router.route("/privacy", {
  21. template: "privacy"
  22. });
  23. Router.route("/about", {
  24. template: "about"
  25. });
  26. Router.route("/admin", {
  27. waitOn: function() {
  28. return Meteor.subscribe("isAdmin", Meteor.userId());
  29. },
  30. action: function() {
  31. var user = Meteor.users.findOne({});
  32. if (user !== undefined && user.profile !== undefined && user.profile.rank === "admin") {
  33. this.render("admin");
  34. } else {
  35. this.redirect("/");
  36. }
  37. }
  38. });
  39. Router.route("/stations", {
  40. waitOn: function() {
  41. return Meteor.subscribe("isAdmin", Meteor.userId());
  42. },
  43. action: function() {
  44. var user = Meteor.users.findOne({});
  45. if (user !== undefined && user.profile !== undefined && user.profile.rank === "admin") {
  46. this.render("stations");
  47. } else {
  48. this.redirect("/");
  49. }
  50. }
  51. });
  52. Router.route("/admin/alerts", {
  53. waitOn: function() {
  54. return Meteor.subscribe("isAdmin", Meteor.userId());
  55. },
  56. action: function() {
  57. var user = Meteor.users.findOne({});
  58. if (user !== undefined && user.profile !== undefined && user.profile.rank === "admin") {
  59. this.render("alertsDashboard");
  60. } else {
  61. this.redirect("/");
  62. }
  63. }
  64. });
  65. Router.route("/:type", {
  66. template: "room"
  67. });
  68. Router.route("/u/:user", {
  69. template: "profile"
  70. });