Git Product home page Git Product logo

chemrtron's Introduction

Chemr

A document viewer; fuzzy match incremental search.

Chemrtron is Chemr on Electron.

Features

  • Create index on-demand
  • Same incremental search user interface to all document

Development

Install Electron

Chemrtron is built with Electron.

npm -g install electron-prebuilt

Clone Repository

git clone https://github.com/cho45/Chemrtron.git

Launch

cd Chemrtron
electron .

Indexer

Search Path

  1. ~/.chemer/indexers/*.js
  2. ./indexers/*.js

Indexer definition

id string

Unique id of this indexer.

name string

Display name of this indexer;

item function(item: Object) => Object

Callback of item called when item will be shown.

beforeSearch function(query: string) => string

A function for query translator.

index function(ctx: IndexerContext) : Promise<String>

A function which returns Promise instance of index data.

Index data is following format:

[Search string]\t[URI]
[Search string]\t[URI]
...

Created index data is cached under ./cache as a file.

index context APIs

pushIndex(name, url)

pushIndex add specified index to current context index.

You do not return any value from a promise returned from index(). Chemr will generate index string from current context index.

fetchDocument(url, opts: Object) : Promise<HTMLDocument>

fetchDocument fetches a URL and create HTMLDocument.

Specified URL is loaded to sandboxed iframe (scripting is disabled).

You may encounter with error when the target URL issues X-Frame-Options header. This is restriction of iframe. You can ignore that error with specifing srcdoc: true option to opts.

With srcdoc: true option, fetchDocument fetches a URL by fetchText and set its result to iframe's srcdoc attribute and append <base> element with target URL to document.head. This means document.URL is not more usable (this may be about:srcdoc). But you can load URLs which uses X-Frame-Options.

fetchJSON(url) : Promise<Object>

fetchJSON fetches a URL by fetchText() and parse with JSON.parse.

fetchText(url) : Promise<string>

fetchText fetches a URL and just resolves with its responseText.

fetchAsXHR(opts) : Promise<XMLHttpRequest>

fetchAsXHR is raw method for fetch*.

crawl(list: Array<string | object>, callback: function (url, doc: HTMLDocument):void)

crawl can crawl specified list which is array of URLs and call callback with its document.

callback function is called with special this object which has pushPage(url) method. pushPage(url) adds to url to current crawl queue.

CONTRIBUTING

See CONTRIBUTING.md

ARCHITECTURE

Chemrtron has 2 browser window (by Electron). One of them is main viewer window and another one is for indexing window which is hidden.

The indexing window is shown under development mode which is switched by settings or menu (View -> Toggle Developer Tools).

A main window and an indexing window is communicate with IPC via Electron main process. (there is no direct connection between them)

RELEASING

  1. Updaste ChangeLog
  2. Edit VERSION file to increment version
  3. git commit -a and git push to uploaded to github
  4. make release creates packages, tag origin/master and upload packages to github releases.

LICENSE

MIT: http://cho45.github.com/mit-license

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.