Revision history for PrettyCategory


Revision [23358]

Last edited on 2016-05-20 07:38:47 by RichardMartinNielsen [Replaces old-style internal links with new pipe-split links.]
Additions:
This gentle rewrite of the [[CategoryActionInfo | Category]] which ships with WikkaWiki 1.1.6.4 was created for use in a translucent website, where I want to show a list of categories and hide some of the CamelCase wiki-ness of the site.
if (!$compact) $str .= '<td>'.$this->Format('[['.$val.' | '.uncamel($val).']]').'</td>';
The uncamel function does not break apart ""AWikiNameWithAnIndefiniteArticle"" properly. I try to avoid such [[WikiName | WikiNames]].
Deletions:
This gentle rewrite of the [[CategoryActionInfo Category]] which ships with WikkaWiki 1.1.6.4 was created for use in a translucent website, where I want to show a list of categories and hide some of the CamelCase wiki-ness of the site.
if (!$compact) $str .= '<td>'.$this->Format('[['.$val.' '.uncamel($val).']]').'</td>';
The uncamel function does not break apart ""AWikiNameWithAnIndefiniteArticle"" properly. I try to avoid such [[WikiName WikiNames]].


Revision [19987]

Edited on 2008-06-02 22:17:36 by RichardMartinNielsen [Replaces old-style internal links with new pipe-split links.]
Additions:
The uncamel function does not break apart ""AWikiNameWithAnIndefiniteArticle"" properly. I try to avoid such [[WikiName WikiNames]].
Deletions:
The uncamel function does not break apart ""AWikiNameWithAnIndefiniteArticle"" properly. I try to avoid such WikiNames.


Revision [19986]

Edited on 2008-06-02 22:16:52 by RichardMartinNielsen [Initial draft with code.]
Additions:
=====PrettyCategory Action=====
This gentle rewrite of the [[CategoryActionInfo Category]] which ships with WikkaWiki 1.1.6.4 was created for use in a translucent website, where I want to show a list of categories and hide some of the CamelCase wiki-ness of the site.
In contrast to PrettyRecentChanges, there are very few deletions necessary and this is essentially about including the uncamel function (used there) here to break up category names into constituent words.
I have many pages which are listed as ""Readings4June2008"" which this code presents as Readings 4 June 2008.
In your actions directory, copy category.php to prettycategory.php
In the new file, insert the following code immediately after the header comments:
Replace the line that reads
$str = " pages belong to ".$page.":";
with
$str = " pages belong to ".uncamel($page).":";
Also replace the line that reads
if (!$compact) $str .= '<td>'.$this->Format('[['.$val.']]').'</td>';
with
if (!$compact) $str .= '<td>'.$this->Format('[['.$val.' '.uncamel($val).']]').'</td>';
//Your whitespace may vary.//
This code is essentially used as a drop-in replacement for the existing Category action.
This could have just been another option passed to recent changes. I'm building a site to be edited and updated by novice users. There is the danger that this code will hide //too// much of the wiki from them, but I'd rather be keeping it from our public audience, as well.
The uncamel function does not break apart ""AWikiNameWithAnIndefiniteArticle"" properly. I try to avoid such WikiNames.
The uncamel function, since it's shared with PrettyRecentChanges, should probably be put into a common file. I admit I don't know a good place to put it. As it is, it is bundled with the code that uses it, for ease of installation and removal.
Deletions:
=====PrettyRecentChanges Action=====
This gentle rewrite of the [[RecentChangesActionInfo RecentChanges]] which ships with WikkaWiki 1.1.6.4 was created for use in a translucent website, where I want to make it possible to show a short list of changed pages while hiding much of the wiki guts.
It creates short unordered lists for each day's changes, up to a total specified by the constant MAX_REVISION_NUMBER_PRETTY which is set (here) at 6. The days retain the essential formatting provided by the original code, including references to the same CSS formatting. Most of the work done here was with the delete key, and a little work to generate the unordered lists.
The other change is the addition of an uncamel function which splits up CamelCase into constituent words and numbers. I have many pages which are listed as ""Readings4June2008"" which this code presents as Readings 4 June 2008.
Place the following code in the actions directory as prettyrecentchanges.php
<?php
/**
* Display a simple list of recently changed pages.
*
* @package Actions
* @name PrettyRecentChanges
*
* @author {@link http://www.mornography.de/ Hendrik Mans} (wakka code)
* @author {@link http://wikkawiki.org/DarTar Dario Taraborelli} (preliminary code cleanup)
* @author {@link http://wikkawiki.org/RichardMartinNielsen Richard Martin-Nielsen} (slight modifications to simplify for easy inclusion in homepages)
* @todo - make datetime format configurable;
* - add configurable option for non-accessible pages {@link http://wush.net/trac/wikka/ticket/178 #178};
* - added extensive logging of events such as page deletion, cloning, ACL change {@link http://wush.net/trac/wikka/ticket/143 #143};
*/
//defaults
if(!defined('REVISION_DATE_FORMAT')) define('REVISION_DATE_FORMAT', 'D, d M Y');
if(!defined('REVISION_TIME_FORMAT')) define('REVISION_TIME_FORMAT', 'H:i T');
if (!defined('PAGE_EDITOR_DIVIDER')) define ('PAGE_EDITOR_DIVIDER', '→');
if (!defined('MAX_REVISION_NUMBER')) define ('MAX_REVISION_NUMBER', '50');
if (!defined('MAX_REVISION_NUMBER_PRETTY')) define ('MAX_REVISION_NUMBER_PRETTY', '6');
//i18n
if (!defined('RECENT_CHANGES_HEADING')) define('RECENT_CHANGES_HEADING', '**Recently changed pages**');
if (!defined('UNREGISTERED_USER')) define('UNREGISTERED_USER', 'unregistered user');
if (!defined('LABEL_HISTORY')) define('LABEL_HISTORY', 'history');
if (!defined('TITLE_REVISION_LINK')) define('TITLE_REVISION_LINK', 'View recent revisions list for %s');
if (!defined('TITLE_HISTORY_LINK')) define('TITLE_HISTORY_LINK', 'View edit history of %s');
if (!defined('WIKIPING_ENABLED')) define('WIKIPING_ENABLED', 'WikiPing enabled: Changes on this wiki are broadcast to <a href="http://%1$s">http://%1$s</a>');
if (!defined('NO_RECENTLY_CHANGED_PAGES')) define ('NO_RECENTLY_CHANGED_PAGES', 'There are no recently changed pages.');
if (!defined('NO_READABLE_RECENTLY_CHANGED_PAGES')) define ('NO_READABLE_RECENTLY_CHANGED_PAGES', 'There are no recently changed pages you have access to.');
//initialization
$max = 0;
$readable = 0;
if ($pages = $this->LoadRecentlyChanged())
{
$curday = '';
$max = MAX_REVISION_NUMBER_PRETTY;
foreach ($pages as $i => $page)
if (($i < $max) && $this->HasAccess('read', $page['tag']))
{
$readable++;
// day header
list($day, $time) = explode(' ', $page['time']);
if ($day != $curday)
{
$dateformatted = date(REVISION_DATE_FORMAT, strtotime($day));
if ($curday)
{
echo '</ul></span>'."\n";
}
echo $dateformatted.':<br />'."\n".'<span class="recentchanges"><ul>'."\n";
$curday = $day;
}
echo '<li>'.$this->Link($page['tag'], '', uncamel($page['tag']), 0).'</li>'."\n";
}
if ($readable == 0)
echo '<em class="error">'.NO_READABLE_RECENTLY_CHANGED_PAGES.'</em>';
echo '</ul></span>'."\n";
//wikiping instructions
$wikipingserver = $this->config['wikiping_server'];
if (!$wikipingserver == '')
$wikipingserver_url_parsed = parse_url($wikipingserver);
$wikipingserver_host = $wikipingserver_url_parsed['host'];
printf('<br /><br />['.WIKIPING_ENABLED.']', $wikipingserver_host);
}
else
{
echo '<em class="error">'.NO_RECENTLY_CHANGED_PAGES.'</em>';
}
?>
This code was originally conceived to be used in a "">>"" section. I apply a title by hand:
>>**Latest News and Updates**{{PrettyRecentChanges}}>>
It needn't be used this way, of course.
This could have just been another option passed to recent changes. I'm building a site to be edited and updated by novice users. They would much prefer to be told to just type ""{{PrettyRecentChanges}}"" than to try to get a series of parameters correct.


Revision [19985]

The oldest known version of this page was created on 2008-06-02 22:08:18 by RichardMartinNielsen [Initial draft with code.]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki