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

chinesedict-js-demo

v0.0.2

Published

Demo of the chinesedict-js module on App Engine

Downloads

4

Readme

Demo Application

You can use the chinesedict-js module on any web or application server. These instructions explain how to a more complex example than the initial example using the App Engine Standard Node.js Runtime Environment, which uses the Express web framework. Actually, the demo only uses Express for static file serving but takes advantage of the economical container-based serving environment provided by App Engine Standard.

Prerequisites

Create a Google Cloud Platform (GCP) project and install the gcloud command line tool.

Set a variable for the top level project directory:

CDICT_HOME=`pwd`

Build the dictionary

Clone the chinesenotes.com project and set an environment variable for the location:

cd $CDICT_HOME/..
git clone https://github.com/alexamies/chinesenotes.com.git
CNREADER_HOME=`pwd`/chinesenotes.com

This contains a tab separated variable (TSV) dictionary file words.txt that we will use for this demo. Change to the build directory and build the JSON format of the dictionary file:

cd $CDICT_HOME/build
node gen_dictionary.js --topic "Buddhism" $CNREADER_HOME/data/words.txt

This generates a words.json file that can be copied to your web dist directory created below.

Build the Web Client

The static files are contained in the directory 'static'. Change to that directory and build the client assets.

cd $CDICT_HOME/demo/static
npm install

Copy the relevant files into a dist directory:

mkdir dist
cp $CDICT_HOME/index.js dist/.
cp $CDICT_HOME/chinesedict.css dist/.
cp node_modules/dialog-polyfill/dialog-polyfill.js dist/.
cp node_modules/dialog-polyfill/dialog-polyfill.css dist/.

This creates the dist directory and writes the bundled JavaScript files there. Copy the dictionary file to the dist directory:

cp $CDICT_HOME/build/words.json dist/.

Run locally

Since the application code does not use any App Engine specific features it can be run without change using Node.js.

cd $CDICT_HOME/demo
npm start

Deploy to App Engine

Set the default GCP project:

GAE_APPLICATION=[Your project id]
gcloud config set project $GAE_APPLICATION

Deploy to App Engine:

gcloud app deploy

Example with Highlighting of Proper Nouns Only

The example in static/highlighting.html demonstrates restricting highlighting of proper nouns only. The other words are clickable but not highlighted. This prevents the user being presented with a page filled with highlighted elements.

Build the whole Chinese Notes dictionary

cd $CDICT_HOME/build
node gen_dictionary.js $CNREADER_HOME/data/words.txt
node check_dictionary.js
cd $CDICT_HOME/demo
cp $CDICT_HOME/build/words.json $CDICT_HOME/demo/static/dist/words_all.json
npm start

The entire Chinese Notes / NTI Reader dictionary is large. It would be ideal to serve it compressed.