VADEThis file consists of binary data and should not be touched by hands!STICKER '/curi_svc'); vhost_define (lpath=>'/curi_svc', ppath=>'/SOAP/', is_dav=>1, soap_user=>'CURI'); DB.DBA.VAD_LOAD_SQL_FILE('/DAV/VAD/c_uri/curi.sql', 1, 'report', 1); ]]> '/c'); vhost_remove (lpath=>'/curi_svc'); DB.DBA.URLREWRITE_DROP_RULELIST ('c_uri_lst'); DB.DBA.URLREWRITE_DROP_RULE ('c_uri_http_rule_2'); DB.DBA.URLREWRITE_DROP_RULE ('c_uri_http_rule_3'); DB.DBA.URLREWRITE_DROP_RULE ('c_uri_http_rule_4'); DB.DBA.URLREWRITE_DROP_RULE ('c_uri_http_rule_5'); ]]> c_uri/about.vsp / C_URI generator

About

What are CURIs

CURIs are Compressed URIs which are easier to share and use wherever it is desirable to replace a long and verbose URI with something a little bit easier for humans to type or short message services to transmit.

The way it works: all URIs are stored in a database table which keeps a unique id number. This number is then converted to base32 encoding, which only uses uppercase letters and numbers from 2 to 7. Note that numbers 1 and 0 are not used in this encoding so it eliminates misinterpretation stemming from the common human error of mistaking letters O and I as numbers 0 and 1.

For Developers - Customizing

The prefix for loading images, CSS, etc. can be set by setting the Virtuoso registry key

CURIUISkinPrefix
to a path relative to this path. It is currently set to

Creating Compressed URIs through an API

GET /c/create?uri=<URI>&res=json

Returns a JSON object containing 2 elements:

{uri:"<Original URI>",c_uri:"<Compressed URI>"}
Go Back
c_uri/create.vsp $ '') { curi := sprintf ('%s%s', pfx, WS..CURI_MAKE_CURI ({?'uri'})); qrcode := WS.CURI.curi_make_qr_code (curi); } if (interactive) { ?> C_URI generator

URI Shortener

'') { if (not interactive) { if (fmt = 'application/json') { http_header ('Content-Type: application/json\r\n'); http ('{"uri":"' || {?'uri'} ||'","c_uri":"' || curi || '"}'); } if (fmt = 'text/plain') { http_header ('Content-Type: text/plain\r\n'); http (curi); } return; } } ?>

qrcode

c_uri/curi.sqlDB.DBA.EXEC_STMT ('create table WS.CURI.LONG_URLS (LU_ID bigint identity (start with 1000000) primary key, LU_CHK varchar, LU_URL long varchar) create unique index LONG_URLS_CHK on WS.CURI.LONG_URLS (LU_CHK)', 0); create procedure WS.CURI.curi_make_curi (in uri varchar) returns varchar { declare curi_iri_id IRI_ID; declare curi_num integer; if (length (uri) > (1900 - 20)) { declare chk varchar; chk := md5 (uri); whenever not found goto nf; select LU_ID into curi_num from WS.CURI.LONG_URLS where LU_CHK = chk; goto ret; nf: insert into WS.CURI.LONG_URLS (LU_CHK, LU_URL) values (chk, uri); curi_num := identity_value (); ret: return '8' || encode_b32_num (curi_num); } curi_iri_id := iri_to_id (uri); -- -- Save the IRI from eventual garbage collection -- sparql insert into { `iri(?:uri)` "true"^^xsd:boolean }; curi_num := iri_id_num (curi_iri_id); return encode_b32_num (curi_num); } ; create procedure WS.CURI.curi_string_to_uri (in curi_string varchar) returns varchar { declare curi_iri_id IRI_ID; declare curi_num integer; if (curi_string [0] = '8'[0]) { declare uri varchar; curi_num := decode_b32_num (ucase(subseq (curi_string, 1))); uri := (select LU_URL from WS.CURI.LONG_URLS where LU_ID = curi_num); return cast (uri as varchar); } curi_num := decode_b32_num (ucase(curi_string)); curi_iri_id := iri_id_from_num (curi_num); return id_to_iri (curi_iri_id); } ; create procedure WS.CURI.curi_make_qr_code (in data_to_qrcode any, in src_width int := 120, in src_height int := 120, in qr_scale int := 4) { declare qrcode_bytes, mixed_content, content varchar; declare qrcode any; if (__proc_exists ('QRcode encodeString8bit', 2) is null) return null; declare exit handler for sqlstate '*' { return null; }; content := "IM CreateImageBlob" (src_width, src_height, 'white', 'jpg'); qrcode := "QRcode encodeString8bit" (data_to_qrcode); qrcode_bytes := aref_set_0 (qrcode, 0); mixed_content := "IM PasteQRcode" (qrcode_bytes, qrcode[1], qrcode[2], qr_scale, qr_scale, 0, 0, cast (content as varchar), length (content)); mixed_content := encode_base64 (cast (mixed_content as varchar)); mixed_content := replace (mixed_content, '\r\n', ''); return mixed_content; } ; exec ('grant execute on WS.CURI.curi_make_curi to CURI'); exec ('grant execute on WS.CURI.curi_string_to_uri to CURI'); exec ('grant execute on WS.CURI.curi_make_qr_code to CURI'); exec ('grant execute on DB.DBA.HTTP_RDF_GET_ACCEPT_BY_Q to CURI'); DB.DBA.VHOST_REMOVE (lpath=>'/c'); DB.DBA.VHOST_DEFINE ( lpath=>'/c', ppath=>'/DAV/VAD/c_uri/', is_dav=>1, vsp_user=>'CURI', ses_vars=>0, opts=>vector ('url_rewrite', 'c_uri_lst'), is_default_host=>0 ); DB.DBA.URLREWRITE_CREATE_RULELIST ('c_uri_lst', 1, vector ('c_uri_http_rule_3', 'c_uri_http_rule_2', 'c_uri_http_rule_5', 'c_uri_http_rule_4','c_uri_http_rule_7','c_uri_http_rule_6')); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('c_uri_http_rule_3', 1, '/c/\x24', vector (), 0, '/c/create.vsp', vector (), NULL, NULL, 1, 0, '' ); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('c_uri_http_rule_2', 1, '/c/(.+)', vector ('p1'), 1, '/c/get.vsp?uri=%U', vector ('p1'), NULL, NULL, 2, 0, '' ); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('c_uri_http_rule_5', 1, '/c/skin/(.*)', vector ('p1'), 1, '/c/skin/%s', vector ('p1'), NULL, NULL, 2, 0, ''); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('c_uri_http_rule_4', 1, '/c/create.vsp\\?uri=(.*)', vector ('p1'), 1, '/c/create.vsp?uri=%s', vector ('p1'), NULL, NULL, 2, 0, ''); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('c_uri_http_rule_7', 1, '/c/create\\?uri=(.*)', vector ('p1'), 1, '/c/create.vsp?uri=%s', vector ('p1'), NULL, NULL, 2, 0, ''); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ('c_uri_http_rule_6', 1, '/c/about.vsp', vector(), 0, '/c/about.vsp', vector(), NULL, NULL, 2, 0, ''); c_uri/get.vsp 404 Not Found

Not Found

Not Found

This URI does not resolve to anything.

To URI Shortener Main

c_uri/getcuri.vsp c_uri/makecuri.vsp - makecuri

CURI Generator

CURIs are compressed URIs which are easy to share and use wherever it is desirable to replace a long and verbose URI with something a little bit easier for humans to type or short message services to transmit.

For example, an URI like this

http://dbpedia.org/sparql/?default-graph-uri=http%3A%2F%2Fdbpedia.org&should-sponge=&query=select+%3Fs+%3Fp+%3Fo+%0D%0Awhere+{%0D%0Agraph+%3Fg+{%3Fs+%3Fp+%3Fo.%0D%0A++++++++++%3Fo+bif%3Acontains+%27duke%27.}++%0D%0A+++++++++{%3Fs+a+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FPerformer%3E.%0D%0A+++++++%3Fs+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2Fname%3E+%3Fo}+UNION%0D%0A+++++++++{%3Fs+%3Fp+%3Fo}+UNION%0D%0A+++++++++{%3Fs+a+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FJazzAlbums%3E+.%0D%0A++++++++++%3Fs+%3Chttp%3A%2F%2Fdbpedia.org%2Fproperty%2Fabstract%3E+%3Fo}%0D%0A}&format=text%2Fhtml&debug=on
would become something like this:
http://balek:8422/curi/BAVAI
.

The way it works: all URIs are stored in a database table which keeps a unique id number. This number is then converted to base32 encoding, which only uses uppercase letters and numbers from 2 to 7. Note that numbers 1 and 0 are not used in this encoding so it eliminates misinterpretation stemming from the common human error of mistaking letters O and I as numbers 0 and 1.

'') { dhost := registry_get ('URIQADefaultHost'); if (dhost is null) dhost := '_CANNOT_GET_HOST_'; chost := http_request_header(lines, 'Host', null, dhost); curi := sprintf ('http://%s%s/%s', chost, http_map_get('domain'), curi_make_curi ({?'uri'})); } ?> Original URI:
New CURI:

Make new CURI

c_uri/skin/i/banbck1.pngPNG  IHDR2gAMAOX2tEXtSoftwareAdobe ImageReadyqe<EIDATxڬ CWYx /&I1B 0TPز@f"FLq|z 8A%KIENDB`c_uri/skin/i/bg_header.png݉PN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