switched home page to active maps instead of my maps
This commit is contained in:
parent
870b4e2829
commit
cb3db06406
8 changed files with 52 additions and 31 deletions
|
@ -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) {
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -42,9 +42,9 @@
|
|||
Metamaps.currentPage = "";
|
||||
</script>
|
||||
<% elsif authenticated? %>
|
||||
<% content_for :title, "My Maps | Metamaps" %>
|
||||
<% content_for :title, "Explore Active Maps | Metamaps" %>
|
||||
<script>
|
||||
Metamaps.Maps.Mine = <%= @maps.to_json.html_safe %>;
|
||||
Metamaps.Maps.Active = <%= @maps.to_json.html_safe %>;
|
||||
Metamaps.currentSection = "";
|
||||
Metamaps.currentPage = "";
|
||||
Metamaps.GlobalUI.Search.isOpen = true;
|
||||
|
|
|
@ -4,21 +4,31 @@
|
|||
# TODO: What url is this accessible at?
|
||||
#%>
|
||||
|
||||
<% content_for :title, "Explore Maps | Metamaps" %>
|
||||
|
||||
|
||||
<script>
|
||||
<% if @request == "active" %>
|
||||
Metamaps.Maps.Active = <%= @maps.to_json.html_safe %>;
|
||||
Metamaps.currentPage = "active";
|
||||
<% if @request == "you" %>
|
||||
Metamaps.Maps.Mine = <%= @maps.to_json.html_safe %>;
|
||||
Metamaps.currentPage = "mine";
|
||||
<% content_for :title, "Explore My Maps | Metamaps" %>
|
||||
|
||||
<% elsif @request == "featured" %>
|
||||
Metamaps.Maps.Featured = <%= @maps.to_json.html_safe %>;
|
||||
Metamaps.currentPage = "featured";
|
||||
<% content_for :title, "Explore Featured Maps | Metamaps" %>
|
||||
|
||||
<% elsif @request == "active" %>
|
||||
Metamaps.Maps.Active = <%= @maps.to_json.html_safe %>;
|
||||
Metamaps.currentPage = "active";
|
||||
<% content_for :title, "Explore Active Maps | Metamaps" %>
|
||||
|
||||
<% elsif @request == "mapper" %>
|
||||
Metamaps.Maps.Mapper = {
|
||||
models: <%= @maps.to_json.html_safe %>,
|
||||
id: <%= params[:id] %>
|
||||
};
|
||||
Metamaps.currentPage = "mapper";
|
||||
<% content_for :title, @user.name + " | Metamaps" %>
|
||||
<% end %>
|
||||
Metamaps.currentSection = "explore";
|
||||
Metamaps.GlobalUI.Search.isOpen = true;
|
||||
|
|
|
@ -212,10 +212,10 @@ Metamaps.Famous.build = function () {
|
|||
Metamaps.Loading.hide();
|
||||
if (Metamaps.Active.Mapper) {
|
||||
|
||||
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Mine );
|
||||
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Active );
|
||||
Metamaps.Views.exploreMaps.render();
|
||||
f.maps.show();
|
||||
f.explore.set('mine');
|
||||
f.explore.set('active');
|
||||
f.explore.show();
|
||||
}
|
||||
else f.explore.set('featured');
|
||||
|
|
|
@ -18,16 +18,16 @@ t.logoContent += '</ul>';
|
|||
t.featuredContent += '<a href="/explore/featured" class="active featuredMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Featured Maps</a>';
|
||||
|
||||
/* logged in explore maps bars */
|
||||
t.mineAuthContent = '<a href="/" class="active myMaps exploreMapsButton"><div class="exploreMapsIcon"></div>My Maps</a>';
|
||||
t.mineAuthContent += '<a href="/explore/active" class="activeMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Recently Active</a>';
|
||||
t.mineAuthContent = '<a href="/explore/mine" class="active myMaps exploreMapsButton"><div class="exploreMapsIcon"></div>My Maps</a>';
|
||||
t.mineAuthContent += '<a href="/" class="activeMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Recently Active</a>';
|
||||
t.mineAuthContent += '<a href="/explore/featured" class="featuredMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Featured</a>';
|
||||
|
||||
t.activeAuthContent = '<a href="/" class="myMaps exploreMapsButton"><div class="exploreMapsIcon"></div>My Maps</a>';
|
||||
t.activeAuthContent += '<a href="/explore/active" class="active activeMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Recently Active</a>';
|
||||
t.activeAuthContent = '<a href="/explore/mine" class="myMaps exploreMapsButton"><div class="exploreMapsIcon"></div>My Maps</a>';
|
||||
t.activeAuthContent += '<a href="/" class="active activeMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Recently Active</a>';
|
||||
t.activeAuthContent += '<a href="/explore/featured" class="featuredMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Featured</a>';
|
||||
|
||||
t.featuredAuthContent = '<a href="/" class="myMaps exploreMapsButton"><div class="exploreMapsIcon"></div>My Maps</a>';
|
||||
t.featuredAuthContent += '<a href="/explore/active" class="activeMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Recently Active</a>';
|
||||
t.featuredAuthContent = '<a href="/explore/mine" class="myMaps exploreMapsButton"><div class="exploreMapsIcon"></div>My Maps</a>';
|
||||
t.featuredAuthContent += '<a href="/" class="activeMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Recently Active</a>';
|
||||
t.featuredAuthContent += '<a href="/explore/featured" class="active featuredMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Featured</a>';
|
||||
|
||||
module.exports = t;
|
||||
|
|
Loading…
Reference in a new issue