Skip to content

Conversation

@green-coder
Copy link
Contributor

References the issue #186

This PR is not ready to be merged yet. Please provide feedback on the code change.

The search page still need a link for the user to go back to the home page.

Vincent Cantin added 3 commits November 18, 2018 16:25
Now we need to adapt the services to work correctly with the search and suggestion URLs.
… into account, adjusted the javascript to work with an initial value in the search form.
@green-coder
Copy link
Contributor Author

green-coder commented Nov 19, 2018

The PR is now ready to be reviewed and merged if appropriate.

I left the suggestion endpoint unfinished, it will make more sense to implement it once we have a better way to do the search.

@martinklepsch martinklepsch merged commit 67f0c80 into cljdoc:master Nov 19, 2018
Copy link
Member

@martinklepsch martinklepsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing Vincent! Merged this just now but here's some feedback. Feel free to push any adjustments straight to master.

</Url>
<Url type="application/x-suggestions+json" template="https://cljdoc.org/suggest">
<Param name="q" value="{searchTerms}"/>
</Url>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it perhaps make sense to comment that out for now to avoid unnecessary requests?

Copy link
Contributor Author

@green-coder green-coder Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to have the suggestion part in the descriptor from the beginning because once the users click on the ➕ icon to adopt the custom search engine, the descriptor used by the browser may be a copy and may not automatically update with the website later.

As for the server load concern, the user seems to need to activate the suggestion options in the browser's preference tab in order to use it. We can expect only a small minority to choose cljdoc instead of google as their primary search engine, so that should normally not be a problem.

image

Let me know if you still prefer that I remove it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the context, makes sense 👍


;; Open Search
[:link {:rel "search" :type "application/opensearchdescription+xml"
:href "/opensearch.xml" :title "Cljdoc"}]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cljdoc (all lower case) would be more "on brand" 😄

([] (search-form ""))
([search-terms]
[:div.w-90.mb4
[:div#cljdoc-search {:initial-value search-terms}]]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe data-initial-value is more appropriate here, but again, not very important.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;; See https://developer.mozilla.org/en-US/docs/Web/OpenSearch for more information.
(defn suggest-api
[context]
(assoc context :response {:status 200
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe sending a 404 here with no content would be more appropriate until this is implemented?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I found the code 501 "not implemented" that fits better, will use it instead.

@green-coder green-coder deleted the open-search branch November 20, 2018 04:45
@martinklepsch
Copy link
Member

Thanks for the adjustments!🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants