--RDF Views for WordPress use wp9; create procedure w3c_date (in ds varchar) { return replace (ds, ' ', 'T') || 'Z'; }; drop view wp_users_rdf; drop view wp_site_rdf; drop view wp_posts_rdf; create view wp_users_rdf as select ID, user_login, user_nicename, user_email as user_email, sha1_digest (user_email) as user_email_sha1, display_name from wp_users; create view wp_site_rdf as select a.option_value url, b.option_value blogname, c.option_value blogdesc from wp_options a, wp_options b, wp_options c where c.option_name = 'blogdescription'and a.option_name = 'siteurl' and b.option_name = 'blogname'; create view wp_posts_rdf as select post_title, p.ID as post_id, post_content, wp9..w3c_date (post_date_gmt) as post_date_gmt, wp9..w3c_date (post_modified_gmt) as post_modified_gmt, user_login, o.option_value as site_url, concat (o.option_value, '?p=', cast (p.ID as varchar)) as post_url, o2.option_value as blogname from wp_posts p, wp_users u, wp_options o, wp_options o2 where ((post_author = u.ID) or (post_author = 0 and u.ID = 1)) and o.option_name = 'siteurl' and p.post_status = 'publish' and o2.option_name = 'blogname'; grant select on wp_users_rdf to "SPARQL"; grant select on wp_site_rdf to "SPARQL"; grant select on wp_posts_rdf to "SPARQL"; grant execute on wp9..w3c_date to "SPARQL"; sparql drop quad map graph iri("http://^{URIQADefaultHost}^/wp_v") . ; sparql drop quad map virtrdf:Wordpress . ; sparql prefix sioc: prefix sioct: prefix atom: prefix rdfs: prefix foaf: prefix dc: prefix dct: prefix skos: prefix geo: prefix v: create iri class v:user_iri "http://^{URIQADefaultHost}^/wp/user/%U" (in user_name varchar not null) . create iri class v:iri "http://^{URIQADefaultHost}^/wp/proxy/%U" (in uri varchar not null) . create iri class v:post_iri "http://^{URIQADefaultHost}^/wp/post/%d" (in post_id integer not null) . create iri class v:site_iri "http://^{URIQADefaultHost}^/wp/site/%U" (in blogname varchar not null) . create iri class v:forum_iri "http://^{URIQADefaultHost}^/wp/blog/%U" (in blogname varchar not null) . create iri class v:mbox "mailto:%s" (in mail varchar not null) . alter quad storage virtrdf:DefaultQuadStorage { create virtrdf:Wordpress as graph iri ("http://^{URIQADefaultHost}^/wp_v") { v:site_iri (wp9.DBA.wp_site_rdf.blogname) a sioc:Space ; dc:title blogname ; sioc:link v:iri (url) ; sioc:host_of v:forum_iri (blogname) . v:forum_iri (wp9.DBA.wp_site_rdf.blogname) a sioc:Forum ; a sioc:Container ; a sioct:Weblog ; dc:title blogname ; sioc:description blogdesc ; sioc:link v:iri (url) ; sioc:has_host v:site_iri (blogname) . v:user_iri (wp9.DBA.wp_users_rdf.user_login) a sioc:User ; sioc:id user_login ; sioc:name user_nicename ; sioc:email v:mbox (user_email) ; sioc:email_sha1 user_email_sha1 . v:post_iri (wp9.DBA.wp_posts_rdf.post_id) a sioc:Item ; a sioc:Post ; a sioct:BlogPost ; dc:title post_title ; dct:created post_date_gmt ; dct:modified post_modified_gmt ; sioc:has_creator v:user_iri (user_login) ; sioc:has_container v:forum_iri (blogname) ; sioc:content post_content ; sioc:link v:iri (post_url) ; sioc:id post_id . v:forum_iri (wp9.DBA.wp_posts_rdf.blogname) sioc:container_of v:post_iri (post_id) . v:user_iri (wp9.DBA.wp_posts_rdf.user_login) sioc:creator_of v:post_iri (post_id) . } } . ; DB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 'wp_rule1', 1, '/(wp)\x24', vector('dummy'), 1, '/sparql?query=select+distinct+%%3Fcls+from+%%3Chttp%%3A%%2F%%2F^{URIQADefaultHost}^%%2Fwp_v%%3E+where+%%7B+%%5B%%5D+a+%%3Fcls+.+%%7D&format=%U', vector('*accept*'), null, '(text/rdf.n3)|(application/rdf.xml)', 2, 303 ); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 'wp_rule2', 1, '/wp/(.*)', vector('path'), 1, '/sparql?query=CONSTRUCT+{+%%3Chttp%%3A//^{URIQADefaultHost}^/wp/%U%%3E+%%3Fp+%%3Fo+}+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/wp_v%%3E+WHERE+{+%%3Chttp%%3A//^{URIQADefaultHost}^/wp/%U%%3E+%%3Fp+%%3Fo+}&format=%U', vector('path', 'path', '*accept*'), null, '(text/rdf.n3)|(application/rdf.xml)', 2, 303 ); DB.DBA.URLREWRITE_CREATE_REGEX_RULE ( 'wp_rule3', 1, '/wp/(user|post|site|proxy|blog)/(.*)', vector('obj', 'path'), 1, '/isparql/execute.html?query=SELECT%%20%%3Fp%%20%%3Fo%%20FROM%%20%%3Chttp%%3A//^{URIQADefaultHost}^/wp_v%%3E%%20WHERE%%20{%%20%%3Chttp%%3A//^{URIQADefaultHost}^/wp/%U/%U%%3E%%20%%3Fp%%20%%3Fo%%20}&endpoint=/sparql', vector('obj', 'path'), null, '(text/html)|(\\*/\\*)', 0, null ); DB.DBA.URLREWRITE_CREATE_RULELIST ( 'wp_rule_list1', 1, vector ( 'wp_rule1', 'wp_rule2', 'wp_rule3' )); DB.DBA.VHOST_REMOVE (lpath=>'/wp'); DB.DBA.VHOST_DEFINE (lpath=>'/wp', ppath=>'/wp/', is_dav=>0, vsp_user=>'dba', is_brws=>1, def_page=>'index.php', opts=>vector ('url_rewrite', 'wp_rule_list1'));