Yesod 1.2 Authorization - haskell

I'm working on a Yesod-based website. I had been reading the Yesod book online, and I ran into an inconvenient discrepancy (Yes, I know the book is out of date). Usually I can just Google around these discrepancies, but I don't know where to start.
In particular, I'm trying to set up authorization for some routes. The Yesod book says I should define
instance YesodAuth MyApp where
isAuthorized RouteR _ = <check for stuff and return an authorization token>
But that method is not defined in Yesod.Auth.YesodAuth anymore. What is the current state of the craft?

I see you already found the answer, but in the future, you may be able to find it more quickly by using a more specialized tool than Google. Probably the best Haskell API search engine for Yesod is this one: FPComplete's Hoogle Search.
There's also the Haskell.org Hoogle Search
And Holumbus's Hayoo Search, at least when it is up. It's down as I'm typing this, but it should return at some point.
Both the Hoogle and Hayoo allow you to search both on function/package names as well as on function signatures, so if you know what the function you want does but not what it's called you can still search for it! They do vary a bit on how they interpret the type you give them and what packages they search by default, so you may want to keep both links handy and try queries on both.
Note that the FPComplete Hoogle searches in all of the packages it indexes by default, while the main Haskell.org one will only search in Haskell Platform packages by default, but will also search in other packages on Hackage if you explicitly ask it to by adding +<package name> to your query string, e.g. isAuthorized +yesod-core for your question.
Based on this haskell-cafe thread the Haskell.org Hoogle search engine will probably have this restriction lifted at some point, but meanwhile you should probably use one of the alternatives I listed if you don't know the package name and you don't think what you're searching for is in the Haskell Platform.
Finally, you can download the hoogle code from Hackage (via cabal install) and it will give you a local package index that you can query from the command line or integrate into an editor. This can be pretty handy for quick look-up of a function that you know exists in the Platform but you can't quite remember the details of.

Okay, I found the method. It is in the Yesod type class now.

Related

Implementing a docs search for multiple docs sites

We have many different documentation sites and I would like to search a keyword across all of these sites. How can I do that?
I already thought about implementing a simple web scraper, but this seems like a very ugly solution.
An alternative may be to use Elasticsearch and somehow point it to the different doc repos.
Are there better suggestions?
Algolia is the absolute best solution that I can think of. There's also Typesense and Meilisearch of course.
Algolia is meant specifically for situations like yours, so it even comes with a crawler.
https://www.algolia.com/products/search-and-discovery/crawler/
https://www.algolia.com/
https://typesense.org/
https://www.meilisearch.com/
Here's a fun page comparing them (probably a little biased in Typesense's favor)
https://typesense.org/typesense-vs-algolia-vs-elasticsearch-vs-meilisearch/
Here are some example sites that use Algolia Search
https://developers.cloudflare.com/
https://getbootstrap.com/docs/5.1/getting-started/introduction/
https://reactjs.org/
https://hn.algolia.com/
If you personally are just trying to search for a keyword, as long as they're indexed by Google, you can always search with the format site:{domain} "keyword"
You can checkout Meilisearch for your use case. Meilisearch is a Rust based and open sourced search engine.
Meilisearch comes with a document scraper tool ( https://github.com/meilisearch/docs-scraper ) that can scrape content and then also index it.
While using it you need to define what exact content you are searching for in the configuration file for the scraper tool. And then you can run the tool using Docker.

Language Server Protocol: find all methods

I am exploring LSP to get a feel for what it can do. Most things are pretty obvious, completion, find references, etc. I've been told that LSP will allow me to find all functions/methods in a given language but I've yet to figure out how that might be possible. After much searching and doing some investigations with a few languages in Emacs, I am starting to doubt that it is even possible. Am I missing something? Is it possible with a given LSP instance to find all methods by file, line and column location?
You would use the workspace symbol functionality. If you look in the "vscode-languageserver-protocol project, it says:
/**
A request to list project-wide symbols matching the query string given
by the WorkspaceSymbolParams. The response is
of type SymbolInformation[] or a Thenable that
resolves to such.
*/
LSP Documentation on Workspace
If you're using a client, you'd find the method that calls that. In the project I'm trying to do, using the Brackets.io client, the method is
client.requestSymbolsForDocument
for example. If you're writing your own client, then you'd implement the appropriate method. You may get some extra help here. For all functions in the current document, then look at document symbols.
That's about as I know, I'm also learning.
Good luck.
Sethmo

How to search newsgroups in gnus

I have gnus working for multiple email addresses with searching via
(nnir-search-engine imap)
I have newsgroup reading setup and working fine too, however, I have never been able to get searching in newsgroups working even though I have
(setq gnus-select-method '(nntp "news.gmane.org"
(nnir-search-engine gmane)))
With the latter, with my cursor on a gname newsgroup, I expect to be able to do G G enter a search and have it return a list of hits as it does with imap search. Instead, I get the message
Contacting host: search.gmane.org:80
open-network-stream: search.gmane.org/80 nodename nor servname provided, or not known
in my mini and Messages buffers.
Any idea what is going on and how to rectify this?
One thought I had was perhaps that I needed to utilize gnu-agent and an agent category to allow me to download messages via J s (all of which I did set up, but haven't fully understood where it is saving, etc.).
Everything else works great in gnus, I just want to search newsgroups too in gnus.
p.s. I have downloaded Unison, which is quite nice and free now, and it can do what I need, but I still hope to do it in gnus.
The gmane search engine does not work because gmane has undergone some changes: gmane search has gone bust for the last two years (?) or so, ever since Lars decided that he was not going to continue with gmane. Although the people who took over brought the nntp service back, search is still missing.
There are other search engines however: the gnus manual lists swish++, swish-e, namazu, notmuch and hyrex (obsolete). I have no idea how well each works: I do know that they require configuration (imap search and gmane search (before it broke), worked right out of the box).
The doc has very few details on the rest, but it does describe how to set up namazu: it requires that you create and maintain index files, presumably indexing a set of local files. The doc's emphasis is on indexing local email, but presumably it would work similarly for downloaded local news articles.

Can Drupal's search module search for a substring? (Partial Search)

Drupal's core search module, only searches for keywords, e.g. "sandwich". Can I make it search with a substring e.g. "sandw" and return my sandwich-results?
Maybe there is a plugin that does that?
The most direct module for it is probably Fuzzy Search. I have not tried it. If you have more advanced search needs on a small to medium sized site, Search Lucene API is a fine solution. For a larger site, or truly advanced needs, Solr is the premiere solution.
Recently I made a patch for Drupal's core search module to provide it with partial search (aka n-gram searches) ability. This is tested against Drupal 6.15 & 6.16 releases. You might want to read about patching.
On the other hand you can make use of Apache Solr Search Integration, Search Lucene API modules or other 3rd-party search solutions which takes more time to implement.
PorterStemmer module has its own different story in which you might be interested, too.
Yes. Fuzzy Search (module) does it. https://drupal.org/project/fuzzysearch
Drupal Finder does it somehow, namely: it has an autosuggest feature, so if You start typich sand it should suggest You a node containing sandwich.

Grails (On App Engine) - Basic Search Functionality

What I need is Search Scaffolding but in its absence I was wondering if you could point me in the direction of any really simple examples for adding search to a domain.
I can't use the searchable plugin as it conflicts with the AppEngine plugin (Unless someone has got this to work?). I just need to be able to filter the scaffold list to contain only the results which match the query. I don't need a pure text box solution, I imagine it too look exactly like the 'create' form except when you submit you get a list of matching objects.
I hope this makes sense, thanks in advance!
Gav
Google App Engine - Full Text Search

Resources