Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Algolia Instantsearch and autocomplete feature #246

Closed
wants to merge 13 commits into from

Conversation

@sandipbhuyan
Copy link
Collaborator

commented Jul 3, 2018

Resolves #245

@sandipbhuyan sandipbhuyan added the gsoc label Jul 3, 2018

@sandipbhuyan sandipbhuyan requested a review from imphil Jul 3, 2018

@sandipbhuyan sandipbhuyan requested a review from agathver Jul 3, 2018

@sandipbhuyan sandipbhuyan force-pushed the sandipbhuyan:algolia-search branch from bf4eb07 to 7f355d1 Jul 3, 2018

@sandipbhuyan sandipbhuyan changed the title Algolia Instantsearch and autocomplete feature Implement Algolia Instantsearch and autocomplete feature Jul 3, 2018

@@ -45,3 +45,7 @@ parameters:
# Register at https://sentry.io
sentry_dsn: '{{ site_sentry_dsn }}'
sentry_env: '{{ site_sentry_env }}'

# Algolia Configuration

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

not required. We are still debating whether to move into Symfony flex or not

@@ -45,3 +45,7 @@ parameters:
# Register at https://sentry.io
sentry_dsn: '{{ site_sentry_dsn }}'
sentry_env: '{{ site_sentry_env }}'

# Algolia Configuration
env(ALGOLIA_APP_ID): '{{ site_algolia_app_id }}'

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

not required. see above

@@ -8,4 +8,4 @@
# Require confirmation of the email address of newly registered users.
# Requires a working mailer setup. Add SMTP credentials in
# secrets/dev-vagrant.secrets.yml before enabling this setting.
#site_user_email_confirmation_enabled: true
#site_user_email_confirmation_enabled: true

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

Configure your IDE to respect eol settings from .editorconfig. There must be a plugin available

*/
public function normalize(NormalizerInterface $serializer, $format = null, array $context = array())
{
return [

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

👍
This is a nice feature

@@ -124,6 +126,24 @@ public function __construct()
$this->members = new ArrayCollection();
}
/**
* Normalizes the object into an array of scalars|arrays.

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

Use @inheritdoc

@@ -323,6 +325,49 @@ public function __construct()
$this->classifications = new ArrayCollection();
}
/**
* Normalizes the object into an array of scalars|arrays.

This comment has been minimized.

$("#{{ search_query_form.q.vars.id }}").focus();
searchFunctions();
options = {
appId: 'ENTER_APPLICATION_ID',

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

You can transclude the site_algolia_app_id here using twig globals

https://stackoverflow.com/a/8360126/2328165

@@ -0,0 +1,171 @@
function algoliaAutocomplete() {
var client = algoliasearch('ENTER_APPLICATION_ID', 'ENTER_APPLICATION_KEY')

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

Possible approach:
Transclude Algolia settings into window.__algoliaConfig__ in a twig template and utilize it by window.__algoliaConfig__.applicationId

<script>
window.__algoliaConfig__ = {
  applicationId: "{{ algolia_app_id }}"
  // ... more settings
}
</script>
var organization = client.initIndex('organization');
var user = client.initIndex('user');

autocomplete('#search-form-input', {debug:true}, [

This comment has been minimized.

Copy link
@agathver

agathver Jul 4, 2018

Collaborator

Make configurable through a parameter

@sandipbhuyan sandipbhuyan force-pushed the sandipbhuyan:algolia-search branch 4 times, most recently from a7baec5 to a974348 Jul 7, 2018

@sandipbhuyan sandipbhuyan force-pushed the sandipbhuyan:algolia-search branch from a974348 to a57e1b8 Jul 10, 2018

@imphil
Copy link
Contributor

left a comment

Thanks @sandipbhuyan! I had an initial look at the code but didn't run it yet, I'll do that later today and get back with more comments.

@@ -49,3 +49,4 @@ parameters:
# Algolia Configuration
env(ALGOLIA_APP_ID): '{{ site_algolia_app_id }}'
env(ALGOLIA_API_KEY): '{{ site_algolia_api_key }}'
ALGOLIA_SEARCH_KEY: '{{ site_algolia_search_key }}'

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

No env() needed on that one? Why? Can we keep the two consistent?

This comment has been minimized.

Copy link
@agathver

agathver Jul 11, 2018

Collaborator

env() is used to substitute for a missing env var, where it is used in getenv. This is supposed to be used directly on the front end.


# Assetic Configuration
assetic:
debug: "%kernel.debug%"
use_controller: false
bundles:
- LibrecoresProjectRepoBundle
- LibrecoresSiteBundle

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

How is this change related to the PR? If it's not related please open a separate PR to keep this one focused.

This comment has been minimized.

Copy link
@sandipbhuyan

sandipbhuyan Jul 10, 2018

Author Collaborator

The algolia autocomplete feature is going to be at home page which is at LibrecoresSiteBundle that's why I have added this bundle here

->getRepository('LibrecoresProjectRepoBundle:Organization')
->findByFragment($searchQuery->getQ());
}
// If searchType is null

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

... then what? How about "search projects by default" (or remove the comment altogether)

</span>
</div>
<hr/>
{% endverbatim %}

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

The indentation of this block got messed up a bit.

$(function() {
$("#{{ search_query_form.q.vars.id }}").focus();
});
{# do not use autofocus attribute to work around FF bug 712130 (FOUC) #}

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

is this comment still relevant?

<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}

{% block pagejs %}
{# do not use autofocus attribute to work around FF bug 712130 (FOUC) #}

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

Place this comment closer to the code it actually describes, please.

<h2><a href="/{{ name }}">{{{ _highlightResult.displayName.value }}}</a></h2>
<div>{{{ _highlightResult.name.value }}}</div>
<hr/>
{% endverbatim %}

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

the indentation got messed up.

joined on {{{ createdAt.date }}}
</i></div>
<hr/>
{% endverbatim %}

This comment has been minimized.

Copy link
@imphil

imphil Jul 10, 2018

Contributor

the indentation got messed up.

@agathver

This comment has been minimized.

Copy link
Collaborator

commented Jul 12, 2018

Barring a few indent errors, this is good to go!

@sandipbhuyan sandipbhuyan force-pushed the sandipbhuyan:algolia-search branch from d98ec34 to 01759e1 Jul 12, 2018

Implement searching through classification feature, Make algolia indi…
…ces settings configuration files

The categoric hierarchy level is indexed under project entity and being sent to algolia, Now a user can configure or modify the algolia settings through the configuration files andimplement hierachichal search menu in instantsearch
@sandipbhuyan

This comment has been minimized.

Copy link
Collaborator Author

commented Jul 31, 2018

#248 and #249 resolved

@imphil

This comment has been minimized.

Copy link
Contributor

commented Aug 1, 2018

squashed and merged in 550622e

@imphil imphil closed this Aug 1, 2018

Improve the LibreCores.org in terms of discoverability automation moved this from Review to Done Aug 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
3 participants
You can’t perform that action at this time.