Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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)

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]
CSV

Convert CSV file to .htaccess directories for w3id.org

positional arguments:
CSV CSV file to parse

optional 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/.htaccess

stain@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)