npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

acdh-noske-search

v0.1.4

Published

Search Interface for Noske

Downloads

249

Readme

ACDH Noske Search UI

This is a simple search UI for the ACDH Noske project. The search client is build with Hey-Api OpenAPI client generator and using acdh-oeaw/noske-ubi9@yaml.

Installation

npm i acdh-noske-search

You can also include the Package via CDN:

<script type="module">
  import { NoskeSearch } from "https://cdn.jsdelivr.net/npm/acdh-noske-search/dist/index.js";
  const search = new NoskeSearch({container: "noske-search"});

  search.stats({...});
</script>

Usage

import { NoskeSearch } from 'acdh-noske-search';
const search = new NoskeSearch({container: "noske-search"}: Options);

search.search({
  client: {
    base: "https://<your-api-endpoint>",
    corpname: "your coprus name",
    attrs: "word,id",
    structs: "doc,docTitle,head,p,imprimatur,list",
    refs: "doc.id,doc.corpus,docTitle.id,p.id,head.id,imprimatur.id,list.id",
  },
  hits: {
    id: "hitsbox",
    css: {
      table: "table-auto",
    }
  },
  pagination: {
    id: "noske-pagination",
  },
  searchInput: {
    id: "noske-input",
  },
  stats: {
    id: "noske-stats",
  },
}: Search);

Add the following HTML to your page:

  • the noske-search div is the container for the search interface. The Container ID is passed to the NoskeSearch constructor and defaults to noske-search.
  • the hitsbox div is the container for the search results. The Container ID is passed to the search method. The ID is required and has not default value.
  • the noske-pagination div is the container for the pagination. The Container ID is passed to the search method. The ID is required and has not default value.
  • the noske-stats div is the container for the search statistics. The Container ID is passed to the search method. The ID is required and has not default value.
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>NoSke Search Interface</title>
  </head>
  <body>
    <div id="noske-search"></div>
    <div id="hitsbox"></div>
    <div>
      <div id="noske-pagination-test"></div>
      <div id="noske-stats"></div>
    </div>
  </body>
</html>

Types

The NoskeSearch class is a generic class and can be used with custom types. The following types are available: /dist/index.d.ts

type Options = {
  container?: string;
};
type Search = {
  client: Client;
  hits: Hits;
  pagination: Pagination;
  searchInput: SearchInput;
  stats: Stats;
  config: Config;
};
type Config = {
  results?: string;
  customUrl?: string;
  urlparam?: string | boolean;
};
type Client = {
  base: string;
  corpname: string;
  viewmode?: "kwic" | "sen" | undefined;
  attrs?: string;
  format?: "json" | "xml" | "csv" | "tsv" | "txt" | "xls" | undefined;
  structs?: string;
  kwicrightctx?: string;
  kwicleftctx?: string;
  refs?: string;
  pagesize?: number;
  fromp?: number;
};
type SearchInput = {
  id: string;
  placeholder?: string;
  css?: {
    div?: string;
    select?: string;
    input?: string;
  };
};
type Pagination = {
  id: string;
  css?: {
    div?: string;
    select?: string;
  };
};
type Hits = {
  id: string;
  css?: {
    div?: string;
    table?: string;
    thead?: string;
    trHead?: string;
    th?: string;
    tbody?: string;
    trBody?: string;
    td?: string;
    kwic?: string;
    left?: string;
    right?: string;
  };
};
type Stats = {
  id: string;
  label?: string;
  css?: {
    div?: string;
    label?: string;
  };
};