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 myCollection = Metamaps.Maps.Mine ? Metamaps.Maps.Mine : [];
|
||||||
var mapperCollection = [];
|
var mapperCollection = [];
|
||||||
var mapperOptionsObj = {id: 'mapper', sortBy: 'name' };
|
var mapperOptionsObj = {id: 'mapper', sortBy: 'updated_at' };
|
||||||
if (Metamaps.Maps.Mapper) {
|
if (Metamaps.Maps.Mapper) {
|
||||||
mapperCollection = Metamaps.Maps.Mapper.models;
|
mapperCollection = Metamaps.Maps.Mapper.models;
|
||||||
mapperOptionsObj.mapperId = Metamaps.Maps.Mapper.id;
|
mapperOptionsObj.mapperId = Metamaps.Maps.Mapper.id;
|
||||||
}
|
}
|
||||||
var featuredCollection = Metamaps.Maps.Featured ? Metamaps.Maps.Featured : [];
|
var featuredCollection = Metamaps.Maps.Featured ? Metamaps.Maps.Featured : [];
|
||||||
var activeCollection = Metamaps.Maps.Active ? Metamaps.Maps.Active : [];
|
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
|
// 'Mapper' refers to another mapper
|
||||||
Metamaps.Maps.Mapper = new Metamaps.Backbone.MapsCollection(mapperCollection, mapperOptionsObj);
|
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' });
|
Metamaps.Maps.Active = new Metamaps.Backbone.MapsCollection(activeCollection, {id: 'active', sortBy: 'updated_at' });
|
||||||
},
|
},
|
||||||
openLightbox: function (which) {
|
openLightbox: function (which) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
},
|
},
|
||||||
home: function () {
|
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';
|
else document.title = 'Home | Metamaps';
|
||||||
|
|
||||||
Metamaps.currentSection = "";
|
Metamaps.currentSection = "";
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
Metamaps.Famous.yield.hide();
|
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.maps.resetScroll(); // sets the scroll back to the top
|
||||||
Metamaps.Famous.explore.show();
|
Metamaps.Famous.explore.show();
|
||||||
|
|
||||||
|
@ -35,9 +35,9 @@
|
||||||
Metamaps.GlobalUI.Search.open();
|
Metamaps.GlobalUI.Search.open();
|
||||||
Metamaps.GlobalUI.Search.lock();
|
Metamaps.GlobalUI.Search.lock();
|
||||||
|
|
||||||
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Mine );
|
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Active );
|
||||||
if (Metamaps.Maps.Mine.length === 0) {
|
if (Metamaps.Maps.Active.length === 0) {
|
||||||
Metamaps.Maps.Mine.getMaps(); // this will trigger an explore maps render
|
Metamaps.Maps.Active.getMaps(); // this will trigger an explore maps render
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Metamaps.Views.exploreMaps.render();
|
Metamaps.Views.exploreMaps.render();
|
||||||
|
@ -71,11 +71,22 @@
|
||||||
// either 'featured', 'mapper', or 'active'
|
// either 'featured', 'mapper', or 'active'
|
||||||
var capitalize = section.charAt(0).toUpperCase() + section.slice(1);
|
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';
|
document.title = 'Explore ' + capitalize + ' Maps | Metamaps';
|
||||||
}
|
}
|
||||||
else if (capitalize === "mapper") {
|
else if (section === "mapper") {
|
||||||
document.title = 'Explore Maps | Metamaps';
|
$.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');
|
$('.wrapper').removeClass('homePage mapPage topicPage');
|
||||||
|
|
|
@ -13,7 +13,7 @@ class MainController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
if authenticated?
|
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)
|
respond_with(@maps, @current)
|
||||||
else
|
else
|
||||||
respond_with(@current)
|
respond_with(@current)
|
||||||
|
|
|
@ -31,7 +31,7 @@ class MapsController < ApplicationController
|
||||||
@request = "active"
|
@request = "active"
|
||||||
|
|
||||||
elsif request.path.index("/explore/featured") != nil
|
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"
|
@request = "featured"
|
||||||
|
|
||||||
elsif request.path.index('/explore/mine') != nil # looking for maps by me
|
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
|
redirect_to activemaps_url and return
|
||||||
end
|
end
|
||||||
# don't need to exclude private maps because they all belong to you
|
# 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"
|
@request = "you"
|
||||||
|
|
||||||
elsif request.path.index('/explore/mapper/') != nil # looking for maps by a mapper
|
elsif request.path.index('/explore/mapper/') != nil # looking for maps by a mapper
|
||||||
@user = User.find(params[:id])
|
@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"
|
@request = "mapper"
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
if @request == "you"
|
if @request == "active" && authenticated?
|
||||||
redirect_to root_url and return
|
redirect_to root_url and return
|
||||||
else
|
|
||||||
respond_with(@maps, @request, @user)
|
|
||||||
end
|
end
|
||||||
|
respond_with(@maps, @request, @user)
|
||||||
}
|
}
|
||||||
format.json { render json: @maps }
|
format.json { render json: @maps }
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,9 +42,9 @@
|
||||||
Metamaps.currentPage = "";
|
Metamaps.currentPage = "";
|
||||||
</script>
|
</script>
|
||||||
<% elsif authenticated? %>
|
<% elsif authenticated? %>
|
||||||
<% content_for :title, "My Maps | Metamaps" %>
|
<% content_for :title, "Explore Active Maps | Metamaps" %>
|
||||||
<script>
|
<script>
|
||||||
Metamaps.Maps.Mine = <%= @maps.to_json.html_safe %>;
|
Metamaps.Maps.Active = <%= @maps.to_json.html_safe %>;
|
||||||
Metamaps.currentSection = "";
|
Metamaps.currentSection = "";
|
||||||
Metamaps.currentPage = "";
|
Metamaps.currentPage = "";
|
||||||
Metamaps.GlobalUI.Search.isOpen = true;
|
Metamaps.GlobalUI.Search.isOpen = true;
|
||||||
|
|
|
@ -4,21 +4,31 @@
|
||||||
# TODO: What url is this accessible at?
|
# TODO: What url is this accessible at?
|
||||||
#%>
|
#%>
|
||||||
|
|
||||||
<% content_for :title, "Explore Maps | Metamaps" %>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
<% if @request == "active" %>
|
<% if @request == "you" %>
|
||||||
Metamaps.Maps.Active = <%= @maps.to_json.html_safe %>;
|
Metamaps.Maps.Mine = <%= @maps.to_json.html_safe %>;
|
||||||
Metamaps.currentPage = "active";
|
Metamaps.currentPage = "mine";
|
||||||
|
<% content_for :title, "Explore My Maps | Metamaps" %>
|
||||||
|
|
||||||
<% elsif @request == "featured" %>
|
<% elsif @request == "featured" %>
|
||||||
Metamaps.Maps.Featured = <%= @maps.to_json.html_safe %>;
|
Metamaps.Maps.Featured = <%= @maps.to_json.html_safe %>;
|
||||||
Metamaps.currentPage = "featured";
|
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" %>
|
<% elsif @request == "mapper" %>
|
||||||
Metamaps.Maps.Mapper = {
|
Metamaps.Maps.Mapper = {
|
||||||
models: <%= @maps.to_json.html_safe %>,
|
models: <%= @maps.to_json.html_safe %>,
|
||||||
id: <%= params[:id] %>
|
id: <%= params[:id] %>
|
||||||
};
|
};
|
||||||
Metamaps.currentPage = "mapper";
|
Metamaps.currentPage = "mapper";
|
||||||
|
<% content_for :title, @user.name + " | Metamaps" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
Metamaps.currentSection = "explore";
|
Metamaps.currentSection = "explore";
|
||||||
Metamaps.GlobalUI.Search.isOpen = true;
|
Metamaps.GlobalUI.Search.isOpen = true;
|
||||||
|
|
|
@ -212,10 +212,10 @@ Metamaps.Famous.build = function () {
|
||||||
Metamaps.Loading.hide();
|
Metamaps.Loading.hide();
|
||||||
if (Metamaps.Active.Mapper) {
|
if (Metamaps.Active.Mapper) {
|
||||||
|
|
||||||
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Mine );
|
Metamaps.Views.exploreMaps.setCollection( Metamaps.Maps.Active );
|
||||||
Metamaps.Views.exploreMaps.render();
|
Metamaps.Views.exploreMaps.render();
|
||||||
f.maps.show();
|
f.maps.show();
|
||||||
f.explore.set('mine');
|
f.explore.set('active');
|
||||||
f.explore.show();
|
f.explore.show();
|
||||||
}
|
}
|
||||||
else f.explore.set('featured');
|
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>';
|
t.featuredContent += '<a href="/explore/featured" class="active featuredMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Featured Maps</a>';
|
||||||
|
|
||||||
/* logged in explore maps bars */
|
/* 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/mine" 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="/" 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.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/mine" 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="/" 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.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/mine" 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="/" 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>';
|
t.featuredAuthContent += '<a href="/explore/featured" class="active featuredMaps exploreMapsButton"><div class="exploreMapsIcon"></div>Featured</a>';
|
||||||
|
|
||||||
module.exports = t;
|
module.exports = t;
|
||||||
|
|
Loading…
Add table
Reference in a new issue