Revision: 8327
http://languagetool.svn.sourceforge.net/languagetool/?rev=8327&view=rev
Author: gulp21-1
Date: 2012-11-09 18:56:51 +0000 (Fri, 09 Nov 2012)
Log Message:
-----------
[extension/fx] fixed broken images problem
added test files
corrected some typos
show response text in case of an error
Modified Paths:
--------------
trunk/extension/common/locales/en-US/description.txt
trunk/extension/firefox/TODO
trunk/extension/firefox/data/panel.css
trunk/extension/firefox/data/panel.js
trunk/extension/firefox/lib/main.js
trunk/extension/firefox/locale/de-DE.properties
trunk/extension/firefox/locale/en-US.properties
trunk/extension/firefox/package.json
Added Paths:
-----------
trunk/extension/common/tests/
trunk/extension/common/tests/FAILING_TESTS
trunk/extension/common/tests/englishTest.html
trunk/extension/common/tests/escapeHtmlTagsTest.html
trunk/extension/common/tests/escapeHtmlTagsTest.txt
trunk/extension/common/tests/escapeUrlTest.html
trunk/extension/common/tests/germanTest.html
trunk/extension/common/tests/index.html
trunk/extension/common/tests/index.html.create.bash
trunk/extension/common/tests/scriptContentsTest.html
Modified: trunk/extension/common/locales/en-US/description.txt
===================================================================
--- trunk/extension/common/locales/en-US/description.txt 2012-11-09
17:34:10 UTC (rev 8326)
+++ trunk/extension/common/locales/en-US/description.txt 2012-11-09
18:56:51 UTC (rev 8327)
@@ -12,19 +12,23 @@
- Select the text that you want to check, or click in a text field if you want
to check its contents.
- Click on the LT icon, which is displayed in the bottom right corner on the
<a
href="http://support.mozilla.org/kb/add-on-bar-quick-access-to-add-ons">add-on
bar</a> by default, to have the text checked.
-By default, the extension tries to use a locally running LanguageTool server.
Download the stand-alone version of LanguageTool from the <a
href="http://languagetool.org/">LanguageTool website</a> and either run
<code>java -cp LanguageTool.jar org.languagetool.server.HTTPServer</code>, or
open LanguageToolGUI.jar with Java and enable the server in the preferences,
and keep the programme running. Alternatively, you can enable the web service
in the <a
href="http://support.mozilla.org/kb/extensions-add-features-to-firefox#w_how-to-change-extension-settings">settings
of the add-on</a> (please read the privacy policy linked above).
+By default, the extension tries to use a locally running LanguageTool server.
Download the stand-alone version of LanguageTool from the <a
href="http://languagetool.org/">LanguageTool website</a> and either run
<code>java -cp LanguageTool.jar org.languagetool.server.HTTPServer</code>, or
open LanguageToolGUI.jar with Java and enable the server in the preferences,
and keep the program running. Alternatively, you can enable the web service in
the <a
href="http://support.mozilla.org/kb/extensions-add-features-to-firefox#w_how-to-change-extension-settings">settings
of the add-on</a> (please read the privacy policy linked above).
LanguageTool tries to auto-detect the language of the text; nevertheless, you
should set a sensible fallback language in the settings of the add-on.
Furthermore, a mother tongue must be set in order to get warnings about false
friends.
If you want to move the LT-icon to another place, follow these steps:
-- Right-click on the add-on bar at the button of the browser window.
-- Select “Customize…”.
+- Right-click on the add-on bar at the bottom of the browser window.
+- Select “Customize…“.
- Drag and drop the icon to wherever you want.
- Click on “Done”.
- You might want to close add-on bar by clicking on the close icon on the
left.
<h1>Known Issues</h1>
+- It is not possible to check texts on websites which were loaded before the
installation of the extension.
- If you select a headline and the following paragraph, you might get a
warning about wrong case because LanguageTool doesn't consider the paragraph.
-- "Text" between <script>-HTML-tags is checked, if it is part of the selection.
-- Sometimes it is possible that you see broken images in the list of errors.
+- “Text“ between <script>-HTML-tags is checked, if it is part of the selection.
+
+<h1>What about Thunderbird?</h1>
+
+Those of you who want to check text in Thunderbird using LanguageTool might
want to try the <a
href="https://addons.mozilla.org/thunderbird/addon/grammar-checker/">Grammar
Checker</a> extension.
Added: trunk/extension/common/tests/FAILING_TESTS
===================================================================
--- trunk/extension/common/tests/FAILING_TESTS (rev 0)
+++ trunk/extension/common/tests/FAILING_TESTS 2012-11-09 18:56:51 UTC (rev
8327)
@@ -0,0 +1,3 @@
+As of 09/11/12
+
+- scriptContentsTest.html
Added: trunk/extension/common/tests/englishTest.html
===================================================================
--- trunk/extension/common/tests/englishTest.html
(rev 0)
+++ trunk/extension/common/tests/englishTest.html 2012-11-09 18:56:51 UTC
(rev 8327)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>englishTest</title>
+</head>
+<body>
+
+Paste your own text here… or check this text too see an few of of the
problems that LanguageTool can detecd.
+
+(4 mistakes)
+
+</body>
+</html>
Added: trunk/extension/common/tests/escapeHtmlTagsTest.html
===================================================================
--- trunk/extension/common/tests/escapeHtmlTagsTest.html
(rev 0)
+++ trunk/extension/common/tests/escapeHtmlTagsTest.html 2012-11-09
18:56:51 UTC (rev 8327)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>escapeHtmlTagsTest</title>
+</head>
+<body>
+
+Here is <noscript><p><img
src="http://languagetool.org/screenshots/art/screenshot_lo3_very_small.png"/></p></noscript>a
image. This<img
src="http://languagetool.org/screenshots/art/screenshot_lo3_very_small.png"/>
should not cause a broken image icon in the results.
+
+(1 mistake)
+
+</body>
+</html>
Added: trunk/extension/common/tests/escapeHtmlTagsTest.txt
===================================================================
--- trunk/extension/common/tests/escapeHtmlTagsTest.txt
(rev 0)
+++ trunk/extension/common/tests/escapeHtmlTagsTest.txt 2012-11-09 18:56:51 UTC
(rev 8327)
@@ -0,0 +1,5 @@
+The script tag should not appear in the popup.
+
+<script>alert("Test");</script>
+
+The links should <a href="..">not not</a> mix up the text. <a
href="example.com">Another link</a>.
\ No newline at end of file
Added: trunk/extension/common/tests/escapeUrlTest.html
===================================================================
--- trunk/extension/common/tests/escapeUrlTest.html
(rev 0)
+++ trunk/extension/common/tests/escapeUrlTest.html 2012-11-09 18:56:51 UTC
(rev 8327)
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>escapeUrlTest</title>
+</head>
+<body>
+
+There should be no problem, when I writes 50 % & an bit more text. (2 mistakes)
+
+</body>
+</html>
Added: trunk/extension/common/tests/germanTest.html
===================================================================
--- trunk/extension/common/tests/germanTest.html
(rev 0)
+++ trunk/extension/common/tests/germanTest.html 2012-11-09 18:56:51 UTC
(rev 8327)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>germanTest</title>
+</head>
+<body>
+
+Nachdem Max nun beinahe drei Stunden mit unbewegter Miene und fast
geschlossenen Liedern auf das LCD-Display starrte, forderte ihn seine Mutter
auf, doch mal rauszugehen , und mit seine Freunden zu speilen. Ihr wurde immer
Angst und bange, wenn sie sehen muss, wie viel Zeit ihr Sohn vor dem Computer
verbingt. Sie glaubst manchmal dass sie ihn bald nur noch per Email erreichen
kann. Vielleicht zu recht.
+
+(13 Fehler)
+
+</body>
+</html>
Added: trunk/extension/common/tests/index.html
===================================================================
--- trunk/extension/common/tests/index.html (rev 0)
+++ trunk/extension/common/tests/index.html 2012-11-09 18:56:51 UTC (rev
8327)
@@ -0,0 +1,15 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Tests</title>
+</head>
+<body>
+<table>
+<tr><td><a href="scriptContentsTest.html">scriptContentsTest.html</a></td></tr>
+<tr><td><a href="germanTest.html">germanTest.html</a></td></tr>
+<tr><td><a href="escapeHtmlTagsTest.txt">escapeHtmlTagsTest.txt</a></td></tr>
+<tr><td><a href="escapeHtmlTagsTest.html">escapeHtmlTagsTest.html</a></td></tr>
+<tr><td><a href="englishTest.html">englishTest.html</a></td></tr>
+</table>
+</body>
+</html>
Added: trunk/extension/common/tests/index.html.create.bash
===================================================================
--- trunk/extension/common/tests/index.html.create.bash
(rev 0)
+++ trunk/extension/common/tests/index.html.create.bash 2012-11-09 18:56:51 UTC
(rev 8327)
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+echo "<!DOCTYPE HTML>" > index.html
+echo "<html>" >> index.html
+echo "<head>" >> index.html
+echo "<title>Tests</title>" >> index.html
+echo "</head>" >> index.html
+echo "<body>" >> index.html
+echo "<table>" >> index.html
+
+for filename in `ls -r`
+do
+ if [[ "$filename" == *.bash ]]; then
+ continue
+ fi
+ if [ "$filename" == "index.html" ]; then
+ continue
+ fi
+ echo "<tr><td><a href=\"$filename\">$filename</a></td></tr>" >>
index.html
+done
+
+echo "</table>" >> index.html
+echo "</body>" >> index.html
+echo "</html>" >> index.html
Property changes on: trunk/extension/common/tests/index.html.create.bash
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/extension/common/tests/scriptContentsTest.html
===================================================================
--- trunk/extension/common/tests/scriptContentsTest.html
(rev 0)
+++ trunk/extension/common/tests/scriptContentsTest.html 2012-11-09
18:56:51 UTC (rev 8327)
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>scriptContentsTest</title>
+</head>
+<body>
+
+Press Control+A. LanguageTool should find exactly one errors (and ignore the
contents of the following code).
+
+<script type="text/javascript">
+try {
+var myvar = "A error";
+} catch( err ) {}
+</script>
+
+</body>
+</html>
Modified: trunk/extension/firefox/TODO
===================================================================
--- trunk/extension/firefox/TODO 2012-11-09 17:34:10 UTC (rev 8326)
+++ trunk/extension/firefox/TODO 2012-11-09 18:56:51 UTC (rev 8327)
@@ -1,9 +1,10 @@
-- bug: CTRL-A and check on languagetool.org and you'll see broken images in the
- list of errors. Maybe HTML escaping is missing?
+- use radio type simple-pref for language selection when it becomes available
in the
+ next version of the sdk (https://bugzilla.mozilla.org/show_bug.cgi?id=710107)
+- possibility to undock the panel
+
- bug: CTRL-A and check on languagetool.org and you'll get Javascript code
checked.
"Text" in between <script>...</script> should probably be ignored.
- This also happens when checking text files like
extension/common/locales/en-US/description.txt.
- if you select a headline and the following paragraph you'll get an error
because
LT doesn't consider the paragraph
Modified: trunk/extension/firefox/data/panel.css
===================================================================
--- trunk/extension/firefox/data/panel.css 2012-11-09 17:34:10 UTC (rev
8326)
+++ trunk/extension/firefox/data/panel.css 2012-11-09 18:56:51 UTC (rev
8327)
@@ -38,4 +38,8 @@
hr:last-child {
display: none;
-}
\ No newline at end of file
+}
+
+.hidden {
+ display: none;
+}
Modified: trunk/extension/firefox/data/panel.js
===================================================================
--- trunk/extension/firefox/data/panel.js 2012-11-09 17:34:10 UTC (rev
8326)
+++ trunk/extension/firefox/data/panel.js 2012-11-09 18:56:51 UTC (rev
8327)
@@ -1,3 +1,10 @@
+function unhide() {
+ for(var i=0; i<document.getElementsByClassName("hidden").length; ++i) {
+ document.getElementsByClassName("hidden")[i].className="";
+ }
+ document.getElementById("unhidelink").innerHTML="";
+}
+
self.port.on("setText", function(text) {
document.getElementById("body").innerHTML=text;
});
@@ -6,11 +13,13 @@
'click',
function(event) {
var t=event.target;
- if(t.nodeName=="A") {
+ if(t.nodeName=="A" && t.toString().indexOf("javascript:")!=0) {
event.stopPropagation();
event.preventDefault();
self.port.emit('linkClicked', t.toString());
}
+ if(t.toString().indexOf("javascript:unhide()")==0)
+ unhide(); // WORKAROUND don't know why fx says
"ReferenceError: unhide is not defined"
},
false
);
Modified: trunk/extension/firefox/lib/main.js
===================================================================
--- trunk/extension/firefox/lib/main.js 2012-11-09 17:34:10 UTC (rev 8326)
+++ trunk/extension/firefox/lib/main.js 2012-11-09 18:56:51 UTC (rev 8327)
@@ -23,10 +23,39 @@
* escape %, ?, and & in url
* normal escape does not work properly with umlauts
*/
-function myEscape(string) {
- return
string.replace(/\%/g,"%25").replace(/\?/g,"%3F").replace(/\&/g,"%26")
+function escapeUrl(string) {
+ return
string.replace(/\%/g,"%25").replace(/\?/g,"%3F").replace(/\&/g,"%26");
}
+/**
+ * escape <, >, and " in xml
+ */
+function escapeXml(string) {
+ return
string.replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""");
+}
+
+/**
+ * removes contents of <script>, html tags, newlines, and trims the resulting
string
+ */
+function preprocess(text) {
+ return text.replace(/\<script\>[\s\S]*?\<\/script\>/gm," <BR> ") //
remove everything between <script>-Tags
+ .replace(/\<\/?([\s\S]*?)\>/gm,"") // remove html tags
+ .replace(/(\r\n|\n|\r)/gm,"") // remove newlines
+ .replace(/(\s+\<BR\>\s+(\<BR\>\s+)*)/g," ") // remove extra
spaces added after newline
+ .replace(/^\s+|\s+$/g,""); // trim
+}
+
+function formatError(error) {
+ var prepend="";
+ if(error.indexOf("not a language code known")!=-1) {
+ prepend=_("checkLanguageCode")+"<br/>";
+ }
+ return prepend
+ + error.replace(/(\r\n|\n|\r)/," <a id=\"unhidelink\"
href=\"javascript:unhide();\">…</a><br/>")
+ .replace(/\<br\/\>/,"<div class=\"hidden\">")
+ + "</div>";
+}
+
function getAttributeValue(string, attribute) {
if(string.indexOf(attribute+"=\"")==-1)
return "";
@@ -67,18 +96,18 @@
}
for(var i=1; i<response.length; ++i) {
- var returnText="<div
class=\"msg\">"+getAttributeValue(response[i],"msg")+"</div>";
+ var returnText="<div
class=\"msg\">"+escapeXml(getAttributeValue(response[i],"msg"))+"</div>";
fromx=getAttributeValue(response[i],"fromx");
tox=getAttributeValue(response[i],"tox");
l=selectedText.substring(0,fromx);
if(l.length>MAXCONTEXTLENGTH) {
- l="…"+l.substring(l.length-MAXCONTEXTLENGTH);
+
l="…"+escapeXml(l.substring(l.length-MAXCONTEXTLENGTH));
}
- m=selectedText.substring(fromx,tox);
+ m=escapeXml(selectedText.substring(fromx,tox));
r=selectedText.substring(tox);
if(r.length>MAXCONTEXTLENGTH) {
- r=r.substring(0,MAXCONTEXTLENGTH)+"…";
+ r=escapeXml(r.substring(0,MAXCONTEXTLENGTH))+"…";
}
id=getAttributeValue(response[i],"ruleId");
if(id.indexOf("MORFOLOGIK")!=-1 || id.indexOf("HUNSPELL")!=-1) {
@@ -122,12 +151,10 @@
function widgetClicked() {
if(selectedText!=null)
- selectedText=selectedText.replace(/(\r\n|\n|\r)/gm," <BR> ") //
remove newlines
-
.replace(/(\s+\<BR\>\s+(\<BR\>\s+)*)/g," ") // remove extra spaces added after
newline
- .replace(/^\s+|\s+$/g,""); // trim
+ selectedText=preprocess(selectedText);
- console.log("Selection: "+selectedText);
- console.log("Selection (escaped): "+myEscape(selectedText));
+ console.log("Selection (preprocessed): "+selectedText);
+ console.log("Selection (escaped): "+escapeUrl(selectedText));
var autodetect="";
if(simpleprefs.prefs.autodetect) {
@@ -139,14 +166,17 @@
mothertongue="&motherTongue="+simpleprefs.prefs.mothertongue;
}
- var
contentString="language="+simpleprefs.prefs.language+mothertongue+autodetect+"&text="+myEscape(selectedText);
+ var
contentString="language="+simpleprefs.prefs.language+mothertongue+autodetect+"&text="+escapeUrl(selectedText);
var checkTextOnline=Request({
url: "http://api.languagetool.org:8081/",
onComplete: function (response) {
if(response.status!=200) {
console.log("Response status:
"+response.status);
- var errorText=_("errorOccuredStatus")+"
"+response.status
+ var errorText=_("errorOccurredStatus")+"
"+response.status
+ if(response.status==500) {
+
errorText+="<br/>"+formatError(response.text);
+ }
panel.port.emit("setText", "<div
class=\"status\">"+errorText+"</div>");
} else {
text=response.text;
@@ -163,7 +193,7 @@
onComplete: function (response) {
if(response.status!=200) {
console.log("Response status:
"+response.status);
- var errorText=_("errorOccuredStatus")+"
"+response.status
+ var errorText=_("errorOccurredStatus")+"
"+response.status
if(simpleprefs.prefs.enableWebService) {
console.log("Connecting with web
service");
errorText+="<br>"+_("usingWebService");
@@ -172,6 +202,8 @@
} else {
if(response.status==0) {
errorText+="<br/>"+_("checkLtRunning");
+ } else if(response.status==500) {
+
errorText+="<br/>"+formatError(response.text);
}
panel.port.emit("setText", "<div
class=\"status\">"+errorText+"</div>");
}
Modified: trunk/extension/firefox/locale/de-DE.properties
===================================================================
--- trunk/extension/firefox/locale/de-DE.properties 2012-11-09 17:34:10 UTC
(rev 8326)
+++ trunk/extension/firefox/locale/de-DE.properties 2012-11-09 18:56:51 UTC
(rev 8327)
@@ -1,4 +1,4 @@
-errorOccuredStatus=Es ist ein Fehler aufgetreten. Statuscode:
+errorOccurredStatus=Es ist ein Fehler aufgetreten. Statuscode:
pleaseWaitWhileChecking=Bitte warten Sie, während der Text überprüft
wird …
noProblemsFound=Es wurden keine Probleme gefunden.
checkSelectionWithLT=Markierten Text oder Text in Textfeld mit LanguageTool
überprüfen
@@ -6,10 +6,11 @@
checkLtRunning=Bitte stellen Sie sicher, dass ein LanguageTool-Server auf Port
8081 läuft oder aktivieren Sie den Webservice in den <a
href="about:addons">Add-on-Einstellungen</a>.
usingWebService=Benutzen des lokalen Servers fehlgeschlagen, verbinde mit
Webservice …
emptyText=Keine Text ist markiert und kein Textfeld ist aktiviert. Bitte
markieren Sie einen Text oder ein Textfeld, um den Text prüfen zu lassen.
+checkLanguageCode=Bitte stellen Sie sicher, dass die Sprachcodes in <a
href="about:addons">den Add-on-Einstellungen</a> richtig sind. Benutzen Sie
Codes wie 'de-DE', nicht 'de_DE', 'de-de' oder 'deutsch'.
textLanguage=Textsprache:
motherTongue=Muttersprache:
autodetect_title=Automatische Erkennung der Textsprache aktivieren
-autodetect_description=Wenn diese Option aktiviert ist, versucht LanguageTool
die Sprache des Textes automatisch zu erkennen. Wenn eine vernünftige
automatische Erkennung nicht möglich ist (d. h. wenn der Text zu kurz ist),
wird die unten angebene Sprache benutzt.
+autodetect_description=Wenn diese Option aktiviert ist, versucht LanguageTool
die Sprache des Textes automatisch zu erkennen. Wenn eine vernünftige
automatische Erkennung nicht möglich ist (d. h. wenn der Text zu kurz ist),
wird die unten angegebene Sprache benutzt.
language_title=Sprache
language_description=LanguageTool wird davon ausgehen, dass der zu prüfenden
Text in dieser Sprache ist. Benutzen Sie Sprachcodes wie 'en-US' oder 'de-DE'.
mothertongue_title=Muttersprache
Modified: trunk/extension/firefox/locale/en-US.properties
===================================================================
--- trunk/extension/firefox/locale/en-US.properties 2012-11-09 17:34:10 UTC
(rev 8326)
+++ trunk/extension/firefox/locale/en-US.properties 2012-11-09 18:56:51 UTC
(rev 8327)
@@ -1,15 +1,16 @@
-errorOccuredStatus=An error occured. Status code:
+errorOccurredStatus=An error occurred. Status code:
pleaseWaitWhileChecking=Please wait while the text is being
checked …
noProblemsFound=No problems have been found.
-checkSelectionWithLT=Check selected text or text in textfield with LanguageTool
+checkSelectionWithLT=Check selected text or text in text field with
LanguageTool
moreInformation=more information
-checkLtRunning=Please make sure that a LanguageTool Server is running on port
8081 or enable the web service in <a href="about:addons">the setttings of the
add-on</a>.
+checkLtRunning=Please make sure that a LanguageTool Server is running on port
8081 or enable the web service in <a href="about:addons">the settings of the
add-on</a>.
usingWebService=Using local server failed, connecting with web
service …
textLanguage=Text language:
motherTongue=Mother tongue:
autodetect_title=Enable auto-detection of the text language
autodetect_description=If this option is enabled, LanguageTool tries to
auto-detect the language of the text. If a sensible auto-detection is not
possible (i.e. the text is too short), the language given below is used.
-emptyText=No text is selected and no textfield is active. Please select a text
or a textfield in order to have the text checked.
+emptyText=No text is selected and no text field is active. Please select a
text or a text field in order to have the text checked.
+checkLanguageCode=Please make sure that the language codes in <a
href="about:addons">the settings of the add-on</a> are correct. Use codes like
'en-US', not 'en_US', 'en-us', or 'english'.
language_title=Language
language_description=LanguageTool will assume that the text to be checked is
in this language. Use language codes like 'en-US' or 'de-DE'.
mothertongue_title=Mother tongue
Modified: trunk/extension/firefox/package.json
===================================================================
--- trunk/extension/firefox/package.json 2012-11-09 17:34:10 UTC (rev
8326)
+++ trunk/extension/firefox/package.json 2012-11-09 18:56:51 UTC (rev
8327)
@@ -2,6 +2,7 @@
"name": "languagetoolfx",
"license": "GPL 3.0",
"author": "Markus Brenneis",
+ "contributors": "The LanguageTool Developers",
"version": "0.1-pre",
"fullName": "LanguageToolFx",
"id": "jid1-j3KiX1n7UXrjxQ",
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits