Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stain/w3id-csv
Attempt to populate https://w3id.org/ .htaccess files from CSV (notably exported from purl.org's database)
https://github.com/stain/w3id-csv
Last synced: about 1 month ago
JSON representation
Attempt to populate https://w3id.org/ .htaccess files from CSV (notably exported from purl.org's database)
- Host: GitHub
- URL: https://github.com/stain/w3id-csv
- Owner: stain
- License: mit
- Created: 2016-02-29T12:46:35.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-29T15:55:55.000Z (almost 9 years ago)
- Last Synced: 2024-11-01T08:50:27.307Z (3 months ago)
- Language: Python
- Size: 6.84 KB
- Stars: 2
- Watchers: 4
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# w3id-csv
Attempt to populate https://w3id.org/ .htaccess files from CSV (notably exported from purl.org's database)
`purl_example.csv` is a CSV file with columns as in
[purl.org's mysql table `purls`](https://lists.w3.org/Archives/Public/public-perma-id/2015Dec/0005.html)## Requirements
- Python 3
- Docker / Docker Compose (for running Apache HTTPD)## Help
```
stain@biggie:~/src/w3id-csv$ python3 cvs2w3id.py --help
usage: cvs2w3id.py [-h] [--output OUTPUT] [--no-header] [--header] [--wipe]
CSVConvert CSV file to .htaccess directories for w3id.org
positional arguments:
CSV CSV file to parseoptional arguments:
-h, --help show this help message and exit
--output OUTPUT Path to populate with .htaccess directories
--no-header Do not skip first line of CSV
--header Skip first line of CSV
--wipe Wipe (any) existing directory
```## Running
```
stain@biggie:~/src/w3id-csv$ python3 cvs2w3id.py purl_example.csv
example/path/deeper -> http://example.com/redirectedDeeper
example/path -> http://example.com/redirectedPath
```This generates a series of `.htaccess` files in `build` (or the specified
`--output` folder):```
stain@biggie:~/src/w3id-csv$ find build/
build/
build/example
build/example/path
build/example/path/deeper
build/example/path/deeper/.htaccess
build/example/path/.htaccessstain@biggie:~/src/w3id-csv$ cat build/example/path/.htaccess
# Generated by cvs2w3id
RewriteEngine On
RewriteRule ^$ http://example.com/redirectedPath [L,R]
```## Testing
Either copy `build/` to an Apache HTTPd installation with `mod_rewrite`
installed, or simply run using [Docker Compose](https://docs.docker.com/compose/):docker-compose up
This will run Apache HTTPd and generate
the redirection tree at http://localhost:8087/
(or equivalent virtual machine host on Windows/OS X)