DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:clock

This is an old revision of the document!


clock plugin

Compatible with DokuWiki

No compatibility info given!

plugin Display a clock in DokuWiki

Last updated on
2010-03-30
Provides
Syntax

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with time

No longer under experimental!

Welcome to clock, a simple yet functional attempt to display a clock inside DokuWiki. Using only the basis of PHP and JavaScript, as well as some pretty basic CSS styling… and voilà: the current time, in your browser.

Syntax

Just write in a line of its own:

{{clock}}

Details:

  • The plugin syntax takes no parameters.
  • Configuration is available via the Configuration Manager.

Download and Installation

To download and install this plugin point your DokuWiki's Plugin Manager to the URL indicated in the download above. That link will always point to the latest release.

It is recommended that you clean your Wiki's cache after installing this plugin.

To see how to enable the fonts for the different styles, see Manual Styling.

Other Details

Demo

:!: The Demo site will show you how does the plugin work, live (although, actually, it's the wiki navigation that functions as the demo for this plugin).

Note language is Spanish but online translators shall do a good job with it.

An example visualization of the clock plugin
(using a custom CSS style to match "24"'s digital clock)
Plugin, with default style.
Plugin, with the “aradio” style.
See Manual Styling, however.
Plugin, with the “tv24” style.
See Manual Styling, however.
Plugin, with the “bluebox” style.

The Helpbar

This version of the plugin implements a help bar that displays the wiki link selected in the Plugin Configuration options (under infopage), or a link to this very page if that variable is left empty. If you want to remove the help bar, just set the variable helpbar to false in your local.php file.

Manual Styling

:?: I installed the plugin but the aradio and tv24 styles won't show with the adequate typefaces?

:!: The aradio and tv24 styles require the client's browser to support CSS3 @font-face method to load external typefaces. Unfortunately only some browsers support this feature with the necessary degree of completeness (tested in Firefox 3.5 and Opera 10.10 at the moment of this writing).

The instructions to enable these fonts in your own DokuWiki installation, assuming you already have them, is as follows:

  1. Your clients need web access to the typeface, so make sure that they can download it by placing a direct link somewhere in your website1).
  2. Substitute the “/path/to/your/typeface” entries in the style.css file with the paths above as appropiate and save.
  3. Flush your DokuWiki cache.
  4. Point your users towards the fonts, as well as installation instructions and, if possible, suggest them to use standards-compliant browsers. That's what the infopage setting is about – just put some text to explain how to install the fonts and some download links2).

This has a double effect: if visitors load the page using an up-to-date browser, the browser itself will take care of downloading and rendering the font; if it doesn't, then users can still download the font themselves and install in their systems, which in Firefox 2+ and Opera 9+ should result in the font becoming available.

By this point, visitors should be able to view the plugin's effect at its full potential if they are using a web browser that follows standards. If for some reason the user can't load the fonts (maybe he is using IE?) the plugin will still render with acceptable defaults.

:?: Can you provide the typefaces?

:!: No, because of license issues. These fonts are not mine, in the sense that I have no copyright over them. I have acquired them for personal use as their licenses establish, but these licenses don't allow for me to directly give them away. I can only suggest you to use either them or similar ones, which is why I provide the family names (“lcdd”, “digitalbreakout” and “atomicclockradio”, the last two are offered as Freeware fonts in some collection sites). You can acquire or design a typeface yourself and serve it to your clients with the procedure above. Also see the style.css file headers for details.

:?: How do I add my own style?

:!: Copy one of the styles of the style.css to your conf/userstyle.css file and edit as appropriate. Pick a name for the style, such as “mystyle” and substitute under “default” in the next sample:

#dw_clock_object.default .face {
  ...
  }

What you are actually styling is the clock's face (a visual container inside the clock itself). Apply the new style by changing the “style” option under the Configuration Manager. Flushing the cache shouldn't be necessary.

Known Issues

Only one instance of the clock is allowed to exist in a DokuWiki page. This is by design. If the syntax mode ({{clock}}) is used again in a page, an anchor-link to the location of the existing clock will be shown instead.

The newest version of the plugin, v1.4, has a cleaner JavaScript code that allows the plugin to operate without much trouble in current browsers like Opera and Firefox (the main ones tested). Safari and Midori, Webkit-based browsers, are reported to work, but I haven't tested them myself. That said, any browser that implements CSS and JavaScript decently and according to standards should be able to display the clock without non-minor issues.

Note that JavaScript support is required for the plugin to work. If you're using Firefox plugins such as “NoScript” in its “ultimate paranoid” mode, you'll see no clock, instead a tag only. Make sure to at least “allow scripts from the same site” for the clock to work. If JavaScript is not enabled, the fallback message method specified with the nojs_fallback option will take place.

Opera 9.5 beta versions have a JS issue where getSeconds() is not correctly implemented, causing the clock to display either “-1” or “ ” (empty) seconds. It doesn't matter, really: at this point you should be using the 10.10 release.

The plugin does not support simultaneous loads (like from a page and a sidebar). This won't affect normal rendering unless the two pages are displayed at once, in which case only the first invocation loaded (usually the normal page) will be rendered correctly, and the other will be left an empty space.

Source Code

Download and unpack from the links above to get a view of the Source Code.

The Major Release

The following are improvements in the latest version (v1.4):

  • A help bar that shows a link to either this page, or a wikipage of your choice (defaults to wiki:clock).
  • A new style, plain, where simply no visual styling is done.
  • A new style, bluebox, featuring a white typeface clock with shadows over a blue background.
  • Code is clearer and neater, in particular the JavaScript that may even work with Internet Explorer now.
  • Slightly higher granularity for clock tick, may prevent time from “slipping by” under higher client load.
  • Compatibility with the text-mode renderer (where simply the time according to the server is displayed).

The following improvements are planned for the major release (v.2.0):

  • Localization3).
  • Code clarity.
  • AM/PM format option.
  • Better @font-face support.
  • An analog visualization mode (using SVG + CSS, maybe?).
  • A sort of print-version rendering.

When will the major be released? Whenever it's ready.

Other Developments

Discussion

Do you have a question? Using Mosaic? Does the clock actually work in Links? Have an urge to beat me to a pulp unless I release the release?

No worries! Leave your questions here and I will try to answer as politely as I can to avoid being beaten to a pulp.

I attempted to disable the info link after the clock without success. Exactly what file and syntax needs to be used?

I tried things in <root>\conf like $conf['helpbar'] = 0;, $helpbar = 0;, etc. Thanks for the help…

2)
be wary of licenses however, and see the point below
3)
right now only English and Spanish are available
plugin/clock.1275873154.txt.gz · Last modified: 2010-06-07 03:12 by 96.18.187.209

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki