DreamWidthUserLink
Questions answered by this recipe
How can I display a link to a Dreamwidth user or community?
Description
Displaying styled dreamwidth user and community links.
Dreamwidth (a clone of LiveJournal) provides markup to display users and communities on external sites in a fashion similar to the way they appear on the site. This recipe enables a simple way to embed the dreamwidth markup in a wiki page.
Installation
Insert the following into your local/config.php
file:
/* Copyright (c) 2012-2015, Tamara Temple <tamouse@gmail.com>. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See pmwiki.php for full details and lack of warranty. */ Markup('dw-user','inline', '/\\(:dw-user\\s*?(.*?):\\)/ei', "dw_user_link('$1')"); function dw_user_link($params='') { $params=stripslashes($params); $defaults=array('name'=>'unknown', 'type'=>'user' ); $DWOptions=array( 'user'=>array( 'image'=>'user.png', 'width'=>'17', 'height'=>'17', 'alt'=>'[personal profile]' ), 'community'=>array( 'image'=>'community.png', 'width'=>'16', 'height'=>'16', 'alt'=>'[community profile]' ) ); $DWLinkFmt = "<span style='white-space: nowrap;'><a href='http://\$DWName.dreamwidth.org/profile'><img src='http://www.dreamwidth.org/img/silk/identity/\$DWImage' alt='\$DWAlt ' width='\$DWWidth' height='\$DWHeight' style='vertical-align: text-bottom; border: 0; padding-right: 1px;' /></a><a href='http://\$DWName.dreamwidth.org/'><b>\$DWName</b></a></span>"; $args = ParseArgs($params); if (isset($args[''])) { // non-parameterized arguments, i.e. (:dw-user name [type]:) $args['name'] = $args[''][0]; $args['type'] = (isset($args[''][1]))?$args[''][1]:$defaults['type']; } $args = array_merge($defaults,$args); $replacements = array(); $replacements['$DWName'] = $args['name']; $replacements['$DWImage'] = $DWOptions[$args['type']]['image']; $replacements['$DWWidth'] = $DWOptions[$args['type']]['width']; $replacements['$DWHeight'] = $DWOptions[$args['type']]['height']; $replacements['$DWAlt'] = $DWOptions[$args['type']]['alt']; $return_text = str_replace(array_keys($replacements),array_values($replacements),$DWLinkFmt); return Keep($return_text); }
Configuration
None to speak of.
Usage
Insert the following markup into your wiki page to display the dreamwidth user:
(:dw-user "name":)
If you want to insert a community name instead of a user name, use:
(:dw-user "name" community:)
Extended forms
The following extended forms are also available:
(:dw-user name="name" type=user:)
or
(:dw-user name="name" type=community:)
Notes
This recipe can be modified to use other LJ or LJ clone's markup if desired.
Change log / Release notes
See also
Contributors
Comments
See discussion at DreamWidthUserLink-Talk?
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.