From 74a6d132bde631b204e9216eb83a1b253f0d86fd Mon Sep 17 00:00:00 2001 From: Rachel Thornton Date: Sat, 30 Apr 2016 11:44:10 -0400 Subject: [PATCH] Search page functions --- src/components/box/box.jsx | 2 ++ src/components/box/box.scss | 8 ++++++++ src/components/carousel/carousel.jsx | 10 ++-------- src/views/explore/explore.jsx | 2 +- src/views/search/search.jsx | 18 +++++++++++------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/components/box/box.jsx b/src/components/box/box.jsx index b85d8e71b..4d824f97f 100644 --- a/src/components/box/box.jsx +++ b/src/components/box/box.jsx @@ -7,6 +7,7 @@ var Box = React.createClass({ type: 'Box', propTypes: { title: React.PropTypes.string.isRequired, + subtitle: React.PropTypes.string, moreTitle: React.PropTypes.string, moreHref: React.PropTypes.string, moreProps: React.PropTypes.object @@ -20,6 +21,7 @@ var Box = React.createClass({

{this.props.title}

+

{this.props.subtitle}

{this.props.moreTitle} diff --git a/src/components/box/box.scss b/src/components/box/box.scss index 01310720f..a553cbefe 100644 --- a/src/components/box/box.scss +++ b/src/components/box/box.scss @@ -73,6 +73,14 @@ $base-bg: $ui-white; float: left; } + h2 { + display: inline-block; + float: left; + font-size: 1rem; + font-weight: normal; + padding-left:5px; + } + p { display: inline-block; float: right; diff --git a/src/components/carousel/carousel.jsx b/src/components/carousel/carousel.jsx index b326f5c86..7f6f5e66c 100644 --- a/src/components/carousel/carousel.jsx +++ b/src/components/carousel/carousel.jsx @@ -44,14 +44,8 @@ var Carousel = React.createClass({ {this.props.items.map(function (item) { var href = ''; var thumbnail_url = item.thumbnail_url; - if (item.thumbnail_url==undefined && item.thumbnail!=undefined) { - var lastFour = (item.id%10000).toString(); - if (item.id%10000<1000) { - while (lastFour.length<4) { - lastFour = "0" + lastFour; - } - } - thumbnail_url = "//cdn.scratch.mit.edu/static/site/projects/thumbnails/"+Math.floor(item.id/10000)+"/"+lastFour+".png"; + if (item.image!=undefined) { + thumbnail_url = item.image; } switch (item.type) { case 'gallery': diff --git a/src/views/explore/explore.jsx b/src/views/explore/explore.jsx index 7215ec363..e33a5d582 100644 --- a/src/views/explore/explore.jsx +++ b/src/views/explore/explore.jsx @@ -29,7 +29,7 @@ var Explore = injectIntl(React.createClass({ return {}; }, componentDidMount: function () { - var pathname = window.location.pathname + var pathname = window.location.pathname; if (pathname.substring(pathname.length-1,pathname.length)=="/") { pathname = pathname.substring(0,pathname.length-1); }; diff --git a/src/views/search/search.jsx b/src/views/search/search.jsx index b0dfa3529..a34b00e3f 100644 --- a/src/views/search/search.jsx +++ b/src/views/search/search.jsx @@ -15,6 +15,7 @@ var Carousel = require('../../components/carousel/carousel.jsx'); var Select = require('../../components/forms/select.jsx'); var offset = 0; var more = []; +var tab = "projects"; var searchTerm = ""; require('./search.scss'); @@ -28,11 +29,13 @@ var Search = injectIntl(React.createClass({ return {}; }, componentDidMount: function () { + var pathname = window.location.search; var q = pathname.lastIndexOf("q="); var and = pathname.indexOf("&"); if (q!=-1 && and!=-1) { searchTerm = pathname.substring(q+2,and).toLowerCase(); }; + searchTerm = searchTerm.split('+').join(' '); this.getSearchResults(0); }, getSearchResults: function () { @@ -68,20 +71,20 @@ var Search = injectIntl(React.createClass({ row4 = row4.slice(12,16); } var rows = [ - , - , - , - , ] if (this.state.searchMore!=undefined && more.length0) { for (var i = 0; i); + rows.push(); } } return rows; @@ -114,15 +117,16 @@ var Search = injectIntl(React.createClass({ return (

- + {this.getTab("all")} {this.getTab("projects")} + {this.getTab("studios")} {this.getTab("forums")} {this.getTab("users")} - {this.getTab("studios")} {/*
Sort by: