一个用于支持众包网站的平台,使用 Golang 为 Elasticsearch 构建
A platform for backing crowdsourcing websites, built in Go for Elasticsearch.
Hive requires elasticsearch version 1.3 or higher. Where you install it is up to you, as you can tell hive the domain and port for accessing elasticsearch at startup.
Installation on a Mac is simple with homebrew:
brew update
brew install elasticsearchYou can find instructions for other platforms in the elasticsearch guide.
There are two options for running hive.
Download the latest release, unzip and double click to start. hive will be running on http://localhost:8080 by default.
This method will allow you to hack on the hive source code. You'll need go installed and a working environment for it ($GOPATH, etc).
mkdir -p $GOPATH/src/github.com/nytlabs
cd $GOPATH/src/github.com/nytlabs
git clone [email protected]:nytlabs/hive.git
cd hive
makeFinally, to start up hive with defaults:
./build/hive-server
2014/10/16 14:52:19 running hive-server on port 8080 storing data in elasticsearch under index hiveAn example specifying all config params:
$ ./build/hive-server -index hive -esDomain localhost -esPort=9200 -port 8888
2014/10/16 14:51:54 running hive-server on port 8888 storing data in a local instance of elasticsearch under index hiveForget what parameters are available? There's help:
$ ./build/hive-server -h
Usage of ./build/hive-server:
-esDomain="localhost": elasticsearch domain
-esPort="9200": elasticsearch port
-index="hive": elasticsearch index name
-port="8080": hive portAll of a project's information is defined in JSON and POST'd to hive at its admin setup endpoint. You can find a full example in this repo.
$ curl -XPOST localhost:8080/admin/setup -d@samples/example.json
2014/11/21 12:29:22 Created project: crowd
2014/11/21 12:29:22 task: 2
2014/11/21 12:29:22 assets: 4A project is a single crowdsourcing app hosted in hive. Everything is scoped to a project, at the very least: assets, assignments, tasks and users.
| Field | Description |
|---|---|
| Id | a unique identifier used as a slug in urls |
| Name | a regular string title for the project |
| Description | optional, additional information about the project |
"Project": {
"Id": "crowd",
"Name": "Crowd",
"Description": "An example crowd sourcing site."
}Tasks are individual actions to do on an asset. A project can have one or more tasks. Criteria for assignment and verification of assets is stored on a task.
| Field | Description |
|---|---|
| Name | a regular string title for the task |
| Description | optional additional information |
| CurrentState | should the task be in the 'available' or 'waiting' state after importing |
| AssignmentCriteria | the criteria used to assign assets for this task |
| CompletionCriteria | the criteria used to mark an asset as 'completed' for this task: Total and Matching counts for submissions |
"Tasks": [
{
"Name": "categorize",
"Description": "categorize images",
"CurrentState": "available",
"AssignmentCriteria": {
"SubmittedData": {
"categorize": {}
}
},
"CompletionCriteria": {
"Total": 50,
"Matching": 50
}
}
]Assets are what get assigned to users and can be images, pdfs, etc. All require a URL and are scoped to a project.
| Field | Description |
|---|---|
| Url | required, where to find this asset |
| Name | optional, a regular string title |
| Metadata | optional, any additional data about this asset, specified as key-value pairs. |
"Assets": [
{
"Name": "Space 1",
"Url": "http://upload.wikimedia.org/wikipedia/commons/8/84/Wormhole.png"
}
]Users are the members of the crowd that you source in your app. They are scoped to a project, so the same person can have multiple records, one per project. Which fields are required is up to you - Hive will create a user with only an ID, to keep the barrier of entry low.
The current user is determined by a cookie named {project_id}_user_id, for example, crowd_user_id. This cookie should contain the id for the current user.
POST /projects/{project_id}/user
Response
{
"Id": "GorJ0TxVRbipE9SIJypEVQ",
"Name": "Resourceful Person",
"Email": "[email protected]",
"Project": "crowd",
"ExternalId": "",
"Counts": {
"Assignments": 10,
"Favorites": 0,
"crowd-categorize": 10,
"crowd-vote": 0
},
"Favorites": {}
}Your site should set the user_id cookie with the Id value returned in this response.
GET /projects/{project_id}/user
Cookie {project_id}_user_id
Response
{
"Id": "GorJ0TxVRbipE9SIJypEVQ",
"Name": "Resourceful Person",
"Email": "[email protected]",
"Project": "crowd",
"ExternalId": "",
"Counts": {
"Assignments": 10,
"Favorites": 0,
"crowd-categorize": 10,
"crowd-vote": 0
},
"Favorites": {}
}Assignments are the work users have to do for a given task and asset. A user cannot get the same assignment twice: assignments are scoped to the current project, task, asset and user.
GET /projects/{project_id}/tasks/{task_id}/assignments
Cookie {project_id}_user_id
Response
…Calling this endpoint will find or create an unfinished task assignment for the current user.
POST /projects/{project_id}/tasks/{task_id}/assignments
Cookie {project_id}_user_id
Response
…Simply post back an updated version of the JSON in the Create Assignment response to submit it (State: finished) or skip it (State: skipped).
GET /projects/{project_id}/tasks/{task_id}/assets/{asset_id}/assignments
Cookie {project_id}_user_id
Response Same as the more general 'create assignment' response
Use this endpoint in situations where you're displaying assets on your site and want to allow users to act on those specifically, rather than a random available valid asset. Specify an asset id and get back an assignment on it for the current user, project and task.
GET /projects/{project_id}/assignments/{assignment_id}
Response
…Returns information for a single assignment by id.
Actions available for assets outside of the admin.
GET /projects/{project_id}/assets/{asset_id}
Response
{
"Asset": {
"Id": "AUnTaQpqzTmtUIq-fdvJ",
"Project": "crowd",
"Url": "http://blogs.scientificamerican.com/observations/files/2013/08/Black_Hole_Milkyway.jpg",
"Name": "Space 3",
"Metadata": null,
"SubmittedData": {
"categorize": null,
"vote": null
},
"Verified": false,
"Counts": {
"Assignments": 0,
"finished": 0,
"skipped": 0,
"unfinished": 0
}
}
}This endpoint returns information for a single asset.
GET /projects/{project_id}/assets/{asset_id}/favorite
Cookie {project_id}_user_id
Response
Favoriting:
{
"AssetId": "AUnTaQpqzTmtUIq-fdvJ",
"Action": "favorited"
}Unfavoriting:
{
"AssetId": "AUnTaQpqzTmtUIq-fdvJ",
"Action": "unfavorited"
}This endpoint toggles favoriting or unfavoriting an asset for the current user.
Actions available for tasks outside of the admin.
GET /projects/{project_id}/tasks
Response
…Returns a list of tasks in this project.
GET /projects/{project_id}/tasks/{task_id}
Response
{
"Task": {
"Id": "crowd-categorize",
"Project": "crowd",
"Name": "categorize",
"Description": "categorize images",
"CurrentState": "available",
"AssignmentCriteria": {
"SubmittedData": {
"categorize": {}
}
},
"CompletionCriteria": {
"Total": 50,
"Matching": 50
}
}
}Returns information for a single task in this project.
Finally, a list of all the API actions.
暂无开放 Issues,或尚未同步最近议题。