Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kn0 committed Dec 31, 2013
0 parents commit 777268a
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
timestamp Plugin for DokuWiki

A plugin that adds a timestamp button to the edit toolbar

All documentation for this plugin can be found at
http://www.dokuwiki.org/plugin:timestamp

If you install this plugin manually, make sure it is installed in
lib/plugins/timestamp/ - if the folder is called different it
will not work!

Please refer to http://www.dokuwiki.org/plugins for additional info
on how to install plugins in DokuWiki.

----
Copyright (C) Trenton Ivey <Trenton.Ivey@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; version 2 of the License

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

See the COPYING file in your DokuWiki folder for details
68 changes: 68 additions & 0 deletions action/Timestamp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* DokuWiki Plugin timestamp (Action Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Trenton Ivey <Trenton.Ivey@gmail.com>
*/

// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();

class action_plugin_timestamp_Timestamp extends DokuWiki_Action_Plugin {

/**
* Registers a callback function for a given event
*
* @param Doku_Event_Handler $controller DokuWiki's event controller object
* @return void
*/
public function register(Doku_Event_Handler &$controller) {

$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handle_toolbar_define');
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown');

}

/**
* Adds a toolbar button to insert timestamps
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_toolbar_define(Doku_Event &$event, $param) {
$event->data[] = array(
'type' => 'timestamp',
'title' => $this->getLang('tb_timestamp_button'),
'icon' => '../../plugins/timestamp/timestamp.png',
'key' => ':',
'block' => false
);
}

/**
* Handles AJAX 'timestamp' request and returns the strftime formatted time
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_ajax_call_unknown(Doku_Event &$event, $param) {
// Make sure we are handleing the correct AJAX
if ($event->data !== 'timestamp') {
return;
}
// No other ajax call handlers are needed
$event->stopPropagation();
$event->preventDefault();
// Set the content type
header('Content-Type: text/plain');
// 'Return' the strftime formated time
echo strftime($this->getConf('timestamp_format'));
}
}

// vim:ts=4:sw=4:et:
8 changes: 8 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
/**
* Default settings for the timestamp plugin
*
* @author Trenton Ivey <Trenton.Ivey@gmail.com>
*/

$conf['timestamp_format'] = '%Y%m%dT%H%M%S%z: ';
9 changes: 9 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Options for the timestamp plugin
*
* @author Trenton Ivey <Trenton.Ivey@gmail.com>
*/


$meta['timestamp_format'] = array('string');
10 changes: 10 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* English language file for timestamp plugin
*
* @author Trenton Ivey <Trenton.Ivey@gmail.com>
*/

$lang['tb_timestamp_button'] = 'Insert a timestamp';

//Setup VIM: ex: et ts=4 :
10 changes: 10 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* english language file for timestamp plugin
*
* @author Trenton Ivey <Trenton.Ivey@gmail.com>
*/

$lang['timestamp_format'] = 'Date format for the timestamp (see PHP\'s <a href="http://php.net/strftime">strftime</a> function)';

//Setup VIM: ex: et ts=4 :
7 changes: 7 additions & 0 deletions plugin.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
base timestamp
author Trenton Ivey
email Trenton.Ivey@gmail.com
date 2013-12-31
name timestamp plugin
desc A plugin that adds a timestamp button to the edit toolbar
url http://www.dokuwiki.org/plugin:timestamp
16 changes: 16 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function addBtnActionTimestamp($btn, props, edid) {
$btn.click(function() {
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{call: 'timestamp'},
function(data) {
// Insert the timestamp
insertAtCarret(edid,fixtxt(data));
// Close out of the picker and return
pickerClose();
},
'text'
);
});
return 'timestamp';
}
Binary file added timestamp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 777268a

Please sign in to comment.