Skip to content

Commit

Permalink
search revamp
Browse files Browse the repository at this point in the history
  • Loading branch information
countable committed Jun 29, 2016
1 parent 90c3554 commit 52708ba
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 52 deletions.
Empty file modified Dockerfile.frontend
100644 → 100755
Empty file.
14 changes: 5 additions & 9 deletions app/assets/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,8 @@ riot.tag('raw', '<span></span>', function (opts) {
this.updateContent();
});



function locationHashChanged() {
var old_tag = pubsub.kwargs['t']; // prevent hash change triggering multiple update events.
set_kwargs();
if (old_tag !== pubsub.kwargs['t']) pubsub.trigger('update_tag', pubsub.kwargs['t']);
}

window.onhashchange = locationHashChanged;
window.onhashchange = function(){
set_kwargs();
console.log("detected hash change to", pubsub.kwargs['t'])
pubsub.trigger('update_tag', pubsub.kwargs['t']);
};
55 changes: 27 additions & 28 deletions app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -10,104 +10,103 @@
%a{:href => "/map"} View all
listings, or choose a category or enter a keyword to begin.
%ul.splash-icons
%li{"data-category" => "Network", :onclick => "pickCategory(event)"}
%li{"data-tag" => "Network", :onclick => "pickCategory(event)"}
%img{:src => "../images/icon/network.png"}/
.blurb
Network
%ul.splash-subtag-menu
%li{"data-tag" => "Events", :onclick => "pickTag(event)"}
%li{"data-tag" => "Events"}
Events
%li{"data-tag" => "Organizations", :onclick => "pickTag(event)"}
%li{"data-tag" => "Organizations"}
Organizations
%li{"data-tag" => "Farms", :onclick => "pickTag(event)"}
%li{"data-tag" => "Farms"}
Farms
%li{"data-category" => "Education", :onclick => "pickCategory(event)"}
%li{"data-tag" => "Education", :onclick => "pickCategory(event)"}
%img{:src => "../images/icon/education.png"}/
.blurb
Education
%ul.splash-subtag-menu
%li{"data-tag" => "Education Programs", :onclick => "pickTag(event)"}
%li{"data-tag" => "Educational Programs"}
Education Programs
%li{"data-tag" => "Publication", :onclick => "pickTag(event)"}
%li{"data-tag" => "Publications"}
Publications
%li{"data-tag" => "Web Resource", :onclick => "pickTag(event)"}
%li{"data-tag" => "Web Resource"}
Web Resources
%li{"data-category" => "Jobs & Training", :onclick => "pickCategory(event)"}
%li{"data-tag" => "Jobs & Training", :onclick => "pickCategory(event)"}
%img{:src => "../images/icon/jobs---training.png"}/
.blurb
Jobs &
%br/
Training
%ul.splash-subtag-menu
%li{"data-tag" => "Jobs", :onclick => "pickTag(event)"}
%li{"data-tag" => "Jobs"}
Jobs
%li{"data-tag" => "Apprenticeships", :onclick => "pickTag(event)"}
%li{"data-tag" => "Apprenticeships"}
Apprenticeships
%li{"data-category" => "Business", :onclick => "pickCategory(event)"}
%li{"data-tag" => "Business", :onclick => "pickCategory(event)"}
%img{:src => "../images/icon/business.png"}/
.blurb
Business
%ul.splash-subtag-menu
%li{"data-tag" => "Business Development", :onclick => "pickTag(event)"}
%li{"data-tag" => "Business Development"}
Business Development
%li{"data-tag" => "Funding", :onclick => "pickTag(event)"}
%li{"data-tag" => "Funding"}
Funding
%li{"data-category" => "Land", :onclick => "pickCategory(event)"}
%li{"data-tag" => "Land", :onclick => "pickCategory(event)"}
%img{:src => "../images/icon/land.png"}/
.blurb
Land
%ul.splash-subtag-menu
%li{"data-tag" => "Land Listings", :onclick => "pickTag(event)"}
%li{"data-tag" => "Land Listings"}
Land Listings
%li{"data-tag" => "Seeking", :onclick => "pickTag(event)"}
%li{"data-tag" => "Seeking"}
Farmers Looking For Land
%li{"data-tag" => "resource", :onclick => "pickTag(event)"}
%li{"data-tag" => "Resources"}
Resources
%li{"data-category" => "Run Your Farm", :onclick => "pickCategory(event)"}
%li{"data-tag" => "Run Your Farm", :onclick => "pickCategory(event)"}
%img{:src => "../images/icon/run-your-farm.png"}/
.blurb
Run Your
%br/
Farm
%ul.splash-subtag-menu
%li{"data-tag" => "Markets", :onclick => "pickTag(event)"}
%li{"data-tag" => "Markets"}
Markets
%li{"data-tag" => "Production Planning Tools", :onclick => "pickTag(event)"}
%li{"data-tag" => "Production Planning Tools"}
Production Planning Tools
%li{"data-tag" => "Seeds", :onclick => "pickTag(event)"}
%li{"data-tag" => "Seeds"}
Seeds
%li{"data-tag" => "Infrastructure", :onclick => "pickTag(event)"}
%li{"data-tag" => "Infrastructure"}
Services and Suppliers
%p
%input.search-box{:onkeyup => "checkKeyUp(event)", :placeholder => "Search: ie) bees, soil testing, etc.", :type => "text"}/
:javascript
console.log('f')
function checkKeyUp(e){
if (e.which === 13) {
window.location = "/map#q=" + e.target.value;
}
}
function pickCategory(e){
window.location = "/map#t=" + encodeURIComponent(e.target.getAttribute('data-tag') || e.target.parentNode.getAttribute('data-category'));
}
function pickTag(e){

//window.location = "/map#t=" + e.target.getAttribute('data-tag');
window.location = "/map#t=" + encodeURIComponent(
e.target.getAttribute('data-tag') || e.target.parentNode.getAttribute('data-tag')
);
}
Binary file removed deploy/soil.sql.bz2
Binary file not shown.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ services:
build:
context: .
dockerfile: Dockerfile.frontend

volumes:
- /data/docker/nginx/ssl:/etc/nginx/conf.d/ssl
mem_limit: 50m
Expand Down
24 changes: 14 additions & 10 deletions public/tags/results.tag
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
</div>

<ul class='results-list' id='results-list'>
<li each={ items } class="{ slugify(categories[0]) } lightbg">
<div if={ CATEGORY_ICONS[slugify( categories[0] )] } class='listing-icon'
style='background:url( { CATEGORY_ICONS[slugify( categories[0] )] }) 10px 10px no-repeat'
<li each={ items } class="{ proper_category_slug } lightbg">
<div if={ CATEGORY_ICONS[proper_category_slug] } class='listing-icon'
style='background:url( { CATEGORY_ICONS[proper_category_slug] }) 10px 10px no-repeat'
></div>
<a class='listing-text' target='{ is_mobile() ? "_self" : "_blank" }' href='/locations/{ id }'>
<label class='{ slugify(categories[0]) }'>{ categories[0].primary.name || categories[0].name }</label>
<label class='{ proper_category_slug }'>{ proper_category }</label>
<span class='name'>{ name }</span><br>
<span if={ city } class='city'>{ city }, { province }</span>
</a>
<div if={ latitude } class='view-on-map { slugify(categories[0]) }' onclick={ view_on_map }>
<div if={ latitude } class='view-on-map { proper_category_slug }' onclick={ view_on_map }>
<span if={ is_mobile() }>GO TO<br>LISTING</span>
<span if={ !is_mobile() }>VIEW ON<br>MAP</span>
<div class='triangle-arrow filled'></div>
Expand Down Expand Up @@ -69,21 +69,21 @@
}

set_tag(e){
console.log(controller.tag === e.item.name);
if (controller.tag === e.item.name) {
if (is_meta(controller.tag)) {
opts.trigger('update_tag', null);
opts.trigger('update_tag_start', null);
} else {
var meta = PRIMARY_CATEGORIES.filter(function(c){return e.item.name === c.name})[0].metaName;
console.log('meta', meta);
opts.trigger('update_tag', meta);
opts.trigger('update_tag_start', meta);
}
} else {
opts.trigger('update_tag', e.item.name);
opts.trigger('update_tag_start', e.item.name);
}
}

set_tag_null(e){
opts.trigger('update_tag', null)
opts.trigger('update_tag_start', null)
}

view_on_map(e) {
Expand Down Expand Up @@ -127,11 +127,15 @@
if (!controller.tag || item.categories[i].meta.name == controller.tag) {
name = item.categories[i].primary ? item.categories[i].primary.name : item.categories[i].name;
cat_counts[name] = (cat_counts[name] || 0) + 1;
item.proper_category_slug = slug(name);
item.proper_category = name;
}
} else {
name = item.categories[i].primary ? item.categories[i].primary.name : item.categories[i].name;
if (name === controller.tag) {
cat_counts[name] = (cat_counts[name] || 0) + 1;
item.proper_category_slug = slug(name);
item.proper_category = name;
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions public/tags/search.tag
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,23 @@
window.location.hash = "#" + hash_parts.join("&");
}

opts.on('update_tag', function(tag){
opts.on('update_tag_start', function(tag){
active_tag = tag;
update_hash();
filter_listings();
});

opts.on('update_tag', function(tag){
active_tag = tag;
setTimeout(filter_listings, 1); // ensure items are loaded after all update_tag events are processed first.
});

function handle_load(){
console.log(is_meta(active_tag) ? 'meta' : 'primary');
var l = orig_listings.filter( function(x){ return listing_visible( x ); } );
opts.trigger('load', l );
}

function filter_listings(){
console.trace();
if( !orig_listings )
{
var path = '/locations.json'
Expand All @@ -82,7 +86,6 @@
listing.dist = Math.abs((listing.latitude || 999) - 49.104430) + Math.abs((listing.longitude || 999) - -122.801094);
});
orig_listings = response;
console.log(response);
handle_load();
});
}
Expand Down

0 comments on commit 52708ba

Please sign in to comment.