diff --git a/app/assets/javascripts/src/Metamaps.GlobalUI.js b/app/assets/javascripts/src/Metamaps.GlobalUI.js index ce83ae80..46a34b5c 100644 --- a/app/assets/javascripts/src/Metamaps.GlobalUI.js +++ b/app/assets/javascripts/src/Metamaps.GlobalUI.js @@ -91,17 +91,17 @@ Metamaps.GlobalUI = { var myCollection = Metamaps.Maps.Mine ? Metamaps.Maps.Mine : []; var mapperCollection = []; - var mapperOptionsObj = {id: 'mapper', sortBy: 'name' }; + var mapperOptionsObj = {id: 'mapper', sortBy: 'updated_at' }; if (Metamaps.Maps.Mapper) { mapperCollection = Metamaps.Maps.Mapper.models; mapperOptionsObj.mapperId = Metamaps.Maps.Mapper.id; } var featuredCollection = Metamaps.Maps.Featured ? Metamaps.Maps.Featured : []; var activeCollection = Metamaps.Maps.Active ? Metamaps.Maps.Active : []; - Metamaps.Maps.Mine = new Metamaps.Backbone.MapsCollection(myCollection, {id: 'mine', sortBy: 'name' }); + Metamaps.Maps.Mine = new Metamaps.Backbone.MapsCollection(myCollection, {id: 'mine', sortBy: 'updated_at' }); // 'Mapper' refers to another mapper Metamaps.Maps.Mapper = new Metamaps.Backbone.MapsCollection(mapperCollection, mapperOptionsObj); - Metamaps.Maps.Featured = new Metamaps.Backbone.MapsCollection(featuredCollection, {id: 'featured', sortBy: 'name' }); + Metamaps.Maps.Featured = new Metamaps.Backbone.MapsCollection(featuredCollection, {id: 'featured', sortBy: 'updated_at' }); Metamaps.Maps.Active = new Metamaps.Backbone.MapsCollection(activeCollection, {id: 'active', sortBy: 'updated_at' }); }, openLightbox: function (which) { diff --git a/app/assets/javascripts/src/Metamaps.Router.js b/app/assets/javascripts/src/Metamaps.Router.js index 5b8f0965..5c5d6879 100644 --- a/app/assets/javascripts/src/Metamaps.Router.js +++ b/app/assets/javascripts/src/Metamaps.Router.js @@ -11,7 +11,7 @@ }, home: function () { - if (Metamaps.Active.Mapper) document.title = 'My Maps | Metamaps'; + if (Metamaps.Active.Mapper) document.title = 'Explore Active Maps | Metamaps'; else document.title = 'Home | Metamaps'; Metamaps.currentSection = ""; @@ -26,7 +26,7 @@ Metamaps.Famous.yield.hide(); - Metamaps.Famous.explore.set('mine'); + Metamaps.Famous.explore.set('active'); Metamaps.Famous.maps.resetScroll(); // sets the scroll back to the top Metamaps.Famous.explore.show(); @@ -35,9 +35,9 @@ Metamaps.GlobalUI.Search.open(); Metamaps.GlobalUI.Search.lock(); - Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Mine ); - if (Metamaps.Maps.Mine.length === 0) { - Metamaps.Maps.Mine.getMaps(); // this will trigger an explore maps render + Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Active ); + if (Metamaps.Maps.Active.length === 0) { + Metamaps.Maps.Active.getMaps(); // this will trigger an explore maps render } else { Metamaps.Views.exploreMaps.render(); @@ -71,11 +71,22 @@ // either 'featured', 'mapper', or 'active' var capitalize = section.charAt(0).toUpperCase() + section.slice(1); - if (capitalize === "featured" || capitalize === "active") { + if (section === "featured" || section === "active") { document.title = 'Explore ' + capitalize + ' Maps | Metamaps'; } - else if (capitalize === "mapper") { - document.title = 'Explore Maps | Metamaps'; + else if (section === "mapper") { + $.ajax({ + url: "/users/" + id + ".json", + success: function (response) { + document.title = response.name + ' | Metamaps'; + }, + error: function () { + + } + }); + } + else if (section === "mine") { + document.title = 'Explore My Maps | Metamaps'; } $('.wrapper').removeClass('homePage mapPage topicPage'); diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 177c7f13..46747f71 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -13,7 +13,7 @@ class MainController < ApplicationController respond_to do |format| format.html { if authenticated? - @maps = Map.where("maps.user_id = ?", @current.id).order("name ASC").page(1).per(20) + @maps = Map.where("maps.permission != ?", "private").order("updated_at DESC").page(1).per(20) respond_with(@maps, @current) else respond_with(@current) diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 268093f1..8f0ced9b 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -31,7 +31,7 @@ class MapsController < ApplicationController @request = "active" elsif request.path.index("/explore/featured") != nil - @maps = Map.where("maps.featured = ? AND maps.permission != ?", true, "private").order("name ASC").page(page).per(20) + @maps = Map.where("maps.featured = ? AND maps.permission != ?", true, "private").order("updated_at DESC").page(page).per(20) @request = "featured" elsif request.path.index('/explore/mine') != nil # looking for maps by me @@ -39,21 +39,21 @@ class MapsController < ApplicationController redirect_to activemaps_url and return end # don't need to exclude private maps because they all belong to you + @maps = Map.where("maps.user_id = ?", @current.id).order("updated_at DESC").page(page).per(20) @request = "you" elsif request.path.index('/explore/mapper/') != nil # looking for maps by a mapper @user = User.find(params[:id]) - @maps = Map.where("maps.user_id = ? AND maps.permission != ?", @user.id, "private").order("name ASC").page(page).per(20) + @maps = Map.where("maps.user_id = ? AND maps.permission != ?", @user.id, "private").order("updated_at DESC").page(page).per(20) @request = "mapper" end respond_to do |format| format.html { - if @request == "you" + if @request == "active" && authenticated? redirect_to root_url and return - else - respond_with(@maps, @request, @user) end + respond_with(@maps, @request, @user) } format.json { render json: @maps } end diff --git a/app/views/main/home.html.erb b/app/views/main/home.html.erb index 2c3f173b..8816d34f 100644 --- a/app/views/main/home.html.erb +++ b/app/views/main/home.html.erb @@ -42,9 +42,9 @@ Metamaps.currentPage = ""; <% elsif authenticated? %> - <% content_for :title, "My Maps | Metamaps" %> + <% content_for :title, "Explore Active Maps | Metamaps" %>