| author | ymh <ymh.work@gmail.com> |
| Wed, 18 Jul 2018 18:17:01 +0200 | |
| changeset 572 | 423316923527 |
| parent 539 | 08e2513dbc2f |
| permissions | -rw-r--r-- |
| 311 | 1 |
## ICONOLAB |
| 25 | 2 |
|
3 |
### 1. Configuration and setup |
|
4 |
||
| 261 | 5 |
#### virtualenv |
| 25 | 6 |
|
7 |
- Install pip |
|
8 |
- Create a virtualenv for the project (using virtualenvwrapper is a good idea if possible). Python version is 3.5.1 |
|
9 |
||
| 311 | 10 |
Example |
11 |
``` |
|
12 |
virtualenv -p python3 ./virtualenv |
|
13 |
. virtualenv/bin/activate |
|
| 25 | 14 |
|
| 311 | 15 |
cd src/ |
16 |
pip install -r requirements/dev.txt |
|
17 |
``` |
|
| 25 | 18 |
|
| 311 | 19 |
#### Frontend development |
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
20 |
|
| 311 | 21 |
Make sure Node.js is installed, and install dependencies |
22 |
``` |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
533
diff
changeset
|
23 |
yarn install |
| 311 | 24 |
``` |
| 25 | 25 |
|
| 311 | 26 |
- To recreate the bundle for production |
27 |
``` |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
533
diff
changeset
|
28 |
yarn run build |
| 311 | 29 |
``` |
| 25 | 30 |
|
| 311 | 31 |
- To recreate the bundle and watch for changes |
32 |
``` |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
533
diff
changeset
|
33 |
yarn run start |
| 311 | 34 |
``` |
| 25 | 35 |
|
| 311 | 36 |
- To launch the Webpack dev server for automated page reload |
37 |
``` |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
533
diff
changeset
|
38 |
yarn run watch |
| 311 | 39 |
``` |
40 |
If `JS_DEV_MODE` is set to `True`, the Webpack dev server should be started. |
|
| 25 | 41 |
|
|
312
44ecdd5a52d4
Configure Webpack dev server for standalone JS development.
Alexandre Segura <mex.zktk@gmail.com>
parents:
311
diff
changeset
|
42 |
- To serve the annotator on a standalone page using Webpack dev server |
|
44ecdd5a52d4
Configure Webpack dev server for standalone JS development.
Alexandre Segura <mex.zktk@gmail.com>
parents:
311
diff
changeset
|
43 |
|
|
44ecdd5a52d4
Configure Webpack dev server for standalone JS development.
Alexandre Segura <mex.zktk@gmail.com>
parents:
311
diff
changeset
|
44 |
``` |
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
533
diff
changeset
|
45 |
yarn run standalone |
|
312
44ecdd5a52d4
Configure Webpack dev server for standalone JS development.
Alexandre Segura <mex.zktk@gmail.com>
parents:
311
diff
changeset
|
46 |
``` |
|
44ecdd5a52d4
Configure Webpack dev server for standalone JS development.
Alexandre Segura <mex.zktk@gmail.com>
parents:
311
diff
changeset
|
47 |
|
|
44ecdd5a52d4
Configure Webpack dev server for standalone JS development.
Alexandre Segura <mex.zktk@gmail.com>
parents:
311
diff
changeset
|
48 |
Go to `http://localhost:8001/webpack-dev-server/`. The page will reload by itself when the JS/CSS code is changed. |
|
44ecdd5a52d4
Configure Webpack dev server for standalone JS development.
Alexandre Segura <mex.zktk@gmail.com>
parents:
311
diff
changeset
|
49 |
|
| 261 | 50 |
#### Django project setup |
| 25 | 51 |
|
52 |
- Copy iconolab/src/settings/dev.py.tmpl into iconolab/src/settings/dev.py, adapt content to configuration |
|
53 |
- cd into iconolab/src folder and run |
|
54 |
||
55 |
python manage.py migrate |
|
56 |
||
57 |
to create database tables |
|
58 |
||
59 |
- Run |
|
60 |
||
61 |
python manage.py createsuperuser |
|
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
62 |
|
| 25 | 63 |
to create an admin user |
64 |
||
| 261 | 65 |
#### Elasticsearch |
| 25 | 66 |
|
| 261 | 67 |
Some objects in Iconolab are indexed and searched using ElasticSearch. You need to configure Haystack (see dev.py.tmpl, HAYSTACK_CONNECTIONS) and run: |
68 |
||
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
69 |
python manage.py rebuild_index |
| 25 | 70 |
|
71 |
||
72 |
### 2. Development server |
|
73 |
||
| 261 | 74 |
#### 2.1 Python server |
75 |
||
| 25 | 76 |
- cd into the iconolab/src folder and run |
77 |
||
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
78 |
python manage.py runserver |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
79 |
|
| 25 | 80 |
By default, the app is accessible through http://127.0.0.1:8000/home |
81 |
||
| 261 | 82 |
#### 2.2 Javascript development |
83 |
||
84 |
- cd into the iconolab/src_js/iconolab-bundle folder and run |
|
85 |
||
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
533
diff
changeset
|
86 |
yarn install |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
533
diff
changeset
|
87 |
yarn run start |
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
88 |
|
| 261 | 89 |
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 |
90 |
edit the code and debug it live in your browser |
|
91 |
||
92 |
### 3. Importing initial data from CSV |
|
| 25 | 93 |
|
| 140 | 94 |
Make sure to have the following in the same folder: |
| 25 | 95 |
|
| 140 | 96 |
* All the images to import. The image names must match their respective item inventory number. |
97 |
* A csv file that contains the metadata for the items you will import |
|
| 261 | 98 |
* A json file for initializing the collection in the database. (Optional if you want to import images in an existing collection) |
99 |
* A json file for the metacategories that will be linked to the collection. |
|
100 |
* Ensure the folder settings.MEDIA_ROOT+/uploads/ exists |
|
| 25 | 101 |
|
| 140 | 102 |
The following django manage.py command is used to import collection data and images: |
| 25 | 103 |
|
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
104 |
``` |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
105 |
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
|
106 |
``` |
| 261 | 107 |
|
108 |
Options: |
|
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
109 |
- ```--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
|
110 |
- ```--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
|
111 |
- ```--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
|
112 |
- ```--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
|
113 |
- ```--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
|
114 |
- ```--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
|
115 |
- ```--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
|
116 |
- ```--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
|
117 |
- ```--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
|
118 |
- ```--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 | 119 |
|
120 |
Notes: |
|
121 |
* The export csv path will be used to find everything else (images and fixtures files). |
|
| 140 | 122 |
* If the csv file is not encoded in utf-8, you MUST provide --encoding so the csv file can be read |
| 261 | 123 |
* You MUST provide either --collection-json or --collection-id, else the command doesn't know to which collection the objects will belong to. |
124 |
* 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. |
|
125 |
* 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). |
|
126 |
||
127 |
### 4. Updating already existing data |
|
| 140 | 128 |
|
| 261 | 129 |
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. |
130 |
||
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
131 |
``` |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
132 |
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
|
133 |
``` |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
134 |
|
| 261 | 135 |
Options: |
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
136 |
- ```--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
|
137 |
- ```--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
|
138 |
- ```--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
|
139 |
|
|
288
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 |
## TO-DOs |
| 299 | 142 |
|
|
287
959cbaad2076
added more documentation for import command and todos in the readme
durandn
parents:
261
diff
changeset
|
143 |
* 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
|
144 |
- contributors_count |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
145 |
- annotations_count |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
146 |
- comments_count |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
147 |
- contribution_calls_count |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
148 |
|
|
287
959cbaad2076
added more documentation for import command and todos in the readme
durandn
parents:
261
diff
changeset
|
149 |
* Annotation validation: there is an example handler in signals/handler.py for validation an annotation |
| 299 | 150 |
|
|
287
959cbaad2076
added more documentation for import command and todos in the readme
durandn
parents:
261
diff
changeset
|
151 |
* Admin interface: add a way to extract data for one or more annotation as .csv |
| 299 | 152 |
|
|
287
959cbaad2076
added more documentation for import command and todos in the readme
durandn
parents:
261
diff
changeset
|
153 |
* Django admin: |
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
154 |
- 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
|
155 |
- 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
|
156 |
|
|
287
959cbaad2076
added more documentation for import command and todos in the readme
durandn
parents:
261
diff
changeset
|
157 |
* 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
|
158 |
|
| 299 | 159 |
* Zoomed images: |
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
160 |
- 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
|
161 |
|
|
287
959cbaad2076
added more documentation for import command and todos in the readme
durandn
parents:
261
diff
changeset
|
162 |
* Fragment editor: |
|
288
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
163 |
- Identify usability issues |
|
9273f1f2c827
clean README text, remove unnecesary settings, refresh base requirements
ymh <ymh.work@gmail.com>
parents:
287
diff
changeset
|
164 |
- Rectangle selection as default |
| 311 | 165 |
- Add a way to define two or more shapes for one fragment |
|
533
e829a7cb5cb7
add import command remark in README.md
ymh <ymh.work@gmail.com>
parents:
312
diff
changeset
|
166 |
|
|
e829a7cb5cb7
add import command remark in README.md
ymh <ymh.work@gmail.com>
parents:
312
diff
changeset
|
167 |
* document the test import command : `python manage.py importimages --collection-json dossierImportMontauban/montauban_collection.json --metacategories-json dossierImportMontauban/montauban_metacategories_import.json --encoding "UTF-8" --delimiter "," dossierImportMontauban/ExportMontauban.csv` |