Re: [web-annotation] Make Selectors available for the wide world?

[fragmention](https://indiewebcamp.com/fragmention) is a relevant 
previous effort at this (without as expressive of a selector vocab). 
/cc @kevinmarks

> I am not as interested in a fragment syntax. I have often explained 
the purpose of the selectors as a mechanism to escape the need to 
define a fragment syntax, a projection to a single string, for 
arbitrarily complex selections.

For some reason that made this click for me. Using data uris as the 
fragment means any LD mimetype (e.g. turtle) could also be used.:
```python
import json
import urllib

OA_CONTEXT = 'http://www.w3.org/ns/anno.jsonld'
JSON_LD_MIMETYPE = 'application/ld+json'
def url_of_quote(document_url, text):
    selector = { '@context': OA_CONTEXT,
                 '@type': 'TextQuoteSelector',
                 'exact': text }
    frag = 'data:{};{}'.format(JSON_LD_MIMETYPE,
                               json.dumps(selector))
    url = '{}#{}'.format(document_url, urllib.quote(frag))
    return url

url = url_of_quote("https://github.com/w3c/web-annotation/issues/110",
                   "I have often explained the purpose of the 
selectors as a "
                   "mechanism to escape the need to define a fragment 
syntax, "
                   "a projection to a single string, for arbitrarily 
complex "
                   "selections.")

print url
```

Produces:
`https://github.com/w3c/web-annotation/issues/110#data%3Aapplication/ld%2Bjson%3B%7B%22%40context%22%3A%20%22http%3A//www.w3.org/ns/anno.jsonld%22%2C%20%22exact%22%3A%20%22I%20have%20often%20explained%20the%20purpose%20of%20the%20selectors%20as%20a%20mechanism%20to%20escape%20the%20need%20to%20define%20a%20fragment%20syntax%2C%20a%20projection%20to%20a%20single%20string%2C%20for%20arbitrarily%20complex%20selections.%22%2C%20%22%40type%22%3A%20%22TextQuoteSelector%22%7D`

Something that GitHub flavored MarkDown has no idea what to do with. 
But Web Annotation clients like Hypothesis could make use of.

-- 
GitHub Notification of comment by gobengo
Please view or discuss this issue at 
https://github.com/w3c/web-annotation/issues/110#issuecomment-159577066
 using your GitHub account

Received on Wednesday, 25 November 2015 11:24:30 UTC