Import xinha so we can switch from htmlarea and fix a bunch of in-browser issues that htmlarea has

This commit is contained in:
Chris Morgan
2005-09-30 02:25:07 +00:00
committed by WineHQ
parent 2311d4d572
commit 9242a68c4a
375 changed files with 26623 additions and 0 deletions

View File

@@ -0,0 +1,104 @@
// Plugin for htmlArea to run code through the server's HTML Tidy
// By Adam Wright, for The University of Western Australia
//
// Email: zeno@ucc.gu.uwa.edu.au
// Homepage: http://blog.hipikat.org/
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
//
// Version: 0.5
// Released to the outside world: 04/03/04
HtmlTidy is a plugin for the popular cross-browser TTY WYSIWYG editor,
htmlArea (http://www.interactivetools.com/products/htmlarea/). HtmlTidy
basically queries HTML Tidy (http://tidy.sourceforge.net/) on the
server side, getting it to make-html-nice, instead of relying on masses
of javascript, which the client would have to download.
Hi, this is a quick explanation of how to install HtmlTidy. Much better
documentation is probably required, and you're welcome to write it :)
* The HtmlTidy directory you should have found this file in should
include the following:
- README
This file, providing help installing the plugin.
- html-tidy-config.cfg
This file contains the configuration options HTML Tidy uses to
clean html, and can be modified to suit your organizations
requirements.
- html-tidy-logic.php
This is the php script, which is queried with dirty html and is
responsible for invoking HTML Tidy, getting nice new html and
returning it to the client.
- html-tidy.js
The main htmlArea plugin, providing functionality to tidy html
through the htmlArea interface.
- htmlarea.js.onmode_event.diff
At the time of publishing, an extra event handler was required
inside the main htmlarea.js file. htmlarea.js may be patched
against this file to make the changes reuquired, but be aware
that the event handler may either now be in the core or
htmlarea.js may have changed enough to invalidate the patch.
UPDATE: now it exists in the official htmlarea.js; applying
this patch is thus no longer necessary.
- img/html-tidy.gif
The HtmlTidy icon, for the htmlArea toolbar. Created by Dan
Petty for The University of Western Australia.
- lang/en.js
English language file. Add your own language files here and
please contribute back into the htmlArea community!
The HtmlArea directory should be extracted to your htmlarea/plugins/
directory.
* Make sure the onMode event handler mentioned above, regarding
htmlarea.js.onmode_event.diff, exists in your htmlarea.js
* html-tidy-logic.php should be executable, and your web server should
be configured to execute php scripts in the directory
html-tidy-logic.php exists in.
* HTML Tidy needs to be installed on your server, and 'tidy' should be
an alias to it, lying in the PATH known to the user executing such
web scripts.
* In your htmlArea configuration, do something like this:
HTMLArea.loadPlugin("HtmlTidy");
editor = new HTMLArea("doc");
editor.registerPlugin("HtmlTidy");
* Then, in your htmlArea toolbar configuration, use:
- "HT-html-tidy"
This will create the 'tidy broom' icon on the toolbar, which
will attempt to tidy html source when clicked, and;
- "HT-auto-tidy"
This will create an "Auto Tidy" / "Don't Tidy" dropdown, to
select whether the source should be tidied automatically when
entering source view. On by default, if you'd like it otherwise
you can do so programatically after generating the toolbar :)
(Or just hack it to be otherwise...)
Thank you.
Any bugs you find can be emailed to zeno@ucc.gu.uwa.edu.au

View File

@@ -0,0 +1,29 @@
// Default configuration file for the htmlArea, HtmlTidy plugin
// By Adam Wright, for The University of Western Australia
//
// Evertything you always wanted to know about HTML Tidy *
// can be found at http://tidy.sourceforge.net/, and a
// quick reference to the configuration options exists at
// http://tidy.sourceforge.net/docs/quickref.html
//
// * But were afraid to ask
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
word-2000: yes
clean: yes
drop-font-tags: no
doctype: auto
drop-empty-paras: yes
drop-proprietary-attributes: yes
enclose-block-text: yes
enclose-text: yes
escape-cdata: yes
logical-emphasis: yes
indent: auto
indent-spaces: 2
break-before-br: yes
output-xhtml: yes
force-output: yes

View File

@@ -0,0 +1,68 @@
<?php
##
## Plugin for htmlArea, to run code through the server's HTML Tidy
## By Adam Wright, for The University of Western Australia
## This is the server-side script, which dirty code is run through.
##
## Distributed under the same terms as HTMLArea itself.
## This notice MUST stay intact for use (see license.txt).
##
// Get the original source
$source = $_POST['htisource_name'];
$source = stripslashes($source);
// Open a tidy process - I hope it's installed!
$descriptorspec = array(
0 => array("pipe", "r"),
1 => array("pipe", "w")
);
$process = proc_open("tidy -utf8 -config html-tidy-config.cfg", $descriptorspec, $pipes);
// Make sure the program started and we got the hooks...
// Either way, get some source code into $source
if (is_resource($process)) {
// Feed untidy source into the stdin
fwrite($pipes[0], $source);
fclose($pipes[0]);
// Read clean source out to the browser
while (!feof($pipes[1])) {
//echo fgets($pipes[1], 1024);
$newsrc .= fgets($pipes[1], 1024);
}
fclose($pipes[1]);
// Clean up after ourselves
proc_close($process);
} else {
// Better give them back what they came with, so they don't lose it all...
$newsrc = "<body>\n" .$source. "\n</body>";
}
// Split our source into an array by lines
$srcLines = explode("\n",$newsrc);
// Get only the lines between the body tags
$startLn = 0;
while ( strpos( $srcLines[$startLn++], '<body' ) === false && $startLn < sizeof($srcLines) );
$endLn = $startLn;
while ( strpos( $srcLines[$endLn++], '</body' ) === false && $endLn < sizeof($srcLines) );
$srcLines = array_slice( $srcLines, $startLn, ($endLn - $startLn - 1) );
// Create a set of javascript code to compile a new source string
foreach ($srcLines as $line) {
$jsMakeSrc .= "\tns += '" . str_replace("'","\'",$line) . "\\n';\n";
}
if(!sizeof($srcLines)) {
echo "alert(HTMLArea._lc('Tidy failed. Check your HTML for syntax errors.', 'HtmlTidy'));\n";
} else {
?>
var ns="";
<?php echo $jsMakeSrc; ?>
editor.setHTML(ns);
<? } ?>

View File

@@ -0,0 +1,105 @@
// Plugin for htmlArea to run code through the server's HTML Tidy
// By Adam Wright, for The University of Western Australia
//
// Distributed under the same terms as HTMLArea itself.
// This notice MUST stay intact for use (see license.txt).
function HtmlTidy(editor) {
this.editor = editor;
var cfg = editor.config;
var bl = HtmlTidy.btnList;
var self = this;
this.onMode = this.__onMode;
// register the toolbar buttons provided by this plugin
var toolbar = [];
for (var i = 0; i < bl.length; ++i) {
var btn = bl[i];
if (btn == "html-tidy") {
var id = "HT-html-tidy";
cfg.registerButton(id, this._lc("HTML Tidy"), editor.imgURL(btn[0] + ".gif", "HtmlTidy"), true,
function(editor, id) {
// dispatch button press event
self.buttonPress(editor, id);
}, btn[1]);
toolbar.push(id);
} else if (btn == "html-auto-tidy") {
var btnTxt = [this._lc("Auto-Tidy"), this._lc("Don't Tidy")];
var optionItems = new Object();
optionItems[btnTxt[0]] = "auto";
optionItems[btnTxt[1]] = "noauto";
var ht_class = {
id : "HT-auto-tidy",
options : optionItems,
action : function (editor) { self.__onSelect(editor, this); },
refresh : function (editor) { },
context : "body"
};
cfg.registerDropdown(ht_class);
}
}
for (var i in toolbar) {
cfg.toolbar[0].push(toolbar[i]);
}
};
HtmlTidy._pluginInfo = {
name : "HtmlTidy",
version : "1.0",
developer : "Adam Wright",
developer_url : "http://blog.hipikat.org/",
sponsor : "The University of Western Australia",
sponsor_url : "http://www.uwa.edu.au/",
license : "htmlArea"
};
HtmlTidy.prototype._lc = function(string) {
return HTMLArea._lc(string, 'HtmlTidy');
}
HtmlTidy.prototype.__onSelect = function(editor, obj) {
// Get the toolbar element object
var elem = editor._toolbarObjects[obj.id].element;
// Set our onMode event appropriately
if (elem.value == "auto")
this.onMode = this.__onMode;
else
this.onMode = null;
};
HtmlTidy.prototype.__onMode = function(mode) {
if ( mode == "textmode" ) {
this.buttonPress(this.editor, "HT-html-tidy");
}
};
HtmlTidy.btnList = [
null, // separator
["html-tidy"],
["html-auto-tidy"]
];
HtmlTidy.prototype.buttonPress = function(editor, id) {
switch (id)
{
case "HT-html-tidy":
{
var oldhtml = editor.getHTML();
if(oldhtml=="") break; //don't clean empty text
// Ask the server for some nice new html, based on the old...
HTMLArea._postback(_editor_url + 'plugins/HtmlTidy/html-tidy-logic.php', {'htisource_name' : oldhtml},
function(javascriptResponse) { eval(javascriptResponse) });
}
break;
}
};
HtmlTidy.prototype.processTidied = function(newSrc) {
editor = this.editor;
editor.setHTML(newSrc);
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

View File

@@ -0,0 +1,17 @@
// I18N constants
// LANG: "de", ENCODING: UTF-8
// Author: Raimund Meyer ray@ray-of-light.org
// FOR TRANSLATORS:
//
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
// (at least a valid email address)
//
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
// (if this is not possible, please include a comment
// that states what encoding is necessary.)
{
"HTML Tidy": "HTML Tidy"
}

View File

@@ -0,0 +1,17 @@
// I18N constants
// LANG: "fr", ENCODING: UTF-8
// Author: Laurent Vilday, mokhet@mokhet.com
// FOR TRANSLATORS:
//
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
// (at least a valid email address)
//
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
// (if this is not possible, please include a comment
// that states what encoding is necessary.)
{
"HTML Tidy": "HTML Tidy"
}

View File

@@ -0,0 +1,16 @@
// I18N constants
// LANG: "nl", ENCODING: UTF-8
// FOR TRANSLATORS:
// Nederlands: MadMiner basura@sitter.nl [2/2005]
// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
// (at least a valid email address)
//
// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
// (if this is not possible, please include a comment
// that states what encoding is necessary.)
{
"HT-html-tidy": "HTML opschonen"
}

View File

@@ -0,0 +1,7 @@
// I18N constants
// LANG: "no", ENCODING: UTF-8
// translated: Kim Steinhaug, http://www.steinhaug.com/, kim@steinhaug.com
{
"HTML Tidy": "HTML Tidy"
}