Revision history for HashAction


Revision [23409]

Last edited on 2016-05-20 07:38:48 by BrianKoontz [Replaces old-style internal links with new pipe-split links.]
Additions:
Creates an MD5 and/or SHA1 hash of the page body it's embedded in. The hash value is calculated from the wiki markup, so it should uniquely identify each page revision regardless of formatting applied to the markup. Currently in use on the [[http://wiki.opennic.glue | OpenNIC wiki]] [requires access to [[http://www.opennicproject.org | OpenNIC DNS]].
Deletions:
Creates an MD5 and/or SHA1 hash of the page body it's embedded in. The hash value is calculated from the wiki markup, so it should uniquely identify each page revision regardless of formatting applied to the markup. Currently in use on the [[http://wiki.opennic.glue OpenNIC wiki]] [requires access to [[http://www.opennicproject.org OpenNIC DNS]].


Revision [20686]

Edited on 2009-06-06 18:32:37 by BrianKoontz [New action for calculating page hashes]
Additions:
===Hash Action===
Creates an MD5 and/or SHA1 hash of the page body it's embedded in. The hash value is calculated from the wiki markup, so it should uniquely identify each page revision regardless of formatting applied to the markup. Currently in use on the [[http://wiki.opennic.glue OpenNIC wiki]] [requires access to [[http://www.opennicproject.org OpenNIC DNS]].
==actions/hash/hash.php==
/**
* Calculate a hash value for the page body.
* Hash value is calculated against the stringified version of the
* wiki markup, not the formatted output. Therefore, restoration of
* older page version should generate the same hash values independent
* of any CSS/formatter modifications.
* Syntax: {{hash type="md5"}} (Generates MD5 sum for page body)
* {{hash type="sha1"}} (Generates SHA1 sum for page body)
* @package Actions
* @version $Id$
* @license http://www.gnu.org/copyleft/gpl.html GNU General
* Public License
* @filesource
* @author {@link http://wikkawiki.org/BrianKoontz Brian Koontz}
if("md5" === $vars['type'])
print md5($this->htmlspecialchars_ent($this->page['body']));
else if("sha1" === $vars['type'])
print sha1($this->htmlspecialchars_ent($this->page['body']));
else
print "<em class=\"error\">Invalid hash type</em>";
Deletions:
===Word Count Action===
Inserts a wordcount (my format, your format, or no format) into a document. Needed something quick and dirty, so there's some refinement yet to be done.
==actions/wordcount.php==
/*
* Word count action
* Author: Brian Koontz <brian@pongonova.net>
*
* Replace instances of {{wordcount}} with the number of words in the
* text
* Optionally: {{wordcount preformatted="1"
* pretext="Some pretext"
* posttext="Some posttext"}}
* where preformatted = "1" produces "+++Word count: 9999 word(s)+++"
* pretext is the text to precede the word count (overrides preformatted)
* posttest is the text to follow the word count (overrides preformatted)
* TODO: Probably counts a lot of things it should, and a lot of
* things it shouldn't. Probably shouldn't count actions or other
* special items.
$preformatted = $vars['preformatted'];
$pretext = $vars['pretext'];
$posttext = $vars['posttext'];
if( $pretext || $posttext) {
$pretext ? 1 : $pretext = '';
$posttext ? 1 : $posttext = '';
} else if($preformatted) {
$pretext = "+++Word count: ";
$posttext = " word(s)+++";
}
$wc = str_word_count($this->page['body']);
echo $pretext.$wc.$posttext;


Revision [20685]

The oldest known version of this page was created on 2009-06-06 18:28:25 by BrianKoontz [New action for calculating page hashes]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki