From 76981e56c5a92dd5d6dc986e77ad4d383f7389db Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 14 Jan 2020 18:12:04 -0500 Subject: [PATCH 1/8] Updated search result limit Removed search from client side, increased from 20 to 100 in search_controller.rb --- app/controllers/api/v1/search_controller.rb | 2 +- app/javascript/gabsocial/actions/search.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index e34753b5..a9b60c69 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Api::V1::SearchController < Api::BaseController - RESULTS_LIMIT = 20 + RESULTS_LIMIT = 100 respond_to :json diff --git a/app/javascript/gabsocial/actions/search.js b/app/javascript/gabsocial/actions/search.js index 7c06670e..b670d25c 100644 --- a/app/javascript/gabsocial/actions/search.js +++ b/app/javascript/gabsocial/actions/search.js @@ -37,7 +37,6 @@ export function submitSearch() { params: { q: value, resolve: true, - limit: 5, }, }).then(response => { if (response.data.accounts) { From b34b9d5446c883b3b3fa97a69e2016671aae1266 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 14 Jan 2020 18:12:45 -0500 Subject: [PATCH 2/8] Updated search_popout.tips.text locale --- app/javascript/gabsocial/locales/ast.json | 2 +- app/javascript/gabsocial/locales/bg.json | 2 +- app/javascript/gabsocial/locales/defaultMessages.json | 2 +- app/javascript/gabsocial/locales/en.json | 2 +- app/javascript/gabsocial/locales/hi.json | 2 +- app/javascript/gabsocial/locales/hr.json | 2 +- app/javascript/gabsocial/locales/hu.json | 2 +- app/javascript/gabsocial/locales/id.json | 2 +- app/javascript/gabsocial/locales/io.json | 2 +- app/javascript/gabsocial/locales/lv.json | 2 +- app/javascript/gabsocial/locales/ms.json | 2 +- app/javascript/gabsocial/locales/sl.json | 2 +- app/javascript/gabsocial/locales/ta.json | 2 +- app/javascript/gabsocial/locales/th.json | 2 +- app/javascript/gabsocial/locales/tr.json | 2 +- app/javascript/gabsocial/locales/uk.json | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/javascript/gabsocial/locales/ast.json b/app/javascript/gabsocial/locales/ast.json index cf9d67b9..d10e280d 100644 --- a/app/javascript/gabsocial/locales/ast.json +++ b/app/javascript/gabsocial/locales/ast.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "etiqueta", "search_popout.tips.status": "estáu", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "usuariu", "search_results.accounts": "Xente", "search_results.hashtags": "Etiquetes", diff --git a/app/javascript/gabsocial/locales/bg.json b/app/javascript/gabsocial/locales/bg.json index 93e850a7..d9653985 100644 --- a/app/javascript/gabsocial/locales/bg.json +++ b/app/javascript/gabsocial/locales/bg.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/defaultMessages.json b/app/javascript/gabsocial/locales/defaultMessages.json index 0bacc9c6..f1c8458a 100644 --- a/app/javascript/gabsocial/locales/defaultMessages.json +++ b/app/javascript/gabsocial/locales/defaultMessages.json @@ -1026,7 +1026,7 @@ "id": "search_popout.tips.full_text" }, { - "defaultMessage": "Simple text returns matching display names, usernames and hashtags", + "defaultMessage": "Simple text returns matching display names, usernames, groups and hashtags", "id": "search_popout.tips.text" }, { diff --git a/app/javascript/gabsocial/locales/en.json b/app/javascript/gabsocial/locales/en.json index 66365f4b..83d79665 100644 --- a/app/javascript/gabsocial/locales/en.json +++ b/app/javascript/gabsocial/locales/en.json @@ -310,7 +310,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favorited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/hi.json b/app/javascript/gabsocial/locales/hi.json index 3c53a68b..e05f9231 100644 --- a/app/javascript/gabsocial/locales/hi.json +++ b/app/javascript/gabsocial/locales/hi.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/hr.json b/app/javascript/gabsocial/locales/hr.json index 677e6d29..454818af 100644 --- a/app/javascript/gabsocial/locales/hr.json +++ b/app/javascript/gabsocial/locales/hr.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/hu.json b/app/javascript/gabsocial/locales/hu.json index 1fc83213..3209d308 100644 --- a/app/javascript/gabsocial/locales/hu.json +++ b/app/javascript/gabsocial/locales/hu.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "felhasználó", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/id.json b/app/javascript/gabsocial/locales/id.json index e9c99f53..c2739efe 100644 --- a/app/javascript/gabsocial/locales/id.json +++ b/app/javascript/gabsocial/locales/id.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "tagar", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/io.json b/app/javascript/gabsocial/locales/io.json index ca9d7091..ff294b9e 100644 --- a/app/javascript/gabsocial/locales/io.json +++ b/app/javascript/gabsocial/locales/io.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/lv.json b/app/javascript/gabsocial/locales/lv.json index 55ec186c..49d00b0c 100644 --- a/app/javascript/gabsocial/locales/lv.json +++ b/app/javascript/gabsocial/locales/lv.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/ms.json b/app/javascript/gabsocial/locales/ms.json index 4b0adf09..bc1d883c 100644 --- a/app/javascript/gabsocial/locales/ms.json +++ b/app/javascript/gabsocial/locales/ms.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/sl.json b/app/javascript/gabsocial/locales/sl.json index dcd88c14..6d7ee45c 100644 --- a/app/javascript/gabsocial/locales/sl.json +++ b/app/javascript/gabsocial/locales/sl.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/ta.json b/app/javascript/gabsocial/locales/ta.json index bf26aaf7..6813c439 100644 --- a/app/javascript/gabsocial/locales/ta.json +++ b/app/javascript/gabsocial/locales/ta.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", diff --git a/app/javascript/gabsocial/locales/th.json b/app/javascript/gabsocial/locales/th.json index 268d0a7a..5fbbba05 100644 --- a/app/javascript/gabsocial/locales/th.json +++ b/app/javascript/gabsocial/locales/th.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "แฮชแท็ก", "search_popout.tips.status": "สถานะ", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "ผู้ใช้", "search_results.accounts": "ผู้คน", "search_results.hashtags": "แฮชแท็ก", diff --git a/app/javascript/gabsocial/locales/tr.json b/app/javascript/gabsocial/locales/tr.json index e6585083..c03f2411 100644 --- a/app/javascript/gabsocial/locales/tr.json +++ b/app/javascript/gabsocial/locales/tr.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, boosted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "durum", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "kullanıcı", "search_results.accounts": "İnsanlar", "search_results.hashtags": "Hashtagler", diff --git a/app/javascript/gabsocial/locales/uk.json b/app/javascript/gabsocial/locales/uk.json index d4d61042..f97cc36f 100644 --- a/app/javascript/gabsocial/locales/uk.json +++ b/app/javascript/gabsocial/locales/uk.json @@ -307,7 +307,7 @@ "search_popout.tips.full_text": "Simple text returns statuses you have written, favourited, reposted, or have been mentioned in, as well as matching usernames, display names, and hashtags.", "search_popout.tips.hashtag": "hashtag", "search_popout.tips.status": "status", - "search_popout.tips.text": "Simple text returns matching display names, usernames and hashtags", + "search_popout.tips.text": "Simple text returns matching display names, usernames, groups and hashtags", "search_popout.tips.user": "user", "search_results.accounts": "People", "search_results.hashtags": "Hashtags", From 6581ac5af9613682e70601e592bd3768f183db21 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 14 Jan 2020 18:12:55 -0500 Subject: [PATCH 3/8] Updated trend item styles --- app/javascript/styles/gabsocial/components.scss | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/javascript/styles/gabsocial/components.scss b/app/javascript/styles/gabsocial/components.scss index fd83909d..ddf7ad9b 100644 --- a/app/javascript/styles/gabsocial/components.scss +++ b/app/javascript/styles/gabsocial/components.scss @@ -4625,14 +4625,20 @@ noscript { text-overflow: ellipsis; white-space: nowrap; + span { + text-decoration: none; + } + strong { - font-weight: 500; + color: $primary-text-color; + font-weight: 600; + text-decoration: none; } a { color: $darker-text-color; text-decoration: none; - font-size: 14px; + font-size: 16px; font-weight: 500; display: block; overflow: hidden; @@ -5198,6 +5204,7 @@ noscript { white-space: nowrap; max-width: 1200px; margin: 0 auto; + height: 32px; } &__type-filters-tabs { From 3126ba8b3c3dcc7d1e9cc5e83a681470234e69e4 Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 14 Jan 2020 18:13:05 -0500 Subject: [PATCH 4/8] Added search_for function on group --- app/models/group.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/models/group.rb b/app/models/group.rb index 1b03b569..c13519cd 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -43,6 +43,17 @@ class Group < ApplicationRecord before_destroy :clean_feed_manager after_create :add_owner_to_accounts + class << self + def search_for(term, limit = 100, offset = 0) + pattern = sanitize_sql_like(term.strip) + '%' + + Group.where('lower(title) like lower(?) AND is_archived=false', pattern) + .order(:title) + .limit(limit) + .offset(offset) + end + end + private def add_owner_to_accounts From 81b2c009a1d5e5b84c8609716b78cd375d66e18d Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 14 Jan 2020 18:13:30 -0500 Subject: [PATCH 5/8] Added groups to search results --- app/javascript/gabsocial/reducers/search.js | 1 + app/models/search.rb | 2 +- app/serializers/rest/search_serializer.rb | 1 + app/serializers/rest/v2/search_serializer.rb | 1 + app/services/search_service.rb | 9 +++++++++ 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/javascript/gabsocial/reducers/search.js b/app/javascript/gabsocial/reducers/search.js index ec3191de..163b47a8 100644 --- a/app/javascript/gabsocial/reducers/search.js +++ b/app/javascript/gabsocial/reducers/search.js @@ -43,6 +43,7 @@ export default function search(state = initialState, action) { accounts: ImmutableList(action.results.accounts.map(item => item.id)), statuses: ImmutableList(action.results.statuses.map(item => item.id)), hashtags: fromJS(action.results.hashtags), + groups: fromJS(action.results.groups), })).set('submitted', true); default: return state; diff --git a/app/models/search.rb b/app/models/search.rb index 676c2a7f..fe5e1eb1 100644 --- a/app/models/search.rb +++ b/app/models/search.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true class Search < ActiveModelSerializers::Model - attributes :accounts, :statuses, :hashtags + attributes :accounts, :statuses, :hashtags, :groups end diff --git a/app/serializers/rest/search_serializer.rb b/app/serializers/rest/search_serializer.rb index 157f543a..769b0700 100644 --- a/app/serializers/rest/search_serializer.rb +++ b/app/serializers/rest/search_serializer.rb @@ -5,6 +5,7 @@ class REST::SearchSerializer < ActiveModel::Serializer has_many :accounts, serializer: REST::AccountSerializer has_many :statuses, serializer: REST::StatusSerializer + has_many :groups, serializer: REST::GroupSerializer def hashtags object.hashtags.map(&:name) diff --git a/app/serializers/rest/v2/search_serializer.rb b/app/serializers/rest/v2/search_serializer.rb index cdb6b3a5..61c531ea 100644 --- a/app/serializers/rest/v2/search_serializer.rb +++ b/app/serializers/rest/v2/search_serializer.rb @@ -4,4 +4,5 @@ class REST::V2::SearchSerializer < ActiveModel::Serializer has_many :accounts, serializer: REST::AccountSerializer has_many :statuses, serializer: REST::StatusSerializer has_many :hashtags, serializer: REST::TagSerializer + has_many :groups, serializer: REST::GroupSerializer end diff --git a/app/services/search_service.rb b/app/services/search_service.rb index e0da61da..50bd0543 100644 --- a/app/services/search_service.rb +++ b/app/services/search_service.rb @@ -16,6 +16,7 @@ class SearchService < BaseService results[:accounts] = perform_accounts_search! if account_searchable? results[:statuses] = perform_statuses_search! if full_text_searchable? results[:hashtags] = perform_hashtags_search! if hashtag_searchable? + results[:groups] = perform_groups_search! end end end @@ -32,6 +33,14 @@ class SearchService < BaseService ) end + def perform_groups_search! + Group.search_for( + @query.gsub(/\A#/, ''), + @limit, + @offset + ) + end + def perform_statuses_search! definition = StatusesIndex.filter(term: { searchable_by: @account.id }) .query(multi_match: { type: 'most_fields', query: @query, operator: 'and', fields: %w(text text.stemmed) }) From 02247354a336b3ac960ffc397b231537ce3aebab Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 14 Jan 2020 18:14:08 -0500 Subject: [PATCH 6/8] Added GroupListItem component --- .../gabsocial/components/group_list_item.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 app/javascript/gabsocial/components/group_list_item.js diff --git a/app/javascript/gabsocial/components/group_list_item.js b/app/javascript/gabsocial/components/group_list_item.js new file mode 100644 index 00000000..59cee23b --- /dev/null +++ b/app/javascript/gabsocial/components/group_list_item.js @@ -0,0 +1,40 @@ +import React from 'react'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import ImmutablePureComponent from 'react-immutable-pure-component'; +import { defineMessages, injectIntl } from 'react-intl'; +import { Link } from 'react-router-dom'; +import { shortNumberFormat } from '../utils/numbers'; + +const messages = defineMessages({ + members: { id: 'groups.card.members', defaultMessage: 'Members' }, +}); + +export default +@injectIntl +class GroupListItem extends ImmutablePureComponent { + static propTypes = { + group: ImmutablePropTypes.map.isRequired, + } + + render() { + const { intl, group } = this.props; + + if (!group) return null; + + return ( +