Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
245 commits
Select commit Hold shift + click to select a range
93b3e9e
add methods and adjust row handling to accommodate subset regex
nichgray Apr 22, 2026
278a0d8
add c option for csv subset regex
nichgray Apr 22, 2026
5d15c59
adjust help syntax
nichgray Apr 22, 2026
5d7d182
remove examples to avoid confusion
nichgray Apr 22, 2026
328d167
Copy changelog template for upcoming changes
techgique Apr 22, 2026
316aeb4
add backtrace for verbose option, shift to message method
nichgray Apr 29, 2026
5438062
remove redundant id note
nichgray Apr 29, 2026
6aacddd
add rescue block to post and prepare_xslt method, raise directory error
nichgray Apr 29, 2026
e018533
shorten Saxon error messages
nichgray Apr 29, 2026
e140a15
print all errors at the end of the post
nichgray Apr 29, 2026
e058d81
add rescue blocks for set_up_services and transform_and_post
nichgray Apr 30, 2026
6810817
add rescue specific to connection error, prompt user to check environ…
nichgray Apr 30, 2026
d045a59
remove redundant error printing
nichgray Apr 30, 2026
edcd33b
adjust saxon error handling to display two lines per error
nichgray Apr 30, 2026
49c6762
add non-normalized column names to broaden applicability of csv trans…
nichgray Apr 30, 2026
951baab
add saxonche to requirements
nichgray Apr 30, 2026
732e6ef
rewrite exec_xsl method to call python script, initialize cmd as array
nichgray Apr 30, 2026
5e356af
create xslt transformation file with saxonche
nichgray Apr 30, 2026
3e91048
shift cmd string to array, refactor tee to Ruby write
nichgray May 1, 2026
b18babd
shift YAML.load_file to YAML.safe_load
nichgray May 1, 2026
276ea24
shift from interpolation to nokogiri builder api in the unlikely even…
nichgray May 1, 2026
86534fd
clean up residual todos
nichgray May 1, 2026
c596e8f
comment out breakpoints, add sys.exit instead as appropriate
nichgray May 5, 2026
079fd31
shift byebug to development dependency
nichgray May 5, 2026
2d0871f
shift omeka-s-tools pkg to cdrh fork
nichgray May 5, 2026
1f9889e
remove unused variables
nichgray May 5, 2026
5bc67a9
remove saxon references from docs, add python instructions
nichgray May 6, 2026
45e2b39
remove deprecated method previously used for saxon call
nichgray May 6, 2026
d49b35b
add text check to itemText method
nichgray May 7, 2026
0e76661
simplify overrides example file
nichgray May 7, 2026
b7a5fb1
add method to check config for req omeka params
nichgray May 7, 2026
126afdb
move DataManager gen out of conditional so data can be validated befo…
nichgray May 7, 2026
c7a4f4f
move DataManager gen out of conditional in post_omeka_html
nichgray May 7, 2026
424a767
remove byebug from dependency list; moved to dev dependency
nichgray May 7, 2026
ee31168
add sys import
nichgray May 7, 2026
8745790
add parens to traceback.print_exc
nichgray May 7, 2026
75824bd
fix comparison typo
nichgray May 7, 2026
d025081
add comment to note non-working function for later refactoring
nichgray May 7, 2026
5ad0fae
add conditional to skip any empty HTML content
nichgray May 7, 2026
bd46097
add SSL verification to Net::HTTP (Solr) and get_url helper
nichgray May 7, 2026
1df43c7
add warning when user and password are set and es_path is http
nichgray May 7, 2026
b283e2d
remove unneeded packages
nichgray May 8, 2026
b96ae40
new file with OmekaContext class, custom exception hierarchy, and log…
nichgray May 8, 2026
5dc4392
refactor as pure functions only, passing in ctx
nichgray May 8, 2026
e32ac2d
remove omeka import; accept omeka_data_base as constructor param
nichgray May 8, 2026
17ea5ce
add ctx arg and property ID cache; fix silent exceptions
nichgray May 8, 2026
f925bcc
wrap body in main(); fix hardcoded path to use env; internal function…
nichgray May 8, 2026
1925121
wrap body in main(); fix hardcoded paths to use env; internal functio…
nichgray May 8, 2026
7b7b06a
add date filter to omeka transformation and posting
nichgray May 8, 2026
fb34614
use safe_load_file instead of safe_load with File.read
nichgray May 13, 2026
95647a1
use safe_load_file instead of safe_load with File.read
nichgray May 13, 2026
6eaa584
align HTTP request variables, remove unnecessary setting of http.veri…
nichgray May 13, 2026
9237fe3
add warning message if regex match does not exist
nichgray May 13, 2026
cbb0e2d
remove commented breakpoints and sys.exit(1)s, so script can proceed …
nichgray May 13, 2026
3988681
add row_filter to build_html_from_csv
nichgray May 13, 2026
8262c38
add row_filter notification to transform_html
nichgray May 13, 2026
7fa412b
add row_filter to transform_solr
nichgray May 13, 2026
248ac9b
add csv filtering to omeka transformation
nichgray May 13, 2026
4bc4f54
fix csv filtering in html transformation
nichgray May 13, 2026
d775c52
reverse earlier interpolation edit, which does not play well with upd…
nichgray May 13, 2026
83b6546
Merge pull request #271 from CDRH/omeka_changes
nichgray May 13, 2026
1e1d0ab
add csv row filter to posting docs
nichgray May 14, 2026
e5d4750
add base-output-uri to cmd in cases of xsl:result-document outputs; u…
nichgray May 14, 2026
a054f1f
remove defunct link
nichgray May 14, 2026
ea07345
Merge branch 'dev' into csv_feature
nichgray May 14, 2026
b40ef43
switch to more recognizable example text
nichgray May 14, 2026
66efb60
standardize and simplify ssl flag-setting
nichgray May 14, 2026
2404ed0
Merge pull request #267 from CDRH/security_updates
techgique May 14, 2026
3a86dc6
Merge pull request #268 from CDRH/error_handling
nichgray May 14, 2026
2299655
eliminate string interpolation in command
nichgray May 15, 2026
4fc455f
Merge pull request #265 from CDRH/csv_feature
wkdewey May 15, 2026
8aad8cf
move python import and check for installed module before transforming…
nichgray May 15, 2026
812b7b7
add PyYAML
nichgray May 15, 2026
eb95ec2
merge dev into upgrades
nichgray May 15, 2026
2eeed60
merge cleanup into upgrades
nichgray May 15, 2026
2851fba
update gem versions
nichgray May 15, 2026
1151deb
add resume option to post
nichgray May 21, 2026
33117c1
add resume_files function to sort and select
nichgray May 21, 2026
cda8446
add resumed option and adjust filtered var accordingly
nichgray May 21, 2026
98f9a00
update docs to add resume option
nichgray May 21, 2026
6269779
update helpers test to test resume option
nichgray May 21, 2026
9879a4c
fix typo
nichgray May 21, 2026
9444bc2
add get_citation function to streamline fields
nichgray May 21, 2026
e29c7a4
add logger to top of module
nichgray May 21, 2026
d697fdf
delete duplicate function
nichgray May 21, 2026
477992c
use context class for resource-item links
nichgray May 21, 2026
77ad8f5
add id_match to conditional to avoid AttributeError
nichgray May 21, 2026
a63a89c
make sure identifier exists before concatenation to avoid TypeError
nichgray May 21, 2026
8b9112a
add dict to maintain field ordering
nichgray May 21, 2026
f4f4a76
refactor source to match citation
nichgray May 21, 2026
79f1f2f
add timeout for iiif request
nichgray May 21, 2026
fc5e2e6
specify encoding for html files
nichgray May 21, 2026
3c2368f
add error handling to dateYear
nichgray May 21, 2026
e202ca0
add error handling for csv ingest
nichgray May 21, 2026
31ea95e
use logger instead of print
nichgray May 21, 2026
b524302
use isinstance instead of type
nichgray May 21, 2026
827dc58
Merge branch 'dev' into resume_post_feature
nichgray May 21, 2026
8500f97
Merge branch 'dev' into saxon_to_saxonche
nichgray May 22, 2026
c10050b
refactor resume as proceed, validate and rescue regex
nichgray May 28, 2026
2f9c473
remove half-finished conflict resolution
nichgray May 28, 2026
f46a2b2
move csv rows option to correct alphabetical location
nichgray May 28, 2026
ee0af0c
add checkpoint, fix typo
nichgray May 28, 2026
b1eabe8
update overlooked resume and change proceed default to false
nichgray May 28, 2026
854e5ac
add iiif_collection param to context class
nichgray May 28, 2026
e101a10
use iiif_collection for collection_name in thumbnail function if it e…
nichgray May 28, 2026
5fa5621
make development default environment
nichgray May 29, 2026
f05b1ca
add extension check for images
nichgray May 29, 2026
3961c79
remove call to datamanager for non-existent check of omeka config values
nichgray May 29, 2026
08e61e1
fix -s option by deleting before manager invocation
nichgray May 29, 2026
b85ab6b
display warning for missing identifier
nichgray May 29, 2026
dc2109e
add finsh_run to print errors and runtime for omeka post
nichgray May 29, 2026
f8268d2
move duplicate code into helpers
nichgray May 29, 2026
46a0f35
use stem rather than full path for regex match
nichgray May 29, 2026
5c44646
add format filter to omeka annex
nichgray Jun 1, 2026
7e14835
require item set id
nichgray Jun 1, 2026
51c1067
catch KeyboardInterrupt at top level and exit with clear error message
nichgray Jun 1, 2026
d1f1457
clarify error msg and exit immediately for HTTPErrors
nichgray Jun 1, 2026
fd34bdf
fix typo
nichgray Jun 2, 2026
eba0682
adjust error handling: add log file and color to terminal output
nichgray Jun 2, 2026
d8b4b65
adjust path for overrides file
nichgray Jun 2, 2026
4fe4628
remove omeka_s_tools module function overrides (will be updated in fork)
nichgray Jun 2, 2026
faca42b
merge configs so env config overrides default
nichgray Jun 3, 2026
47b95d1
add Python setuptools version for omeka_s_tools installation
nichgray Jun 3, 2026
c94ccf7
shift JSON info message to relative path
nichgray Jun 4, 2026
359633d
add info message to alert user that overrides file is in use
nichgray Jun 4, 2026
6794f65
use RotatingFileHandler to manage size of log file
nichgray Jun 4, 2026
e1be997
make logs dir if it does not exist
nichgray Jun 5, 2026
33a5eb3
shift info message about overrides to warning
nichgray Jun 5, 2026
5057c96
move overrides get_fields call to context so every item does not call it
nichgray Jun 5, 2026
96b5168
shift type checks to isinstance, per linter
nichgray Jun 5, 2026
085a34a
update pkgs, remove unused pkgs
nichgray Jun 5, 2026
b27592e
add python/omeka requirements and notes to setup
nichgray Jun 5, 2026
07db539
fix has_relation field to handle null values
nichgray Jun 5, 2026
e8757b5
update omeka setup docs
nichgray Jun 5, 2026
02525f5
cleanup docs
nichgray Jun 5, 2026
3547e66
update overrides and posting docs, minor adjustments to setup docs
nichgray Jun 5, 2026
7c7a29a
update examples in docs, remove git-ignore note
nichgray Jun 5, 2026
115a388
fix typo and indentation
nichgray Jun 5, 2026
d939f75
add conditional so last file is not written to checkpoint if posting …
nichgray Jun 5, 2026
7e3e09a
add clear checkpoint helper
nichgray Jun 8, 2026
d3662b7
fix checkpoint handling: remove -t limit, add branch for process sort…
nichgray Jun 8, 2026
2d6b01f
align proceed with post sort (directory-based)
nichgray Jun 8, 2026
20d77f7
fix spacing
nichgray Jun 8, 2026
560db41
add omeka options to main post list so all are accounted for somewhere
nichgray Jun 8, 2026
1242454
add omeka json output option
nichgray Jun 8, 2026
c242bdb
update omeka docs w/r/t restructuring
nichgray Jun 8, 2026
ab77a33
comment out -01-01 handling so this can be done on case-by-case basis
nichgray Jun 8, 2026
2777216
add note about pip upgrade to docs
nichgray Jun 9, 2026
d96390a
refactor sorted in proceed_files to avoid excessive looping
nichgray Jun 9, 2026
1e7526d
fix spacing
nichgray Jun 9, 2026
dee3cb0
Merge pull request #278 from CDRH/resume_post_feature
nichgray Jun 9, 2026
4c69df5
Merge pull request #269 from CDRH/saxon_to_saxonche
nichgray Jun 9, 2026
6298539
shift bundler dev dependency back to earlier constraint with explanation
nichgray Jun 10, 2026
08e5970
remove unused imports
nichgray Jun 10, 2026
fc9a8ba
remove unused functions; csv is handled on Ruby side of datura
nichgray Jun 10, 2026
740e718
refactor to limit glob calls to one pass for filter_items_by_date and…
nichgray Jun 10, 2026
fd675f5
shift break to continue so valid values continue processing
nichgray Jun 10, 2026
77e5ec5
clear out redundant check for already_linked values
nichgray Jun 10, 2026
10cacab
check for all required keys at once and give user comprehensive feedb…
nichgray Jun 10, 2026
3efbe10
add rest-client to file with parent FileType class (rather than files…
nichgray Jun 10, 2026
6d41fa8
move error reporting into omeka_context
nichgray Jun 10, 2026
ce6256d
make title required, alert user if it is missing and skip item
nichgray Jun 10, 2026
bd9cc9b
add 403 to 401 auth error handling
nichgray Jun 11, 2026
c43a13d
remove unused error class definitions
nichgray Jun 11, 2026
464a8a6
add error message for ModuleNotFoundError
nichgray Jun 11, 2026
19fca49
remove extraneous media-skip note
nichgray Jun 11, 2026
92bcb55
cleanup
nichgray Jun 11, 2026
46d5c06
move date pattern into overrides
nichgray Jun 11, 2026
4975476
cleanup
nichgray Jun 11, 2026
9c19bf8
adjust env_config to fail if no environment config is present
nichgray Jun 11, 2026
325b0c2
cleanup
nichgray Jun 11, 2026
e279f7b
shorten path in error message
nichgray Jun 11, 2026
d105e68
use relative paths in missing title and identifier error messages
nichgray Jun 11, 2026
21e479f
move from deprecated rest-client gem to built-in net/http gem
nichgray Jun 15, 2026
d16f2a2
fix @auth_header call to be local rather than calling module-level va…
nichgray Jun 15, 2026
5243eb6
shift bundler constraints up; as dev dependency this should not cause…
nichgray Jun 15, 2026
9ca0e0d
fix typo
nichgray Jun 15, 2026
d45fa05
fix typo
nichgray Jun 16, 2026
5d2554d
reverse nokogiri and byebug changes
nichgray Jun 16, 2026
7d0024d
fix overlooked nokogiri change
nichgray Jun 16, 2026
88d8718
Merge pull request #281 from CDRH/upgrades
nichgray Jun 18, 2026
21f3fa1
separate out field mappings into overrideable manifest
nichgray Jun 18, 2026
e70b637
consolidate empty functions and separate logic for overridability
nichgray Jun 18, 2026
66fa30c
cleanup
nichgray Jun 19, 2026
41649d5
cleanup
nichgray Jun 19, 2026
c4267be
rename field overrides example file and create process overrides exam…
nichgray Jun 19, 2026
1214975
refactor to enable process overrides; use importlib instead of sys.path
nichgray Jun 19, 2026
3df19a5
length-format file_handler log levelname to 8 chars
nichgray Jun 19, 2026
eeb3aa8
add format_filter to doc comments
nichgray Jun 19, 2026
a01aae5
add missing options to doc comments
nichgray Jun 19, 2026
e37116e
update comments in reset_client to clarify rationale for client reset
nichgray Jun 19, 2026
6698764
add csv_rows option to run_omeka_script helper
nichgray Jun 22, 2026
2d8ca93
shift .format() syntax to f-strings
nichgray Jun 22, 2026
cd7677b
Merge branch 'omeka_changes_structural' into function_refactor_for_ov…
nichgray Jun 22, 2026
6620b66
shift .format() syntax to f-strings in overrides file
nichgray Jun 22, 2026
aae0618
shift .format() syntax to f-strings in overrides-related error msgs
nichgray Jun 22, 2026
93656d6
fix iiif path in overrides examples
nichgray Jun 22, 2026
ca40763
account for dicts in person, contributor, and creator fields
nichgray Jun 22, 2026
4f358b8
remove omeka_s fields from core datura; these should be worked into A…
nichgray Jun 22, 2026
d8323c3
allow get_omeka_ids to search across item sets if none is passed
nichgray Jun 22, 2026
295c651
remove omeka_s fields from manifest
nichgray Jun 22, 2026
5ca83d9
Merge pull request #284 from CDRH/new_override_structure
nichgray Jun 26, 2026
f3f09e4
rename row as json_item
nichgray Jun 26, 2026
6e9c320
Merge pull request #283 from CDRH/function_refactor_for_overrides
nichgray Jun 26, 2026
49d951a
Merge branch 'dev' into omeka_changes_structural
nichgray Jun 26, 2026
122976e
Merge pull request #275 from CDRH/omeka_changes_structural
nichgray Jun 26, 2026
ecbcdb6
organize options alphabetically
nichgray Jun 26, 2026
faf98ef
add p and u to bin files
nichgray Jun 26, 2026
49771d3
extend and reorder run_omeka_script helper
nichgray Jun 26, 2026
517ef16
shorten override path in warning
nichgray Jun 26, 2026
2570a35
add c and p to html_and_media_ingest; cleanup
nichgray Jun 26, 2026
f289661
add c and p options; cleanup
nichgray Jun 26, 2026
0de2e05
add c and p options and helper functions to context; cleanup
nichgray Jun 26, 2026
4121b96
add c and p options to omeka.py
nichgray Jun 26, 2026
c513d75
limit -c format to csv for extra backstop layer
nichgray Jun 26, 2026
107ab5b
revise rescue to raise ArgumentError rather than proceed if csv regex…
nichgray Jul 9, 2026
d182a61
add missing write to checkpoint file for omeka html and media
nichgray Jul 13, 2026
778ef69
add try/except blocks for -j in omeka post
nichgray Jul 13, 2026
d43c808
add regex validation to omeka scripts (Ruby helpers check with Python…
nichgray Jul 13, 2026
da0f0bd
delete stale json before full omeka post
nichgray Jul 13, 2026
3f0b14b
update omeka overrides paths and setup docs
nichgray Jul 14, 2026
61f6c60
add api version to default config
nichgray Jul 14, 2026
992ce5d
restructure requirements, update docs
nichgray Jul 14, 2026
ee297c6
update docs to reflect new stale json deletion step
nichgray Jul 14, 2026
6e27de6
add cautionary note to -s description in post docs
nichgray Jul 14, 2026
921da9d
add rescue to json delete loop
nichgray Jul 15, 2026
52dab2c
fix typo
nichgray Jul 16, 2026
b528b0b
remove note about pip from requirements
nichgray Jul 16, 2026
36cfd5e
update overrides docs
nichgray Jul 16, 2026
fd8e09b
Merge pull request #285 from CDRH/final_changes
nichgray Jul 16, 2026
042d7bb
Merge pull request #286 from CDRH/refresh_json
nichgray Jul 16, 2026
be591bc
set items for all envs to default private
nichgray Jul 21, 2026
f41d74e
add option for is_public metadata field override
nichgray Jul 21, 2026
0de8b47
exit immediately if no matching json files are found
nichgray Jul 21, 2026
c59824a
shift to f-string
nichgray Jul 22, 2026
47ec98c
Merge pull request #287 from CDRH/set_default_private
nichgray Jul 23, 2026
e0e81ad
Merge pull request #288 from CDRH/enhancements
nichgray Jul 27, 2026
a3e4880
add count and compiled end-run list for skipped es items
nichgray Jul 29, 2026
f6e3110
fix msg syntax for skipped items
nichgray Aug 5, 2026
9650940
Merge pull request #290 from CDRH/compile_skipped
nichgray Aug 5, 2026
7dd288e
adjust media is_public to True rather than pulling from context
nichgray Aug 12, 2026
056fef2
add full as fallback for iiif path when no param is listed
nichgray Aug 14, 2026
bb58614
Merge pull request #292 from CDRH/iiif_param_fix
karindalziel Aug 14, 2026
c76e63e
update changelog for v2.0.0
nichgray Aug 17, 2026
7af5e54
remove date placeholder from changelog entry
nichgray Aug 17, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,40 @@ Versioning](https://semver.org/spec/v2.0.0.html).
### Security
-->

## [v2.0.0] - Shift to saxonche, improve error handling, refactor Omeka S posting, add post options
[v2.0.0]: https://github.com/CDRH/datura/compare/v1.1.0...v2.0.0

### Added
- `--csv-rows` filter option added to enable line-by-line transformation of CSV data
- `--json-output` option (Omeka specific) added to output JSON instead of posting to Omeka S
- `--proceed` option added to enable restarting of post from a checkpoint

### Changed
- Omeka S posting pipeline refactored to, among other things:
- introduce `OmekaContext` dataclass to encapsulate shared runtime state into a single object
- restructure overrides and update example files
- add filter from Ruby side (`--update`)
- remove all output JSON as part of a complete post to Omeka S
- adjust params for Omeka S API calls (see [`omeka_s_tools` fork](https://github.com/CDRH/omeka_s_tools))
- update dependency list and create `requirements.in` file from which `requirements.txt` can be auto-generated
- improve logging and error handling
- fix bugs
- Updated Ruby and Python dependencies where possible, removed unused/deprecated dependencies
- Improved error handling: clarify XML/CSV parse errors and environment errors, show all errors at end of post
- Created option and fall-back to `full` for iiif URL creation

### Removed
- Removed `RestClient` in favor of built-in `net-http` library

### Migration
- Shifted to use Python `saxonche` package instead of Saxon calls to eliminate per-file JVM startup

### Security
- `safe_load` added for YAML
- SSL verification and regex validation added

Note that several of the above changes and some of the language and description in the documentation were created with Claude Code. All code and documentation has been reviewed and updated by CDRH staff.

## [v1.1.0] - Omeka S Posting
[v1.1.0]: https://github.com/CDRH/datura/compare/v1.0.1...v1.1.0

Expand Down
10 changes: 4 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ PATH
remote: .
specs:
datura (1.1.0)
byebug (~> 11.0)
colorize (~> 0.8.1)
nokogiri (~> 1.10)
colorize (~> 1.0)
nokogiri (~> 1.18)
pdf-reader (~> 2.12)
rest-client (~> 2.1)

Expand All @@ -15,7 +14,7 @@ GEM
afm (0.2.2)
bigdecimal (3.3.1)
byebug (11.1.3)
colorize (0.8.1)
colorize (1.1.0)
domain_name (0.6.20240107)
hashery (2.1.2)
http-accept (1.7.0)
Expand All @@ -26,7 +25,6 @@ GEM
logger
mime-types-data (~> 3.2025, >= 3.2025.0507)
mime-types-data (3.2026.0414)
mini_portile2 (2.8.9)
minitest (5.27.0)
netrc (0.11.0)
nokogiri (1.18.10)
Expand Down Expand Up @@ -56,7 +54,7 @@ PLATFORMS
x86_64-darwin-20

DEPENDENCIES
bundler (>= 1.16.0, < 3.0)
bundler (>= 2.0, < 5.0)
datura!
minitest (~> 5.0)
rake (~> 13.0)
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ source "https://rubygems.org"
gem "datura", git: "https://github.com/CDRH/datura.git", tag: "v0.0.0"
```

If this is the first datura repository on your machine, install saxon as a system wide executable. [Saxon setup documentation](docs/4_developers/saxon.md).

Then, in the directory with the Gemfile, run the following:
After that, in the directory with the Gemfile, run the following:

```
gem install bundler
Expand All @@ -29,7 +27,10 @@ bundle install
bundle exec setup
```

The last step should add files and some basic directories. Have a look at the [setup instructions](/docs/1_setup/collection_setup.md) to learn how to add your files and start working with the data!
The setup step should add files and some basic directories. If this is the first datura repository on your machine, you will need to install Python 3. You will also need to install `saxonche`. `saxonche` is included in `requirements.txt`, which should have been added as part of setup, so you can install it by following the Omeka setup [instructions](/docs/1_setup/omeka_setup.md#enabling-a-virtual-environment) for installing Python dependencies.

Now you are ready to have a look at the [setup instructions](/docs/1_setup/collection_setup.md) to learn how to add your files and start working with the data!


### RVM

Expand Down
9 changes: 7 additions & 2 deletions bin/post
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@

require "datura"

manager = Datura::DataManager.new
manager.run
begin
manager = Datura::DataManager.new
manager.run
rescue => e
puts e.message.red
exit 1
end
121 changes: 102 additions & 19 deletions bin/post_omeka
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env ruby

require "datura"
require "byebug"
require "optparse"
require "shellwords"

@usage = "Usage: post_omeka -[options]..."

Expand All @@ -13,48 +11,133 @@ options = {}
optparse = OptionParser.new do |opts|
# Set a banner
opts.banner = @usage
opts.on('-s', '--skip', 'skip generation step and just post to Omeka') do
generate_es = false
opts.on('-c', '--csv-rows [input]', 'only process CSV rows matching this identifier regex') do |input|
if input && input.length > 0
options["csv_rows"] = input
end
end

opts.on('-e', '--environment [input]', 'environment (development, production)') do |input|
opts.on('-e', '--environment [input]', 'environment (default: development, or production)') do |input|
if input && input.length > 0
options["environment"] = input
end
end

opts.on('-f', '--format [input]', 'only post files of this format (tei, csv, vra, ead, html, pdf, webs)') do |input|
if input && input.length > 0
options["format"] = input
end
end

opts.on('-j', '--json-output', 'write Omeka S item payloads to output/<environment>/omeka/ instead of posting to the API (API connection still required for property ID lookups)') do
options["json_output"] = true
end

opts.on('-p', '--proceed [input]', 'proceed from the file matching this regex, or from the last checkpoint if no value given') do |input|
options["proceed"] = input
end

opts.on('-r', '--regex [input]', 'only generate and post files matching this regex') do |input|
if input && input.length > 0
options["regex"] = input
end
end

opts.on('-s', '--skip', 'skip generation step and just post to Omeka') do
generate_es = false
end

opts.on('-u', '--update [input]', 'only post files updated after this date (today, 2015-01-01, or 2015-01-01T18:24)') do |input|
if input && input.length > 0
options["update_time"] = input
end
end

opts.on('-[!-~]', '-[!-~] [input]', 'arguments for the main Datura script') do |name, value|
#does nothing, this is a placeholder to catch all arguments not needed now and pass them along to the main script
end
end
#parse, but do not consume, command line arguments (the usual parse! would consume them)
optparse.parse(ARGV)
Datura::Helpers.validate_regex(options["regex"], "--regex") if options["regex"]
Datura::Helpers.validate_regex(options["csv_rows"], "--csv-rows") if options["csv_rows"]
#remove options not used in the main script
ARGV.delete("-s")
ARGV.delete("--skip")
#-p checkpointing belongs to the Omeka posting step (Python); strip it so
#DataManager does not trigger the Ruby proceed/checkpoint logic instead
ARGV.delete("-p")
ARGV.delete("--proceed")
ARGV.reject! { |arg| arg.start_with?("--proceed=") || (arg.start_with?("-p") && arg.length > 2) }
#if -p was given, resolve the proceed value from the Python checkpoint and
#re-inject into ARGV so DataManager also starts from the same file, preventing
#all source files from being transformed unnecessarily
if options.key?("proceed")
proceed_value = options["proceed"]
if proceed_value.nil?
env = options["environment"] || "development"
checkpoint_file = File.join("logs", "proceed_omeka_#{env}")
if File.exist?(checkpoint_file)
last = File.read(checkpoint_file).strip
unless last.empty?
print "Continue from #{last}? (y/n): "
$stdout.flush
response = $stdin.gets&.chomp&.downcase || ""
if response == "y"
proceed_value = last
else
puts "Exiting."
exit 0
end
end
end
if proceed_value.nil?
puts "ERROR: --proceed given with no value but no checkpoint file found at #{checkpoint_file}"
exit 1
end
end
ARGV.push("--proceed=#{proceed_value}")
options["proceed"] = proceed_value
end
ARGV.delete("-j")
ARGV.delete("--json-output")
#if -c/--csv-rows is set and no format was specified, restrict generation to CSV only
if options["csv_rows"] && !options["format"] && !ARGV.any? { |a| a == "-f" || a == "--format" || a.start_with?("--format=") }
ARGV.push("-f", "csv")
end
#add options to output a json file instead of posting it to Elasticsearch
ARGV.unshift("-x", "es", "-o", "-t")
#skip generation step with option -s
#create DataManager before conditional run
manager = Datura::DataManager.new
# On full runs (no limiting flags), clear all ES output before transforms so
# that deleted source files do not persist in the output directory. This makes
# the output directory a faithful reflection of the current source tree.
# -s (skip transforms) is supported for limited runs only; combining -s with
# an unrestricted full run would clear the output and leave nothing to post.
is_limited_run = options["regex"] || options["format"] || options["proceed"] || options["csv_rows"]
if generate_es && !is_limited_run
env = options.fetch("environment", "development")
out_es = File.join(Dir.pwd, "output", env, "es")
if Dir.exist?(out_es)
files = Dir.glob("#{out_es}/*.json")
cleared = 0

files.each do |f|
begin
File.delete(f)
cleared += 1
rescue => e
puts "There was an error deleting a file: #{e.message}".red
end
end
puts "Cleared #{cleared} file(s) from output/#{env}/es"
end
end
if generate_es
manager = Datura::DataManager.new
manager.run
end
datura_dir = File.join(File.dirname(__FILE__), "..")
# path to the gem's config files
python_script_path = File.join(datura_dir, "lib", "datura", "python", "json_to_omeka.py")
#run posting script into Omeka S
if File.exist?("#{python_script_path}")
command = ["python3", python_script_path]
if options["environment"]
command.append("-e", Shellwords.escape(options["environment"]))
end
if options["regex"]
command.append("-r", Shellwords.escape(options["regex"]))
end
system(*command)
else
puts("Omeka script not found at #{python_script_path}".red)
end
Datura::Helpers.run_omeka_script(python_script_path, options)
Loading