This readme is somewhat out of date. TODO: update this
BlueServer is a web app that turns lists of Chinese words and sentences into beautiful Anki cards. It is written in plain Go, HAML and coffee script and uses cc-cedict as its Chinese-English dictionary and the online dictionary of the Taiwanese Ministry of Education as its Chinese-Chinese dictionary. You can see BlueServer live here
BlueServer requires a sqlite database of the CC-CEDICT as generated by cedictTxt2Db. If you do not need the newest version of the dictionary, you can download a recent version here. When you execute blueServer, $CEDICT_DB has to contain the path of this file.
BlueServer also requires haml, coffee script and go to be installed on your system.
Once you have installed all the requirements, you can install BlueServer by changing into the $GOPATH/src/github.com/jsoendermann/blueServer directory and executing build.sh.
To run blueServer, change into the build/ subdirectory of your installation and type blueServer. Building and executing the server can be combined by executing
./build.sh && (cd build && CEDICT_DB="/path/to/cedict.sqlite3" blueServer )
in a terminal.
BlueServer is written in Go using "net/http". blueServer.go contains the main() function that sets up the program.
After assembling the static html using mustache.go, the main function sets up the web server by registering handlers for all routes and calling http.ListenAndServe(":8080", nil)
Once it is running, BlueServer responds to the following routes:
/vocab/
/vocab/lookup/<word>
/sentences/
/sentences/lookup/<sentence>
/assets/<file>
/vocab/ and /sentences/ are handled by small anonymous functions that deliver statc html and /assets/ is handled by a http.FileServer that serves all the assets. Most of the code in blueServer.go is responsible for the json api at /vocab/lookup/ and /sentences/lookup/.
This api is called by the coffee script code which sends ajax requests to the server when the user wants to look up words or sentences.
The handler function for /vocab/lookup looks up the requested word in the sqlite cedict database. The handler function for /sentences/lookup uses another api at http://www.moedict.tw/uni/. The code for these lookups can be found in jsoendermann/cedict and jsoendermann/moedict. For more details, see also the comments in blueServer.go.