Plugin Directory

Changeset 769768


Ignore:
Timestamp:
09/10/2013 03:15:49 PM (13 years ago)
Author:
aveltens
Message:

version 0.3

Location:
wp-linked-data/trunk
Files:
9 added
4 edited

Legend:

Unmodified
Added
Removed
  • wp-linked-data/trunk/rdf/RdfBuilder.php

    r715544 r769768  
    77 */
    88class RdfBuilder {
     9
     10    private $webIdService;
     11
     12    public function __construct ($webIdService) {
     13        $this->webIdService = $webIdService;
     14    }
    915
    1016    public function buildGraph ($queriedObject, $wpQuery) {
     
    4450
    4551        $author = get_userdata ($post->post_author);
    46         $accountUri = $this->getAccountUri ($author);
     52        $accountUri = $this->webIdService->getAccountUri ($author);
    4753        $accountResource = $graph->resource ($accountUri, 'sioc:UserAccount');
    4854        $accountResource->set ('sioc:name', $author->display_name);
     
    6066    }
    6167
    62     private function getAuthorUri ($author) {
    63         return $this->getAuthorDocumentUri ($author) . '#me';
    64     }
    65 
    66     private function getAccountUri ($author) {
    67         return $this->getAuthorDocumentUri ($author) . '#account';
    68     }
    69 
    70     private function getAuthorDocumentUri ($author) {
    71         return untrailingslashit (get_author_posts_url ($author->ID));
    72     }
    73 
    7468    private function getRdfTypeForPost ($queriedObject) {
    7569        if ($queriedObject->post_type == 'post') {
     
    8074
    8175    private function buildGraphForUser ($graph, $user, $wpQuery) {
    82         $author_uri = $this->getAuthorUri ($user);
    83         $account_uri = $this->getAccountUri ($user);
     76        $author_uri = $this->webIdService->getWebIdOf ($user);
     77        $account_uri = $this->webIdService->getAccountUri ($user);
    8478        $author_resource = $graph->resource ($author_uri, 'foaf:Person');
    8579        $account_resource = $graph->resource ($account_uri, 'sioc:UserAccount');
     
    9589        $account_resource->set ('sioc:account_of', $author_resource);
    9690
     91        $this->addRsaPublicKey ($user, $graph, $author_resource);
     92        $this->addAdditionalRdf ($user, $graph);
     93
    9794        $this->linkAllPosts ($wpQuery, $graph, $account_resource, 'sioc:creator_of');
    9895        return $graph;
     96    }
     97
     98    private function addRsaPublicKey ($user, $graph, $author_resource) {
     99        $rsaPublicKey = $this->webIdService->getRsaPublicKey ($user);
     100        if ($rsaPublicKey) {
     101            $key_resource = $graph->newBNode ('cert:RSAPublicKey');
     102            $key_resource->set ('cert:exponent', new \EasyRdf_Literal_Integer($rsaPublicKey->getExponent ()));
     103            $key_resource->set ('cert:modulus', new \EasyRdf_Literal_HexBinary($rsaPublicKey->getModulus ()));
     104            $author_resource->set ('cert:key', $key_resource);
     105        }
     106    }
     107
     108    private function addAdditionalRdf ($user, $graph) {
     109        $rdf = get_the_author_meta ('additionalRdf', $user->ID);
     110        if (!empty($rdf)) {
     111            $graph->parse ($rdf);
     112        }
    99113    }
    100114
  • wp-linked-data/trunk/readme.txt

    r715552 r769768  
    1313== Description ==
    1414
    15 This plugin publishes blog post metadata and data about the author according to the Linked Data Principles defined by Tim Berners-Lee. (http://www.w3.org/DesignIssues/LinkedData.html)
     15=== Linked Data ===
    1616
    1717Turtle and RDF/XML documents can be retrieved performing a HTTP GET request with an appropriate HTTP-Accept-Header set. Blog posts and pages are identified by their original document URI appended by the fragment identifier #it.
     
    2121You may use curl to retrieve Linked Data, e.g.:
    2222
    23 curl -H 'Accept: text/turtle' http://example.org/2013/04/my-first-blog-post
     23curl -H 'Accept: text/turtle' http://example.org/2013/04/my-first-blog-post#it
    2424
    25 An author, as a person, is identified by the author page URI appended by the fragment identifier #me.
     25An author, as a person, is per default identified by the author page URI appended by the fragment identifier #me.
    2626
    2727E.g. if the authors page is http://example.org/author/alice, the person Alice is identified by http://example.org/author/alice#me
     
    3030
    3131curl -H 'Accept: text/turtle' http://example.org/author/alice#me
     32
     33Instead of using WordPress to host the FOAF-Profile, you are able to link your existing WebID to your WordPress account. (See next section)
     34
     35=== WebID ===
     36
     37The Plugin adds a WebID section to the user profile screen in the admin backend. (Note: The section is only available, when editing _your own_ profile).
     38
     39==== WebID Location ====
     40
     41You can choose, where your WebID is hosted:
     42
     431. Locally hosted WebID: The WebID is hosted within your wordpress blog at http://[your-domain]/author/[your-username]#me
     442. Custom WebID: You may enter whatever your WebID URI is and your WordPress account will be linked to it.
     45
     46Whatever option you choose, your wordpress account will always be identified as "http://[your-domain]\>/author/[your-username]>#account". The option only affects, how you, as a person, will be identified.
     47
     48If you do not have a WebID yet, choose the first option, or get a WebID at http://my-profile.eu. More Information about WebID: http://webid.info/
     49
     50==== RSA Public Key ====
     51
     52You may enter the exponent and modulus of the public key of your WebID certificate. This will allow you to use your WordPress WebID for authentication elsewhere on the web. The wp-linked-data plugin is not yet capable of creating WebID certificates, so you will have to create the certificate with another tool (e.g. openssl) and enter the data into this section afterwards.
     53
     54==== Additional RDF Triples ====
     55
     56You may enter any RDF triples as RDF/XML, Turtle or N3. The triples will occur in the RDF representation of your WordPress profile document at at http://[your-domain]/author/[your-username]
    3257
    3358== Installation ==
     
    4166== Changelog ==
    4267
     68= 0.3 =
     69* choose between locally hosted WebID and custom WebID
     70* add RSA public key to your profile
     71* add custom RDF triples to your profile document
     72
    4373= 0.2 =
    4474* distinguish users (persons) and their user accounts
  • wp-linked-data/trunk/wp-linked-data-initialize.php

    r705406 r769768  
    44    class WpLinkedDataInitializer {
    55
     6        private $webIdService;
     7
    68        function initialize () {
    79            $this->registerRdfNamespaces ();
     10            $this->webIdService = new \org\desone\wordpress\wpLinkedData\UserProfileWebIdService();
    811            $contentNegotiation = $this->getSupportedContentNegotiation ();
    9             $rdfBuilder = new \org\desone\wordpress\wpLinkedData\RdfBuilder();
     12            $rdfBuilder = new \org\desone\wordpress\wpLinkedData\RdfBuilder($this->webIdService);
    1013            $rdfPrinter = new \org\desone\wordpress\wpLinkedData\RdfPrinter();
    1114            $interceptor = new \org\desone\wordpress\wpLinkedData\RequestInterceptor(
     
    1316            );
    1417            return $interceptor;
     18        }
     19
     20        function getUserProfileController () {
     21            return new \org\desone\wordpress\wpLinkedData\UserProfileController($this->webIdService);
    1522        }
    1623
  • wp-linked-data/trunk/wp-linked-data.php

    r715544 r769768  
    44Plugin URI: http://wordpress.org/extend/plugins/wp-linked-data/
    55Description: Publishing blog contents as linked data
    6 Version: 0.2
     6Version: 0.3
    77Author: Angelo Veltens
    88Author URI: http://me.desone.org/person/aveltens#me
     
    2424    require_once(WP_LINKED_DATA_PLUGIN_DIR_PATH . 'rdf/RdfPrinter.php');
    2525    require_once(WP_LINKED_DATA_PLUGIN_DIR_PATH . 'lib/EasyRdf.php');
     26    require_once(WP_LINKED_DATA_PLUGIN_DIR_PATH . 'controller/UserProfileController.php');
     27    require_once(WP_LINKED_DATA_PLUGIN_DIR_PATH . 'service/UserProfileWebIdService.php');
    2628}
    2729
     
    3335            if (phpVersionSupported()) {
    3436                add_action('admin_init', array(&$this, 'showWarningIfPeclHttpMissing'));
     37
    3538                $interceptor = $wpLinkedDataInitializer->initialize ();
    3639                add_action ('wp', array(&$interceptor, 'intercept'));
     40
     41                $userProfileController = $wpLinkedDataInitializer->getUserProfileController ();
     42                add_action ('show_user_profile', array(&$userProfileController, 'renderWebIdSection'));
     43                add_action ('personal_options_update', array(&$userProfileController, 'saveWebIdData'));
    3744            }
    3845        }
Note: See TracChangeset for help on using the changeset viewer.