src/README.md
author ymh <ymh.work@gmail.com>
Fri, 27 Jan 2017 12:19:50 +0100
changeset 307 97d0bb077be7
parent 299 fb07469bfb55
permissions -rw-r--r--
Added tag 0.0.20 for changeset 392cabcac2d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     1
## ICONOLAB ##
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     2
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     3
### 1. Configuration and setup
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     4
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
     5
#### virtualenv
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     6
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     7
- Install pip
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     8
- Create a virtualenv for the project (using virtualenvwrapper is a good idea if possible). Python version is 3.5.1
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
     9
- Run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    10
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    11
    pip install -r requirements.txt
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    12
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    13
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    14
#### node.js
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    15
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    16
- Make sure nodejs is installed
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    17
- cd into iconolab/src/iconolab/static/iconolab/js and run
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    18
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    19
    npm install
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    20
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    21
- To recreate the bundle file that lives in dist/
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    22
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    23
    npm build
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    24
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    25
- To add a new js module, you can add it to the js/components folder and then run
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
    26
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    27
    npm start
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    28
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    29
#### Django project setup
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    30
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    31
- Copy iconolab/src/settings/dev.py.tmpl into iconolab/src/settings/dev.py, adapt content to configuration
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    32
- cd into iconolab/src folder and run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    33
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    34
    python manage.py migrate
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    35
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    36
to create database tables
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    37
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    38
- Run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    39
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    40
    python manage.py createsuperuser
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    41
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    42
to create an admin user
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    43
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    44
#### Elasticsearch
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    45
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    46
Some objects in Iconolab are indexed and searched using ElasticSearch. You need to configure Haystack (see dev.py.tmpl, HAYSTACK_CONNECTIONS) and run:
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    47
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    48
    python manage.py rebuild_index
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    49
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    50
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    51
### 2. Development server
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    52
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    53
#### 2.1 Python server
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    54
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    55
- cd into the iconolab/src folder and run
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    56
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    57
    python manage.py runserver
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    58
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    59
By default, the app is accessible through http://127.0.0.1:8000/home
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    60
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    61
#### 2.2 Javascript development
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    62
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    63
- cd into the iconolab/src_js/iconolab-bundle folder and run
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    64
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    65
    npm install
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    66
    npm run start
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    67
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    68
This will serve the iconolab.js file in the iconolab/src/iconolab/static/js and update it on changes you make in the js code in src_js so you can
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    69
edit the code and debug it live in your browser
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    70
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    71
### 3. Importing initial data from CSV
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    72
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    73
Make sure to have the following in the same folder:
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    74
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    75
* All the images to import. The image names must match their respective item inventory number.
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    76
* A csv file that contains the metadata for the items you will import
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    77
* A json file for initializing the collection in the database. (Optional if you want to import images in an existing collection)
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    78
* A json file for the metacategories that will be linked to the collection.
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    79
* Ensure the folder settings.MEDIA_ROOT+/uploads/ exists
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    80
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
    81
The following django manage.py command is used to import collection data and images:
25
843863132ac9 Readme edit and initial data fixture
durandn
parents: 15
diff changeset
    82
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    83
```
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    84
python manage.py importimages <:export-csv-path> --delimiter <:delimiter> --encoding <:encoding> --collection-json <:collection_fixture_FILENAME> (OR --collection-id <:collection_id> if collection already exists in db) --metacategories-json <:metacategories_json_FILENAME>
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    85
```
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    86
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
    87
Options:
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    88
- ```--delimiter```: the delimiter for the csv file. For special ascii characters add a # before the code. Supported special chars are 9 (tab), 29 (Group separator), 30 (Record separator), 31 (Unit separator)
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    89
- ```--encoding```: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    90
- ```--collection-json```: the json file to create the collection from
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    91
- ```--collection-id```: the id of the collection to import into, it must already exist
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    92
- ```--metacategories-json```: the json file to create metacategories on the collection we're importing into
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    93
- ```--jpeg-quality```: the jpeg quality: default to the setting IMG_JPG_DEFAULT_QUALITY
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    94
- ```--no-jpg-conversion```: set to True so the command will not convert the images to jpg. Useful for pre-converted jpeg and especially when importing large image banks
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    95
- ```--img-filename-identifier```: the column from which the command will try to find images in the folder: use keys from the setting IMPORT_FIELDS_DICT. Default is "INV".
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    96
- ```--filename-regexp-prefix```: allows you to customize the way the command try to find images by specifying a regexp pattern to match *before* the identifier provided in img-filename-identifier. Defaults to .*
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
    97
- ```--filename-regexp-suffix```: allows you to customize the way the command try to find images by specifying a regexp pattern to match *after* the identifier provided in img-filename-identifier. Defaults to [\.\-_].*
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
    98
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
    99
Notes:
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
   100
* The export csv path will be used to find everything else (images and fixtures files).
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   101
* If the csv file is not encoded in utf-8, you MUST provide --encoding so the csv file can be read
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   102
* You MUST provide either --collection-json or --collection-id, else the command doesn't know to which collection the objects will belong to.
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   103
* To find all images for a given item, the command will try to match filenames according to the pattern build from the 3 options: filename-regexp-prefix+<value of img-filename-identifier>+filename-regexp-suffix. For instance by default, for an object with an INV of MIC.3.10, the files MIC.3.10.jpg and MIC.3.10.verso.jpg would be matched and linked to the object.
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   104
* The command will first parse the csv, then create the objects in the database (Item and ItemMetadata), then move the images to the settings.MEDIA_ROOT+/uploads/ folder after converting them to JPEG, then create the database objects for the images. The command will ignore any csv row that lacks an image or any csv row that already has a database entry for the collection (by default INV number is used to test if a database entry exists).
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   105
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   106
### 4. Updating already existing data
140
b0aae3bc25d2 updated readme for importimages command
durandn
parents: 46
diff changeset
   107
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   108
Another management command allows for editing data using only a .csv file. The command will go through the csv and update the metadatas for every objects it finds in the database with the csv row content.
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   109
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   110
```
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   111
python manage.py updatecollection --collection-id=<:id> --delimiter=<:delimiter> --encoding=<:encoding>
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   112
```
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   113
261
0d89d1066874 updated Readmes
durandn
parents: 154
diff changeset
   114
Options:
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   115
- ```--delimiter```: the delimiter for the csv file. For special ascii characters add a # before the code. Supported special chars are 9 (tab), 29 (Group separator), 30 (Record separator), 31 (Unit separator)
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   116
- ```--encoding```: the encoding provided if the csv is not in utf-8. Exemple: 8859 for ISO-8859
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   117
- ```--collection-id```: the id of the collection to import into, it must already exist
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   118
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   119
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   120
 ## TO-DOs
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
   121
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   122
 * Add a stat object for items with the following stats (at least?)
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   123
     - contributors_count
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   124
     - annotations_count
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   125
     - comments_count
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   126
     - contribution_calls_count
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   127
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   128
 * Annotation validation: there is an example handler in signals/handler.py for validation an annotation
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
   129
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   130
 * Admin interface: add a way to extract data for one or more annotation as .csv
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
   131
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   132
 * Django admin:
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   133
     - Search annotation/item/image by guid
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   134
     - More complete infos per row for object lists
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   135
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   136
 * History view: to be able to visualize the history of a given annotation
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   137
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
   138
 * Zoomed images:
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   139
     - Zoomed images on annotation pages and item list pages (thumbnail sizes must be sorted out to be pre-generated for the list pages)
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   140
287
959cbaad2076 added more documentation for import command and todos in the readme
durandn
parents: 261
diff changeset
   141
 * Fragment editor:
288
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   142
     - Identify usability issues
9273f1f2c827 clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents: 287
diff changeset
   143
     - Rectangle selection as default
299
fb07469bfb55 correct js compilation
ymh <ymh.work@gmail.com>
parents: 288
diff changeset
   144
     - Add a way to define two or more shapes for one fragment