Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Hackage spice #120

Closed
wants to merge 2 commits into from
Closed

Hackage spice #120

wants to merge 2 commits into from

Conversation

nomeata
Copy link
Contributor

@nomeata nomeata commented Feb 3, 2013

This is a code preview, the data source is not yet online (waiting for sol/hackage-jsonp#3). Then, this gives a nice short overview about the hackage package of the given name.

BTW, is there a way to avoid the „more at ...“ link and format that part directly?

@jagtalon
Copy link
Member

jagtalon commented Feb 6, 2013

Got it! Do you have a sample JSON file for testing?

@nomeata
Copy link
Contributor Author

nomeata commented Feb 6, 2013

Eh, sure:

{"condLibrary":{"condTreeComponents":[],"condTreeConstraints":[["base",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"4.3"},{"LaterVersion":"4.3"}]},{"EarlierVersion":"5"}]}],["yesod-core",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.1.5"},{"LaterVersion":"1.1.5"}]},{"EarlierVersion":"1.2"}]}],["yesod-auth",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.1"},{"LaterVersion":"1.1"}]},{"EarlierVersion":"1.2"}]}],["yesod-json",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.1"},{"LaterVersion":"1.1"}]},{"EarlierVersion":"1.2"}]}],["yesod-persistent",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.1"},{"LaterVersion":"1.1"}]},{"EarlierVersion":"1.2"}]}],["yesod-form",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.1"},{"LaterVersion":"1.1"}]},{"EarlierVersion":"1.3"}]}],["yesod-default",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.1.3"},{"LaterVersion":"1.1.3"}]},{"EarlierVersion":"1.2"}]}],["monad-control",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.3"},{"LaterVersion":"0.3"}]},{"EarlierVersion":"0.4"}]}],["transformers",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.2.2"},{"LaterVersion":"0.2.2"}]},{"EarlierVersion":"0.4"}]}],["wai",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.3"},{"LaterVersion":"1.3"}]},{"EarlierVersion":"1.4"}]}],["wai-extra",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.3"},{"LaterVersion":"1.3"}]},{"EarlierVersion":"1.4"}]}],["hamlet",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.1"},{"LaterVersion":"1.1"}]},{"EarlierVersion":"1.2"}]}],["shakespeare-js",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.0.2"},{"LaterVersion":"1.0.2"}]},{"EarlierVersion":"1.2"}]}],["shakespeare-css",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.0"},{"LaterVersion":"1.0"}]},{"EarlierVersion":"1.1"}]}],["warp",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.3"},{"LaterVersion":"1.3"}]},{"EarlierVersion":"1.4"}]}],["blaze-html",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.5"},{"LaterVersion":"0.5"}]},{"EarlierVersion":"0.6"}]}],["blaze-markup",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.5.1"},{"LaterVersion":"0.5.1"}]},{"EarlierVersion":"0.6"}]}],["aeson",{"AnyVersion":[]}]],"condTreeData":{"libExposed":true,"exposedModules":[["Yesod"]],"libBuildInfo":{"defaultLanguage":null,"installIncludes":[],"extraLibs":[],"options":[[{"GHC":[]},["-Wall"]]],"oldExtensions":[],"cSources":[],"targetBuildDepends":[],"includes":[],"frameworks":[],"ghcProfOptions":[],"buildable":true,"defaultExtensions":[],"extraLibDirs":[],"customFieldsBI":[],"otherExtensions":[],"pkgconfigDepends":[],"cppOptions":[],"ldOptions":[],"ccOptions":[],"includeDirs":[],"otherModules":[],"otherLanguages":[],"buildTools":[],"ghcSharedOptions":[],"hsSourceDirs":[]}}},"condTestSuites":[],"condExecutables":[["yesod-ghc-wrapper",{"condTreeComponents":[],"condTreeConstraints":[["base",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"4"},{"LaterVersion":"4"}]},{"EarlierVersion":"5"}]}],["Cabal",{"AnyVersion":[]}]],"condTreeData":{"buildInfo":{"defaultLanguage":null,"installIncludes":[],"extraLibs":[],"options":[],"oldExtensions":[],"cSources":[],"targetBuildDepends":[],"includes":[],"frameworks":[],"ghcProfOptions":[],"buildable":true,"defaultExtensions":[],"extraLibDirs":[],"customFieldsBI":[],"otherExtensions":[],"pkgconfigDepends":[],"cppOptions":[],"ldOptions":[],"ccOptions":[],"includeDirs":[],"otherModules":[],"otherLanguages":[],"buildTools":[],"ghcSharedOptions":[],"hsSourceDirs":[]},"exeName":"","modulePath":"ghcwrapper.hs"}}],["yesod-ld-wrapper",{"condTreeComponents":[],"condTreeConstraints":[["base",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"4"},{"LaterVersion":"4"}]},{"EarlierVersion":"5"}]}],["Cabal",{"AnyVersion":[]}]],"condTreeData":{"buildInfo":{"defaultLanguage":null,"installIncludes":[],"extraLibs":[],"options":[],"oldExtensions":[],"cSources":[],"targetBuildDepends":[],"includes":[],"frameworks":[],"ghcProfOptions":[],"buildable":true,"defaultExtensions":[],"extraLibDirs":[],"customFieldsBI":[],"otherExtensions":[],"pkgconfigDepends":[],"cppOptions":["-DLDCMD"],"ldOptions":[],"ccOptions":[],"includeDirs":[],"otherModules":[],"otherLanguages":[],"buildTools":[],"ghcSharedOptions":[],"hsSourceDirs":[]},"exeName":"","modulePath":"ghcwrapper.hs"}}],["yesod-ar-wrapper",{"condTreeComponents":[],"condTreeConstraints":[["base",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"4"},{"LaterVersion":"4"}]},{"EarlierVersion":"5"}]}],["Cabal",{"AnyVersion":[]}]],"condTreeData":{"buildInfo":{"defaultLanguage":null,"installIncludes":[],"extraLibs":[],"options":[],"oldExtensions":[],"cSources":[],"targetBuildDepends":[],"includes":[],"frameworks":[],"ghcProfOptions":[],"buildable":true,"defaultExtensions":[],"extraLibDirs":[],"customFieldsBI":[],"otherExtensions":[],"pkgconfigDepends":[],"cppOptions":["-DARCMD"],"ldOptions":[],"ccOptions":[],"includeDirs":[],"otherModules":[],"otherLanguages":[],"buildTools":[],"ghcSharedOptions":[],"hsSourceDirs":[]},"exeName":"","modulePath":"ghcwrapper.hs"}}],["yesod",{"condTreeComponents":[[{"Var":{"OS":{"Windows":[]}}},{"condTreeComponents":[],"condTreeConstraints":[],"condTreeData":{"buildInfo":{"defaultLanguage":null,"installIncludes":[],"extraLibs":[],"options":[],"oldExtensions":[],"cSources":[],"targetBuildDepends":[],"includes":[],"frameworks":[],"ghcProfOptions":[],"buildable":true,"defaultExtensions":[],"extraLibDirs":[],"customFieldsBI":[],"otherExtensions":[],"pkgconfigDepends":[],"cppOptions":["-DWINDOWS"],"ldOptions":[],"ccOptions":[],"includeDirs":[],"otherModules":[],"otherLanguages":[],"buildTools":[],"ghcSharedOptions":[],"hsSourceDirs":[]},"exeName":"","modulePath":""}},null]],"condTreeConstraints":[["base",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"4.3"},{"LaterVersion":"4.3"}]},{"EarlierVersion":"5"}]}],["ghc",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"7.0.3"},{"LaterVersion":"7.0.3"}]},{"EarlierVersion":"7.8"}]}],["ghc-paths",{"UnionVersionRanges":[{"ThisVersion":"0.1"},{"LaterVersion":"0.1"}]}],["parsec",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"2.1"},{"LaterVersion":"2.1"}]},{"EarlierVersion":"4"}]}],["text",{"UnionVersionRanges":[{"ThisVersion":"0.11"},{"LaterVersion":"0.11"}]}],["shakespeare-text",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.0"},{"LaterVersion":"1.0"}]},{"EarlierVersion":"1.1"}]}],["shakespeare",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.0.2"},{"LaterVersion":"1.0.2"}]},{"EarlierVersion":"1.1"}]}],["shakespeare-js",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.0.2"},{"LaterVersion":"1.0.2"}]},{"EarlierVersion":"1.2"}]}],["shakespeare-css",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"1.0.2"},{"LaterVersion":"1.0.2"}]},{"EarlierVersion":"1.1"}]}],["bytestring",{"UnionVersionRanges":[{"ThisVersion":"0.9.1.4"},{"LaterVersion":"0.9.1.4"}]}],["time",{"UnionVersionRanges":[{"ThisVersion":"1.1.4"},{"LaterVersion":"1.1.4"}]}],["template-haskell",{"AnyVersion":[]}],["directory",{"UnionVersionRanges":[{"ThisVersion":"1.0"},{"LaterVersion":"1.0"}]}],["Cabal",{"AnyVersion":[]}],["unix-compat",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.2"},{"LaterVersion":"0.2"}]},{"EarlierVersion":"0.5"}]}],["containers",{"UnionVersionRanges":[{"ThisVersion":"0.2"},{"LaterVersion":"0.2"}]}],["attoparsec",{"UnionVersionRanges":[{"ThisVersion":"0.10"},{"LaterVersion":"0.10"}]}],["http-types",{"UnionVersionRanges":[{"ThisVersion":"0.7"},{"LaterVersion":"0.7"}]}],["blaze-builder",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.2.1.4"},{"LaterVersion":"0.2.1.4"}]},{"EarlierVersion":"0.4"}]}],["filepath",{"UnionVersionRanges":[{"ThisVersion":"1.1"},{"LaterVersion":"1.1"}]}],["process",{"AnyVersion":[]}],["zlib",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.5"},{"LaterVersion":"0.5"}]},{"EarlierVersion":"0.6"}]}],["tar",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.4"},{"LaterVersion":"0.4"}]},{"EarlierVersion":"0.5"}]}],["system-filepath",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.4"},{"LaterVersion":"0.4"}]},{"EarlierVersion":"0.5"}]}],["system-fileio",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.3"},{"LaterVersion":"0.3"}]},{"EarlierVersion":"0.4"}]}],["unordered-containers",{"AnyVersion":[]}],["yaml",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.8"},{"LaterVersion":"0.8"}]},{"EarlierVersion":"0.9"}]}],["optparse-applicative",{"UnionVersionRanges":[{"ThisVersion":"0.4"},{"LaterVersion":"0.4"}]}],["fsnotify",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.0"},{"LaterVersion":"0.0"}]},{"EarlierVersion":"0.1"}]}],["split",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.2"},{"LaterVersion":"0.2"}]},{"EarlierVersion":"0.3"}]}],["file-embed",{"AnyVersion":[]}],["conduit",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.5"},{"LaterVersion":"0.5"}]},{"EarlierVersion":"0.6"}]}],["resourcet",{"IntersectVersionRanges":[{"UnionVersionRanges":[{"ThisVersion":"0.3"},{"LaterVersion":"0.3"}]},{"EarlierVersion":"0.5"}]}],["base64-bytestring",{"AnyVersion":[]}],["lifted-base",{"AnyVersion":[]}],["http-reverse-proxy",{"UnionVersionRanges":[{"ThisVersion":"0.1.1"},{"LaterVersion":"0.1.1"}]}],["network",{"AnyVersion":[]}],["http-conduit",{"AnyVersion":[]}],["network-conduit",{"AnyVersion":[]}],["project-template",{"UnionVersionRanges":[{"ThisVersion":"0.1.1"},{"LaterVersion":"0.1.1"}]}]],"condTreeData":{"buildInfo":{"defaultLanguage":null,"installIncludes":[],"extraLibs":[],"options":[[{"GHC":[]},["-Wall","-threaded"]]],"oldExtensions":[],"cSources":[],"targetBuildDepends":[],"includes":[],"frameworks":[],"ghcProfOptions":[],"buildable":true,"defaultExtensions":[],"extraLibDirs":[],"customFieldsBI":[],"otherExtensions":[],"pkgconfigDepends":[],"cppOptions":[],"ldOptions":[],"ccOptions":[],"includeDirs":[],"otherModules":[["Scaffolding","Scaffolder"],["Devel"],["Build"],["GhcBuild"],["Keter"],["AddHandler"],["Paths_yesod"],["Options"]],"otherLanguages":[],"buildTools":[],"ghcSharedOptions":[],"hsSourceDirs":[]},"exeName":"","modulePath":"main.hs"}}]],"condBenchmarks":[],"packageDescription":{"homepage":"http://www.yesodweb.com/","customFieldsPD":[],"testSuites":[],"license":"MIT","executables":[],"specVersionRaw":{"Right":{"UnionVersionRanges":[{"ThisVersion":"1.6"},{"LaterVersion":"1.6"}]}},"category":"Web, Yesod","extraSrcFiles":["input/*.cg","hsfiles/mongo.hsfiles","hsfiles/mysql.hsfiles","hsfiles/postgres.hsfiles","hsfiles/simple.hsfiles","hsfiles/sqlite.hsfiles"],"author":"Michael Snoyman <michael@snoyman.com>","copyright":"","bugReports":"","package":{"pkgVersion":"1.1.8","pkgName":"yesod"},"dataDir":"","pkgUrl":"","library":null,"benchmarks":[],"buildType":{"Simple":[]},"maintainer":"Michael Snoyman <michael@snoyman.com>","extraTmpFiles":[],"sourceRepos":[{"repoBranch":null,"repoType":{"Git":[]},"repoLocation":"https://github.com/yesodweb/yesod","repoModule":null,"repoTag":null,"repoSubdir":null,"repoKind":{"RepoHead":[]}}],"description":"A RESTful web framework with strong compile-time guarantees of correctness. It also affords space efficient code, highly concurrent loads, and portability to many deployment backends (via the wai package), from CGI to stand-alone serving.\n\nYesod also focuses on developer productivity. Yesod integrates well with tools for all your basic web development (wai, persistent, and shakespeare/hamlet)\n\nThe Yesod documentation site <http://www.yesodweb.com/> has much more information, including on the supporting packages mentioned above.","buildDepends":[],"testedWith":[],"licenseFile":"LICENSE","dataFiles":[],"stability":"Stable","synopsis":"Creation of type-safe, RESTful web applications."},"genPackageFlags":[]}

but I hope that sol/hackage-jsonp#3 gets applied soon, then you can test it with the real deal.

@achudnov
Copy link

Will this include API search eventually? What I mean is the ability to search individual functions/datatypes/typeclasses by name or, maybe even, by type -- not only package names. For example like in http://www.haskell.org/hoogle/ or http://holumbus.fh-wedel.de/hayoo/hayoo.html ?

@nomeata
Copy link
Contributor Author

nomeata commented Feb 19, 2013

Not this web service – but if you want API search, then just use the hayoo spice..?

@nomeata
Copy link
Contributor Author

nomeata commented Feb 25, 2013

Ok, the service is live, so from my side this pull request can be merged and deployed.

@jagtalon
Copy link
Member

@nomeata I think it would be better if the plugin would let users search in a case-insensitive way. The plugin that you submitted doesn't trigger with ac-boolean or hpath:
Screenshot from 2013-02-25 15:41:50

But it triggers with AC-Boolean or HPath:
Screenshot from 2013-02-25 15:42:03

Maybe instead of calling one JSON, we could call two JSONs. If you take a look at the Twitter plugin, you'd see that different sub-plugins can function as one. I was thinking along the lines of making a sub-plugin that calls latest-package-versions.jsonp like so:

spice to => 'http://typeful.net/~tbot/hackage/latest-package-versions.jsonp';

Why? Well, because it has a record of all the packages (I think). Your spice.js would then pre-digest your data, masticating and making it more palatable for your second sub-plugin (you call the second sub-plugin via nrj):

...
root.hackagePackageVersionsCallback = function(packages) {
    // Remove the trigger word.
    var query = DDG.get_query().replace(/(^|\s)(hackage|haskell)($|\s)/, '');
    // Convert multiple spaces into a single one.
    query = query.replace(/[ ]+/, ' ');
    // Remove trailing / leading spaces.
    query = query.replace(/^\s+|\s+$/, '');
    // Convert to lowercase.
    query = query.toLowerCase();

    var hasOwn = ({}).hasOwnProperty;
    var all_packages = {};

    // Key gets the lowercase, and the value gets the unmodified string. 
    for(var normal_case in packages) {
        if(hasOwn.call(packages, normal_case)) {
            all_packages[normal_case.toLowerCase()] = normal_case;
        }
    }

    // If the query exists in the dictionary, call Hackage::PackageDetails.
    if(all_packages[query.toLowerCase()]) {
        nrj("/js/spice/hackage/package_details/" + all_packages[query.toLowerCase()]);
    }
};

root.hackageDataCallback = function(re) { ... };

If you look closely, you'd see a function called nrj. This is in charge of calling the second sub-plugin; your original plugin which has this:

spice to => 'http://www.typeful.net/~tbot/hackage/packages/$1/$1.jsonp';

To summarize the relationship between the two plugins:

  1. User will search for "hackage ac-boolean."
  2. The plugin will call Mr. JSON One (http://typeful.net/~tbot/hackage/latest-package-versions.jsonp), process it, and call the second plugin by using nrj.
  3. The plugin will call Mr. JSON Two (http://www.typeful.net/~tbot/hackage/packages/$1/$1.jsonp), process it, and display the results by calling nra.

@nomeata
Copy link
Contributor Author

nomeata commented Feb 26, 2013

Sounds feasible. Can we still get this version live first, or is this a hard requirement? I’m very much more motivated to work on code that is in use than code that just sits in a pull request.

@jagtalon
Copy link
Member

@nomeata It's not really a hard requirement, but people might not actually see the ZCI because the person might have entered the wrong case. I'll make a few modifications first before it can go live.

@jagtalon
Copy link
Member

What do you think of this?

Selection_004

It was modeled after Hayoo!

Selection_005

Should be live in a few days. 👍

Thanks for contributing!

@jagtalon jagtalon closed this Feb 27, 2013
@nomeata
Copy link
Contributor Author

nomeata commented Feb 27, 2013

Cool, thanks!

I would not worry too much about cases, despite the first few entries on the list, the large majority of packages have lowercase-only names.

@jagtalon
Copy link
Member

No problem!

@nomeata
Copy link
Contributor Author

nomeata commented Mar 11, 2013

What’s the status of this? When will be live?

@jagtalon
Copy link
Member

Hi @nomeata. There's just a bit of a problem loading the JSON. https://jagtalon.duckduckgo.com/js/spice/hackage/package_details/GoogleChart shouldn't redirect, to http://typeful.net/~tbot/hackage/packages/GoogleChart/GoogleChart.json.

We're trying to fix that.

@jagtalon
Copy link
Member

@nomeata Got it. Turns out that www.typeful.net redirects to typeful.net.

@jagtalon
Copy link
Member

Search Haskell packages using the Hackage plugin thanks to (github.com/nomeata) duckduckgo.com/?q=hackage+wea…

— DuckDuckHack (@DuckDuckHack) March 14, 2013
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

@nomeata
Copy link
Contributor Author

nomeata commented Mar 14, 2013

Great, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants