cygri/prefix.cc — pull request #3 by RubenVerborgh (2013-08-10 20:20:32+00:00)
Title: Add automated copying of prefixes

**Warning: this is only an example implementation for discussion**

Most of the time when using prefix.cc, I just want to directly copy a declaration in Turtle, JSON, or whatever language I'm working in. For the moment, I still have to:
- click through the right representation
- locate the declaration
- select it
- copy it

Therefore, I'm looking into a solution where I can just click the format to copy the prefix, [as suggested](https://twitter.com/cygri/status/366207443207852032) :smile:

This demo implementation does exactly that. If you go to http://prefixcc.local/foaf and click "n3", "xml", "sparql", etc., the corresponding prefix will be copied to your clipboard.

Will it _works_, it is still to basic. The main challenges are:
- **Integrating it into the existing clean UI.** Right now, I'm replacing the existing functionality, whereas this is probably not desired. But what do we want? An extra "copy" link after each item would be ugly.
- **Avoiding code duplication.** Currently, the declaration-generating code is in the JavaScript code. I hacked it in there, because the links are generated in a generic way in `footer.php`, where `@$links` is a key/value dictionary where the keys are URIs and the values labels. Extending this to have the `data-clipboard-text` attribute would mean changing some code, so I would like to ask your opinion first.

**TL;DR:** it works – it's ugly – send suggestions and I'll implement it properly