<docbook><section><title>VirtRDFViewWordpressScript</title><bridgehead class="http://www.w3.org/1999/xhtml:h2"><ulink url="WordPress">WordPress</ulink> Linked Data Views Script to set up your own instance</bridgehead>
<programlisting>use wordpress;

drop view wpl_users_rdf;
drop view wpl_site_rdf;
drop view wpl_posts_rdf;

sparql
prefix v: &lt;http://www.openlinksw.com/schemas/wp#&gt;
drop quad map virtrdf:Wordpress .
drop iri class v:user_iri .
drop iri class v:iri .
drop iri class v:post_iri .
drop iri class v:site_iri .
drop iri class v:forum_iri .
drop iri class v:mbox .
;


use wordpress;

create procedure w3c_date (in ds varchar)
{
  return replace (ds, &#39; &#39;, &#39;T&#39;) || &#39;Z&#39;;
};

create view wpl_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 wpl_users;

create view wpl_site_rdf as select a.option_value url, b.option_value blogname, c.option_value blogdesc from wpl_options a, wpl_options b, wpl_options c where c.option_name = &#39;blogdescription&#39;and a.option_name = &#39;siteurl&#39; and b.option_name = &#39;blogname&#39;;

create view wpl_posts_rdf as select post_title, p.ID as post_id, post_content,
        wordpress..w3c_date (post_date_gmt) as post_date_gmt, wordpress..w3c_date (post_modified_gmt) as post_modified_gmt, user_login,
        o.option_value as site_url, concat (o.option_value, &#39;?p=&#39;, cast (p.ID as varchar)) as post_url,
        o2.option_value as blogname
        from
        wpl_posts p, wpl_users u, wpl_options o, wpl_options o2 where ((post_author = u.ID) or (post_author = 0 and u.ID = 1)) and o.option_name = &#39;siteurl&#39; and p.post_status = &#39;publish&#39; and o2.option_name = &#39;blogname&#39;;

grant select on wpl_users_rdf to &quot;SPARQL&quot;;
grant select on wpl_site_rdf to &quot;SPARQL&quot;;
grant select on wpl_posts_rdf to &quot;SPARQL&quot;;
grant execute on wordpress..w3c_date to &quot;SPARQL&quot;;


sparql
prefix sioc: &lt;http://rdfs.org/sioc/ns#&gt;
prefix sioct: &lt;http://rdfs.org/sioc/types#&gt;
prefix atom: &lt;http://atomowl.org/ontologies/atomrdf#&gt;
prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt;
prefix foaf: &lt;http://xmlns.com/foaf/0.1/&gt;
prefix dc: &lt;http://purl.org/dc/elements/1.1/&gt;
prefix dct: &lt;http://purl.org/dc/terms/&gt;
prefix skos: &lt;http://www.w3.org/2004/02/skos/core#&gt;
prefix geo: &lt;http://www.w3.org/2003/01/geo/wgs84_pos#&gt;
prefix v: &lt;http://www.openlinksw.com/schemas/wp#&gt;

create iri class v:user_iri &quot;http://^{URIQADefaultHost}^/wordpress/user/%U#this&quot; (in user_name varchar not null) .
create iri class v:iri &quot;http://^{URIQADefaultHost}^/wordpress/proxy/%U#this&quot; (in uri varchar not null) .
create iri class v:post_iri &quot;http://^{URIQADefaultHost}^/wordpress/post/%d#this&quot; (in post_id integer not null) .
create iri class v:site_iri  &quot;http://^{URIQADefaultHost}^/wordpress/site/%U#this&quot; (in blogname varchar not null) .
create iri class v:forum_iri &quot;http://^{URIQADefaultHost}^/wordpress/blog/%U#this&quot; (in blogname varchar not null) .
create iri class v:mbox &quot;mailto:%s&quot; (in mail varchar not null) .

alter quad storage virtrdf:DefaultQuadStorage
  {
    create virtrdf:Wordpress as graph iri (&quot;http://^{URIQADefaultHost}^/wpl_v&quot;)
      {

        v:site_iri (wordpress.DBA.wpl_site_rdf.blogname) a sioc:Space ;
        dc:title blogname ;
        sioc:link v:iri (url) ;
        sioc:host_of v:forum_iri (blogname) .

        v:forum_iri (wordpress.DBA.wpl_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 (wordpress.DBA.wpl_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 (wordpress.DBA.wpl_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 (wordpress.DBA.wpl_posts_rdf.blogname) sioc:container_of v:post_iri (post_id) .
       v:user_iri (wordpress.DBA.wpl_posts_rdf.user_login) sioc:creator_of v:post_iri (post_id) .

      }
  } .
;


DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
    &#39;wpl_rule3&#39;,
    1,
    &#39;/wordpress/([^#]*)&#39;,
    vector(&#39;path&#39;),
    1,
    &#39;/sparql?query=DESCRIBE+%%3Chttp%%3A//^{URIQADefaultHost}^/wordpress/%U%%23this%%3E+FROM+%%3Chttp%%3A//^{URIQADefaultHost}^/wpl_v%%3E&amp;format=%U&#39;,
    vector(&#39;path&#39;, &#39;path&#39;, &#39;*accept*&#39;),
    null,
    &#39;(text/rdf.n3)|(application/rdf.xml)&#39;,
    2,
    null
    );

DB.DBA.URLREWRITE_CREATE_REGEX_RULE (
    &#39;wpl_rule2&#39;,
    1,
    &#39;/wordpress/(user|post|site|proxy|blog)/([^#]*)&#39;,
    vector(&#39;obj&#39;, &#39;path&#39;),
    1,
    &#39;/ode/index.html?uri=http%%3A//^{URIQADefaultHost}^/wordpress/%U/%U%%23this&#39;,
    vector(&#39;obj&#39;, &#39;path&#39;),
    null,
    &#39;(text/html)|(\\*/\\*)&#39;,
    0,
    303
    );


DB.DBA.URLREWRITE_CREATE_RULELIST (
    &#39;wpl_rule_list1&#39;,
    1,
    vector (
                &#39;wpl_rule2&#39;,
                &#39;wpl_rule3&#39;
          ));

DB.DBA.VHOST_REMOVE (lpath=&gt;&#39;/wordpress&#39;);
DB.DBA.VHOST_DEFINE (lpath=&gt;&#39;/wordpress&#39;, ppath=&gt;&#39;/vad/vsp/wordpress/&#39;, is_dav=&gt;0, vsp_user=&gt;&#39;dba&#39;, is_brws=&gt;1, def_page=&gt;&#39;index.php&#39;,
    opts=&gt;vector (&#39;url_rewrite&#39;, &#39;wpl_rule_list1&#39;));

</programlisting><bridgehead class="http://www.w3.org/1999/xhtml:h3">References</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem><ulink url="WordPressSIOCRef">WordPress SIOC Reference</ulink> </listitem>
<listitem><ulink url="http://ods.openlinksw.com/dataspace/dav/wiki/ODS/OdsIntegrationWordPress">WordPress Installation Guide</ulink> </listitem>
</itemizedlist></section></docbook>