Code Monkey home page Code Monkey logo

divisionlists's Introduction

Division Lists

An example of marking up division lists using Sinatra and CouchDB.

Files

  • report.xml - the original provided demo file
  • example.html - an example of the same content in HTML 5
  • default.css - CSS file to make example.html a bit cleaner

Setting Up

To get this to work, you're going to need CouchDB, couchdb-lucene and couchapp. If you already have those, feel free to skip past the instally stuff

Installing stuff

CouchDB

If you're on a Mac, CouchDBX is your best bet (or if you really must tinker, try this at your own risk); otherwise the nice folk over at CouchOne should have something for you

CouchApp

CouchApp is a great way to package up the inner workings of your CouchDB - views, fulltext indexes, that sort of thing - without pushing individual documents around by hand. Follow the installation instructions in the official README file

couchdb-lucene

The search engine bit. Reasonably painful to set up, but worth the effort.

  1. Install Maven 2 if you don't already have it (good news fellow Mac-heads, nothing to do here). Everyone else you need to go over here
  2. Grab the couchdb-lucene code from the github repository (hit the download source button over in the top right)
  3. Unpack the couchdb-lucene code, open up a Terminal/iTerm/Command prompt window and navigate to the right directory
  4. Type mvn
  5. Make some tea, this could take a while
  6. Navigate to the target subfolder and unpack the zip file you find in there
  7. Rename the resulting folder couchdb-lucene and move it to where you want your couchdb-lucene app to live (I've put mine in /usr/local)
  8. Locate your CouchDB local.ini file (if you're using CouchDBX you need to right-click on CouchDBX in your Applications folder and select "Show Package Contents", from there it's in Contents / Resources / couchdbx-core / couchdb_VERSION / etc / couchdb)
  9. Hack in the following:
    
     [external]
     fti=/path/to/python /path/to/couchdb-lucene/tools/couchdb-external-hook.py
         
     [httpd_db_handlers]
     _fti = {couch_httpd_external, handle_external_req, <<"fti">>}
     
  10. Under [couchdb] change os_process_timeout as follows:
    os_process_timeout=60000 ; increase the timeout from 5 seconds.
  11. Save the ini file and restart CouchDB

Setting up the app

Setup the database

  1. Start CouchDB (if it isn't already running)
  2. Grab a Terminal window and navigate to the db folder
  3. Run couchapp push http://localhost:5984/divisionlists
  4. Run rake load_data

Start couchdb-lucene

  1. In a new Terminal window, navigate to your couchdb-lucene folder
  2. Run bin/run

A few examples

As well as using the app search (which is pretty basic at the moment) you can query the lucene index directly:


http://localhost:5984/divisionlists/_fti/_design/data/main?q=Roman

http://localhost:5984/divisionlists/_fti/_design/data/main?q=constituency:Essex

http://localhost:5984/divisionlists/_fti/_design/data/main?q=title:Lord

http://localhost:5984/divisionlists/_fti/_design/data/main?q=name:Christie

http://localhost:5984/divisionlists/_fti/_design/data/main?q=name:David

http://localhost:5984/divisionlists/_fti/_design/data/main?q=name:%22Winston%20Spencer%20Churchill%22

http://localhost:5984/divisionlists/_fti/_design/data/main?q=aye:%22winston%20spencer%20churchill%22

http://localhost:5984/divisionlists/_fti/_design/data/main?q=noe:%22winston%20spencer%20churchill%22

divisionlists's People

Contributors

lizconlan avatar

Watchers

 avatar

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.