/coyote

Image annotation site and API to enable the distributed annotation of museum images.

Primary LanguageRubyOtherNOASSERTION

COYOTE

Travis CI Code Climate Test Coverage

Image annotation site and API to enable the distributed annotation of museum images built on RubyOnRails with MySQL (via MariaDB).

Setup

bundle install

#Set up the .env, override at .env.development and .env.test if needed

#Create the DBs for dev and test
bin/rake db:create db:migrate db:seed
RAILS_ENV=test bin/rake db:create db:migrate

Secure creds are kept untracked in .env

Test

Lint the FactoryGirls

bin/rake factory_girl:lint

Then, run the test suite:

#Once
bin/rspec

#Or dynamically via the guard daemon
guard
#Leave that running while you develop
#Then press enter or update a page and the test suite will run

Deploy

bundle exec cap production deploy

Update website images

# update images from past 2 minutes on local
bin/rake websites:update
# update images from past 60 minutes on local
bin/rake websites:update[60]
# update images from past 60 minutes on production
TASK="websites:update[60] bundle exec cap production rake"

Usage

#run the server
bin/rails s

#Automatically run tests as you work
#You might need to install a shim for guard
guard

#Run the tests on their own
bin/rspec

#Run the console
bin/rails c

Vagrant Setup

Some folks like to use an enclosed dev environment. Here's a virtual machine dev environment that can be run with the open source engine vagrant. This approach can reduce your dev setup time.

Install vagrant and run vagrant up Then, you can view the site like so:

vagrant up
ssh -N -L 3000:localhost:3000 vagrant@localhost -p 2222 
#Vagrant is the password
#In another terminal
open http://localhost:3000

Server Setup

Assuming a recent Ubuntu distribution...

#For MariaDB 
sudo add-apt-repository 'deb http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu trusty main'
sudo apt-get update
sudo apt-get install -y software-properties-common graphviz git libpq-dev gawk build-essential libreadline6-dev zlib1g-dev libssl-dev libyaml-dev autoconf libgdbm-dev libncurses5-dev automake libtool bison pkg-config libffi-dev mariadb-server libmariadbclient-dev git make gcc  zlib1g-dev  libssl-dev libreadline6-dev libxml2-dev libsqlite3-dev nginx openssl libreadline6 libreadline6-dev curl git-core zlib1g libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool pkg-config libffi-dev libv8-dev  imagemagick libmagickwand-dev fail2ban ruby-mysql 

sudo apt-get upgrade -y
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

# Check .ruby-version to make sure this is up-to-date
rbenv install -v 2.3.1
rbenv global 2.3.1
echo "gem: --no-document" > ~/.gemrc

gem install bundler

# Edit config/thin.production.yml
# Edit config/nginx.site.conf 
# Then copy or link to your /etc/nginx/sites-available
# Enable it

# Finish mysql setup


# Then locally edit your config/deploy/production.rb
# And edit your config/deploy.rb

# Then deploy
bundle exec cap production deploy

Components

##Data model

Data model

For use on nomnoml

[<frame>Coyote data model|
  [User | id: int | first_name: string | last_name: string |  email: string | admin: bool | timestamps]
  [Image | id: int |url : string | canonical_id: string | priority: boolean | title: text | page_urls: text]
  [Tag | id: int | title: string]
  [Group | id: int | title: string]
  [Description | id: int | locale:str(en) | text: text | timestamps]
  [Website | id: int | url: string | title: string | timestamps]
  [Status | id: int | title: string | description: text]
  [Meta| id: int| title: string | instructions: text]

  [Assignment]->[Image]
  [Assignment]->[User]

  [Description]->[User]
  [Description]->[Meta]
  [Description]->[Status]

  [Image]->[Group]
  [Image]->[Website]
  [Image] +-> 0..* [Description]
  [Image] +-> 0..* [Tag]
]

Descriptions have an audit log that tracks changes across most columns.

Links

Versus

License

MPLv2