Skip to content

Commit

Permalink
Item10844: initial checkin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/HyphenatorContrib@11855 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Jun 6, 2011
0 parents commit 22e09b0
Show file tree
Hide file tree
Showing 47 changed files with 3,273 additions and 0 deletions.
101 changes: 101 additions & 0 deletions data/System/HyphenatorContrib.txt
@@ -0,0 +1,101 @@
%META:TOPICINFO{author="micha" comment="reprev" date="1307359498" format="1.1" reprev="2" version="2"}%
---+!! %TOPIC%
%SHORTDESCRIPTION%

%TOC%

This is a jQuery plugin integrating [[http://code.google.com/p/hyphenator/][Hyphenator.js]] by Mathias Nater.

Hyphenator.js ...

* automatically hyphenates texts on websites
* runs on any modern browser that supports !JavaScript and the soft hyphen (­).
* automatically breaks URLs on any browser that supports the zero width space.
* runs on the client in order that the HTML source of the website may be served clean and svelte and that it can respond to text resizings by the user.
* follows the ideas of unobtrusive !JavaScript.
* has a documented API and is highly configurable to meet your needs.
* supports a wide range of languages.
* relies on Franklin M. Liangs hyphenation algorithm (PDF) commonly known from !LaTeX and !OpenOffice.
* is free software licensed under LGPL v3 with additional permission to distribute non-source (e.g., minimized or compacted) forms of that code (see source code header for details).

Supported languages are:
* English
* German
* French
* Dutch (thanks to Remco Bloemen)
* Swedish (thanks to Andreas Johansson)
* Spanish (thanks to Luis Pab�n)
* Malayalam, Tamil, Hindi, Oriya, Kannda, Telugu, Bengali, Gujarati and Panjabi (thanks to Santhosh Thottingal)
* Italian (thanks to Stefano Gorini)
* Finnish (thanks to Olli Wilkman)
* Russian (thanks to Dmitry Vedernikov)
* Polish (thanks to Kamil)
* Danish (thanks to Henrik Ryom)
* Portuguese (thanks to Lailson Bandeira)
* Hungarian (thanks to P�ter Nagy)
* Czech (thanks to Martin Hasoň)
* Ukrainian (thanks to Alexey Grekov)
* Turkish (thanks to Andreas Lappe)
* Armenian (thanks to Sahak Petrosyan)
* Lithuanian (thanks to Rogutės Sparnuotos)
* Slovenian (thanks to Mojca Miklavec)
* Latin (thanks to Pablo Rodr�guez)
* Greek, monoton, polyton and ancient (thanks to Pablo Rodr�guez)
* Belarusian (thanks to Olexandr Zhydenko)
* Norwegian (coming soon, thanks to Erik Erik Seierstad)
* Latvian (coming soon, thanks to Kristaps Karlsons)

A custom jQuery adapter makes sure text loaded asynchronously is processed later on as well.

For further information see http://code.google.com/p/hyphenator/

---++ Usage

To load the hyphenator into the current page use

<verbatim class="tml">
%JQREQUIRE{"hyphenator"}%
</verbatim>

Then add the =.hyphenate= class name to those html elements that contain text to be hyphenated.
Use =.donthyphenate= to exclude areas from being processed. The language used for processing the
text is extracted from the html language settings.

<verbatim class="html">
<div class="hyphenate" style="text-align:justify">
This text is processed by Hyphenator.js

<div class="donthyphenate">
This text is _excluded_ from hyphenation
</div>

</div>

This text is _not_ processed.

<div class="hyphenate">
This text is processed as well.
</div>
</verbatim>


---++ Installation Instructions

%$INSTALL_INSTRUCTIONS%

---++ Info
<!--
* Set SHORTDESCRIPTION = %$SHORTDESCRIPTION%
-->

| Author(s): | Michael Daum|
| Copyright: | &copy; 2011 Mathias Nater http://code.google.com/p/hyphenator/ (Hyphenator.js) %BR% \
&copy; 2011 Michael Daum http://michaeldaumconsulting.com (foswiki integration) |
| License: | [[http://www.gnu.org/licenses/lgpl.html][GNU Lesser General Public License]] |
| Release: | %$RELEASE% |
| Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 06 Jun 2011: | (1.0) initial release of foswiki plugin |
| Dependencies: | %$DEPENDENCIES% |
| Home page: | Foswiki:Extensions/%TOPIC% |
| Support: | Foswiki:Support/%TOPIC% |
31 changes: 31 additions & 0 deletions lib/Foswiki/Contrib/HyphenatorContrib.pm
@@ -0,0 +1,31 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# HyphenatorContrib is Copyright (C) 2011 Michael Daum http://michaeldaumconsulting.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.
#
# 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, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Contrib::HyphenatorContrib;

use strict;
use warnings;

our $VERSION = '$Rev$';
our $RELEASE = '1.00';
our $SHORTDESCRIPTION = 'Automatically hyphenates text';
our $NO_PREFS_IN_TOPIC = 1;

sub init {
require Foswiki::Plugins::JQueryPlugin ();
Foswiki::Plugins::JQueryPlugin::registerPlugin("Hyphenator", "Foswiki::Contrib::HyphenatorContrib::Core");
}

1;
8 changes: 8 additions & 0 deletions lib/Foswiki/Contrib/HyphenatorContrib/Config.spec
@@ -0,0 +1,8 @@
# ---+ Extensions
# ---++ JQueryPlugin
# ---+++ Extra plugins
# **STRING**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Hyphenator}{Module} = 'Foswiki::Contrib::HyphenatorContrib::Core';
# **BOOLEAN**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Hyphenator}{Enabled} = 1;
1;
52 changes: 52 additions & 0 deletions lib/Foswiki/Contrib/HyphenatorContrib/Core.pm
@@ -0,0 +1,52 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# HyphenatorContrib is Copyright (C) 2011 Michael Daum http://michaeldaumconsulting.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.
#
# 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, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Contrib::HyphenatorContrib::Core;

use strict;
use warnings;

use Foswiki::Plugins::JQueryPlugin::Plugin ();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

=begin TML
---+ package Foswiki::Contrib::HyphenatorContrib::Core
This is the perl stub for the hyphenator plugin.
=cut

sub new {
my $class = shift;
my $session = shift || $Foswiki::Plugins::SESSION;

my $this = bless(
$class->SUPER::new(
$session,
name => 'Hyphenator',
version => '3.3.0',
author => 'Mathias Nater',
homepage => 'http://code.google.com/p/hyphenator/',
javascript => ['hyphenator.js', 'hyphenator.init.js'],
puburl => '%PUBURLPATH%/%SYSTEMWEB%/HyphenatorContrib',
),
$class
);

return $this;
}

1;
1 change: 1 addition & 0 deletions lib/Foswiki/Contrib/HyphenatorContrib/DEPENDENCIES
@@ -0,0 +1 @@
Foswiki::Plugins::JQueryPlugin,>=4.10,perl,Required.
48 changes: 48 additions & 0 deletions lib/Foswiki/Contrib/HyphenatorContrib/MANIFEST
@@ -0,0 +1,48 @@
data/System/HyphenatorContrib.txt 0644
lib/Foswiki/Contrib/HyphenatorContrib/Config.spec 0644
lib/Foswiki/Contrib/HyphenatorContrib/Core.pm 0644
lib/Foswiki/Contrib/HyphenatorContrib.pm 0644
pub/System/HyphenatorContrib/hyphenator.init.js 0644
pub/System/HyphenatorContrib/hyphenator.init.js.gz 0644
pub/System/HyphenatorContrib/hyphenator.init.uncompressed.js 0644
pub/System/HyphenatorContrib/hyphenator.js 0644
pub/System/HyphenatorContrib/hyphenator.js.gz 0644
pub/System/HyphenatorContrib/hyphenator.uncompressed.js 0644
pub/System/HyphenatorContrib/Makefile 0644
pub/System/HyphenatorContrib/patterns/be.js 0644
pub/System/HyphenatorContrib/patterns/bn.js 0644
pub/System/HyphenatorContrib/patterns/ca.js 0644
pub/System/HyphenatorContrib/patterns/cs.js 0644
pub/System/HyphenatorContrib/patterns/da.js 0644
pub/System/HyphenatorContrib/patterns/de.js 0644
pub/System/HyphenatorContrib/patterns/el-monoton.js 0644
pub/System/HyphenatorContrib/patterns/el-polyton.js 0644
pub/System/HyphenatorContrib/patterns/en-gb.js 0644
pub/System/HyphenatorContrib/patterns/en-us.js 0644
pub/System/HyphenatorContrib/patterns/es.js 0644
pub/System/HyphenatorContrib/patterns/fi.js 0644
pub/System/HyphenatorContrib/patterns/fr.js 0644
pub/System/HyphenatorContrib/patterns/grc.js 0644
pub/System/HyphenatorContrib/patterns/gu.js 0644
pub/System/HyphenatorContrib/patterns/hi.js 0644
pub/System/HyphenatorContrib/patterns/hu.js 0644
pub/System/HyphenatorContrib/patterns/hy.js 0644
pub/System/HyphenatorContrib/patterns/it.js 0644
pub/System/HyphenatorContrib/patterns/kn.js 0644
pub/System/HyphenatorContrib/patterns/la.js 0644
pub/System/HyphenatorContrib/patterns/lt.js 0644
pub/System/HyphenatorContrib/patterns/lv.js 0644
pub/System/HyphenatorContrib/patterns/ml.js 0644
pub/System/HyphenatorContrib/patterns/nl.js 0644
pub/System/HyphenatorContrib/patterns/no-nb.js 0644
pub/System/HyphenatorContrib/patterns/or.js 0644
pub/System/HyphenatorContrib/patterns/pa.js 0644
pub/System/HyphenatorContrib/patterns/pl.js 0644
pub/System/HyphenatorContrib/patterns/pt.js 0644
pub/System/HyphenatorContrib/patterns/ru.js 0644
pub/System/HyphenatorContrib/patterns/sl.js 0644
pub/System/HyphenatorContrib/patterns/sv.js 0644
pub/System/HyphenatorContrib/patterns/ta.js 0644
pub/System/HyphenatorContrib/patterns/te.js 0644
pub/System/HyphenatorContrib/patterns/tr.js 0644
pub/System/HyphenatorContrib/patterns/uk.js 0644
24 changes: 24 additions & 0 deletions lib/Foswiki/Contrib/HyphenatorContrib/build.pl
@@ -0,0 +1,24 @@
#!/usr/bin/perl -w
BEGIN { unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} ); }
use Foswiki::Contrib::Build;

# Create the build object
$build = new Foswiki::Contrib::Build('HyphenatorContrib');

# (Optional) Set the details of the repository for uploads.
# This can be any web on any accessible Foswiki installation.
# These defaults will be used when expanding tokens in .txt
# files, but be warned, they can be overridden at upload time!

# name of web to upload to
$build->{UPLOADTARGETWEB} = 'Extensions';
# Full URL of pub directory
$build->{UPLOADTARGETPUB} = 'http://foswiki.org/pub';
# Full URL of bin directory
$build->{UPLOADTARGETSCRIPT} = 'http://foswiki.org/bin';
# Script extension
$build->{UPLOADTARGETSUFFIX} = '';

# Build the target on the command line, or the default target
$build->build($build->{target});

5 changes: 5 additions & 0 deletions pub/System/HyphenatorContrib/Makefile
@@ -0,0 +1,5 @@
FOSWIKI_ROOT?=~/foswiki/trunk/core
TARGET=hyphenator.js hyphenator.init.js

-include $(FOSWIKI_ROOT)/pub/System/JQueryPlugin/Makefile.include

35 changes: 35 additions & 0 deletions pub/System/HyphenatorContrib/hyphenator.init.uncompressed.js
@@ -0,0 +1,35 @@
jQuery(function($) {
var opts = {
classname: 'hyphenate',
donthyphenateclassname: 'donthyphenate',
minwordlength: 6,
intermediatestate: 'visible',
displaytogglebox: false,
hyphenchar: '&shy;',
urlhyphenchar: '',
remoteloading: true,
orphancontrol: 2,
defaultlanguage: 'en',
onhyphenationdonecallback: function() {
$("."+opts.classname).addClass("jqInitedHyphenate");
//$("#HyphenatorToggleBox").css({position:'fixed'});
//console.log("done hyphenate");
}
};

// mark them hyphenated right away in case livequery executes
// earlier than the hyphenator
$("."+opts.classname).addClass("jqInitedHyphenate");

// global config
Hyphenator.config(opts);

// run the first time manually
Hyphenator.run();

// any further run is initiated by async content later on
$("."+opts.classname+":not(.jqInitedHyphenate)").livequery(function() {
Hyphenator.run();
});

});

0 comments on commit 22e09b0

Please sign in to comment.