[MediaWiki-commits] [Gerrit] Use experimental WSYSIWYG editor conditionally - change (mediawiki...ContentTranslation)

2014-06-16 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/140053

Change subject: Use experimental WSYSIWYG editor conditionally
..

Use experimental WSYSIWYG editor conditionally

Introducing boolean global $wgContentTranslationWYSIWYGEditor
Default value is false.

Change-Id: I9f604f53ef333a9f980aefdc628abd25fa3f4728
---
M ContentTranslation.hooks.php
M ContentTranslation.php
M Resources.php
M modules/editor/ext.cx.editor.js
4 files changed, 21 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/53/140053/1

diff --git a/ContentTranslation.hooks.php b/ContentTranslation.hooks.php
index 54b4fda..d87a812 100644
--- a/ContentTranslation.hooks.php
+++ b/ContentTranslation.hooks.php
@@ -16,7 +16,7 @@
 * Hook: BeforePageDisplay
 */
public static function addModules( $out, $skin ) {
-   global $wgContentTranslationEventLogging;
+   global $wgContentTranslationEventLogging, 
$wgContentTranslationWYSIWYGEditor;
 
$title = $out-getTitle();
$user = $out-getUser();
@@ -41,6 +41,13 @@
) );
}
 
+   if ( $wgContentTranslationWYSIWYGEditor ) {
+   // WYSIWYGEditor
+   $out-addModules( 'ext.cx.editor.medium' );
+   } else {
+   // Just ContentEditable
+   $out-addModules( 'ext.cx.editor' );
+   }
return true;
}
 
@@ -75,11 +82,12 @@
 * @return bool
 */
public static function addConfig( $vars ) {
-   global $wgContentTranslationServerURL, 
$wgContentTranslationDomainTemplate;
+   global $wgContentTranslationServerURL, 
$wgContentTranslationDomainTemplate,
+   $wgContentTranslationWYSIWYGEditor;
 
$vars['wgContentTranslationServerURL'] = 
$wgContentTranslationServerURL;
$vars['wgContentTranslationDomainTemplate'] = 
$wgContentTranslationDomainTemplate;
-
+   $vars['wgContentTranslationWYSIWYGEditor'] = 
$wgContentTranslationWYSIWYGEditor;
return true;
}
 }
diff --git a/ContentTranslation.php b/ContentTranslation.php
index 0f91931..12804eb 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -46,7 +46,7 @@
 
 // Content translation server URL
 $GLOBALS['wgContentTranslationServerURL'] = 'http://localhost:8080';
-
+$GLOBALS['wgContentTranslationWYSIWYGEditor'] = false;
 $GLOBALS['wgContentTranslationParsoid'] = array(
'url' = 'http://parsoid.wmflabs.org/',
'timeout' = 100 * 1000, // Parsoid timeout in milliseconds
diff --git a/Resources.php b/Resources.php
index 8d64aa3..8d0d61a 100644
--- a/Resources.php
+++ b/Resources.php
@@ -77,7 +77,6 @@
'dependencies' = array(
'jquery.uls.data',
'mediawiki.Uri',
-   'ext.cx.editor'
),
'styles' = array(
'translation/styles/ext.cx.translation.less',
@@ -237,14 +236,16 @@
 $wgResourceModules['ext.cx.editor'] = array(
'scripts' = array(
'editor/ext.cx.editor.js',
+   ),
+) + $resourcePaths;
+
+$wgResourceModules['ext.cx.editor.medium'] = array(
+   'scripts' = array(
+   'editor/ext.cx.editor.js',
'editor/medium/medium-editor.js'
),
'styles' = array(
'editor/medium/medium-editor.css',
'editor/medium/theme/agora.css'
-   ),
-   'dependencies' = array(
-   'ext.cx.entrypoint',
-   'mediawiki.jqueryMsg',
),
 ) + $resourcePaths;
diff --git a/modules/editor/ext.cx.editor.js b/modules/editor/ext.cx.editor.js
index 6b7e755..dada243 100644
--- a/modules/editor/ext.cx.editor.js
+++ b/modules/editor/ext.cx.editor.js
@@ -43,8 +43,9 @@
}
// Make the element editable
this.$editableElement.attr( 'contenteditable', true );
-   // Initialize a WYSIWYG editor
-   this.wysiwygEditor();
+   if ( mw.config.get( 'wgContentTranslationWYSIWYGEditor' ) ) {
+   this.wysiwygEditor();
+   }
};
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/140053
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f604f53ef333a9f980aefdc628abd25fa3f4728
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Section alignment corrections - change (mediawiki...ContentTranslation)

2014-06-13 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/139334

Change subject: Section alignment corrections
..

Section alignment corrections

* Used a div as placeholder instead of using the same tag in source as
  placeholer, so that we can better control the dimensions of this div
* Initiate the calculate the section dimensions only after a few milliseconds
  delay to make sure the style sheets of source page is ready and applied

Bug: 66411
Change-Id: Ic71b52d2218e7ffe971d249a917a26b00f9afc33
---
M modules/translation/ext.cx.translation.js
M modules/translation/styles/ext.cx.translation.less
2 files changed, 61 insertions(+), 60 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/34/139334/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 74995f4..8210494 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -80,8 +80,16 @@
};
 
ContentTranslationEditor.prototype.listen = function () {
+   var cxTranslation = this;
mw.hook( 'mw.cx.translation.add' ).add( $.proxy( this.update, 
this ) );
-   mw.hook( 'mw.cx.source.loaded' ).add( $.proxy( 
this.addPlaceholders, this ) );
+   mw.hook( 'mw.cx.source.loaded' ).add( function () {
+   // Delay adding placeholders. If we calculate the 
section
+   // dimensions before all css and screenpainting is done,
+   // there is a chance for section missalignment
+   window.setTimeout( function () {
+   cxTranslation.addPlaceholders();
+   }, 2000 );
+   } );
};
 
/**
@@ -89,10 +97,20 @@
 * @param {string} sourceId source section identifier
 */
ContentTranslationEditor.prototype.update = function ( sourceId ) {
-   var $section = $( jquerySelectorForId( sourceId, 't' ) );
+   var targetSectionId, $section;
 
-   // Copy the whole section html to translation section.
-   $section.html( $( '#' + sourceId ).html() );
+   targetSectionId = jquerySelectorForId( sourceId, 'cx' );
+   $section = $( targetSectionId );
+   // Replace the placeholder with the source section
+   $section.replaceWith( $( '#' + sourceId )
+   .clone()
+   .attr( {
+   'id': 'cx' + sourceId,
+   'contenteditable': true,
+   'data-source': sourceId
+   } )
+   );
+   $section = $( targetSectionId );
 
// For every segment, use MT as replacement
$section.find( '.cx-segment' ).each( function () {
@@ -101,9 +119,12 @@
$( this ).html( translation );
}
} );
+   // Adapt the links
$section.adaptLinks( mw.cx.targetLanguage );
// Trigger input event so that the alignemnt is right.
-   $section.trigger( 'input' );
+   $section.on( 'input', keepAlignment )
+   .trigger( 'input' );
+   // Attach an editor
$section.cxEditor();
this.calculateCompletion();
mw.hook( 'mw.cx.translation.change' ).fire();
@@ -216,17 +237,17 @@
 
function sourceSectionClickHandler() {
/*jshint validthis:true */
-   $( jquerySelectorForId( $( this ).attr( 'id' ), 't' ) ).click();
+   $( jquerySelectorForId( $( this ).attr( 'id' ), 'cx' ) 
).click();
}
 
function sourceSectionMouseEnterHandler() {
/*jshint validthis:true */
-   $( jquerySelectorForId( $( this ).attr( 'id' ), 't' ) 
).mouseenter();
+   $( jquerySelectorForId( $( this ).attr( 'id' ), 'cx' ) 
).mouseenter();
}
 
function sourceSectionMouseLeaveHandler() {
/*jshint validthis:true */
-   $( jquerySelectorForId( $( this ).attr( 'id' ), 't' ) 
).mouseleave();
+   $( jquerySelectorForId( $( this ).attr( 'id' ), 'cx' ) 
).mouseleave();
}
 
/**
@@ -234,64 +255,44 @@
 * are aligned to the source sections. Also provides mouse hover 
effects.
 */
ContentTranslationEditor.prototype.addPlaceholders = function () {
-   var $content, template,
-   $sections, i, $section, sourceSectionId, $sourceSection,
-   cxSectionSelector = mw.cx.getSectionSelector();
+   var $sourceContent, template, $sourceSection, 

[MediaWiki-commits] [Gerrit] Editor: remove link from editor toolbar since it is handled ... - change (mediawiki...ContentTranslation)

2014-06-10 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138554

Change subject: Editor: remove link from editor toolbar since it is handled 
differently
..

Editor: remove link from editor toolbar since it is handled differently

Change-Id: I2cbb0a6809c87f17dc2f9d05875ee3a2661676a1
---
M modules/editor/ext.cx.editor.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/54/138554/1

diff --git a/modules/editor/ext.cx.editor.js b/modules/editor/ext.cx.editor.js
index e790241..189e882 100644
--- a/modules/editor/ext.cx.editor.js
+++ b/modules/editor/ext.cx.editor.js
@@ -14,7 +14,7 @@
 
var editorOptions = {
cleanPastedHTML: true,
-   buttons: [ 'bold', 'italic', 'anchor', 'header1', 'header2', 
'unorderedlist', 'orderedlist', 'indent', 'outdent' ],
+   buttons: [ 'bold', 'italic', 'header1', 'header2', 
'unorderedlist', 'orderedlist', 'indent', 'outdent' ],
firstHeader: 'h2',
secondHeader: 'h3'
};

-- 
To view, visit https://gerrit.wikimedia.org/r/138554
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cbb0a6809c87f17dc2f9d05875ee3a2661676a1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Cards: refactor all common styles to ext.cx.tools.card RL mo... - change (mediawiki...ContentTranslation)

2014-06-10 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138569

Change subject: Cards: refactor all common styles to ext.cx.tools.card RL module
..

Cards: refactor all common styles to ext.cx.tools.card RL module

Change-Id: I8e0dae9edcb2bfbe49dd070246b5225859141dd8
---
M Resources.php
A modules/tools/styles/ext.cx.tools.card.less
M modules/tools/styles/ext.cx.tools.dictionary.less
M modules/tools/styles/ext.cx.tools.instructions.less
M modules/tools/styles/ext.cx.tools.less
M modules/tools/styles/ext.cx.tools.link.less
6 files changed, 49 insertions(+), 36 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/69/138569/1

diff --git a/Resources.php b/Resources.php
index ed368a6..8d64aa3 100644
--- a/Resources.php
+++ b/Resources.php
@@ -113,6 +113,12 @@
),
 ) + $resourcePaths;
 
+$wgResourceModules['ext.cx.tools.card'] = array(
+   'styles' = array(
+   'tools/styles/ext.cx.tools.card.less',
+   ),
+) + $resourcePaths;
+
 $wgResourceModules['ext.cx.tools.instructions'] = array(
'scripts' = array(
'tools/ext.cx.tools.instructions.js',
@@ -132,6 +138,7 @@
),
'dependencies' = array(
'ext.cx.tools.manager',
+   'ext.cx.tools.card',
),
 ) + $resourcePaths;
 
@@ -147,6 +154,7 @@
),
'dependencies' = array(
'ext.cx.tools.manager',
+   'ext.cx.tools.card',
),
 ) + $resourcePaths;
 
@@ -164,6 +172,7 @@
),
'dependencies' = array(
'ext.cx.tools.manager',
+   'ext.cx.tools.card',
),
 ) + $resourcePaths;
 
diff --git a/modules/tools/styles/ext.cx.tools.card.less 
b/modules/tools/styles/ext.cx.tools.card.less
new file mode 100644
index 000..52b2401
--- /dev/null
+++ b/modules/tools/styles/ext.cx.tools.card.less
@@ -0,0 +1,39 @@
+@import ../../base/styles/grid/agora-grid;
+
+.card {
+   background: #FF;
+   border: 1px solid #C9C9C9;
+   border-radius: 2px;
+   box-shadow: 0 1px 0 #C9C9C9;
+   margin-top: 15px;
+   :hover {
+   border-color: #BB;
+   box-shadow: 0 1px 0 #BB;
+   }
+}
+
+.card__title {
+.mw-ui-item;
+.mw-ui-one-whole;
+color: #c9c9c9;
+padding: 4px;
+}
+
+/* Cards animation */
+@keyframes card-show-animation {
+   0% {
+   opacity: 0;
+   transform: rotate(10deg);
+   left: 200px;
+   }
+   50% {
+   opacity: 0;
+   transform: rotate(10deg);
+   left: 200px;
+   }
+   100% {
+   opacity: 1;
+   transform: rotate(0deg);
+   left: 0px;
+   }
+}
diff --git a/modules/tools/styles/ext.cx.tools.dictionary.less 
b/modules/tools/styles/ext.cx.tools.dictionary.less
index a6fd86b..8105a45 100644
--- a/modules/tools/styles/ext.cx.tools.dictionary.less
+++ b/modules/tools/styles/ext.cx.tools.dictionary.less
@@ -7,8 +7,7 @@
font-size: medium;
padding-top: 8px;
 
-   .card__title {
-   .mw-ui-item;
+.card__title {
.mw-ui-one-third;
}
 
diff --git a/modules/tools/styles/ext.cx.tools.instructions.less 
b/modules/tools/styles/ext.cx.tools.instructions.less
index 1541519..0aa9ff0 100644
--- a/modules/tools/styles/ext.cx.tools.instructions.less
+++ b/modules/tools/styles/ext.cx.tools.instructions.less
@@ -6,24 +6,6 @@
position: relative;
 }
 
-@keyframes card-show-animation {
-   0% {
-   opacity: 0;
-   transform: rotate(10deg);
-   left: 200px;
-   }
-   50% {
-   opacity: 0;
-   transform: rotate(10deg);
-   left: 200px;
-   }
-   100% {
-   opacity: 1;
-   transform: rotate(0deg);
-   left: 0px;
-   }
-}
-
 .card__section.guidelines {
text-align: center;
color: #3366bb;
diff --git a/modules/tools/styles/ext.cx.tools.less 
b/modules/tools/styles/ext.cx.tools.less
index a14e143..0834b87 100644
--- a/modules/tools/styles/ext.cx.tools.less
+++ b/modules/tools/styles/ext.cx.tools.less
@@ -1,17 +1,5 @@
 @import ../../base/styles/grid/agora-grid;
 
-.card {
-   background: #FF;
-   border: 1px solid #C9C9C9;
-   border-radius: 2px;
-   box-shadow: 0 1px 0 #C9C9C9;
-   margin-top: 15px;
-   :hover {
-   border-color: #BB;
-   box-shadow: 0 1px 0 #BB;
-   }
-}
-
 .card.search {
/* @embed */
background: url(../images/search.png) no-repeat scroll 10px center 
#FF;
diff --git a/modules/tools/styles/ext.cx.tools.link.less 
b/modules/tools/styles/ext.cx.tools.link.less
index cc7acd9..5fb342e 100644
--- a/modules/tools/styles/ext.cx.tools.link.less
+++ 

[MediaWiki-commits] [Gerrit] Cards: add animation to dictionary and link cards too - change (mediawiki...ContentTranslation)

2014-06-10 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138570

Change subject: Cards: add animation to dictionary and link cards too
..

Cards: add animation to dictionary and link cards too

Change-Id: I5f6539d8bee52ddaf3c39bea2b9faa8617923e23
---
M modules/tools/styles/ext.cx.tools.dictionary.less
M modules/tools/styles/ext.cx.tools.link.less
2 files changed, 12 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/70/138570/1

diff --git a/modules/tools/styles/ext.cx.tools.dictionary.less 
b/modules/tools/styles/ext.cx.tools.dictionary.less
index 8105a45..8f8103c 100644
--- a/modules/tools/styles/ext.cx.tools.dictionary.less
+++ b/modules/tools/styles/ext.cx.tools.dictionary.less
@@ -1,5 +1,11 @@
 @import ../../base/styles/grid/agora-grid;
 
+.card.dictionary {
+animation-name: card-show-animation;
+   animation-duration: 1.5s;
+position: relative;
+}
+
 .card__title-row {
.mw-ui-item;
.mw-ui-one-whole;
diff --git a/modules/tools/styles/ext.cx.tools.link.less 
b/modules/tools/styles/ext.cx.tools.link.less
index 5fb342e..df88f7b 100644
--- a/modules/tools/styles/ext.cx.tools.link.less
+++ b/modules/tools/styles/ext.cx.tools.link.less
@@ -1,5 +1,11 @@
 @import ../../base/styles/grid/agora-grid;
 
+.card.link {
+animation-name: card-show-animation;
+   animation-duration: 1.5s;
+position: relative;
+}
+
 .card__remove-link {
@vertical-margin: 10px;
@horizontal-margin: 15px;

-- 
To view, visit https://gerrit.wikimedia.org/r/138570
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5f6539d8bee52ddaf3c39bea2b9faa8617923e23
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Cards: Check for no cards in regular interval, show default ... - change (mediawiki...ContentTranslation)

2014-06-10 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138576

Change subject: Cards: Check for no cards in regular interval, show default card
..

Cards: Check for no cards in regular interval, show default card

Change-Id: I248f6e380961f998e77000ca1f76051388766f06
---
M modules/tools/ext.cx.tools.manager.js
1 file changed, 10 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/76/138576/1

diff --git a/modules/tools/ext.cx.tools.manager.js 
b/modules/tools/ext.cx.tools.manager.js
index 2291fd9..680bc0f 100644
--- a/modules/tools/ext.cx.tools.manager.js
+++ b/modules/tools/ext.cx.tools.manager.js
@@ -65,7 +65,7 @@
 * @param {Array|Object|string} The data passed by the event.
 */
CXToolManager.prototype.dispatch = function ( eventName ) {
-   var index, tools, cxToolManager = this,
+   var index, tools,
data = Array.prototype.slice.apply( arguments );
 
mw.log( '[CX] event:' + eventName + ' , data:' + data );
@@ -75,15 +75,6 @@
// Call render function on the current setting module.
this.showCard( tools[ index ], data );
}
-
-   // Wait for a while before checking if any cards are shown
-   // XXX This works, but can go wrong as we have more cards. Need
-   // to think more robust way.
-   window.setTimeout( function () {
-   if ( !cxToolManager.$container.find( '.card' ).length ) 
{
-   cxToolManager.showCard( 
cxToolManager.options.defaultTool );
-   }
-   }, 1000 );
};
 
/**
@@ -91,13 +82,21 @@
 * dispatch them
 */
CXToolManager.prototype.listen = function () {
-   var event;
+   var event, cxToolManager = this;
 
for ( event in this.eventRegistry ) {
mw.hook( event ).add(
$.proxy( this.dispatch, this, event )
);
}
+
+   // Check if there are any cards shown in regular time intervals
+   // If not show the default tool
+   window.setInterval( function () {
+   if ( !cxToolManager.$container.find( '.card' ).length ) 
{
+   cxToolManager.showCard( 
cxToolManager.options.defaultTool );
+   }
+   }, 5000 );
};
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/138576
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I248f6e380961f998e77000ca1f76051388766f06
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Tools: Make the search field really a search field - change (mediawiki...ContentTranslation)

2014-06-10 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138579

Change subject: Tools: Make the search field really a search field
..

Tools: Make the search field really a search field

use type=search

Change-Id: I1b368fadb2ffe428a9710b1cd0e0e42090e12217
---
M modules/tools/ext.cx.tools.js
1 file changed, 7 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/79/138579/1

diff --git a/modules/tools/ext.cx.tools.js b/modules/tools/ext.cx.tools.js
index fab5518..d5b9783 100644
--- a/modules/tools/ext.cx.tools.js
+++ b/modules/tools/ext.cx.tools.js
@@ -37,7 +37,7 @@
};
 
ContentTranslationTools.prototype.render = function () {
-   var $progressBar;
+   var $progressBar, $search;
 
this.$searchBox = $( 'div' )
.addClass( 'card search cx-tools--container' );
@@ -46,13 +46,13 @@
$progressBar = $( 'div' )
.addClass( 'cx-header__progressbar' )
.cxProgressBar();
-
-   this.$searchBox.append(
-   $( 'input' )
+   $search = $( 'input' )
.addClass( 'tools-words-search box' )
-   .attr( 'placeholder', mw.msg( 'cx-tools-searchbox-text' 
) )
-   );
-
+   .attr( {
+   placeholder: mw.msg( 'cx-tools-searchbox-text' 
),
+   type: 'search'
+   } );
+   this.$searchBox.append( $search );
this.$container.append(
$progressBar,
this.$searchBox,

-- 
To view, visit https://gerrit.wikimedia.org/r/138579
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b368fadb2ffe428a9710b1cd0e0e42090e12217
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Blacklist all templates for the source article - change (mediawiki...ContentTranslation)

2014-06-10 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138777

Change subject: Blacklist all templates for the source article
..

Blacklist all templates for the source article

Do not present them to translator.
In follow up commits, we will selectively enable them

Change-Id: Ib634f4e1c4f2b944efa41692f5055ba1d520561e
---
M Resources.php
A modules/source/conf/en-es.json
A modules/source/conf/es-ca.json
A modules/source/ext.cx.source.filter.js
M modules/source/ext.cx.source.js
M modules/translation/ext.cx.translation.js
6 files changed, 87 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/77/138777/1

diff --git a/Resources.php b/Resources.php
index ed368a6..7219cca 100644
--- a/Resources.php
+++ b/Resources.php
@@ -56,7 +56,10 @@
 ) + $resourcePaths;
 
 $wgResourceModules['ext.cx.source'] = array(
-   'scripts' = 'source/ext.cx.source.js',
+   'scripts' =  array(
+   'source/ext.cx.source.js',
+   'source/ext.cx.source.filter.js'
+   ),
'styles' = array(
'source/styles/ext.cx.source.less',
),
diff --git a/modules/source/conf/en-es.json b/modules/source/conf/en-es.json
new file mode 100644
index 000..bcf487e
--- /dev/null
+++ b/modules/source/conf/en-es.json
@@ -0,0 +1,3 @@
+{
+   enabled: []
+}
diff --git a/modules/source/conf/es-ca.json b/modules/source/conf/es-ca.json
new file mode 100644
index 000..bcf487e
--- /dev/null
+++ b/modules/source/conf/es-ca.json
@@ -0,0 +1,3 @@
+{
+   enabled: []
+}
diff --git a/modules/source/ext.cx.source.filter.js 
b/modules/source/ext.cx.source.filter.js
new file mode 100644
index 000..fadb89a
--- /dev/null
+++ b/modules/source/ext.cx.source.filter.js
@@ -0,0 +1,72 @@
+/**
+ * ContentTranslation Tools
+ * A tool that allows editors to translate pages from one language
+ * to another with the help of machine translation and other translation tools
+ *
+ * @file
+ * @ingroup Extensions
+ * @copyright See AUTHORS.txt
+ * @license GPL-2.0+
+ */
+( function ( $, mw ) {
+   'use strict';
+
+   /**
+* Fetch the source content filter configuration for the given
+* language pairs
+*/
+   function fetchFilterConfiguration( sourceLanguage, targetLanguage ) {
+   return $.getJSON( mw.config.get( 'wgExtensionAssetsPath' ) +
+   '/ContentTranslation/modules/source/conf/' + 
sourceLanguage + '-' + targetLanguage + '.json' );
+   }
+
+   /**
+* CXSourceFilter
+*
+* @class
+*/
+   function CXSourceFilter( element ) {
+   this.$container = $( element );
+   this.listen();
+   }
+
+   CXSourceFilter.prototype.filter = function ( configuration ) {
+   $( '[typeof=mw:Transclusion]' ).each( function () {
+   var templateName = $( this ).data( 'mw' ).parts[ 0 
].template.target.wt;
+   if ( configuration.enabled  
configuration.enabled.indexOf( templateName ) = 0 ) {
+   mw.log( '[CX] Keeping template:' + templateName 
);
+   } else {
+   mw.log( '[CX] Removing template:' + 
templateName );
+   $( this ).remove();
+   }
+   } );
+   mw.hook( 'mw.cx.source.ready' ).fire();
+   };
+
+   CXSourceFilter.prototype.listen = function () {
+   var filter = this;
+   mw.hook( 'mw.cx.source.loaded' ).add( function () {
+   fetchFilterConfiguration( mw.cx.sourceLanguage, 
mw.cx.targetLanguage ).done( function ( configuration ) {
+   filter.filter( configuration );
+   } ).fail( function () {
+   filter.filter();
+   } );
+   } );
+   };
+
+   $.fn.cxFilterSource = function () {
+   return this.each( function () {
+   var $this = $( this ),
+   data = $this.data( 'cxSourceFilter' );
+
+   if ( !data ) {
+   $this.data(
+   'cxSourceFilter', ( data = new 
CXSourceFilter( this ) )
+   );
+   }
+
+   } );
+   };
+
+   $.fn.cxSource.defaults = {};
+}( jQuery, mediaWiki ) );
diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index 20cc248..5b14dbc 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -22,7 +22,7 @@
$.get( mw.config.get( 'wgContentTranslationServerURL' ) + 
'/page/' + language + '/' + title )
.done( function ( response ) {
 

[MediaWiki-commits] [Gerrit] Update the dictionary test page as per api changes - change (mediawiki...cxserver)

2014-06-08 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/138301

Change subject: Update the dictionary test page as per api changes
..

Update the dictionary test page as per api changes

Change-Id: I96a2fb6e957a59d18161b9433641232681393ee9
---
M public/dictionary/js/main.js
1 file changed, 21 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/01/138301/1

diff --git a/public/dictionary/js/main.js b/public/dictionary/js/main.js
index 3f461f3..dc7b664 100644
--- a/public/dictionary/js/main.js
+++ b/public/dictionary/js/main.js
@@ -2,21 +2,33 @@
 ( function ( $ ) {
'use strict';
 
-   $( document ).ready( function () {
-   $( 'button' ).click( function () {
-   $( '.definition' ).empty();
-   var word = $( 'input[name=word]' ).val(),
-   from = $( 'input[name=sourceLanguage]' ).val(),
-   to = $( 'input[name=targetLanguage]' ).val();
-   $.get( word + '/' + from + '/' + to, function ( 
response ) {
+   function lookup() {
+   $( '.definition' ).empty();
+   var word = $( 'input[name=word]' ).val(),
+   from = $( 'input[name=sourceLanguage]' ).val(),
+   to = $( 'input[name=targetLanguage]' ).val();
+   $.get( word + '/' + from + '/' + to, function ( response ) {
+   if ( response.translations ) {
$.each( response.translations, function ( 
index, translation ) {
$( '.definition' ).append( 
translation.phrase );
$( '.definition' ).append( '\n' );
$( '.definition' ).append( 
translation.info );
$( '.definition' ).append( '\n' );
} );
-   $( 'progress' ).hide();
-   } );
+   }
+   if ( response.freetext ) {
+   $.each( response.freetext, function ( index, 
freetext ) {
+   $( '.definition' ).append( 
freetext.text );
+   $( '.definition' ).append( '\n' );
+   $( '.definition' ).append( 
freetext.sources );
+   $( '.definition' ).append( '\n' );
+   } );
+   }
+   $( 'progress' ).hide();
} );
+   }
+
+   $( document ).ready( function () {
+   $( 'button' ).click( lookup );
} );
 }( jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/138301
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I96a2fb6e957a59d18161b9433641232681393ee9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Minor whitespace, comment, variable cleanup - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137543

Change subject: Minor whitespace, comment, variable cleanup
..

Minor whitespace, comment, variable cleanup

Change-Id: I0c603573f7f047598aee1268aaba0d16427546a9
---
M modules/tools/ext.cx.tools.js
1 file changed, 4 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/43/137543/1

diff --git a/modules/tools/ext.cx.tools.js b/modules/tools/ext.cx.tools.js
index 2efb8f0..fab5518 100644
--- a/modules/tools/ext.cx.tools.js
+++ b/modules/tools/ext.cx.tools.js
@@ -25,10 +25,12 @@
ContentTranslationTools.prototype.init = function () {
this.render();
this.$toolsContainer.cxtoolmanager();
+   // Handle enter key press in the search field.
this.$searchBox.find( 'input' ).keypress( function ( event ) {
if ( event.which === 13 ) {
-   mw.hook( 'mw.cx.search.word' ).fire( $( this 
).val().trim().toLowerCase() );
-   mw.hook( 'mw.cx.search.link'). fire( $( this 
).val().trim().toLowerCase() );
+   var text = $( this ).val().trim().toLowerCase();
+   mw.hook( 'mw.cx.search.word' ).fire( text );
+   mw.hook( 'mw.cx.search.link' ).fire( text );
}
} );
mw.hook( 'mw.cx.tools.ready' ).fire();

-- 
To view, visit https://gerrit.wikimedia.org/r/137543
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c603573f7f047598aee1268aaba0d16427546a9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Use jsonp for fetching link lookup - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137547

Change subject: Use jsonp for fetching link lookup
..

Use jsonp for fetching link lookup

Change-Id: Ie4b6d1d0c37471d8859ca7fe30eda0472e23f8ad
---
M modules/tools/ext.cx.tools.link.js
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/47/137547/1

diff --git a/modules/tools/ext.cx.tools.link.js 
b/modules/tools/ext.cx.tools.link.js
index 9e1fe3c..d006d89 100644
--- a/modules/tools/ext.cx.tools.link.js
+++ b/modules/tools/ext.cx.tools.link.js
@@ -55,7 +55,11 @@
prop: 'pageimages',
piprop: 'thumbnail',
pithumbsize: 100,
+   redirects: true,
format: 'json'
+   }, {
+   url: '//' + mw.cx.targetLanguage + 
'.wikipedia.org/w/api.php',
+   dataType: 'jsonp'
} );
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/137547
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie4b6d1d0c37471d8859ca7fe30eda0472e23f8ad
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Error handler for dictionary lookup failures - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137548

Change subject: Error handler for dictionary lookup failures
..

Error handler for dictionary lookup failures

Hide the dictionary card if the api response is a failre

Change-Id: I1998e87aa01f602995000b32d936621e454f977f
---
M modules/tools/ext.cx.tools.dictionary.js
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/48/137548/1

diff --git a/modules/tools/ext.cx.tools.dictionary.js 
b/modules/tools/ext.cx.tools.dictionary.js
index 3419762..bb9d840 100644
--- a/modules/tools/ext.cx.tools.dictionary.js
+++ b/modules/tools/ext.cx.tools.dictionary.js
@@ -103,7 +103,8 @@
}
this.$card.find( '.card__headword' ).text( word );
getTranslation( word, mw.cx.sourceLanguage, 
mw.cx.targetLanguage )
-   .done( $.proxy( this.showResult, this ) );
+   .done( $.proxy( this.showResult, this ) )
+   .fail( $.proxy( this.stop, this ) );
};
 
DictionaryCard.prototype.stop = function () {

-- 
To view, visit https://gerrit.wikimedia.org/r/137548
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1998e87aa01f602995000b32d936621e454f977f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Avoid reference links from triggers for link cards - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137858

Change subject: Avoid reference links from triggers for link cards
..

Avoid reference links from triggers for link cards

Change-Id: I62f4fe180023cb11f4956882a0d263b0cd66920b
---
M modules/translation/ext.cx.translation.js
1 file changed, 5 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/58/137858/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 429ccd5..6d888c7 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -108,7 +108,11 @@
this.calculateCompletion();
mw.hook( 'mw.cx.translation.change' ).fire();
$section.on( 'click', 'a', function () {
-   mw.hook( 'mw.cx.select.link' ).fire( $( this ) );
+   var $link = $( this );
+   // avoid all reference links
+   if ( !$link.parent().hasClass( 'reference' ) ) {
+   mw.hook( 'mw.cx.select.link' ).fire( $link );
+   }
} );
$section.on( 'click', function () {
var selection = window.getSelection().toString();

-- 
To view, visit https://gerrit.wikimedia.org/r/137858
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I62f4fe180023cb11f4956882a0d263b0cd66920b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Support variadic arguments for event dispatcher - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137868

Change subject: Support variadic arguments for event dispatcher
..

Support variadic arguments for event dispatcher

Change-Id: I7607311db9a2237c1dc026e984ec7ced0bcfe502
---
M modules/tools/ext.cx.tools.manager.js
1 file changed, 8 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/68/137868/1

diff --git a/modules/tools/ext.cx.tools.manager.js 
b/modules/tools/ext.cx.tools.manager.js
index 9768262..2291fd9 100644
--- a/modules/tools/ext.cx.tools.manager.js
+++ b/modules/tools/ext.cx.tools.manager.js
@@ -64,12 +64,13 @@
 * @param {string} eventName event name
 * @param {Array|Object|string} The data passed by the event.
 */
-   CXToolManager.prototype.dispatch = function ( eventName, data ) {
-   var index, tools, cxToolManager = this;
+   CXToolManager.prototype.dispatch = function ( eventName ) {
+   var index, tools, cxToolManager = this,
+   data = Array.prototype.slice.apply( arguments );
 
-   //this.hideCards();
mw.log( '[CX] event:' + eventName + ' , data:' + data );
tools = this.eventRegistry[ eventName ];
+   data = data.splice( 1 );
for ( index in tools ) {
// Call render function on the current setting module.
this.showCard( tools[ index ], data );
@@ -113,7 +114,10 @@
}
tool = new mw.cx.tools[ toolName ]();
this.$container.append( tool.getCard() );
-   tool.start( data );
+   if ( typeof data === 'string' ) {
+   data = new Array( data );
+   }
+   tool.start.apply( tool, data );
this.tools[ toolName ] = tool;
};
 

-- 
To view, visit https://gerrit.wikimedia.org/r/137868
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7607311db9a2237c1dc026e984ec7ced0bcfe502
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Allow exploring the links in source article as well. - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137869

Change subject: Allow exploring the links in source article as well.
..

Allow exploring the links in source article as well.

Change-Id: Ia6f3f0087f0cb4cfc2e3e773aa95c1c680827271
---
M modules/source/ext.cx.source.js
M modules/tools/ext.cx.tools.link.js
2 files changed, 22 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/69/137869/1

diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index 32cc7bf..20cc248 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -111,6 +111,12 @@
 */
ContentTranslationSource.prototype.disableLinks = function () {
this.$content.find( 'a' ).bind( 'click', function () {
+   var $link = $( this );
+   // avoid all reference links
+   if ( !$link.parent().hasClass( 'reference' ) ) {
+   mw.hook( 'mw.cx.select.link' ).fire( 
$link.text(), mw.cx.sourceLanguage );
+   }
+   // Disable link click
return false;
} );
};
diff --git a/modules/tools/ext.cx.tools.link.js 
b/modules/tools/ext.cx.tools.link.js
index d093746..1f2d4fb 100644
--- a/modules/tools/ext.cx.tools.link.js
+++ b/modules/tools/ext.cx.tools.link.js
@@ -51,7 +51,7 @@
}
};
 
-   function getLink( word ) {
+   function getLink( word, language ) {
var api = new mw.Api();
 
return api.get( {
@@ -63,8 +63,10 @@
redirects: true,
format: 'json'
}, {
-   url: '//' + mw.cx.targetLanguage + 
'.wikipedia.org/w/api.php',
-   dataType: 'jsonp'
+   url: '//' + language + '.wikipedia.org/w/api.php',
+   dataType: 'jsonp',
+   // This prevents warnings about the unrecognized 
parameter _
+   cache: true
} );
}
 
@@ -158,9 +160,10 @@
}
}
 
-   LinkCard.prototype.start = function ( link ) {
+   LinkCard.prototype.start = function ( link, language ) {
var word, linkCard = this;
 
+   language = language || mw.cx.targetLanguage;
if ( typeof link === 'string' ) {
word = link;
} else {
@@ -174,11 +177,18 @@
this.$card.hide();
if ( this.$link ) {
this.$card.show();
+   // Since this is an existing link, we can show the link 
title early.
+   this.$card.find( '.card__link-text' )
+   .text( word )
+   .attr( {
+   target: '_blank',
+   href: '//' + language + 
'.wikipedia.org/wiki/' + word
+   } );
this.$addLink.hide();
} else {
this.$removeLink.hide();
}
-   getLink( word ).done( function ( response ) {
+   getLink( word, language ).done( function ( response ) {
var imgSrc, pageId, range, page;
 
pageId = Object.keys( response.query.pages )[ 0 ];
@@ -194,7 +204,7 @@
.text( page.title )
.attr( {
target: '_blank',
-   href: '//' + mw.cx.targetLanguage + 
'.wikipedia.org/wiki/' + page.title
+   href: '//' + language + 
'.wikipedia.org/wiki/' + page.title
} );
linkCard.$addLink.click( function () {
restoreSelection( range );

-- 
To view, visit https://gerrit.wikimedia.org/r/137869
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia6f3f0087f0cb4cfc2e3e773aa95c1c680827271
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Dictionary: Add a little padding for the word translations - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137880

Change subject: Dictionary: Add a little padding for the word translations
..

Dictionary: Add a little padding for the word translations

Change-Id: Ic3cb1e0bb4b918e3ab5ffdd41227c3c85eec3ef9
---
M modules/tools/styles/ext.cx.tools.dictionary.less
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/80/137880/1

diff --git a/modules/tools/styles/ext.cx.tools.dictionary.less 
b/modules/tools/styles/ext.cx.tools.dictionary.less
index c48b157..a6fd86b 100644
--- a/modules/tools/styles/ext.cx.tools.dictionary.less
+++ b/modules/tools/styles/ext.cx.tools.dictionary.less
@@ -76,5 +76,6 @@
.mw-ui-one-whole;
float: none; // XXX why would it be needed?
clear: both;
+   padding: 5px;
text-align: center;
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/137880
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic3cb1e0bb4b918e3ab5ffdd41227c3c85eec3ef9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Remove mw.cx.select.link from supported event for Dictionary - change (mediawiki...ContentTranslation)

2014-06-05 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137879

Change subject: Remove mw.cx.select.link from supported event for Dictionary
..

Remove mw.cx.select.link from supported event for Dictionary

word selection and search is enough for dictionary

Change-Id: I77d3ec50af3a630e998243c21c53188155eac49b
---
M modules/tools/ext.cx.tools.dictionary.js
1 file changed, 0 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/79/137879/1

diff --git a/modules/tools/ext.cx.tools.dictionary.js 
b/modules/tools/ext.cx.tools.dictionary.js
index bb9d840..7acc26f 100644
--- a/modules/tools/ext.cx.tools.dictionary.js
+++ b/modules/tools/ext.cx.tools.dictionary.js
@@ -114,7 +114,6 @@
DictionaryCard.prototype.getTriggerEvents = function () {
return [
'mw.cx.select.word',
-   'mw.cx.select.link',
'mw.cx.search.word'
];
};

-- 
To view, visit https://gerrit.wikimedia.org/r/137879
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I77d3ec50af3a630e998243c21c53188155eac49b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Links card: Remove link feature - change (mediawiki...ContentTranslation)

2014-06-04 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137275

Change subject: Links card: Remove link feature
..

Links card: Remove link feature

Change-Id: I2fcfc8ff12e06a685cff428feb191119d585e769
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M modules/tools/ext.cx.tools.js
A modules/tools/ext.cx.tools.link.js
A modules/tools/styles/ext.cx.tools.link.less
M modules/translation/ext.cx.translation.js
7 files changed, 118 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/75/137275/1

diff --git a/Resources.php b/Resources.php
index a767996..2fe558b 100644
--- a/Resources.php
+++ b/Resources.php
@@ -108,6 +108,7 @@
'ext.cx.tools.manager',
'ext.cx.tools.dictionary',
'ext.cx.tools.instructions',
+   'ext.cx.tools.link'
),
 ) + $resourcePaths;
 
@@ -148,6 +149,21 @@
),
 ) + $resourcePaths;
 
+$wgResourceModules['ext.cx.tools.link'] = array(
+   'scripts' = array(
+   'tools/ext.cx.tools.link.js',
+   ),
+   'styles' = array(
+   'tools/styles/ext.cx.tools.link.less',
+   ),
+   'messages' = array(
+   'cx-tools-link-remove',
+   ),
+   'dependencies' = array(
+   'ext.cx.tools.manager',
+   ),
+) + $resourcePaths;
+
 $wgResourceModules['ext.cx.progressbar'] = array(
'scripts' = 'tools/ext.cx.progressbar.js',
'styles' = array(
diff --git a/i18n/en.json b/i18n/en.json
index bd9d8cb..5803fb9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -36,5 +36,6 @@
cx-tools-instructions-text6: When you are happy with the result, 
press \{{int:cx-publish-button}}\.,
cx-tools-searchbox-text: Search for a word,
cx-tools-view-guidelines: [$1 View translation guidelines],
-   cx-tools-dictionary-title: Definition
+   cx-tools-dictionary-title: Definition,
+   cx-tools-link-remove: Remove link
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 0571e0e..09109e7 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -39,5 +39,6 @@
cx-tools-searchbox-text: Placeholder text for the searchbox on the 
translation tools column,
cx-tools-dictionary-title: Used as the title for a card that shows 
dictinary definition.,
cx-tools-view-guidelines: Parameters:\n* $1 - the URL pointing to 
the guidelines for translation in Wikipedia,
-   cx-tools-dictionary-title: Title of definition tool card
+   cx-tools-dictionary-title: Title of definition tool card,
+   cx-tools-link-remove: Text shown in link tool card. Clicking on it 
removes the link in the context
 }
diff --git a/modules/tools/ext.cx.tools.js b/modules/tools/ext.cx.tools.js
index 4f2f8ce..2efb8f0 100644
--- a/modules/tools/ext.cx.tools.js
+++ b/modules/tools/ext.cx.tools.js
@@ -28,6 +28,7 @@
this.$searchBox.find( 'input' ).keypress( function ( event ) {
if ( event.which === 13 ) {
mw.hook( 'mw.cx.search.word' ).fire( $( this 
).val().trim().toLowerCase() );
+   mw.hook( 'mw.cx.search.link'). fire( $( this 
).val().trim().toLowerCase() );
}
} );
mw.hook( 'mw.cx.tools.ready' ).fire();
diff --git a/modules/tools/ext.cx.tools.link.js 
b/modules/tools/ext.cx.tools.link.js
new file mode 100644
index 000..8fddfd6
--- /dev/null
+++ b/modules/tools/ext.cx.tools.link.js
@@ -0,0 +1,70 @@
+/**
+ * ContentTranslation Tools
+ * A tool that allows editors to translate pages from one language
+ * to another with the help of machine translation and other translation tools
+ *
+ * @file
+ * @ingroup Extensions
+ * @copyright See AUTHORS.txt
+ * @license GPL-2.0+
+ */
+( function ( $, mw ) {
+   'use strict';
+
+   function LinkCard() {
+   this.$card = null;
+   this.$removeLink = null;
+   this.$link = null;
+   }
+
+   LinkCard.prototype.getCard = function () {
+
+   this.$card = $( 'div' )
+   .addClass( 'card link' );
+
+   this.$removeLink = $( 'div' )
+   .addClass( 'card__remove-link' )
+   .text( mw.msg( 'cx-tools-link-remove' ) );
+
+   this.$card.append( this.$removeLink );
+   this.listen();
+   return this.$card;
+   };
+
+   LinkCard.prototype.removeLink = function () {
+   if ( this.$link ) {
+   this.$link.after( this.$link.text() ).remove();
+   this.$removeLink.hide();
+   }
+   };
+
+   LinkCard.prototype.listen = function () {
+   this.$removeLink.on( 'click', $.proxy( this.removeLink, this ) 
);
+   };
+
+   LinkCard.prototype.start = function ( 

[MediaWiki-commits] [Gerrit] Avoid overlap of content with the column sub titles - change (mediawiki...ContentTranslation)

2014-06-04 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/137536

Change subject: Avoid overlap of content with the column sub titles
..

Avoid overlap of content with the column sub titles

The page content was overlapping with language, view page sub titles
making the view page link not clickable

Change-Id: I932841a952a2db51ade876d99e64e379337b14d3
---
M modules/base/styles/ext.cx.base.less
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/36/137536/1

diff --git a/modules/base/styles/ext.cx.base.less 
b/modules/base/styles/ext.cx.base.less
index 32dcac0..d123659 100644
--- a/modules/base/styles/ext.cx.base.less
+++ b/modules/base/styles/ext.cx.base.less
@@ -45,6 +45,10 @@
.mw-ui-one-half(@palm);
 }
 
+.cx-column__content {
+   clear: both;
+}
+
 .cx-column--tools {
.mw-ui-one-whole(@palm);
background: #f0f0f0;

-- 
To view, visit https://gerrit.wikimedia.org/r/137536
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I932841a952a2db51ade876d99e64e379337b14d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Make it possible to choose source and target languages - change (mediawiki...ContentTranslation)

2014-06-03 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136978

Change subject: Make it possible to choose source and target languages
..

Make it possible to choose source and target languages

* URL param 'from' to specify source language. Default value is 
wgContentLanguage
* URL param 'to' to specify target language. Default value is wgUserLanguage

Change-Id: I12b1d158d19a934cf69aacae80c8f9a906c8e2b1
---
M modules/entrypoint/ext.cx.entrypoint.js
M modules/source/ext.cx.source.js
2 files changed, 3 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/78/136978/1

diff --git a/modules/entrypoint/ext.cx.entrypoint.js 
b/modules/entrypoint/ext.cx.entrypoint.js
index 1bd1a67..d8377a0 100644
--- a/modules/entrypoint/ext.cx.entrypoint.js
+++ b/modules/entrypoint/ext.cx.entrypoint.js
@@ -41,7 +41,7 @@
window.location.href = mw.util.getUrl(
'Special:ContentTranslation', {
page: sourceTitle,
-   lang: targetLanguage,
+   to: targetLanguage,
targettitle: targetTitle
}
);
diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index 8d2d4c1..9e4dc11 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -45,8 +45,8 @@
 
ContentTranslationSource.prototype.init = function () {
mw.cx.sourceTitle = new mw.Uri().query.page;
-   mw.cx.targetLanguage = new mw.Uri().query.lang || '';
-   mw.cx.sourceLanguage = mw.config.get( 'wgContentLanguage' );
+   mw.cx.targetLanguage = new mw.Uri().query.to || mw.config.get( 
'wgUserLanguage' );
+   mw.cx.sourceLanguage = new mw.Uri().query.from || 
mw.config.get( 'wgContentLanguage' );
this.render();
mw.cx.fetchPage( mw.cx.sourceTitle, mw.cx.sourceLanguage );
this.listen();

-- 
To view, visit https://gerrit.wikimedia.org/r/136978
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I12b1d158d19a934cf69aacae80c8f9a906c8e2b1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Increase api timeout for publishing, better error handling f... - change (mediawiki...ContentTranslation)

2014-06-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136739

Change subject: Increase api timeout for publishing, better error handling for 
publishing
..

Increase api timeout for publishing, better error handling for publishing

* Increased the ajax timeout for the publishing 100*1000 milliseconds
* Increase the parsoid http response timeout to 100*1000 milliseconds
* Pass the exception details from parsoid api call to client instead of
  hardcoded string.

Change-Id: I8303db0f6db31fc21ea04a506e40e2fbbcaee891
---
M ContentTranslation.php
M api/ApiContentTranslationPublish.php
M modules/translation/ext.cx.publish.js
3 files changed, 7 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/39/136739/1

diff --git a/ContentTranslation.php b/ContentTranslation.php
index 2b92c38..9939917 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -50,7 +50,7 @@
 
 $GLOBALS['wgContentTranslationParsoid'] = array(
'url' = 'http://parsoid.wmflabs.org/',
-   'timeout' = 15,
+   'timeout' = 100*1000, // Parsoid timeout in milliseconds
'prefix' = 'enwiki',
 );
 
diff --git a/api/ApiContentTranslationPublish.php 
b/api/ApiContentTranslationPublish.php
index 8edf224..820f990 100644
--- a/api/ApiContentTranslationPublish.php
+++ b/api/ApiContentTranslationPublish.php
@@ -82,7 +82,7 @@
try {
$wikitext = $this-convertHtmlToWikitext( $title, 
$params['html'] );
} catch ( MWException $e ) {
-   $this-dieUsage( 'Conversion to wikitext with parsoid 
failed', 'parsoidserver' );
+   $this-dieUsage( $e-getMessage(), 'parsoidserver' );
}
 
$saveresult = $this-saveWikitext( $title, $wikitext, $params );
diff --git a/modules/translation/ext.cx.publish.js 
b/modules/translation/ext.cx.publish.js
index c8ae9d2..5c01392 100644
--- a/modules/translation/ext.cx.publish.js
+++ b/modules/translation/ext.cx.publish.js
@@ -70,11 +70,15 @@
function publishTranslation( title, content, sourceTitle ) {
var api = new mw.Api();
 
-   return api.postWithEditToken( {
+   return api.postWithToken( 'edit', {
action: 'cxpublish',
title: title,
html: content,
sourcetitle: sourceTitle
+   }, {
+   // A bigger timeout since publishing after converting 
html to wikitext
+   // parsoid is not a fast operation.
+   timeout: 100 * 1000 // in milliseconds
} );
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/136739
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8303db0f6db31fc21ea04a506e40e2fbbcaee891
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Remove unused wgContentTranslationServerTimeout - change (mediawiki...ContentTranslation)

2014-06-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136973

Change subject: Remove unused wgContentTranslationServerTimeout
..

Remove unused wgContentTranslationServerTimeout

Change-Id: Ib5757e399409c8b556ec5837f71c60f8b8aaa962
---
M ContentTranslation.php
1 file changed, 0 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/73/136973/1

diff --git a/ContentTranslation.php b/ContentTranslation.php
index 2b92c38..39cd4a5 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -46,7 +46,6 @@
 
 // Content translation server URL
 $GLOBALS['wgContentTranslationServerURL'] = 'http://localhost:8080';
-$GLOBALS['wgContentTranslationServerTimeout'] = 15;
 
 $GLOBALS['wgContentTranslationParsoid'] = array(
'url' = 'http://parsoid.wmflabs.org/',

-- 
To view, visit https://gerrit.wikimedia.org/r/136973
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib5757e399409c8b556ec5837f71c60f8b8aaa962
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add .jsbeautifyrc - change (mediawiki...ContentTranslation)

2014-06-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136974

Change subject: Add .jsbeautifyrc
..

Add .jsbeautifyrc

Change-Id: Iddff23ceeb2aa11967889712ce7d62f17252b0d3
---
A .jsbeautifyrc
1 file changed, 16 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/74/136974/1

diff --git a/.jsbeautifyrc b/.jsbeautifyrc
new file mode 100644
index 000..e835270
--- /dev/null
+++ b/.jsbeautifyrc
@@ -0,0 +1,16 @@
+{
+preserve_newlines: true,
+jslint_happy: true,
+keep_array_indentation: true,
+space_before_conditional: true,
+max_preserve_newlines: 10,
+brace_style: collapse,
+keep_function_indentation: false,
+break_chained_methods: false,
+eval_code: false,
+unescape_strings: false,
+wrap_line_length: 0,
+space_in_paren: true,
+git_happy: true,
+indent_with_tabs: true
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/136974
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iddff23ceeb2aa11967889712ce7d62f17252b0d3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Send 404 if dictionary not found for language pairs - change (mediawiki...cxserver)

2014-05-30 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136305

Change subject: Send 404 if dictionary not found for language pairs
..

Send 404 if dictionary not found for language pairs

Change-Id: I8dc7ddd7e4c34cb8f2da7904f5a6f79927c6
---
M ContentTranslationService.js
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/05/136305/1

diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index 17142b2..7c535cb 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -82,6 +82,10 @@
toolset;
 
toolset = registry.getToolSet( from, to );
+   if ( !toolset || !toolset.dictionary ) {
+   res.send( 404 );
+   return;
+   }
dictionaryProviders = require( __dirname + '/dictionary' );
dictClient = dictionaryProviders[ toolset.dictionary.provider ];
dictClient.getTranslations( word, from, to ).then( function ( data ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/136305
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8dc7ddd7e4c34cb8f2da7904f5a6f79927c6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Use the port from config.js if available - change (mediawiki...cxserver)

2014-05-29 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136278

Change subject: Use the port from config.js if available
..

Use the port from config.js if available

Bug: 64540
Change-Id: Id3d3804eb3914bcc7596b50b07adce899cbb7441
---
M ContentTranslationService.js
1 file changed, 10 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/78/136278/1

diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index 17142b2..1b5ba64 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -21,11 +21,19 @@
app = express(),
logger = require( __dirname + '/utils/Logger.js' ),
args = require( 'minimist' )( process.argv.slice( 2 ) ),
-   port = args.port || 8080,
+   port = args.port,
privateKey,
certificate,
credentials,
pkg = require( __dirname + '/package.json' );
+
+if ( !port ) {
+   try {
+   port = require( __dirname + '/config.js' ).port;
+   } catch ( e ) {
+   port = 8080;
+   }
+}
 
 app = express();
 // Starts https server only if all needed args provided, else starts http 
server.
@@ -98,7 +106,7 @@
 } );
 // Everything else goes through this.
 app.use( express.static( __dirname + '/public' ) );
-logger.info( instanceName + ' ready. Listening on port: ' + port );
+console.log( instanceName + ' ready. Listening on port: ' + port );
 server.listen( port );
 
 module.exports = app;

-- 
To view, visit https://gerrit.wikimedia.org/r/136278
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id3d3804eb3914bcc7596b50b07adce899cbb7441
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Fix page freeze on table copy and align - change (mediawiki...ContentTranslation)

2014-05-29 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/136286

Change subject: Fix page freeze on table copy and align
..

Fix page freeze on table copy and align

The alignment correction logic uses min-height css property and it is
undefined for table elements.
Added a safegurad for alignment correction by pixel accuracy algorithm
not entering to an infinite loop state.

Bug: 64542
Change-Id: I6d625caa4c714d08a41bc122d7fcff9085e1710d
---
M modules/translation/ext.cx.translation.js
1 file changed, 12 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/86/136286/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index eb98235..a9e8085 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -284,10 +284,16 @@
 * so that they will appear top aligned.
 */
function keepAlignment() {
-   var $sourceSection, sectionHeight, sourceSectionHeight, 
$section;
+   var $sourceSection, sectionHeight, sourceSectionHeight, 
$section, steps = 0;
 
/*jshint validthis:true */
$section = $( this );
+
+   if ( $section.prop( 'tagName' ) === 'TABLE' ) {
+   // 'min-height' is undefined for table elements
+   return true;
+   }
+
$sourceSection = $( '#' + $section.data( 'source' ) );
$sourceSection.css( 'min-height', '' );
 
@@ -304,11 +310,15 @@
// Experiments shows a few pixels difference
// Here we do it by 10px steps till we reach equal 
height.
while ( sectionHeight !== sourceSectionHeight ) {
-   sectionHeight = sectionHeight = sectionHeight + 
10;
+   sectionHeight = sectionHeight + 10;
$sourceSection.css( 'min-height', sectionHeight 
);
$section.css( 'min-height', sectionHeight );
sectionHeight = $section.height();
sourceSectionHeight = $sourceSection.height();
+   if ( steps++ === 1000 ) {
+   mw.log( 'Alignment attempt is not 
succeeding. Aborting.' );
+   break;
+   }
}
}
}

-- 
To view, visit https://gerrit.wikimedia.org/r/136286
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6d625caa4c714d08a41bc122d7fcff9085e1710d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Adapt the link on the source text copied as template for tra... - change (mediawiki...ContentTranslation)

2014-05-28 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135751

Change subject: Adapt the link on the source text copied as template for 
translation
..

Adapt the link on the source text copied as template for translation

* Introduce $.fn.adaptLinks
* Link adaptation does not have any UI now. It happens when user clicks
  on the placeholders in translation column or sections in the source column.
  When source text is copied, links are translated-technically the href values
  of links are modified

Change-Id: I2be61a4c9d7e550d8106399db04290737daa6bc3
---
M Resources.php
A modules/tools/ext.cx.tools.linkadaptor.js
M modules/translation/ext.cx.translation.js
3 files changed, 107 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/51/135751/1

diff --git a/Resources.php b/Resources.php
index f8bbb8d..99ef882 100644
--- a/Resources.php
+++ b/Resources.php
@@ -90,6 +90,7 @@
'scripts' = array(
'tools/ext.cx.tools.js',
'tools/ext.cx.tools.helpmessage.js',
+   'tools/ext.cx.tools.linkadaptor.js',
),
'styles' = array(
'tools/styles/ext.cx.tools.less',
diff --git a/modules/tools/ext.cx.tools.linkadaptor.js 
b/modules/tools/ext.cx.tools.linkadaptor.js
new file mode 100644
index 000..8e16f8c
--- /dev/null
+++ b/modules/tools/ext.cx.tools.linkadaptor.js
@@ -0,0 +1,105 @@
+/**
+ * ContentTranslation Tools
+ * Link Adaptor
+ *
+ * @file
+ * @ingroup Extensions
+ * @copyright See AUTHORS.txt
+ * @license GPL-2.0+
+ */
+( function ( $, mw ) {
+   'use strict';
+
+   /**
+* Link Adaptor
+* @class
+*/
+   function LinkAdaptor() {
+   // TODO This will get expanded as we add link adaptation UX.
+   }
+
+   /**
+* Adapt the given title to a target language
+* @param {string|string[]} titles A titles or or array of titles
+* @param {string} targetLanguage Language to which the links are to be 
adapted
+* @return {jQuery.Promise}
+*/
+   LinkAdaptor.prototype.adapt = function ( titles, targetLanguage ) {
+   var api, deferred;
+
+   api = new mw.Api();
+   deferred = $.Deferred();
+   if ( !$.isArray( titles ) ) {
+   titles = new Array( titles );
+   }
+   api.get( {
+   action: 'query',
+   titles: titles.join( '|' ),
+   prop: 'langlinks',
+   lllang: targetLanguage,
+   format: 'json'
+   } ).done( function ( response ) {
+   var linkPairs = {};
+   if ( response.query ) {
+   $.each( response.query.pages, function ( key, 
value ) {
+   linkPairs[ value.title ] = 
value.langlinks  value.langlinks[ 0 ]  value.langlinks[ 0 ][ '*' ];
+   } );
+   }
+   deferred.resolve( linkPairs );
+   } ).fail( function ( error ) {
+   mw.log( 'Error while adapting links:' + error );
+   // No need to make this error visible beyond logging
+   deferred.resolve( {} );
+   } );
+   return deferred.promise();
+   };
+
+   /**
+* Remove the leading slashes or dots if any.
+*/
+   function cleanupLinkHref( href ) {
+   return href.replace( './', '' );
+   }
+
+   /**
+* jQuery plugin to adapt all the links with rel=mw:WikiLink
+* @param {string} targetLanguage
+*/
+   $.fn.adaptLinks = function ( targetLanguage ) {
+   var linkAdaptor = new LinkAdaptor();
+   return this.each( function () {
+   var $this = $( this ),
+   $links,
+   sourceTitles;
+
+   $links = $this.find( 'a[rel=mw:WikiLink]' );
+   // Collect all sourceTitles;
+   sourceTitles = $links.map( function () {
+   var href = $( this ).attr( 'href' );
+   // some cleanup
+   return cleanupLinkHref( href );
+   } ).get();
+
+   function apply( adaptations ) {
+   $links.map( function () {
+   var $this = $( this ),
+   href = $this.attr( 'href' );
+
+   href = cleanupLinkHref( href );
+   if ( adaptations[ href ] ) {
+  

[MediaWiki-commits] [Gerrit] Show error message when server is not reachable - change (mediawiki...ContentTranslation)

2014-05-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135741

Change subject: Show error message when server is not reachable
..

Show error message when server is not reachable

Change-Id: Ic8bf615e8daeaa2e51a30222bed6cdc51b07db3e
---
M modules/source/ext.cx.source.js
1 file changed, 17 insertions(+), 5 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/41/135741/1

diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index a897fd1..8d2d4c1 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -11,11 +11,23 @@
 ( function ( $, mw ) {
'use strict';
 
-   mw.cx.fetchPage = function ( sourcePage, sourceLanguage ) {
-   $.get( mw.config.get( 'wgContentTranslationServerURL' ) + 
'/page/' + sourceLanguage + '/' + sourcePage, function ( response ) {
-   mw.cx.data = response;
-   mw.hook( 'mw.cx.source.ready' ).fire();
-   } );
+   /**
+* Fetch the page with given title and language.
+* Response contains
+* @param {string} title Title of the page to be fetched
+* @param {string} language Language of the page requested. This will 
be used to
+* identify the host wiki.
+*/
+   mw.cx.fetchPage = function ( title, language ) {
+   $.get( mw.config.get( 'wgContentTranslationServerURL' ) + 
'/page/' + language + '/' + title )
+   .done( function ( response ) {
+   mw.cx.data = response;
+   mw.hook( 'mw.cx.source.ready' ).fire();
+   } ).fail( function () {
+   $( '.cx-header__infobar' )
+   .text( mw.msg( 
'cx-error-server-connection' ) )
+   .show();
+   } );
};
 
/**

-- 
To view, visit https://gerrit.wikimedia.org/r/135741
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8bf615e8daeaa2e51a30222bed6cdc51b07db3e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Return early when parsoid response is failure - change (mediawiki...cxserver)

2014-05-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135742

Change subject: Return early when parsoid response is failure
..

Return early when parsoid response is failure

Not having this early return was causing the error:
Cannot read property 'statusCode' of undefined

Change-Id: I1d99521b93719ef9eeec6641dafa4fba46aa87ab
---
M pageloader/PageLoader.js
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/42/135742/1

diff --git a/pageloader/PageLoader.js b/pageloader/PageLoader.js
index c4ed012..2bb0d11 100644
--- a/pageloader/PageLoader.js
+++ b/pageloader/PageLoader.js
@@ -42,9 +42,11 @@
function ( error, response, body ) {
if ( error ) {
deferred.reject( new Error( error ) );
+   return;
}
if ( response.statusCode !== 200 ) {
deferred.reject( new Error( 'Error while 
fetching page: ' + response.statusCode ) );
+   return;
}
deferred.resolve( body );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/135742
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d99521b93719ef9eeec6641dafa4fba46aa87ab
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Remove unwanted anonymous functions - change (mediawiki...UniversalLanguageSelector)

2014-05-26 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135398

Change subject: Remove unwanted anonymous functions
..

Remove unwanted anonymous functions

Change-Id: Ieefbd58fbc829182048df1d89921b97599a3392c
---
M resources/js/ext.uls.interface.js
1 file changed, 3 insertions(+), 9 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/98/135398/1

diff --git a/resources/js/ext.uls.interface.js 
b/resources/js/ext.uls.interface.js
index 4ebc846..593e6f6 100644
--- a/resources/js/ext.uls.interface.js
+++ b/resources/js/ext.uls.interface.js
@@ -252,15 +252,11 @@
window.clearTimeout( tipsyTimer );
} );
$( '.tipsy' ).on( 'mouseout', function () {
-   tipsyTimer = window.setTimeout( function () {
-   hideTipsy();
-   }, timeout );
+   tipsyTimer = window.setTimeout( hideTipsy, 
timeout );
} );
 
// hide the tooltip when clicked on it
-   $( '.tipsy' ).on( 'click', function () {
-   hideTipsy();
-   } );
+   $( '.tipsy' ).on( 'click', hideTipsy );
 
// Event handler for links in the tooltip.
// It looks like the tipsy is always created from 
scratch so that
@@ -280,9 +276,7 @@
deferred.resolve();
}, mw.config.get( 'wgULSEventLogging' ) * 500 );
} );
-   tipsyTimer = window.setTimeout( function () {
-   hideTipsy();
-   }, timeout );
+   tipsyTimer = window.setTimeout( hideTipsy, timeout );
}
 
function hideTipsy() {

-- 
To view, visit https://gerrit.wikimedia.org/r/135398
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ieefbd58fbc829182048df1d89921b97599a3392c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Fix the missing close icon in ULS - change (mediawiki...UniversalLanguageSelector)

2014-05-26 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135404

Change subject: Fix the missing close icon in ULS
..

Fix the missing close icon in ULS

Regression after the patch I39005ef2425c01b8623bf9df6d75c1e27f1c5bda
and I4a2542b3b745b8b749845a7e8dbb926dd5c4f0e4
Missed to rename the class in MW ULS.

Change-Id: If44d225a2e859dafa544b4a99ee554cecbfd8aca
---
M resources/js/ext.uls.languagesettings.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/04/135404/1

diff --git a/resources/js/ext.uls.languagesettings.js 
b/resources/js/ext.uls.languagesettings.js
index ebe49cf..a6360c2 100644
--- a/resources/js/ext.uls.languagesettings.js
+++ b/resources/js/ext.uls.languagesettings.js
@@ -22,7 +22,7 @@
var closeRow, settingsMenu, settingsPanel, windowTemplate, panelsRow, 
buttonsRow;
 
closeRow = 'div class=row' +
-   'div class=uls-language-settings-close-block eight columns 
offset-by-fourspan id=languagesettings-close 
class=icon-close/span/div' +
+   'div class=uls-language-settings-close-block eight columns 
offset-by-fourspan id=languagesettings-close 
class=uls-icon-close/span/div' +
'/div';
settingsMenu = 'div class=four columns languagesettings-menu' +
'h1 data-i18n=ext-uls-language-settings-title/h1' +

-- 
To view, visit https://gerrit.wikimedia.org/r/135404
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If44d225a2e859dafa544b4a99ee554cecbfd8aca
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Qunit tests for dictionary - change (mediawiki...cxserver)

2014-05-26 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135412

Change subject: Qunit tests for dictionary
..

Qunit tests for dictionary

Contains basic tests for jsondict dictionary backend

Change-Id: I9004d33a4507025776925f19baf53f6d25ebb74b
---
M index.js
A tests/dictionary/Dictionary.test.js
M tests/index.js
3 files changed, 21 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/12/135412/1

diff --git a/index.js b/index.js
index 792f349..cf444b8 100644
--- a/index.js
+++ b/index.js
@@ -1,3 +1,4 @@
 module.exports = {
+   Dictionary: require( './dictionary' ),
Segmenter: require( './segmentation/CXSegmenter.js' ).CXSegmenter
 };
diff --git a/tests/dictionary/Dictionary.test.js 
b/tests/dictionary/Dictionary.test.js
new file mode 100644
index 000..3cd0b5d
--- /dev/null
+++ b/tests/dictionary/Dictionary.test.js
@@ -0,0 +1,18 @@
+QUnit.module( 'Dictioanary' );
+
+QUnit.test( 'Dictionary tests', function ( assert ) {
+   QUnit.stop();
+   CX.Dictionary.JsonDict.getTranslations( 'you', 'en', 'es' ).then( 
function ( result ) {
+   assert.strictEqual( result.source, 'you',
+   'Result contains the given word' );
+   assert.strictEqual( result.translations.length, 5,
+   'Found 5 results' );
+   QUnit.start();
+   } );
+   QUnit.stop();
+   CX.Dictionary.JsonDict.getTranslations( 'this_word_does_not_exist', 
'en', 'es' ).then( function ( result ) {
+   assert.strictEqual( result.translations.length, 0,
+   'Found 0 results' );
+   QUnit.start();
+   } );
+} );
diff --git a/tests/index.js b/tests/index.js
index 553b396..8d8ef0f 100644
--- a/tests/index.js
+++ b/tests/index.js
@@ -1,7 +1,8 @@
 /*jshint node:true */
 var qunit = require( 'qunit' ),
tests = [
-   './tests/segmentation/CXSegmenter.test.js'
+   './tests/segmentation/CXSegmenter.test.js',
+'./tests/dictionary/Dictionary.test.js'
];
 
 qunit.setup( {

-- 
To view, visit https://gerrit.wikimedia.org/r/135412
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9004d33a4507025776925f19baf53f6d25ebb74b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add .jsbeautifyrc - change (mediawiki...cxserver)

2014-05-26 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135417

Change subject: Add .jsbeautifyrc
..

Add .jsbeautifyrc

Contains the code formatting rules as per MW javascript conventions

Change-Id: I87cb34140e048fe8411100731a780512bc883388
---
A .jsbeautifyrc
1 file changed, 17 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/17/135417/1

diff --git a/.jsbeautifyrc b/.jsbeautifyrc
new file mode 100644
index 000..2310eb6
--- /dev/null
+++ b/.jsbeautifyrc
@@ -0,0 +1,17 @@
+{
+preserve_newlines: true,
+jslint_happy: true,
+keep_array_indentation: true,
+space_before_conditional: true,
+max_preserve_newlines: 10,
+brace_style: collapse,
+keep_function_indentation: false,
+break_chained_methods: false,
+eval_code: false,
+unescape_strings: false,
+wrap_line_length: 0,
+space_in_paren: true,
+   space_in_square_bracket: true,
+git_happy: true,
+indent_with_tabs: true
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/135417
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87cb34140e048fe8411100731a780512bc883388
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add AUTHORS.txt - change (mediawiki...cxserver)

2014-05-25 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135390

Change subject: Add AUTHORS.txt
..

Add AUTHORS.txt

Change-Id: I135439d691a9bca0c5887a6da5962770c915a637
---
A AUTHORS.txt
1 file changed, 9 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/90/135390/1

diff --git a/AUTHORS.txt b/AUTHORS.txt
new file mode 100644
index 000..e9ef0d4
--- /dev/null
+++ b/AUTHORS.txt
@@ -0,0 +1,9 @@
+Amir E. Aharoni amir.ahar...@mail.huji.ac.il
+David Chan da...@sheetmusic.org.uk
+Kartik Mistry kartik.mis...@gmail.com
+Niklas Laxström niklas.laxst...@gmail.com
+Pau Giner pau.gi...@gmail.com
+Runa Bhattacharjee run...@gmail.com
+Santhosh Thottingal santhosh.thottin...@gmail.com
+Siebrand Mazeland s.mazel...@xs4all.nl
+Sucheta Ghoshal sucheta.ghos...@gmail.com
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/135390
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I135439d691a9bca0c5887a6da5962770c915a637
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Pageloader: Use only parsoid and remove hardcoded enwiki host - change (mediawiki...cxserver)

2014-05-23 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135016

Change subject: Pageloader: Use only parsoid and remove hardcoded enwiki host
..

Pageloader: Use only parsoid and remove hardcoded enwiki host

* Remvoed the MediaWiki page loader because we need parsoid actually
* Make the page loader work with any source language
* Added a bit of error handling

Change-Id: I6a5add64bf057575f42e2bb9635b0f2a506973bc
---
M ContentTranslationService.js
M config.example.js
D pageloader/MediaWikiApiPageLoader.js
M pageloader/PageLoader.js
D pageloader/ParsoidPageLoader.js
5 files changed, 31 insertions(+), 121 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/16/135016/1

diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index 3789500..7723f6a 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -66,6 +66,10 @@
title: title,
segmentedContent: segmenter.getSegmentedContent(),
} );
+   }, function ( error ) {
+   res.send( {
+   error: error
+   } );
} );
 } );
 
diff --git a/config.example.js b/config.example.js
index 7eacd64..1e3180e 100644
--- a/config.example.js
+++ b/config.example.js
@@ -2,13 +2,7 @@
 
 module.exports = {
port: 8080,
-   pageloaderservice: 'parsoid',
-   pageloaderservices: {
-   parsoid: {
-   api: 'http://parsoid-lb.eqiad.wikimedia.org'
-   },
-   mediawiki: {
-   api: 'http://en.wikipedia.org/w/api.php'
-   }
+   parsoid: {
+   api: 'http://parsoid-lb.eqiad.wikimedia.org'
}
 };
diff --git a/pageloader/MediaWikiApiPageLoader.js 
b/pageloader/MediaWikiApiPageLoader.js
deleted file mode 100644
index 0311f6b..000
--- a/pageloader/MediaWikiApiPageLoader.js
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Loads html for pages to translate via MediaWiki API
- *
- * @file
- * @copyright See AUTHORS.txt
- * @license GPL-2.0+
- */
-
-'use strict';
-
-var request = require( 'request' ),
-   Q = require( 'q' );
-
-/**
- * @class MediaWikiApiPageLoader
- */
-function MediaWikiApiPageLoader( api ) {
-   this.api = api;
-}
-
-MediaWikiApiPageLoader.prototype.load = function ( documentId ) {
-   var deferred = Q.defer();
-
-   request(
-   this.api + '?action=parseformat=jsonpage=' + 
encodeURIComponent( documentId ),
-   function ( error, response, body ) {
-   if ( error ) {
-   deferred.reject( error );
-   }
-
-   if ( response.statusCode !== 200 ) {
-   deferred.reject( response.statusCode );
-   }
-
-   deferred.resolve( JSON.parse( body ).parse.text['*'] );
-   }
-   );
-
-   return deferred.promise;
-};
-
-module.exports.MediaWikiApiPageLoader = MediaWikiApiPageLoader;
diff --git a/pageloader/PageLoader.js b/pageloader/PageLoader.js
index ecc99a3..d91bf3e 100644
--- a/pageloader/PageLoader.js
+++ b/pageloader/PageLoader.js
@@ -8,7 +8,9 @@
 
 'use strict';
 
-var config;
+var config,
+   request = require( 'request' ),
+   Q = require( 'q' );
 
 try {
// TODO: Have an example configuration file.
@@ -16,46 +18,41 @@
 } catch ( e ) {
// TODO: define this configuration in better way
config = {
-   pageloaderservice: 'parsoid',
-   pageloaderservices: {
-   parsoid: {
-   api: 'http://parsoid.wmflabs.org'
-   },
-   mediawiki: {
-   api: 'http://en.wikipedia.org/w/api.php'
-   }
+   parsoid: {
+   api: 'http://parsoid.wmflabs.org'
}
};
 }
 
 /**
  * @class ParsoidPageLoader
+ *
+ * @param {string} page
+ * @param {string} sourceLanguage
+ * @retrun {Q.Promise}
  */
-function PageLoader( page ) {
+function PageLoader( page, sourceLanguage ) {
this.page = page;
+   this.sourceLanguage = sourceLanguage;
 }
 
 PageLoader.prototype.load = function () {
-   var loader, promise, ParsoidPageLoader, MediaWikiApiPageLoader, title;
+   var deferred = Q.defer();
 
-   // FIXME This way of getting tile is not reliable
-   title = this.page.split( '/' ).pop();
+   request(
+   config.parsoid.api + '/' + this.sourceLanguage + 'wiki/' + 
this.page,
+   function ( error, response, body ) {
+   if ( error ) {
+   deferred.reject( error );
+   }
+   if ( response.statusCode !== 200 ) {
+ 

[MediaWiki-commits] [Gerrit] Dictionary: Json file dictionary backend - change (mediawiki...cxserver)

2014-05-23 Thread Santhosh (Code Review)
Santhosh has submitted this change and it was merged.

Change subject: Dictionary: Json file dictionary backend
..


Dictionary: Json file dictionary backend

* Reads dictionaries from json files
* Introduce toolset registry to pick suitable dictionary providers
* Use a consistent return format:
{
source: manzana,
translations: [
{
phrase: apple,
info: (noun),
sources: [fd-spa-eng]
},
...
]
}

Change-Id: Ifddfd359ebdbfbfdc1b26a70cdd29949ee230f40
---
M ContentTranslationService.js
A dictionary/index.js
A dictionary/jsondict/JsonDict.js
A dictionary/jsondict/JsonDictRegistry.json
A dictionary/jsondict/dictionaries/freedict-eng-spa.json
A registry/Registry.json
A registry/index.js
7 files changed, 6,054 insertions(+), 4 deletions(-)

Approvals:
  Santhosh: Looks good to me, approved
  jenkins-bot: Verified




-- 
To view, visit https://gerrit.wikimedia.org/r/134617
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifddfd359ebdbfbfdc1b26a70cdd29949ee230f40
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com
Gerrit-Reviewer: Divec da...@sheetmusic.org.uk
Gerrit-Reviewer: Santhosh santhosh.thottin...@gmail.com
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Dict dictionary protocol backend - change (mediawiki...cxserver)

2014-05-23 Thread Santhosh (Code Review)
Santhosh has submitted this change and it was merged.

Change subject: Dict dictionary protocol backend
..


Dict dictionary protocol backend

* Implements a dict protocol client and a dictionary registry
* Exposes a REST api dictionary/:word/:from/:to

Example: http://localhost:8000/dictionary/pen/en/de
Result:
{
  definitions: [
{
  def: pen /pen/\r\n (Schreib-) Feder; Füller; Griffel m; Stift m,
  db: {
name: fd,
desc: English-German FreeDict Dictionary ver. 0.3.5
  }
}
  ],
  suggestions: []
}

Change-Id: I138b5d457ce46c5bfe4e760d95f29c3adf25abfd
---
M ContentTranslationService.js
A dictionary/dict/Dict.js
A dictionary/dict/DictClient.js
A dictionary/dict/DictRegistry.json
A dictionary/dict/Readme.md
A public/dictionary/css/main.css
A public/dictionary/index.html
A public/dictionary/js/main.js
8 files changed, 958 insertions(+), 0 deletions(-)

Approvals:
  Santhosh: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index 3789500..a36d5e9 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -69,6 +69,17 @@
} );
 } );
 
+app.get( '/dictionary/:word/:from/:to', function ( req, res ) {
+   var sourceLanguage = req.params.from,
+   word = req.params.word,
+   targetLanguage = req.params.to,
+   dictClient = require( __dirname + '/dictionary/dict/Dict.js' );
+
+   dictClient.getDefinition( word, sourceLanguage, targetLanguage ).then( 
function ( data ) {
+   res.send( data );
+   } );
+} );
+
 app.get( '/version', function ( req, res ) {
var version = {
name: pkg.name,
diff --git a/dictionary/dict/Dict.js b/dictionary/dict/Dict.js
new file mode 100644
index 000..5c8aef0
--- /dev/null
+++ b/dictionary/dict/Dict.js
@@ -0,0 +1,29 @@
+var dictClient = require( __dirname + '/DictClient.js' ),
+   dictRegistry = require( __dirname + '/DictRegistry.json' ),
+   Q = require( 'q' );
+
+function findDatabase( source, target ) {
+   var dictionaries = dictRegistry[ source ]  dictRegistry[ source ][ 
target ];
+   if ( !dictionaries ) {
+   return null;
+   }
+   return Object.keys( dictionaries );
+}
+
+function getDefinition( word, from, to ) {
+   var deferred = Q.defer();
+   dictClient.lookup( word, {
+   db: findDatabase( from, to ),
+   action: 'def',
+   suggestions: true,
+   error: function ( responseCode, message ) {
+   deferred.reject( responseCode + ': ' + message );
+   },
+   success: function ( data ) {
+   deferred.resolve( data );
+   }
+   } );
+   return deferred.promise;
+}
+
+module.exports.getDefinition = getDefinition;
diff --git a/dictionary/dict/DictClient.js b/dictionary/dict/DictClient.js
new file mode 100644
index 000..5e11c77
--- /dev/null
+++ b/dictionary/dict/DictClient.js
@@ -0,0 +1,501 @@
+/**
+ * Dict dictionary protocol client as per RFC 2229
+ * Credits:
+ *Dict client implementation borrowed from: 
https://github.com/ptrm/dict.json
+ *Copyright (c) 2010 Piotrek Marciniak piot...@ptrm.eu, MIT Style License
+ * RFC 2229: http://www.dict.org/rfc2229.txt
+ *@author Santhosh Thottingal santhosh.thottin...@gmail.com
+ *@license MIT
+ */
+
+var sys = require( 'sys' ),
+   net = require( 'net' ),
+   logLevel, config;
+
+logLevel = {
+   silent: 0,
+   standard: 1,
+   diagnostic: 2,
+   verbose: 3
+};
+config = {
+   logging: logLevel.silent,
+   dictd: {
+   port: '2628',
+   host: '127.0.0.1',
+   timeout: 700
+   },
+   db: '!' // First match
+};
+
+function firstObj( list ) {
+   var obj = null,
+   idx;
+
+   if ( typeof list !== 'object' ) {
+   return null;
+   }
+   for ( idx in list ) {
+   obj = list[ idx ];
+   break;
+   }
+
+   return obj;
+}
+
+/**
+ * Simple logger, mainly for debugging
+ */
+function log( msg, level ) {
+   if ( !level ) {
+   level = logLevel.standard;
+   }
+   if ( level = config.logging ) {
+   sys.log( msg );
+   }
+}
+
+/**
+ * Sanitize the words
+ * @param {Object} words
+ */
+function parseWords( words ) {
+   var i, word, db, nDb, dbIdx,
+   res = {},
+   count = 0;
+
+   for ( i in words ) {
+   if ( typeof words[ i ].word !== 'string' ) {
+   continue;
+   }
+   // cleanup the word by removing traling new line characters
+   word = words[ i ].word.replace( /[\r\n]/g, '' 
).trim().toLowerCase();
+
+   db = [];
+   if ( words[ i ].db ) {
+   

[MediaWiki-commits] [Gerrit] Update the Dict client to match the updated API output format - change (mediawiki...cxserver)

2014-05-23 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/135022

Change subject: Update the Dict client to match the updated API output format
..

Update the Dict client to match the updated API output format

Sample outout:

{
  source: Food,
  translations: [
{
  phrase: food /fuːd/\r\n Ernährung; Essen n; Fressen n; Kost f; 
Lebensmittel; Nahrung f; Speise f,
  info: ,
  sources: [
[
  fd-eng-deu
]
  ]
}
  ]
}

Followup: I138b5d457ce46c5bfe4e760d95f29c3adf25abfd
Change-Id: I26eb2d40da268ddbfcb91b01b7c88cbb67fa05ed
---
M dictionary/dict/Dict.js
M public/dictionary/js/main.js
2 files changed, 45 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/22/135022/1

diff --git a/dictionary/dict/Dict.js b/dictionary/dict/Dict.js
index 5c8aef0..583abca 100644
--- a/dictionary/dict/Dict.js
+++ b/dictionary/dict/Dict.js
@@ -10,20 +10,55 @@
return Object.keys( dictionaries );
 }
 
-function getDefinition( word, from, to ) {
-   var deferred = Q.defer();
+/**
+ * Get possible translations and information about them
+ *
+ * The deferred return structure is like:
+ * {
+ * source: manzana,
+ * translations: [
+ * {
+ * phrase: apple,
+ * info: ,
+ * sources: [fd-spa-eng]
+ * },
+ * ...
+ * ]
+ * }
+ *
+ * @method
+ * @param {string} source Source language word or phrase
+ * @param {string} sourceLang Source language BCP47 code
+ * @param {string} targetLang Target language BCP47 code
+ * @returns {Object} deferred.promise
+ */
+function getTranslations( word, from, to ) {
+   var deferred = Q.defer(),
+   db;
+   db = findDatabase( from, to );
dictClient.lookup( word, {
-   db: findDatabase( from, to ),
+   db: db,
action: 'def',
suggestions: true,
error: function ( responseCode, message ) {
deferred.reject( responseCode + ': ' + message );
},
-   success: function ( data ) {
-   deferred.resolve( data );
+   success: function ( result ) {
+   var i, translations = [];
+   for ( i = 0; i  result.definitions.length; i++ ) {
+   translations.push( {
+   'phrase': result.definitions[ i ].def,
+   info: '', // Dict cannot provide this 
info
+   'sources': [ db ]
+   } );
+   }
+   deferred.resolve( {
+   'source': word,
+   'translations': translations
+   } );
}
} );
return deferred.promise;
 }
 
-module.exports.getDefinition = getDefinition;
+module.exports.getTranslations = getTranslations;
diff --git a/public/dictionary/js/main.js b/public/dictionary/js/main.js
index 7d80ed8..3f461f3 100644
--- a/public/dictionary/js/main.js
+++ b/public/dictionary/js/main.js
@@ -9,11 +9,11 @@
from = $( 'input[name=sourceLanguage]' ).val(),
to = $( 'input[name=targetLanguage]' ).val();
$.get( word + '/' + from + '/' + to, function ( 
response ) {
-   $.each( response.definitions, function ( index, 
definition ) {
-   $( '.definition' ).append( 
definition.def );
+   $.each( response.translations, function ( 
index, translation ) {
+   $( '.definition' ).append( 
translation.phrase );
$( '.definition' ).append( '\n' );
-   $( '.definition' ).append( 
definition.db.desc );
-   $( '.definition' ).append( '\n\n' );
+   $( '.definition' ).append( 
translation.info );
+   $( '.definition' ).append( '\n' );
} );
$( 'progress' ).hide();
} );

-- 
To view, visit https://gerrit.wikimedia.org/r/135022
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26eb2d40da268ddbfcb91b01b7c88cbb67fa05ed
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org

[MediaWiki-commits] [Gerrit] Make default wgContentTranslationServerURL match default cxs... - change (mediawiki...ContentTranslation)

2014-05-21 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/134565

Change subject: Make default wgContentTranslationServerURL match default 
cxserver port
..

Make default wgContentTranslationServerURL match default cxserver port

Change-Id: Ib10e46f0512aacbaf569bf6cbf722939d373476c
---
M ContentTranslation.php
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/65/134565/1

diff --git a/ContentTranslation.php b/ContentTranslation.php
index 567d104..2b92c38 100644
--- a/ContentTranslation.php
+++ b/ContentTranslation.php
@@ -45,7 +45,7 @@
 $GLOBALS['wgMessagesDirs']['ContentTranslation'] = $dir/i18n;
 
 // Content translation server URL
-$GLOBALS['wgContentTranslationServerURL'] = 'http://localhost:8000';
+$GLOBALS['wgContentTranslationServerURL'] = 'http://localhost:8080';
 $GLOBALS['wgContentTranslationServerTimeout'] = 15;
 
 $GLOBALS['wgContentTranslationParsoid'] = array(

-- 
To view, visit https://gerrit.wikimedia.org/r/134565
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib10e46f0512aacbaf569bf6cbf722939d373476c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add the missing css file for the html interface of server - change (mediawiki...cxserver)

2014-05-21 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/134618

Change subject: Add the missing css file for the html interface of server
..

Add the missing css file for the html interface of server

Change-Id: I4a55284b302fff312b4fa0a4cd82bd48cf43bca7
---
A public/css/main.css
1 file changed, 42 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/18/134618/1

diff --git a/public/css/main.css b/public/css/main.css
new file mode 100644
index 000..5b4623c
--- /dev/null
+++ b/public/css/main.css
@@ -0,0 +1,42 @@
+ body {
+ width: 80%;
+ margin-left: 10%;
+ }
+ label {
+ width: 20%;
+ }
+ input {
+ width: 40%;
+ padding: 5px;
+ }
+ .lang {
+ width: 5%;
+ }
+ button {
+ width: 10%;
+ padding: 5px;
+ }
+ .status {
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ right: 0;
+ height: 16px;
+ padding: 5px;
+ background: #ccc;
+ color: green;
+ font-size: 0.8em;
+ }
+ .cx-segment:hover {
+ background-color: #ccc;
+ }
+ .cx-link:hover {
+ background-color: #aaa;
+ }
+ .form {
+ border: 1px solid #000;
+ padding: 10px;
+ }
+ .info {
+ color: #555;
+ }

-- 
To view, visit https://gerrit.wikimedia.org/r/134618
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a55284b302fff312b4fa0a4cd82bd48cf43bca7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Dictionary: Json file dictionary backend - change (mediawiki...cxserver)

2014-05-21 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/134617

Change subject: Dictionary: Json file dictionary backend
..

Dictionary: Json file dictionary backend

* Reads dictionaries from json files
* Introduce toolset registry to pick suitable dictionary providers
* Output format from all backends are same

Change-Id: Ifddfd359ebdbfbfdc1b26a70cdd29949ee230f40
---
M ContentTranslationService.js
A dictionary/index.js
A dictionary/jsondict/JsonDict.js
A dictionary/jsondict/JsonDictRegistry.json
A dictionary/jsondict/dictionaries/freedict-eng-spa.json
A registry/Registry.json
A registry/index.js
7 files changed, 6,022 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/17/134617/1


-- 
To view, visit https://gerrit.wikimedia.org/r/134617
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifddfd359ebdbfbfdc1b26a70cdd29949ee230f40
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Update jquery.uls to afb99eb0 - change (mediawiki...UniversalLanguageSelector)

2014-05-21 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/134622

Change subject: Update jquery.uls to afb99eb0
..

Update jquery.uls to afb99eb0

* Multiple css selector renaming
* Hide misplaced borders in the compact design
* Fix the jQuery migration warnings for jQuery 1.11.1

Change-Id: I4a2542b3b745b8b749845a7e8dbb926dd5c4f0e4
---
M lib/jquery.uls/css/jquery.uls.compact.css
M lib/jquery.uls/css/jquery.uls.css
M lib/jquery.uls/css/jquery.uls.mobile.css
M lib/jquery.uls/src/jquery.uls.core.js
M lib/jquery.uls/src/jquery.uls.lcd.js
5 files changed, 25 insertions(+), 26 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/22/134622/1

diff --git a/lib/jquery.uls/css/jquery.uls.compact.css 
b/lib/jquery.uls/css/jquery.uls.compact.css
index a958c80..04961ce 100644
--- a/lib/jquery.uls/css/jquery.uls.compact.css
+++ b/lib/jquery.uls/css/jquery.uls.compact.css
@@ -1,6 +1,7 @@
 .uls-compact .icon-close,
-.uls-compact .uls-title,
-.uls-compact .map-block {
+.uls-compact .uls-title-region,
+.uls-compact .map-block,
+.uls-compact #settings-block {
display: none !important;
 }
 
diff --git a/lib/jquery.uls/css/jquery.uls.css 
b/lib/jquery.uls/css/jquery.uls.css
index c54dba8..4e80c6b 100644
--- a/lib/jquery.uls/css/jquery.uls.css
+++ b/lib/jquery.uls/css/jquery.uls.css
@@ -115,12 +115,12 @@
-ms-filter: 
progid:DXImageTransform.Microsoft.gradient(startColorstr=#253366bb, 
endColorstr=#253366bb);
 }
 
-.map-block .active {
+.uls-map-block .active {
border-bottom-color: #3366bb;
border-bottom-style: solid;
 }
 
-.uls-menu .row .map-block {
+.uls-menu .row .uls-map-block {
top: 1px;
margin-right: 0;
padding-right: 0;
@@ -133,7 +133,7 @@
transition: opacity 0.2s linear;
 }
 
-.map-block a {
+.uls-map-block a {
color: #333;
opacity: 0;
-moz-transition: opacity 0.15s linear;
@@ -142,25 +142,25 @@
transition: opacity 0.15s linear;
 }
 
-.uls-menu .map-block:hover,
-.uls-menu .map-block:hover a {
+.uls-menu .uls-map-block:hover,
+.uls-menu .uls-map-block:hover a {
opacity: 1;
color: #333;
 }
 
-.map-block .uls-region-1 {
+.uls-map-block .uls-region-1 {
border-color: transparent;
 }
 
-.map-block:hover .active {
+.uls-map-block:hover .active {
border-color: #3366bb;
 }
 
-.map-block .active a {
+.uls-map-block .active a {
font-weight: bold;
 }
 
-.icon-close {
+.uls-icon-close {
/* @embed */
background: transparent url('../images/close.png') no-repeat scroll 
center center;
/* @embed */
@@ -172,7 +172,7 @@
cursor: pointer;
 }
 
-.uls-menu .languagefilter {
+.uls-menu .uls-languagefilter {
background-color: transparent;
border: 1px solid #c9c9c9;
border-radius: 2px 2px 2px 2px;
@@ -186,11 +186,11 @@
transition: border 0.15s linear 0s;
 }
 
-.uls-menu .languagefilter:focus {
+.uls-menu .uls-languagefilter:focus {
border: 1px solid #3366bb;
 }
 
-.uls-menu .search {
+.uls-menu .uls-search {
position: relative;
filter: 
progid:DXImageTransform.Microsoft.gradient(startColorstr='#F0F0F0', 
endColorstr='#FBFBFB');
background: #f8f8f8;
@@ -208,7 +208,7 @@
border-bottom-color: #DDD;
 }
 
-.uls-menu .search-label {
+.uls-menu .uls-search-label {
/* @embed */
background: transparent url('../images/search.png') no-repeat scroll 
right center;
/* @embed */
@@ -221,7 +221,7 @@
float: right;
 }
 
-.uls-menu .languagefilter-clear {
+.uls-menu .uls-languagefilter-clear {
/* @embed */
background: transparent url('../images/clear.png') no-repeat scroll 
left center;
/* @embed */
@@ -235,7 +235,7 @@
margin-left: -32px;
 }
 
-.uls-menu .filterinput {
+.uls-menu .uls-filterinput {
position: absolute;
top: 0;
left: 0;
@@ -245,7 +245,7 @@
text-align: left;
 }
 
-.uls-menu .filtersuggestion {
+.uls-menu .uls-filtersuggestion {
padding: 6px;
background-color: white;
color: #888;
@@ -255,6 +255,6 @@
left: 1px;
 }
 
-.uls-menu .search-input-block {
+.uls-menu .uls-search-input-block {
position: relative;
 }
diff --git a/lib/jquery.uls/css/jquery.uls.mobile.css 
b/lib/jquery.uls/css/jquery.uls.mobile.css
index 6db4962..5d3e06e 100644
--- a/lib/jquery.uls/css/jquery.uls.mobile.css
+++ b/lib/jquery.uls/css/jquery.uls.mobile.css
@@ -27,8 +27,8 @@
float: left !important;
}
 
-   .uls-mobile div.map-block a,
-   .uls-mobile div.map-block {
+   .uls-mobile .uls-map-block a,
+   .uls-mobile .uls-map-block {
opacity: 1 !important;
}
 
diff --git a/lib/jquery.uls/src/jquery.uls.core.js 
b/lib/jquery.uls/src/jquery.uls.core.js
index 5f9d837..2b7e458 100644
--- 

[MediaWiki-commits] [Gerrit] Update the class names per update jquery.uls lib - change (mediawiki...UniversalLanguageSelector)

2014-05-21 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/134781

Change subject: Update the class names per update jquery.uls lib
..

Update the class names per update jquery.uls lib

jquery.uls renamed settings-block class to uls-settings-block.
Similarly icon-close to uls-icon-close

Change-Id: I39005ef2425c01b8623bf9df6d75c1e27f1c5bda
---
M resources/css/ext.uls.languagesettings.css
M resources/css/ext.uls.pt.css
M resources/js/ext.uls.interface.js
3 files changed, 8 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/81/134781/1

diff --git a/resources/css/ext.uls.languagesettings.css 
b/resources/css/ext.uls.languagesettings.css
index 270c887..223d1a1 100644
--- a/resources/css/ext.uls.languagesettings.css
+++ b/resources/css/ext.uls.languagesettings.css
@@ -1,4 +1,4 @@
-#settings-block {
+#uls-settings-block {
border-top: 1px solid #C9C9C9;
background: #f8f8f8;
background: -webkit-gradient(linear, left top, left bottom, 
from(#FBFBFB), to(#F0F0F0));
diff --git a/resources/css/ext.uls.pt.css b/resources/css/ext.uls.pt.css
index acd4197..40cabee 100644
--- a/resources/css/ext.uls.pt.css
+++ b/resources/css/ext.uls.pt.css
@@ -31,7 +31,7 @@
direction: ltr;
 }
 
-#settings-block {
+#uls-settings-block {
border-top: 1px solid #C9C9C9;
background: #f8f8f8;
background: -webkit-gradient(linear, left top, left bottom, 
from(#FBFBFB), to(#F0F0F0));
@@ -44,14 +44,14 @@
border-radius: 0 0 5px 5px;
 }
 
-#settings-block div.display-settings-block,
-#settings-block div.input-settings-block {
+#uls-settings-block div.display-settings-block,
+#uls-settings-block div.input-settings-block {
display: inline-block;
margin: 8px 15px;
color: #565656;
 }
 
-#settings-block div.display-settings-block:hover,
-#settings-block div.input-settings-block:hover {
+#uls-settings-block div.display-settings-block:hover,
+#uls-settings-block div.input-settings-block:hover {
color: #252525;
 }
diff --git a/resources/js/ext.uls.interface.js 
b/resources/js/ext.uls.interface.js
index c127547..aee6534 100644
--- a/resources/js/ext.uls.interface.js
+++ b/resources/js/ext.uls.interface.js
@@ -64,7 +64,7 @@
function addDisplaySettings( uls ) {
var $displaySettings = displaySettings();
 
-   uls.$menu.find( '#settings-block' ).append( $displaySettings );
+   uls.$menu.find( '#uls-settings-block' ).append( 
$displaySettings );
$displaySettings.on( 'click', function () {
var languagesettings = $displaySettings.data( 
'languagesettings' ),
displaySettingsOptions = {
@@ -102,7 +102,7 @@
function addInputSettings( uls ) {
var $inputSettings = inputSettings();
 
-   uls.$menu.find( '#settings-block' ).append( $inputSettings );
+   uls.$menu.find( '#uls-settings-block' ).append( $inputSettings 
);
$inputSettings.on( 'click', function () {
var position = uls.position(),
languagesettings = $inputSettings.data( 
'languagesettings' );

-- 
To view, visit https://gerrit.wikimedia.org/r/134781
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I39005ef2425c01b8623bf9df6d75c1e27f1c5bda
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Dict dictionary protocol backend - change (mediawiki...cxserver)

2014-05-19 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/134074

Change subject: Dict dictionary protocol backend
..

Dict dictionary protocol backend

* Implements a dict protocol client and a dictionary registry
* Exposes a REST api dictionary/:word/:from/:to

Example: http://localhost:8000/dictionary/pen/en/de
Result:
{
  definitions: [
{
  def: pen /pen/\r\n (Schreib-) Feder; Füller; Griffel m; Stift m,
  db: {
name: fd,
desc: English-German FreeDict Dictionary ver. 0.3.5
  }
}
  ],
  suggestions: []
}

Change-Id: I138b5d457ce46c5bfe4e760d95f29c3adf25abfd
---
M ContentTranslationService.js
A dictionary/dict/Dict.js
A dictionary/dict/DictClient.js
A dictionary/dict/DictRegistry.json
A dictionary/dict/Readme.md
5 files changed, 856 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/74/134074/1

diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index 3789500..a36d5e9 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -69,6 +69,17 @@
} );
 } );
 
+app.get( '/dictionary/:word/:from/:to', function ( req, res ) {
+   var sourceLanguage = req.params.from,
+   word = req.params.word,
+   targetLanguage = req.params.to,
+   dictClient = require( __dirname + '/dictionary/dict/Dict.js' );
+
+   dictClient.getDefinition( word, sourceLanguage, targetLanguage ).then( 
function ( data ) {
+   res.send( data );
+   } );
+} );
+
 app.get( '/version', function ( req, res ) {
var version = {
name: pkg.name,
diff --git a/dictionary/dict/Dict.js b/dictionary/dict/Dict.js
new file mode 100644
index 000..5c8aef0
--- /dev/null
+++ b/dictionary/dict/Dict.js
@@ -0,0 +1,29 @@
+var dictClient = require( __dirname + '/DictClient.js' ),
+   dictRegistry = require( __dirname + '/DictRegistry.json' ),
+   Q = require( 'q' );
+
+function findDatabase( source, target ) {
+   var dictionaries = dictRegistry[ source ]  dictRegistry[ source ][ 
target ];
+   if ( !dictionaries ) {
+   return null;
+   }
+   return Object.keys( dictionaries );
+}
+
+function getDefinition( word, from, to ) {
+   var deferred = Q.defer();
+   dictClient.lookup( word, {
+   db: findDatabase( from, to ),
+   action: 'def',
+   suggestions: true,
+   error: function ( responseCode, message ) {
+   deferred.reject( responseCode + ': ' + message );
+   },
+   success: function ( data ) {
+   deferred.resolve( data );
+   }
+   } );
+   return deferred.promise;
+}
+
+module.exports.getDefinition = getDefinition;
diff --git a/dictionary/dict/DictClient.js b/dictionary/dict/DictClient.js
new file mode 100644
index 000..2701af6
--- /dev/null
+++ b/dictionary/dict/DictClient.js
@@ -0,0 +1,484 @@
+/**
+ * Dict dictionary protocol client
+ * Credits:
+ *Dict client implmentation borrowed from: 
https://github.com/ptrm/dict.json
+ *Copyright (c) 2010 Piotrek Marciniak piot...@ptrm.eu, MIT Style License
+ *
+ *@author Santhosh Thottingal santhosh.thottin...@gmail.com
+ *@license MIT
+ */
+
+var sys = require( 'sys' ),
+   net = require( 'net' ),
+   logLevel = {
+   silent: 0,
+   standard: 1,
+   diagnostic: 2,
+   verbose: 3
+   },
+   config = {
+   logging: logLevel.silent,
+   dictd: {
+   port: '2628',
+   host: '127.0.0.1',
+   timeout: 700
+   },
+   db: '!' // First match
+   };
+
+function firstObj( list ) {
+   var obj = null,
+   idx;
+
+   if ( typeof list !== 'object' ) {
+   return null;
+   }
+   for ( idx in list ) {
+   obj = list[ idx ];
+   break;
+   }
+
+   return obj;
+}
+
+function log( msg, level ) {
+   if ( !level ) {
+   level = logLevel.standard;
+   }
+   if ( level = config.logging ) {
+   sys.log( msg );
+   }
+}
+
+function parseWords( words ) {
+   var i, word, db, nDb, dbIdx,
+   res = {},
+   count = 0;
+
+   for ( i in words ) {
+   if ( typeof words[ i ].word !== 'string' ) {
+   continue;
+   }
+   word = words[ i ].word.replace( /[\r\n]/g, '' 
).trim().toLowerCase();
+
+   db = [];
+   if ( words[ i ].db ) {
+   if ( typeof words[ i ].db !== 'object' ) {
+   words[ i ].db = new Array( words[ i ].db );
+   }
+   for ( dbIdx in words[ 

[MediaWiki-commits] [Gerrit] Remove Rot13 dummy translation - change (mediawiki...cxserver)

2014-05-12 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/132918

Change subject: Remove Rot13 dummy translation
..

Remove Rot13 dummy translation

Change-Id: Ic3ebbd138acf6c557a47696d94bacdb5a6e9210b
---
M index.js
M models/DataModelManager.js
D mt/CXMTInterface.js
D mt/providers/Rot13.js
M tests/index.js
D tests/mt/Rot13/Rot13.test.js
D tests/mt/Rot13/Rot13.test.json
7 files changed, 2 insertions(+), 162 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/18/132918/1

diff --git a/index.js b/index.js
index 889..792f349 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,3 @@
 module.exports = {
-   Segmenter: require( './segmentation/CXSegmenter.js' ).CXSegmenter,
-   Rot13Service: require( './mt/providers/Rot13.js' ).Rot13Service
+   Segmenter: require( './segmentation/CXSegmenter.js' ).CXSegmenter
 };
diff --git a/models/DataModelManager.js b/models/DataModelManager.js
index 02c62ed..60391b6 100644
--- a/models/DataModelManager.js
+++ b/models/DataModelManager.js
@@ -10,7 +10,6 @@
 'use strict';
 
 var CXSegmenter = require( __dirname + '/../segmentation/CXSegmenter.js' 
).CXSegmenter,
-   CXMTInterface = require( __dirname + '/../mt/CXMTInterface.js' 
).CXMTInterface,
logger = require( __dirname + '/../utils/Logger.js' );
 
 /**
@@ -29,7 +28,6 @@
 CXDataModelManager.prototype.init = function () {
var dataModelManager = this,
segmenter,
-   mtInterface,
PageLoader, pageloader;
 
// TODO: refactor this
@@ -60,14 +58,6 @@
};
 
dataModelManager.publish();
-
-   // TODO: Dispatch the context to a number of 
task runners
-   // Once each task runners finish, publish.
-   mtInterface = new CXMTInterface( 
dataModelManager.context );
-   mtInterface.translate( 
dataModelManager.dataModel.segments ).then( function ( translations ) {
-   dataModelManager.dataModel.mt = 
translations;
-   dataModelManager.publish();
-   } );
}, function () {
logger.error( 'Error in retrieving the page ' +
dataModelManager.context.sourcePage );
diff --git a/mt/CXMTInterface.js b/mt/CXMTInterface.js
deleted file mode 100644
index 6858900..000
--- a/mt/CXMTInterface.js
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Content Translation Machine Translation Interface.
- *
- */
-
-'use strict';
-
-var Rot13Service = require( __dirname + '/providers/Rot13.js' ).Rot13Service;
-
-/**
- * @class CxTranslator
- */
-function CXMTInterface( context ) {
-   this.context = context;
-}
-
-CXMTInterface.prototype.translate = function ( segments ) {
-   return ( new Rot13Service( this.context ) ).translate( segments );
-};
-
-module.exports.CXMTInterface = CXMTInterface;
diff --git a/mt/providers/Rot13.js b/mt/providers/Rot13.js
deleted file mode 100644
index ae9f0ae..000
--- a/mt/providers/Rot13.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Rot13 Translation service
- *
- * A dummy interface to test the CX MT
- */
-
-'use strict';
-
-var Q = require( 'q' ),
-   SAXParser = require( 'sax' ).SAXParser;
-
-/**
- * @class Rot13Service
- */
-function Rot13Service( config ) {
-   this.config = config;
-   this.parser = null;
-}
-
-function rot13( text ) {
-   return text.replace( /[a-zA-Z]/g, function ( c ) {
-   return String.fromCharCode( ( c = 'Z' ? 90 : 122 ) = ( c = 
c.charCodeAt( 0 ) + 13 ) ? c : c - 26 );
-   } );
-}
-
-Rot13Service.prototype.translate = function ( segments ) {
-   var rot13 = this,
-   deferred = Q.defer(),
-   mt = {};
-
-   // Simulate a 1000 millisecond delay.
-   setTimeout( function () {
-   var translation,
-   segmentId;
-
-   for ( segmentId in segments ) {
-   rot13.parser = new SAXParser();
-   rot13.prepareParser();
-
-   // Wrap the source with p to make it valid dom 
fragment
-   rot13.parser.write( 'p' + segments[ segmentId 
].source + '/p' );
-   translation = rot13.parser.parsedText;
-   translation = translation.substr( 3, translation.length 
- 7 );
-   mt[ segmentId ] = translation;
-   }
-
-   deferred.resolve( mt );
-   }, 1000 );
-
-   return deferred.promise;
-};
-
-Rot13Service.prototype.prepareParser = function () {
-   var parser = this.parser;
-
-   parser.parsedText = '';
-
-   /**
-* Entity handler
-*/

[MediaWiki-commits] [Gerrit] Remove Rot13 dummy translation - change (mediawiki...ContentTranslation)

2014-05-12 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/132919

Change subject: Remove Rot13 dummy translation
..

Remove Rot13 dummy translation

Change-Id: Iab52084a5e76a7415fbc9d278436eb06dd149ea6
---
M modules/translation/ext.cx.translation.js
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/19/132919/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index a9adf14..eb98235 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -94,7 +94,10 @@
 
// For every segment, use MT as replacement
$section.find( '.cx-segment' ).each( function () {
-   $( this ).html( mw.cx.data.mt[ $( this ).data( 
'segmentid' ) ] );
+   var translation = mw.cx.data.mt  mw.cx.data.mt[ $( 
this ).data( 'segmentid' ) ];
+   if ( translation ) {
+   $( this ).html( translation );
+   }
} );
 
// Trigger input event so that the alignemnt is right.

-- 
To view, visit https://gerrit.wikimedia.org/r/132919
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iab52084a5e76a7415fbc9d278436eb06dd149ea6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Use cxserver apis for data instead of websockets - change (mediawiki...ContentTranslation)

2014-05-12 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/132932

Change subject: Use cxserver apis for data instead of websockets
..

Use cxserver apis for data instead of websockets

See I120cb20fe672565343d8223312947ee55e211a9c

Change-Id: I61ae1f6eaa5ca426df5522f788aad014dd086f5f
---
M Resources.php
D modules/base/ext.cx.datamanager.js
M modules/source/ext.cx.source.js
M specials/SpecialContentTranslation.php
4 files changed, 10 insertions(+), 61 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/32/132932/1

diff --git a/Resources.php b/Resources.php
index a702217..f8bbb8d 100644
--- a/Resources.php
+++ b/Resources.php
@@ -17,7 +17,6 @@
 $wgResourceModules['ext.cx.model'] = array(
'scripts' = array(
'base/ext.cx.model.js',
-   'base/ext.cx.datamanager.js',
),
 ) + $resourcePaths;
 
diff --git a/modules/base/ext.cx.datamanager.js 
b/modules/base/ext.cx.datamanager.js
deleted file mode 100644
index 79e815a..000
--- a/modules/base/ext.cx.datamanager.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * ContentTranslation extension
- * A tool that allows editors to translate pages from one language
- * to another with the help of machine translation and other translation tools
- *
- * @file
- * @ingroup Extensions
- * @copyright See AUTHORS.txt
- * @license GPL-2.0+
- */
-( function ( $, mw ) {
-   'use strict';
-
-   var socket;
-
-   /* global io */
-   function initConnection() {
-   if ( !window.io ) {
-   return false;
-   }
-   socket = io.connect( mw.config.get( 
'wgContentTranslationServerURL' ) );
-   mw.log( '[CX] Connected to server' );
-   return true;
-   }
-
-   function updateModel( data ) {
-   mw.log( '[CX] Received data from server' );
-   mw.cx.data = data;
-   mw.hook( 'mw.cx.source.ready' ).fire();
-   }
-
-   mw.cx.connect = function () {
-   if ( !socket ) {
-   if ( !initConnection() ) {
-   // io not defined. Server is unreachable.
-   $( '.cx-header__infobar' )
-   .text( mw.msg( 
'cx-error-server-connection' ) )
-   .show();
-   return;
-   }
-   }
-   socket.emit( 'cx.init', {
-   // FIXME
-   sourcePage: 'http://en.wikipedia.org/wiki/' + 
mw.cx.sourceTitle,
-   sourceLanguage: mw.cx.sourceLanguage,
-   targetLanguage: mw.cx.targetLanguage,
-   channel: 'cx'
-   } );
-   mw.log( '[CX] Sending context information to server' );
-   socket.on( 'cx.data.update', updateModel );
-   };
-
-}( jQuery, mediaWiki ) );
diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index 553f75e..a897fd1 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -11,6 +11,13 @@
 ( function ( $, mw ) {
'use strict';
 
+   mw.cx.fetchPage = function ( sourcePage, sourceLanguage ) {
+   $.get( mw.config.get( 'wgContentTranslationServerURL' ) + 
'/page/' + sourceLanguage + '/' + sourcePage, function ( response ) {
+   mw.cx.data = response;
+   mw.hook( 'mw.cx.source.ready' ).fire();
+   } );
+   };
+
/**
 * ContentTranslationSource
 *
@@ -27,8 +34,9 @@
ContentTranslationSource.prototype.init = function () {
mw.cx.sourceTitle = new mw.Uri().query.page;
mw.cx.targetLanguage = new mw.Uri().query.lang || '';
+   mw.cx.sourceLanguage = mw.config.get( 'wgContentLanguage' );
this.render();
-   mw.cx.connect();
+   mw.cx.fetchPage( mw.cx.sourceTitle, mw.cx.sourceLanguage );
this.listen();
};
 
@@ -37,8 +45,6 @@
 */
ContentTranslationSource.prototype.render = function () {
var $heading, $languageLabel, $articleLink, $subHeading, 
$loader;
-
-   mw.cx.sourceLanguage = mw.config.get( 'wgContentLanguage' );
 
this.$container.prop( {
lang: mw.cx.sourceLanguage,
@@ -60,7 +66,7 @@
'cx-source-view-page',
mw.util.getUrl( mw.cx.sourceTitle )
).parse()
-   );
+   );
 
$subHeading = $( 'div' )
.addClass( 'cx-column__sub-heading' )
diff --git a/specials/SpecialContentTranslation.php 

[MediaWiki-commits] [Gerrit] Rewrite the server as stateless, define REST apis - change (mediawiki...cxserver)

2014-05-12 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/132931

Change subject: Rewrite the server as stateless, define REST apis
..

Rewrite the server as stateless, define REST apis

Removed redis, websocket based architecture
Introduced simple express server with REST apis
APIs included now:
/version - to get the version information of the server
/page/:language/:title - Fetch the page with given title
and language. The output contains segment annotated page content

Allowed CORS for now.

Change-Id: I120cb20fe672565343d8223312947ee55e211a9c
---
M ContentTranslationService.js
D models/DataModelManager.js
M package.json
M public/index.html
M public/js/main.js
5 files changed, 82 insertions(+), 285 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/31/132931/1

diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index c635f1f..32fb516 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -14,104 +14,68 @@
 
 'use strict';
 
-var instanceName, context, port, app, server, io, fs, redis, express,
-RedisStore, logger, args, privateKey, certificate, credentials;
+var instanceName,
+   server,
+   fs = require( 'fs' ),
+   express = require( 'express' ),
+   app = express(),
+   logger = require( __dirname + '/utils/Logger.js' ),
+   args = require( 'minimist' )( process.argv.slice( 2 ) ),
+   port = args.port || 8000,
+   privateKey,
+   certificate,
+   credentials,
+   pkg = require( __dirname + '/package.json' );
 
-logger = require( __dirname + '/utils/Logger.js' );
-express = require( 'express' );
-fs = require( 'fs' );
-args = require( 'minimist' )( process.argv.slice( 2 ) );
-port = args.port || 8000;
 app = express();
-
 // Starts https server only if all needed args provided, else starts http 
server.
 if ( args.secure  args.key  args.cert ) {
-   privateKey  = fs.readFileSync( args.key, 'utf8' );
+   privateKey = fs.readFileSync( args.key, 'utf8' );
certificate = fs.readFileSync( args.cert, 'utf8' );
-   credentials = { key: privateKey, cert: certificate };
+   credentials = {
+   key: privateKey,
+   cert: certificate
+   };
server = require( 'https' ).createServer( credentials, app );
 } else {
server = require( 'http' ).createServer( app );
 }
 
-io = require( 'socket.io' ).listen( server, {
-   logger: {
-   debug: logger.debug,
-   info: logger.info,
-   error: logger.error,
-   warn: logger.warn
-   }
-} );
-
-// Production log configuration.
-io.configure( 'production', function () {
-   io.set( 'log level', 1 ); // reduce logging
-   io.enable( 'browser client minification' ); // send minified client
-   io.enable( 'browser client etag' ); // apply etag caching logic based 
on version number
-   io.enable( 'browser client gzip' ); // gzip the file
-
-   // enable all transports
-   io.set( 'transports', [
-   'websocket',
-   'flashsocket',
-   'htmlfile',
-   'xhr-polling',
-   'jsonp-polling'
-   ] );
-} );
-
-// Development log configuration.
-io.configure( 'development', function () {
-   io.enable( 'browser client gzip' ); // gzip the file, reduce the log 
size
-   io.set( 'transports', [ 'websocket' ] );
-} );
-
-redis = require( 'redis' );
-// Use Redis as the store for socket.io
-RedisStore = require( 'socket.io/lib/stores/redis' );
-io.set( 'store',
-   new RedisStore( {
-   redisPub: redis.createClient(),
-   redisSub: redis.createClient(),
-   redisClient: redis.createClient()
-   } )
-);
 instanceName = 'worker(' + process.pid + ')';
-// socket.io connection establishment
-io.sockets.on( 'connection', function ( socket ) {
-   var dataModelManager,
-   CXDataModelManager,
-   redisSub = redis.createClient();
-
-   logger.debug( 'Client connected to ' + instanceName + '. Socket: ' + 
socket.id );
-   redisSub.subscribe( 'cx' );
-   redisSub.on( 'message', function ( channel, message ) {
-   socket.emit( 'cx.data.update', JSON.parse( message ) );
-   logger.debug( 'Received from channel #' + channel + ':' + 
message );
-   } );
-
-   socket.on( 'cx.init', function ( data ) {
-   CXDataModelManager = require( __dirname + 
'/models/DataModelManager.js' ).CXDataModelManager;
-   context = {
-   sourceLanguage: data.sourceLanguage,
-   targetLanguage: data.targetLanguage,
-   sourcePage: data.sourcePage,
-   pub: redis.createClient(),
-   store: redis.createClient()
-   };
-

[MediaWiki-commits] [Gerrit] Experiment: Apertium APY webservice based MT backend - change (mediawiki...cxserver)

2014-04-28 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/130050

Change subject: Experiment: Apertium APY webservice based MT backend
..

Experiment: Apertium APY webservice based MT backend

Not for review.

Change-Id: I4f81f9198df2d54ec132a0b1c9a11fe907d6620a
---
M index.js
A mt/providers/Apertium.js
M tests/index.js
A tests/mt/Apertium/Apertium.test.js
A tests/mt/Apertium/Apertium.test.json
5 files changed, 90 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/50/130050/1

diff --git a/index.js b/index.js
index 889..6da44c2 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,5 @@
 module.exports = {
Segmenter: require( './segmentation/CXSegmenter.js' ).CXSegmenter,
-   Rot13Service: require( './mt/providers/Rot13.js' ).Rot13Service
+   Rot13Service: require( './mt/providers/Rot13.js' ).Rot13Service,
+   ApertiumService: require( './mt/providers/Apertium.js' ).ApertiumService
 };
diff --git a/mt/providers/Apertium.js b/mt/providers/Apertium.js
new file mode 100644
index 000..9a696fa
--- /dev/null
+++ b/mt/providers/Apertium.js
@@ -0,0 +1,48 @@
+/**
+ *Apertium Translation service
+ *
+ * A dummy interface to test the CX MT
+ */
+
+'use strict';
+
+var Q = require( 'q' ),
+   request = require( 'request' );
+
+/**
+ * @class ApertiumService
+ */
+function ApertiumService( config ) {
+   this.config = config;
+   this.parser = null;
+}
+
+ApertiumService.prototype.translate = function ( segments ) {
+   var deferred = Q.defer(),
+   mt = {}, chain,
+   segmentIds;
+
+   segmentIds = Object.keys( segments );
+   chain = segmentIds.reduce( function ( previous, segmentId ) {
+   return previous.then( function () {
+   var deferred = Q.defer(),
+   req;
+
+   req = 
'http://localhost:2737/translate?langpair=eng|spaq=' + segments[ segmentId 
].source;
+   request( req, function ( error, response, body ) {
+   mt[ segmentId ] = JSON.parse( body 
).responseData.translatedText;
+   deferred.resolve();
+   } );
+   return deferred.promise;
+   } );
+   }, Q.resolve( 'start' ) );
+
+   chain.then( function () {
+   deferred.resolve( mt );
+   } );
+
+   return deferred.promise;
+};
+
+
+module.exports.ApertiumService = ApertiumService;
diff --git a/tests/index.js b/tests/index.js
index 48c2460..d13ba4b 100644
--- a/tests/index.js
+++ b/tests/index.js
@@ -3,6 +3,7 @@
tests = [
'./tests/segmentation/CXSegmenter.test.js',
'./tests/mt/Rot13/Rot13.test.js',
+   './tests/mt/Apertium/Apertium.test.js'
];
 
 qunit.setup( {
diff --git a/tests/mt/Apertium/Apertium.test.js 
b/tests/mt/Apertium/Apertium.test.js
new file mode 100644
index 000..0c49209
--- /dev/null
+++ b/tests/mt/Apertium/Apertium.test.js
@@ -0,0 +1,17 @@
+'use strict';
+
+QUnit.module( 'Apertium' );
+QUnit.test( 'Apertium tests', function ( assert ) {
+   var apertium, tests = require( './Apertium.test.json' );
+
+   apertium = new CX.ApertiumService();
+   QUnit.stop();
+   apertium.translate( tests.source ).then( function ( result ) {
+   var segmentId;
+
+   for ( segmentId in tests.source ) {
+   assert.strictEqual( result[ segmentId ], tests.result[ 
segmentId ] );
+   }
+   QUnit.start();
+   } );
+} );
diff --git a/tests/mt/Apertium/Apertium.test.json 
b/tests/mt/Apertium/Apertium.test.json
new file mode 100644
index 000..b32956b
--- /dev/null
+++ b/tests/mt/Apertium/Apertium.test.json
@@ -0,0 +1,22 @@
+{
+   source: {
+   1: {
+   source: Debian
+   },
+   2: {
+   source: pHello world/p
+   },
+   3: {
+   source: iThis is in Italics/i Some other text
+   },
+   4: {
+   source: Sentence one. a href=\#\reference/a 
Starts with reference
+   }
+   },
+   result: {
+   1: *Debian,
+   2: pHola Mundo/p,
+   3: iEsto es en Cursiva/i Algunos otro texto,
+   4: Sentenciar uno. Un *href=\
+   }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/130050
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f81f9198df2d54ec132a0b1c9a11fe907d6620a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing 

[MediaWiki-commits] [Gerrit] Simple clean up of article before parsing - change (mediawiki...cxserver)

2014-04-25 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/129653

Change subject: Simple clean up of article before parsing
..

Simple clean up of article before parsing

Just get body of the content from Parsoid

Change-Id: I8f4127f4d21f1c00652ef1e18baac0c9d1ff0612
---
M segmentation/CXSegmenter.js
1 file changed, 11 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/53/129653/1

diff --git a/segmentation/CXSegmenter.js b/segmentation/CXSegmenter.js
index 7591432..9ea81fb 100644
--- a/segmentation/CXSegmenter.js
+++ b/segmentation/CXSegmenter.js
@@ -27,6 +27,7 @@
 };
 
 CXSegmenter.prototype.parse = function () {
+   this.content = this.getBody( this.content );
this.parser.parse( this.content );
this.links = this.parser.links;
this.segmentedContent = this.parser.segmentedContent;
@@ -34,6 +35,15 @@
 
 CXSegmenter.prototype.getLinks = function () {
return this.links;
+};
+
+/**
+ * Get the body part alone for the content.
+ */
+CXSegmenter.prototype.getBody = function () {
+   var $container = $( 'div' ).html( this.content );
+   $container = $container.find( 'body' );
+   return $container.length ? $container[ 0 ].outerHTML : this.content;
 };
 
 CXSegmenter.prototype.extractSegments = function () {
@@ -44,7 +54,7 @@
var $section = $( section ),
segmentId = $section.data( 'segmentid' );
 
-   segmenter.segments[segmentId] = {
+   segmenter.segments[ segmentId ] = {
source: $section.html()
};
} );

-- 
To view, visit https://gerrit.wikimedia.org/r/129653
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8f4127f4d21f1c00652ef1e18baac0c9d1ff0612
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Some cleanup on html before saving - change (mediawiki...ContentTranslation)

2014-04-25 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/129658

Change subject: Some cleanup on html before saving
..

Some cleanup on html before saving

This will eventually moved to server as noted as TODO

Change-Id: I0e3e81fd09e6fb3029db1b5dfecf4157b6b34e57
---
M modules/translation/ext.cx.publish.js
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/58/129658/1

diff --git a/modules/translation/ext.cx.publish.js 
b/modules/translation/ext.cx.publish.js
index bb0e08c..c8ae9d2 100644
--- a/modules/translation/ext.cx.publish.js
+++ b/modules/translation/ext.cx.publish.js
@@ -24,6 +24,8 @@
$translatedContent.find( '.cx-segment' ).replaceWith( function 
() {
return $( this ).html();
} );
+   // TODO: This clean up should be done even before segmentation 
at server.
+   $translatedContent.find( 'link, title' ).remove();
 
// Remove placeholder sections that are empty
// TODO: This can be better done if all placeholder sections 
has a semantic

-- 
To view, visit https://gerrit.wikimedia.org/r/129658
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0e3e81fd09e6fb3029db1b5dfecf4157b6b34e57
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] WIP Redis Cache model - change (mediawiki...cxserver)

2014-04-24 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/129396

Change subject: WIP Redis Cache model
..

WIP Redis Cache model

See https://www.mediawiki.org/wiki/Content_translation/Caching

Change-Id: Id0355e995e2dbd146eefd4574bbacce6ccc8226c
---
M models/DataModelManager.js
1 file changed, 31 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/96/129396/1

diff --git a/models/DataModelManager.js b/models/DataModelManager.js
index 02c62ed..640ca38 100644
--- a/models/DataModelManager.js
+++ b/models/DataModelManager.js
@@ -33,10 +33,10 @@
PageLoader, pageloader;
 
// TODO: refactor this
-   this.context.store.get( this.context.sourcePage, function ( err, data ) 
{
-   dataModelManager.dataModel = JSON.parse( data );
+   this.context.store.get( this.getCacheKey() + ':segmentedContent', 
function ( err, data ) {
+   dataModelManager.dataModel.segmentedContent = data;
 
-   if ( dataModelManager.dataModel ) {
+   if ( data ) {
// data model present in redis store
dataModelManager.publish();
} else {
@@ -81,18 +81,40 @@
  */
 CXDataModelManager.prototype.publish = function () {
var dataModelManager = this,
-   data = JSON.stringify( dataModelManager.getDataModel() );
+   key, segmentId, commandQueue, linkId,
+   data = dataModelManager.getDataModel();
 
// TODO: Make the key unique, language pair also should be considered
-   // TODO: Make the data model in the redis store more granular than
-   // a single json dump.
-   this.context.store.set( this.dataModel.sourcePage, data, function () {
-   dataModelManager.context.pub.publish( 'cx', data );
+   // TODO: Rafactor to a cache manager
+   key = this.getCacheKey();
+   commandQueue = this.context.store.multi();
+   commandQueue.set( key + ':segmentedContent', data.segmentedContent );
+   for ( segmentId in data.segments ) {
+   commandQueue.hmset( key + ':segments:' + segmentId, 
data.segments[ segmentId ] );
+   }
+   for ( segmentId in data.mt ) {
+   commandQueue.set( key + ':mt:' + segmentId, data.mt[ segmentId 
] );
+   }
+   for ( linkId in data.links ) {
+   commandQueue.hmset( key + ':links:' + segmentId, data.links[ 
linkId ] );
+   }
+   commandQueue.exec( function ( error ) {
+   if ( error ) {
+   throw ( error );
+   }
+   dataModelManager.context.pub.publish( 'cx', JSON.stringify( 
data ) );
} );
 
-   logger.debug( 'Sending data. Version: ' + this.dataModel.version );
+   logger.debug( 'Sending data.Version: ' + this.dataModel.version );
 
this.incrementVersionNumber();
+};
+
+/**
+ * Update the version number of the model
+ */
+CXDataModelManager.prototype.getCacheKey = function () {
+   return this.context.sourceLanguage + ':' + this.context.sourcePage + 
':' + this.context.targetLanguage;
 };
 
 /**
@@ -101,7 +123,6 @@
 CXDataModelManager.prototype.incrementVersionNumber = function () {
this.dataModel.version += 1;
 };
-
 /**
  * Get the data model
  */

-- 
To view, visit https://gerrit.wikimedia.org/r/129396
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0355e995e2dbd146eefd4574bbacce6ccc8226c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Remove unwanted new line and tab characters from the parsed ... - change (mediawiki...cxserver)

2014-04-22 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/129099

Change subject: Remove unwanted new line and tab characters from the parsed 
output
..

Remove unwanted new line and tab characters from the parsed output

This was introduced to help debugging. Removing them now

Change-Id: Ia02457f9d771598f0e702d8a5cecfccce055be67
---
M segmentation/languages/CXParser.js
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/99/129099/1

diff --git a/segmentation/languages/CXParser.js 
b/segmentation/languages/CXParser.js
index 9562eb7..532d538 100644
--- a/segmentation/languages/CXParser.js
+++ b/segmentation/languages/CXParser.js
@@ -82,7 +82,7 @@
this.inSentence = true;
this.sawSentenceEndCandidate = false;
this.inReference = false;
-   return '\n\tspan class=cx-segment data-segmentid=' + ( 
this.segmentCount++ ) + '';
+   return 'span class=cx-segment data-segmentid=' + ( 
this.segmentCount++ ) + '';
 };
 
 /**
@@ -252,7 +252,7 @@
// Avoid dangling sentence.
this.print( this.endSentence() );
}
-   this.print( '/' + tag + '\n' );
+   this.print( '/' + tag + '' );
} else {
this.print( '/' + tag + '' );
}

-- 
To view, visit https://gerrit.wikimedia.org/r/129099
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia02457f9d771598f0e702d8a5cecfccce055be67
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Show error message when server connection failed - change (mediawiki...ContentTranslation)

2014-04-16 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126214

Change subject: Show error message when server connection failed
..

Show error message when server connection failed

Change-Id: I9d93c1f451d7fd325bbc9274a7fb39a4dc31374a
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M modules/base/ext.cx.datamanager.js
M modules/header/ext.cx.header.render.js
M modules/header/styles/ext.cx.header.less
6 files changed, 31 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/14/126214/1

diff --git a/Resources.php b/Resources.php
index 84c2de3..5a37e7b 100644
--- a/Resources.php
+++ b/Resources.php
@@ -51,7 +51,8 @@
),
'messages' = array(
'cx-header-translation-center',
-   'cx-publish-button'
+   'cx-publish-button',
+   'cx-error-server-connection',
),
 ) + $resourcePaths;
 
diff --git a/i18n/en.json b/i18n/en.json
index 1a570b7..e7055ba 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -28,5 +28,6 @@
 cx-tools-instructions-text5: Publish the translation,
 cx-tools-instructions-text6: When you are happy with the result, press 
{{int:cx-publish-button}}.,
 cx-tools-searchbox-text: Search for a word,
-cx-tools-view-guidelines: [$1 View translation guidelines]
+cx-tools-view-guidelines: [$1 View translation guidelines],
+   cx-error-server-connection: Error: Could not connect to the server
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 904d1b1..4809242 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -29,5 +29,6 @@
 cx-tools-instructions-text5: Help text for the translation tools pane.,
 cx-tools-instructions-text6: Help text for the translation tools 
pane.\n\nRefers to {{msg-mw|Cx-publish-button}}.,
 cx-tools-searchbox-text: Placeholder text for the searchbox on the 
translation tools column,
-cx-tools-view-guidelines: Parameters:\n* $1 - the URL pointing to the 
guidelines for translation in Wikipedia
+cx-tools-view-guidelines: Parameters:\n* $1 - the URL pointing to the 
guidelines for translation in Wikipedia,
+   cx-error-server-connection: Error message shown when connection to 
the ontent translation server is failed.
 }
diff --git a/modules/base/ext.cx.datamanager.js 
b/modules/base/ext.cx.datamanager.js
index a404c73..79e815a 100644
--- a/modules/base/ext.cx.datamanager.js
+++ b/modules/base/ext.cx.datamanager.js
@@ -15,8 +15,12 @@
 
/* global io */
function initConnection() {
+   if ( !window.io ) {
+   return false;
+   }
socket = io.connect( mw.config.get( 
'wgContentTranslationServerURL' ) );
mw.log( '[CX] Connected to server' );
+   return true;
}
 
function updateModel( data ) {
@@ -27,7 +31,13 @@
 
mw.cx.connect = function () {
if ( !socket ) {
-   initConnection();
+   if ( !initConnection() ) {
+   // io not defined. Server is unreachable.
+   $( '.cx-header__infobar' )
+   .text( mw.msg( 
'cx-error-server-connection' ) )
+   .show();
+   return;
+   }
}
socket.emit( 'cx.init', {
// FIXME
diff --git a/modules/header/ext.cx.header.render.js 
b/modules/header/ext.cx.header.render.js
index 2328bae..16cc732 100644
--- a/modules/header/ext.cx.header.render.js
+++ b/modules/header/ext.cx.header.render.js
@@ -13,7 +13,7 @@
 
mw.cx.ContentTranslationHeader.prototype.render = function () {
var $logo, $userName, $userDetails, $headerBar, $publishButton,
-   $translationCenterLink, $translationCenter;
+   $translationCenterLink, $translationCenter, $infoBar;
 
$logo = $( 'div' ).addClass( 'cx-header__logo' );
$userName = $( 'a' )
@@ -35,9 +35,12 @@
$headerBar = $( 'div' )
.addClass( 'cx-header__bar' )
.append( $translationCenter, $publishButton );
+   $infoBar = $( 'div' )
+   .addClass( 'cx-header__infobar' )
+   .hide();
this.$container
.addClass( 'cx-header' )
-   .append( $logo, $userDetails, $headerBar );
+   .append( $logo, $userDetails, $headerBar, $infoBar );
};
 
 }( jQuery, mediaWiki ) );
diff --git a/modules/header/styles/ext.cx.header.less 
b/modules/header/styles/ext.cx.header.less
index a909d11..4591efd 100644
--- a/modules/header/styles/ext.cx.header.less
+++ 

[MediaWiki-commits] [Gerrit] Sanitize the jquery id for the translation section - change (mediawiki...ContentTranslation)

2014-04-16 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126230

Change subject: Sanitize the jquery id for the translation section
..

Sanitize the jquery id for the translation section

Make sure we use a valid jquery selector.

Change-Id: Id21ce64d80f8026274b258e4d3790e694f74cecf
---
M modules/translation/ext.cx.translation.js
1 file changed, 15 insertions(+), 4 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/30/126230/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index add1daa..447a053 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -161,13 +161,24 @@
 * @param {string} [prefix] id prefix
 */
function jquerySelectorForId( id, prefix ) {
+   var selector, randomId;
+
+   randomId = '#' + prefix + ( Math.floor( Math.random() * 100 
) + 1 );
prefix = prefix || '';
if ( !id ) {
-   return '#' + prefix + ( Math.floor( Math.random() * 
100 ) + 1 );
+   selector = randomId;
+   } else {
+   // make it a string
+   id = id + '';
+   selector = '#' + prefix + id.replace( 
/(:|\/|\.|\[|\])/g, '\\$1' );
}
-   // make it a string
-   id = id + '';
-   return '#' + prefix + id.replace( /(:|\/|\.|\[|\])/g, '\\$1' );
+   try {
+   // Make sure jQuery consider it as a valid selector.
+   $( selector );
+   } catch ( error ) {
+   selector = randomId;
+   }
+   return selector;
}
 
function souceSectionClickHandler() {

-- 
To view, visit https://gerrit.wikimedia.org/r/126230
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id21ce64d80f8026274b258e4d3790e694f74cecf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Remove the empty sections and do not add placeholders for them - change (mediawiki...ContentTranslation)

2014-04-16 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126231

Change subject: Remove the empty sections and do not add placeholders for them
..

Remove the empty sections and do not add placeholders for them

Change-Id: Ia896f6daafccbbfd66c985d5d25d220a8a0895ff
---
M modules/translation/ext.cx.translation.js
1 file changed, 3 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/31/126231/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 447a053..2436b95 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -212,7 +212,9 @@
$section = $( $sections[ i ] );
sourceSectionId = $section.attr( 'id' );
$sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
-   if ( $sourceSection.height() === 0 ) {
+   if ( $sourceSection.height() === 0 || 
!$sourceSection.text().trim() ) {
+   $sourceSection.remove();
+   $section.remove();
// Source section has height as 0. This 
indicates an empty
// section - mainly resulting from spurious 
wikitext
continue;

-- 
To view, visit https://gerrit.wikimedia.org/r/126231
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia896f6daafccbbfd66c985d5d25d220a8a0895ff
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Mask the templates and make it not editable - change (mediawiki...ContentTranslation)

2014-04-16 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126234

Change subject: Mask the templates and make it not editable
..

Mask the templates and make it not editable

Change-Id: I2a43e51893e94a2340fc4536e422c330fee90a62
---
M modules/translation/ext.cx.translation.js
M modules/translation/styles/ext.cx.translation.less
2 files changed, 15 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/34/126234/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 2436b95..0135952 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -201,7 +201,7 @@
 */
ContentTranslationEditor.prototype.addPlaceholders = function () {
var cxSectionSelector = this.getSectionSelector(),
-   $content,
+   $content, template,
$sections, i, $section, sourceSectionId, $sourceSection;
 
// Clone the source article and work on this detached object
@@ -209,6 +209,7 @@
$content = $( '.cx-column--source .cx-column__content' 
).clone();
$sections = $content.find( cxSectionSelector );
for ( i = 0; i  $sections.length; i++ ) {
+   template = false;
$section = $( $sections[ i ] );
sourceSectionId = $section.attr( 'id' );
$sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
@@ -220,6 +221,13 @@
continue;
}
 
+   // Mask the templates
+   if ( $sourceSection.attr( 'typeof' ) === 
'mw:Transclusion' ) {
+   $section.addClass( 'cx-mw-template' );
+   $sourceSection.addClass( 'cx-mw-template' );
+   template = true;
+   }
+
$section.empty();
$section.css( {
'min-height': $sourceSection.height(),
@@ -228,8 +236,8 @@
$section.attr( {
'id': 't' + sourceSectionId,
'data-source': sourceSectionId,
-   // Sections are editable
-   'contenteditable': true
+   // Sections are editable if they are not 
templates
+   'contenteditable': template ? false : true
} );
 
// Attach event handlers for sections
diff --git a/modules/translation/styles/ext.cx.translation.less 
b/modules/translation/styles/ext.cx.translation.less
index 217db28..bf70c96 100644
--- a/modules/translation/styles/ext.cx.translation.less
+++ b/modules/translation/styles/ext.cx.translation.less
@@ -18,4 +18,8 @@
font-weight: lighter;
color: #AAA;
cursor: pointer;
+}
+
+.cx-mw-template {
+   -webkit-mask-image: -webkit-linear-gradient(top, rgba(0,0,0,0.4), 
rgba(0,0,0,0.4));
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/126234
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2a43e51893e94a2340fc4536e422c330fee90a62
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Remove a console debug statement added in I579c3ccb6e0c1ad - change (mediawiki...UniversalLanguageSelector)

2014-04-15 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/126199

Change subject: Remove a console debug statement added in I579c3ccb6e0c1ad
..

Remove a console debug statement added in I579c3ccb6e0c1ad

Change-Id: Ifbbc9b8b3a643d38fd8874e23c1087e5ee431e80
---
M lib/jquery.webfonts.js
1 file changed, 0 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/99/126199/1

diff --git a/lib/jquery.webfonts.js b/lib/jquery.webfonts.js
index 1fb59d4..c28df95 100644
--- a/lib/jquery.webfonts.js
+++ b/lib/jquery.webfonts.js
@@ -308,7 +308,6 @@
return item.replace( /[\s']/g, '' );
} );
fontFamily = fontFamily.replace( /[\s']/g, '' );
-   console.log(fontFamily+':'+overridableFontFamilies);
return $.inArray( fontFamily, overridableFontFamilies ) 
= 0;
},
 

-- 
To view, visit https://gerrit.wikimedia.org/r/126199
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbbc9b8b3a643d38fd8874e23c1087e5ee431e80
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Update jquery.webfonts to 372aad1 - change (mediawiki...UniversalLanguageSelector)

2014-04-14 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/125701

Change subject: Update jquery.webfonts to 372aad1
..

Update jquery.webfonts to 372aad1

Introduce overridable font family option
Font stacks given in overridableFontFamilies will be overridden
as as exception to the general policy of not altering elements with
explicit font family styles

Change-Id: I579c3ccb6e0c1ad39d434651a4689e8c595e5a84
---
A lib/jquery.i18n/.directory
A lib/jquery.uls/src/.directory
M lib/jquery.webfonts.js
3 files changed, 64 insertions(+), 19 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/01/125701/1

diff --git a/lib/jquery.i18n/.directory b/lib/jquery.i18n/.directory
new file mode 100644
index 000..03e1705
--- /dev/null
+++ b/lib/jquery.i18n/.directory
@@ -0,0 +1,6 @@
+[Dolphin]
+SortOrder=1
+SortRole=size
+Timestamp=2014,1,23,2,41,46
+Version=3
+ViewMode=1
diff --git a/lib/jquery.uls/src/.directory b/lib/jquery.uls/src/.directory
new file mode 100644
index 000..2318bfc
--- /dev/null
+++ b/lib/jquery.uls/src/.directory
@@ -0,0 +1,4 @@
+[Dolphin]
+Timestamp=2013,11,25,9,40,39
+Version=3
+VisibleRoles=Icons_text,Icons_size,Icons_date
diff --git a/lib/jquery.webfonts.js b/lib/jquery.webfonts.js
index acacaa6..1fb59d4 100644
--- a/lib/jquery.webfonts.js
+++ b/lib/jquery.webfonts.js
@@ -174,8 +174,7 @@
 * different language than what the element itself has.
 */
parse: function() {
-   var append,
-   webfonts = this,
+   var webfonts = this,
// Fonts can be added indirectly via classes, 
but also with
// style attributes. For lang attributes we 
will use our font
// if they don't have explicit font already.
@@ -186,12 +185,18 @@
// Object keys are the font family, values are 
list of plain elements.
elementQueue = {};
 
-   // Append function that keeps the array as a set (no 
dupes)
-   append = function( array, value ) {
-   if ( $.inArray( value, array )  0 ) {
-   array.push( value );
+   // Add to the font queue(no dupes)
+   function addToFontQueue( value ) {
+   if ( $.inArray( value, fontQueue )  0 ) {
+   fontQueue.push( value );
}
-   };
+   }
+
+   // Add to the font queue
+   function addToElementQueue( element, fontFamily ) {
+   elementQueue[fontFamily] = 
elementQueue[fontFamily] || [];
+   elementQueue[fontFamily].push( element );
+   }
 
$elements.each( function( i, element ) {
var fontFamilyStyle, fontFamily,
@@ -207,18 +212,28 @@
// Note: It is unclear whether this can ever be 
falsy. Maybe also
// browser specific.
if ( fontFamilyStyle ) {
-   fontFamily = fontFamilyStyle.split( ',' 
)[0];
-
-   // Remove the ' and  characters if any.
-   fontFamily = $.trim( 
fontFamily.replace( /[']/g, '' ) );
-
-   append( fontQueue, fontFamily );
+   // if it is overridable, override. 
always.
+   if ( webfonts.isOverridable( 
fontFamilyStyle ) ) {
+   fontFamily = webfonts.getFont( 
element.lang || webfonts.language );
+   // We do not have fonts for all 
languages
+   if ( fontFamily ) {
+   addToFontQueue( 
fontFamily );
+   addToElementQueue( 
element, fontFamily );
+   }
+   return;
+   } else {
+   fontFamily = 
fontFamilyStyle.split( ',' )[0];
+   // Remove the ' and  
characters if any.
+   fontFamily = $.trim( 
fontFamily.replace( /[']/g, '' ) );
+   addToFontQueue( fontFamily );
+

[MediaWiki-commits] [Gerrit] Allow overriding the header styles from typography refresh - change (mediawiki...UniversalLanguageSelector)

2014-04-14 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/125702

Change subject: Allow overriding the header styles from typography refresh
..

Allow overriding the header styles from typography refresh

Bug: 63718
Change-Id: Ifa36c6718694158c44da09ae8eb62d31ef5fd0a0
---
M resources/js/ext.uls.webfonts.js
1 file changed, 3 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/02/125702/1

diff --git a/resources/js/ext.uls.webfonts.js b/resources/js/ext.uls.webfonts.js
index 242116f..80dc4df 100644
--- a/resources/js/ext.uls.webfonts.js
+++ b/resources/js/ext.uls.webfonts.js
@@ -129,7 +129,7 @@
$.extend( $.fn.webfonts.defaults, {
repository: mediawikiFontRepository,
fontStack: $( 'body' ).css( 'font-family' ).split( /, 
/g ),
-   exclude: mw.config.get( 'wgULSNoWebfontsSelectors' 
).join( ', ' )
+   exclude: mw.config.get( 'wgULSNoWebfontsSelectors' 
).join( ', ' ),
} );
 
$.fn.webfonts.defaults = $.extend( $.fn.webfonts.defaults, {
@@ -202,7 +202,8 @@
}
 
return excludes;
-   }() )
+   }() ),
+   overridableFontFamilies: [ 'Linux Libertine, Georgia, 
Times, serif' ]
} );
 
// Execute after task queue is processed so that the rendering 
is complete.

-- 
To view, visit https://gerrit.wikimedia.org/r/125702
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa36c6718694158c44da09ae8eb62d31ef5fd0a0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Segmentation: More fixes related to references at end of sen... - change (mediawiki...cxserver)

2014-04-10 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/125103

Change subject: Segmentation: More fixes related to references at end of 
sentence
..

Segmentation: More fixes related to references at end of sentence

References need special handling because it can appear after a period
but still part of previous sentences.

It is also possible that they come repeated. example: ...end.[1][2]

To handle this repeated reference, we are undoing the last segment close.

But there were some bugs in resetting the inReference flag causing the
undo end sentence deleting actual content

This patch fixes them and add more tests

Change-Id: Icc4d1b6ddad804d5365a0001c7b93f3ac78c9b23
---
M segmentation/languages/CXParser.js
M tests/segmentation/SegmentationTests.json
A tests/segmentation/data/result-15.html
A tests/segmentation/data/result-ends-with-bracket.html
A tests/segmentation/data/result-ends-with-references-missing-letters.html
A tests/segmentation/data/test-15.html
A tests/segmentation/data/test-ends-with-bracket.html
A tests/segmentation/data/test-ends-with-references-missing-letters.html
8 files changed, 39 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/03/125103/1

diff --git a/segmentation/languages/CXParser.js 
b/segmentation/languages/CXParser.js
index bf1ce9e..fc6d200 100644
--- a/segmentation/languages/CXParser.js
+++ b/segmentation/languages/CXParser.js
@@ -1,6 +1,7 @@
 'use strict';
 
 var SAXParser = require( 'sax' ).SAXParser,
+   logger = require( __dirname + '/utils/Logger.js' ),
util = require( 'util' );
 
 /**
@@ -79,6 +80,7 @@
 CXParser.prototype.startSentence = function () {
this.inSentence = true;
this.sawSentenceEndCandidate = false;
+   this.inReference = false;
return '\n\tspan class=cx-segment data-segmentid=' + ( 
this.segmentCount++ ) + '';
 };
 
@@ -94,8 +96,15 @@
  * Undo end a sentence
  */
 CXParser.prototype.undoEndSentence = function () {
+   var lastClose;
this.inSentence = true;
-   this.segmentedContent = this.segmentedContent.substr( 0, 
this.segmentedContent.length - 7 );
+   lastClose = this.segmentedContent.substr( this.segmentedContent.length 
- 7, this.segmentedContent.length )
+   // Make sure we are not deleting anything other than close tag.
+   if ( lastClose === '/span' ) {
+   this.segmentedContent = this.segmentedContent.substr( 0, 
this.segmentedContent.length - 7 );
+   } else {
+   logger.warn( 'Error in undoEndSentence. Attempted deleting 
content' );
+   }
 };
 
 /**
@@ -174,7 +183,7 @@
 
if ( this.sawSentenceEndCandidate ) {
if ( tag.name === 'span' 
-   tag.attributes.class === 'reference'  ( 
this.inSentence || this.inReference )  this.sawSentenceEndCandidate ) {
+   tag.attributes.class === 'reference'  ( 
this.inSentence || this.inReference ) ) {
// Sentences staring with reference links.
// Example: Sentence one.[1] Sentence two
// Here [1] is not part of Sentence two. It is 
reference for Sentence one.
@@ -188,14 +197,13 @@
}
this.inReference = true;
}
-
-   // Check if we need to reset inReference state. References 
contains an 'a' tag
-   // inside 'span' tag
-   if ( this.inReference  !( tag.name === 'a' || tag.name === 
'span' ) ) {
-   // Reset inReference
-   this.inReference = false;
-   this.sawSentenceEndCandidate = false;
-   }
+   }
+   // Check if we need to reset inReference state. References contains an 
'a' tag
+   // inside 'span' tag
+   if ( this.inReference  tag.name !== 'a'  tag.name !== 'span' ) {
+   // Reset inReference
+   this.inReference = false;
+   this.sawSentenceEndCandidate = false;
}
// Start of tag
this.print( '' + tag.name );
diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index 205bf1f..aec60ca 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -6,6 +6,11 @@
result: result-1.html
},
{
+   desc: Sentence ending with ),
+   source: test-ends-with-bracket.html,
+   result: result-ends-with-bracket.html
+   },
+   {
desc: Exclamation, punctuation test,
source: test-2.html,
result: result-2.html
@@ -69,6 +74,16 @@
desc: Paragraph from Debian 

[MediaWiki-commits] [Gerrit] Fix the miss-alignment of sections by few pixels - change (mediawiki...ContentTranslation)

2014-04-09 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124794

Change subject: Fix the miss-alignment of sections by few pixels
..

Fix the miss-alignment of sections by few pixels

From tests, it is found that sections alignment go wrong by
a few pixels even after correct height is set. Browser does not
use that exact value probably due to rounding and other unknown
factors.

This patch tries to fix it by adjusting the height till an agreable
height is found

Change-Id: Ic8b846e86e1e855d91254969fb35ed461baeb6cc
---
M modules/translation/ext.cx.translation.js
1 file changed, 23 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/94/124794/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index dca569f..f2e1c9a 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -183,15 +183,20 @@
var $section, sourceSectionId, $sourceSection;
 
$section = $( this );
+   if ( $section.height() === 0 ) {
+   // Source section has height as 0. This 
indicates an empty
+   // section - mainly resulting from spurious 
wikitext
+   return;
+   }
sourceSectionId = $section.attr( 'id' );
$sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
-   $section.css( 'min-height', $section.height() )
+   $section.empty();
+   $section.css( 'min-height', $sourceSection.height() )
.attr( {
'id': 't' + sourceSectionId,
'data-source': sourceSectionId,
'contenteditable': true
} );
-   $section.empty();
$section.on( 'input', keepAlignment );
// Bind events to the placeholder sections
$sourceSection.click( function () {
@@ -216,11 +221,26 @@
/*jshint validthis:true */
$section = $( this );
$sourceSection = $( '#' + $section.data( 'source' ) );
-   sectionHeight = $section.height();
$sourceSection.css( 'min-height', '' );
+
sourceSectionHeight = $sourceSection.height();
+   sectionHeight = $section.height();
+
if ( sourceSectionHeight  sectionHeight ) {
$sourceSection.css( 'min-height', sectionHeight );
+   sourceSectionHeight = $sourceSection.height();
+   sectionHeight = $section.height();
+   // Fun stuff - setting a calculated min-height will not 
guarantee
+   // equal height for all kind of section pairs.
+   // Experiments shows a few pixels difference
+   // Here we do it by 10px steps till we reach equal 
height.
+   while ( sectionHeight !== sourceSectionHeight ) {
+   sectionHeight = sectionHeight = sectionHeight + 
10;
+   $sourceSection.css( 'min-height', sectionHeight 
);
+   $section.css( 'min-height', sectionHeight );
+   sectionHeight = $section.height();
+   sourceSectionHeight = $sourceSection.height();
+   }
}
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/124794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic8b846e86e1e855d91254969fb35ed461baeb6cc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Performance fixes for preparing translation editor - change (mediawiki...ContentTranslation)

2014-04-09 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124814

Change subject: Performance fixes for preparing translation editor
..

Performance fixes for preparing translation editor

Detach the editor while preparing it to boost performance

And some code cleanup

Change-Id: I9b4fafd772a43b1d6d8312d065efabccd674f14b
---
M modules/translation/ext.cx.translation.js
1 file changed, 43 insertions(+), 31 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/14/124814/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 897dd46..9daa322 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -65,17 +65,11 @@
this.$container.append( $content );
mw.hook( 'mw.cx.translation.change' ).fire();
this.$title = this.$container.find( '.cx-column__title' );
-   this.$content = this.$container.find( '.cx-column__content' );
};
 
ContentTranslationEditor.prototype.listen = function () {
mw.hook( 'mw.cx.translation.add' ).add( $.proxy( this.update, 
this ) );
mw.hook( 'mw.cx.source.loaded' ).add( $.proxy( 
this.addPlaceholders, this ) );
-
-   this.$content.on( 'input', function () {
-   mw.hook( 'mw.cx.translation.change' ).fire();
-   } );
-
};
 
/**
@@ -145,13 +139,13 @@
mw.hook( 'mw.cx.translation.add' ).fire( $( this ).data( 
'source' ) );
}
 
-   function sectionMouseEnter() {
+   function sectionMouseEnterHandler() {
/*jshint validthis:true */
$( this ).addClass( 'placeholder' ).html( '+ Add Translation' );
$( jquerySelectorForId( $( this ).data( 'source' ) ) 
).addClass( 'highlight' );
}
 
-   function sectionMouseLeave() {
+   function sectionMouseLeaveHandler() {
/*jshint validthis:true */
$( this ).removeClass( 'placeholder' ).empty();
$( jquerySelectorForId( $( this ).data( 'source' ) ) 
).removeClass( 'highlight' );
@@ -171,25 +165,44 @@
id = id + '';
return '#' + prefix + id.replace( /(:|\/|\.|\[|\])/g, '\\$1' );
}
+
+   function souceSectionClickHandler() {
+   /*jshint validthis:true */
+   $( jquerySelectorForId( $( this ).attr( 'id' ), 't' ) ).click();
+   }
+
+   function souceSectionMouseEnterHandler() {
+   /*jshint validthis:true */
+   $( jquerySelectorForId( $( this ).attr( 'id' ), 't' ) 
).mouseenter();
+   }
+
+   function souceSectionMouseLeaveHandler() {
+   /*jshint validthis:true */
+   $( jquerySelectorForId( $( this ).attr( 'id' ), 't' ) 
).mouseleave();
+   }
/**
 * Add placeholders for translation sections. The placeholders
 * are aligned to the source sections. Also provides mouse hover 
effects.
 */
ContentTranslationEditor.prototype.addPlaceholders = function () {
-   var cxSectionSelector = this.getSectionSelector();
+   var cxSectionSelector = this.getSectionSelector(),
+   $content,
+   $sections, i, $section, sourceSectionId, $sourceSection;
 
-   this.$content.html( mw.cx.data.segmentedContent );
-   this.$content.find( cxSectionSelector ).each( function () {
-   var $section, sourceSectionId, $sourceSection;
-
-   $section = $( this );
-   if ( $section.height() === 0 ) {
-   // Source section has height as 0. This 
indicates an empty
-   // section - mainly resulting from spurious 
wikitext
-   return;
-   }
+   // Clone the source article and work on this detached object
+   // to help performance
+   $content = $( '.cx-column--source .cx-column__content' 
).clone();
+   $sections = $content.find( cxSectionSelector );
+   for ( i = 0; i  $sections.length; i++ ) {
+   $section = $( $sections[ i ] );
sourceSectionId = $section.attr( 'id' );
$sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
+   if ( $sourceSection.height() === 0 ) {
+   // Source section has height as 0. This 
indicates an empty
+   // section - mainly resulting from spurious 
wikitext
+   continue;
+   }
+
$section.empty();

[MediaWiki-commits] [Gerrit] Set the width also for the placeholder sections - change (mediawiki...ContentTranslation)

2014-04-09 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124813

Change subject: Set the width also for the placeholder sections
..

Set the width also for the placeholder sections

While emptying content width can go to 0 and prevent showing placehodler
text.

Change-Id: I5640b53ee9b0848baa95f928783c6479d40cab58
---
M modules/translation/ext.cx.translation.js
1 file changed, 9 insertions(+), 6 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/13/124813/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index f2e1c9a..897dd46 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -191,12 +191,15 @@
sourceSectionId = $section.attr( 'id' );
$sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
$section.empty();
-   $section.css( 'min-height', $sourceSection.height() )
-   .attr( {
-   'id': 't' + sourceSectionId,
-   'data-source': sourceSectionId,
-   'contenteditable': true
-   } );
+   $section.css( {
+   'min-height': $sourceSection.height(),
+   width: $sourceSection.width()
+   } );
+   $section.attr( {
+   'id': 't' + sourceSectionId,
+   'data-source': sourceSectionId,
+   'contenteditable': true
+   } );
$section.on( 'input', keepAlignment );
// Bind events to the placeholder sections
$sourceSection.click( function () {

-- 
To view, visit https://gerrit.wikimedia.org/r/124813
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5640b53ee9b0848baa95f928783c6479d40cab58
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Avoid handling sections with 0 height - change (mediawiki...ContentTranslation)

2014-04-08 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124526

Change subject: Avoid handling sections with 0 height
..

Avoid handling sections with 0 height

Source section has height as 0. This indicates an empty
section - mainly resulting from spurious wikitext

Change-Id: If9e3e558d4ec5ee94bba21555eb4d5b43b0fa1c5
---
M modules/translation/ext.cx.translation.js
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/26/124526/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index dca569f..2bbdbbe 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -183,6 +183,11 @@
var $section, sourceSectionId, $sourceSection;
 
$section = $( this );
+   if ( $section.height() === 0 ) {
+   // Source section has height as 0. This 
indicates an empty
+   // section - mainly resulting from spurious 
wikitext
+   return;
+   }
sourceSectionId = $section.attr( 'id' );
$sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
$section.css( 'min-height', $section.height() )

-- 
To view, visit https://gerrit.wikimedia.org/r/124526
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If9e3e558d4ec5ee94bba21555eb4d5b43b0fa1c5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Simplify the UI construction code, remove progress bar - change (mediawiki...ContentTranslation)

2014-04-08 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124578

Change subject: Simplify the UI construction code, remove progress bar
..

Simplify the UI construction code, remove progress bar

Progress bar will re-appear in tools column soon

Change-Id: I6f7bdc9cefda505c7da41d201cc7d57b7e57c164
---
M modules/header/ext.cx.header.render.js
R modules/tools/ext.cx.progressbar.js
R modules/tools/styles/ext.cx.progressbar.less
3 files changed, 25 insertions(+), 32 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/78/124578/1

diff --git a/modules/header/ext.cx.header.render.js 
b/modules/header/ext.cx.header.render.js
index df76cc4..2328bae 100644
--- a/modules/header/ext.cx.header.render.js
+++ b/modules/header/ext.cx.header.render.js
@@ -12,39 +12,32 @@
'use strict';
 
mw.cx.ContentTranslationHeader.prototype.render = function () {
-   this.$container.addClass( 'cx-header' );
-   this.$container.append(
-   $( 'div' )
-   .addClass( 'cx-header__logo' ),
-   $( 'div' )
-   .addClass( 'cx-header__user-details' )
-   .append(
-   $( 'a' )
-   .addClass( 
'cx-header__user-details__user-name' )
-   .attr( 'href', mw.util.getUrl( 
'User:' + mw.user.getName() ) )
-   .text( mw.user.getName() )
-   )
-   );
+   var $logo, $userName, $userDetails, $headerBar, $publishButton,
+   $translationCenterLink, $translationCenter;
 
-   this.$container.append(
-   $( 'div' )
-   .addClass( 'cx-header__bar' )
-   .append(
-   $( 'div' )
-   .addClass( 
'cx-header__translation-center' )
-   .append(
-   $( 'a' )
-   .text( mw.msg( 
'cx-header-translation-center' ) )
-   .attr( 'href', 
'#' )
-   ),
-   $( 'div' )
-   .addClass( 
'cx-header__progressbar' )
-   .cxProgressBar(),
-   $( 'button' )
-   .addClass( 'cx-header__publish 
publish mw-ui-button mw-ui-constructive' )
-   .text( mw.msg( 
'cx-publish-button' ) )
-   )
-   );
+   $logo = $( 'div' ).addClass( 'cx-header__logo' );
+   $userName = $( 'a' )
+   .addClass( 'cx-header__user-details__user-name' )
+   .attr( 'href', mw.util.getUrl( 'User:' + 
mw.user.getName() ) )
+   .text( mw.user.getName() );
+   $userDetails = $( 'div' )
+   .addClass( 'cx-header__user-details' )
+   .append( $userName );
+   $publishButton = $( 'button' )
+   .addClass( 'cx-header__publish publish mw-ui-button 
mw-ui-constructive' )
+   .text( mw.msg( 'cx-publish-button' ) );
+   $translationCenterLink = $( 'a' )
+   .text( mw.msg( 'cx-header-translation-center' ) )
+   .attr( 'href', '#' );
+   $translationCenter = $( 'div' )
+   .addClass( 'cx-header__translation-center' )
+   .append( $translationCenterLink );
+   $headerBar = $( 'div' )
+   .addClass( 'cx-header__bar' )
+   .append( $translationCenter, $publishButton );
+   this.$container
+   .addClass( 'cx-header' )
+   .append( $logo, $userDetails, $headerBar );
};
 
 }( jQuery, mediaWiki ) );
diff --git a/modules/header/ext.cx.progressbar.js 
b/modules/tools/ext.cx.progressbar.js
similarity index 100%
rename from modules/header/ext.cx.progressbar.js
rename to modules/tools/ext.cx.progressbar.js
diff --git a/modules/header/styles/ext.cx.progressbar.less 
b/modules/tools/styles/ext.cx.progressbar.less
similarity index 100%
rename from modules/header/styles/ext.cx.progressbar.less
rename to modules/tools/styles/ext.cx.progressbar.less

-- 
To view, visit 

[MediaWiki-commits] [Gerrit] Move the progress bar to tools column - change (mediawiki...ContentTranslation)

2014-04-08 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124579

Change subject: Move the progress bar to tools column
..

Move the progress bar to tools column

Match the style as per
https://commons.wikimedia.org/w/index.php?title=File:Content-translation-designs.pdfpage=6

Change-Id: I0ddab8db7bdc410708d8320af12e936dd03b65a7
---
M Resources.php
M modules/header/styles/ext.cx.header.less
M modules/tools/ext.cx.progressbar.js
M modules/tools/ext.cx.tools.js
M modules/tools/styles/ext.cx.progressbar.less
5 files changed, 22 insertions(+), 31 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/79/124579/1

diff --git a/Resources.php b/Resources.php
index c0dbd22..3f531ce 100644
--- a/Resources.php
+++ b/Resources.php
@@ -47,7 +47,6 @@
),
'dependencies' = array(
'mediawiki.jqueryMsg',
-   'ext.cx.progressbar',
'ext.cx.publish',
),
'messages' = array(
@@ -105,14 +104,15 @@
'cx-tools-view-guidelines',
),
'dependencies' = array(
+   'ext.cx.progressbar',
'mediawiki.jqueryMsg',
),
 ) + $resourcePaths;
 
 $wgResourceModules['ext.cx.progressbar'] = array(
-   'scripts' = 'header/ext.cx.progressbar.js',
+   'scripts' = 'tools/ext.cx.progressbar.js',
'styles' = array(
-   'header/styles/ext.cx.progressbar.less',
+   'tools/styles/ext.cx.progressbar.less',
),
'messages' = array(
'cx-header-progressbar-text'
diff --git a/modules/header/styles/ext.cx.header.less 
b/modules/header/styles/ext.cx.header.less
index b475fcd..7d9857e 100644
--- a/modules/header/styles/ext.cx.header.less
+++ b/modules/header/styles/ext.cx.header.less
@@ -39,11 +39,6 @@
}
 }
 
-.cx-header__progressbar {
-   .mw-ui-item;
-   .mw-ui-one-sixth;
-}
-
 .cx-header__publish {
.mw-ui-item;
.mw-ui-one-eighth;
diff --git a/modules/tools/ext.cx.progressbar.js 
b/modules/tools/ext.cx.progressbar.js
index 71c315a..1a3b78b 100644
--- a/modules/tools/ext.cx.progressbar.js
+++ b/modules/tools/ext.cx.progressbar.js
@@ -34,13 +34,10 @@
.addClass( 'cx-progressbar' )
.append(
$( 'span' ).addClass( 
'cx-progressbar__bar' )
-   ),
-   $( 'span' ).addClass( 'cx-progressbar__text' )
+   )
);
 
this.$bar = this.$container.find( '.cx-progressbar__bar' );
-   this.$text = this.$container.find( '.cx-progressbar__text' );
-
this.update( 0 );
};
 
@@ -51,7 +48,7 @@
ProgressBar.prototype.update = function ( percentage ) {
this.status = percentage;
this.$bar.css( 'width', this.status + '%' );
-   this.$text.text( mw.msg( 'cx-header-progressbar-text',
+   this.$container.attr( 'title', mw.msg( 
'cx-header-progressbar-text',
mw.language.convertNumber( percentage ) ) );
};
 
diff --git a/modules/tools/ext.cx.tools.js b/modules/tools/ext.cx.tools.js
index 5b240fe..50e7e57 100644
--- a/modules/tools/ext.cx.tools.js
+++ b/modules/tools/ext.cx.tools.js
@@ -24,9 +24,16 @@
}
 
ContentTranslationTools.prototype.init = function () {
-   this.helpMessage();
+   this.render();
};
 
+   ContentTranslationTools.prototype.render = function () {
+   var $progressBar = $( 'div' )
+   .addClass( 'cx-header__progressbar' )
+   .cxProgressBar();
+   this.$container.append( $progressBar );
+   this.helpMessage();
+   };
ContentTranslationTools.prototype.listen = function () {
$( window ).scroll( $.proxy( this.scroll, this ) );
};
diff --git a/modules/tools/styles/ext.cx.progressbar.less 
b/modules/tools/styles/ext.cx.progressbar.less
index f77ff32..86d2eff 100644
--- a/modules/tools/styles/ext.cx.progressbar.less
+++ b/modules/tools/styles/ext.cx.progressbar.less
@@ -1,31 +1,23 @@
 @import ../../base/styles/grid/agora-grid;
 
+.cx-header__progressbar {
+   .mw-ui-one-whole;
+}
+
 .cx-progressbar {
.mw-ui-item;
-   .mw-ui-one-sixth;
-   height: 10px;
-   border-radius: 10px;
+   .mw-ui-one-whole;
+   height: 5px;
border: 1px solid #ddd;
background: #fbfbfb;
vertical-align: middle;
-   position: absolute;
+   padding: 0;
 }
 
 .cx-progressbar__bar {
background: #3892E3;
-   display: inline-block;
-   height: 10px;
-   border-radius: 10px;
-   position: absolute;
+   display: block;
+   height: 5px;

[MediaWiki-commits] [Gerrit] Move all test htmls to html files to avoid difficult to read... - change (mediawiki...cxserver)

2014-04-07 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124298

Change subject: Move all test htmls to html files to avoid difficult to read 
escaped html
..

Move all test htmls to html files to avoid difficult to read escaped html

Change-Id: I4ee76ef58c5b3ab171269dbbe1a083dbb78382ec
---
M tests/segmentation/CXSegmenter.test.js
M tests/segmentation/SegmentationTests.json
A tests/segmentation/data/result-1.html
A tests/segmentation/data/result-10.html
A tests/segmentation/data/result-11.html
A tests/segmentation/data/result-12.html
A tests/segmentation/data/result-13.html
A tests/segmentation/data/result-14.html
A tests/segmentation/data/result-2.html
A tests/segmentation/data/result-3.html
A tests/segmentation/data/result-4.html
A tests/segmentation/data/result-5.html
A tests/segmentation/data/result-6.html
A tests/segmentation/data/result-7.html
A tests/segmentation/data/result-8.html
A tests/segmentation/data/result-9.html
A tests/segmentation/data/result-debian-1.html
A tests/segmentation/data/test-1.html
A tests/segmentation/data/test-10.html
A tests/segmentation/data/test-11.html
A tests/segmentation/data/test-12.html
A tests/segmentation/data/test-13.html
A tests/segmentation/data/test-14.html
A tests/segmentation/data/test-2.html
A tests/segmentation/data/test-3.html
A tests/segmentation/data/test-4.html
A tests/segmentation/data/test-5.html
A tests/segmentation/data/test-6.html
A tests/segmentation/data/test-7.html
A tests/segmentation/data/test-8.html
A tests/segmentation/data/test-9.html
A tests/segmentation/data/test-debian-1.html
32 files changed, 270 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/98/124298/1

diff --git a/tests/segmentation/CXSegmenter.test.js 
b/tests/segmentation/CXSegmenter.test.js
index 2b3ae2b..4ce33f9 100644
--- a/tests/segmentation/CXSegmenter.test.js
+++ b/tests/segmentation/CXSegmenter.test.js
@@ -1,5 +1,6 @@
 QUnit.module( 'CXSegmenter' );
 
+var fs = require( 'fs' );
 QUnit.test( 'Segmentation tests', function ( assert ) {
var i, len, lang, test, tests, segmenter, result,
count = 0,
@@ -13,11 +14,14 @@
tests = allTests[ lang ];
for ( i = 0, len = allTests[ lang ].length; i  len; i++ ) {
test = tests[ i ];
-   segmenter = new CX.Segmenter( test.source, lang );
+   testData = fs.readFileSync( __dirname + '/data/' + 
test.source, 'utf8' );
+   segmenter = new CX.Segmenter( testData, lang );
segmenter.segment();
result = segmenter.getSegmentedContent();
result = result.replace( /(\r\n|\n|\t|\r)/gm, '' );
-   assert.strictEqual( result, test.result, test.desc || 
'' );
+   expectedResultData = fs.readFileSync( __dirname + 
'/data/' + test.result, 'utf8' );
+   expectedResultData = expectedResultData.replace( 
/(\r\n|\n|\t|\r)/gm, '' );
+   assert.strictEqual( result, expectedResultData, 
test.desc || '' );
}
}
 } );
diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index da8d73f..205bf1f 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -1,72 +1,81 @@
 {
en: [
{
-   source: pA simple paragraph./p,
-   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\A simple paragraph./span/p
+   desc: Simple paragraph test,
+   source: test-1.html,
+   result: result-1.html
},
{
-   source: pHello! Mr. D. John, How are you?/p,
-   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\Hello! /spanspan class=\cx-segment\ 
data-segmentid=\2\Mr. D. John, How are you?/span/p
+   desc: Exclamation, punctuation test,
+   source: test-2.html,
+   result: result-2.html
},
{
-   source: pThis is first sentence. This is second 
sentence./p,
-   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\This is first sentence. /spanspan class=\cx-segment\ 
data-segmentid=\2\This is second sentence./span/p
+   desc: Multiple sentences,
+   source: test-3.html,
+   result: result-3.html
},
{
-   source: pThis is first sentence. This is second 
sentence/p,
-   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\This is first sentence. /spanspan 

[MediaWiki-commits] [Gerrit] Segmentation: Reference handling improvements - change (mediawiki...cxserver)

2014-04-03 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123522

Change subject: Segmentation: Reference handling improvements
..

Segmentation: Reference handling improvements

This patch tries to improve the segementation of cases like
First sentence.[1] Another sentence

We cannot split at period because [1] is a reference link for
First sentence

Change-Id: Id0a16d7ab77d9860e5690090f15f8f07679ca5c4
---
M segmentation/languages/CXParser.js
M tests/segmentation/SegmentationTests.json
2 files changed, 18 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/22/123522/1

diff --git a/segmentation/languages/CXParser.js 
b/segmentation/languages/CXParser.js
index a57502f..5713b2d 100644
--- a/segmentation/languages/CXParser.js
+++ b/segmentation/languages/CXParser.js
@@ -122,7 +122,8 @@
text = text.replace( /(\w*)([.!?][\s])/g, textSplit );
// content terminating with [.|!|?]
text = text.replace( /([.!?])$/, function ( match, p1 ) {
-   return p1 + parser.endSentence();
+   parser.seenSentenceEnd = true;
+   return p1; // + parser.endSentence();
} );
this.print( text );
 };
@@ -159,6 +160,13 @@
this.print( this.startSentence() );
}
 
+   if ( tag.name === 'span'  this.seenSentenceEnd 
+   tag.attributes.class === 'reference'  this.inSentence ) {
+   // Sentences staring with reference links.
+   // Example: Sentence one.[1] Sentence two
+   // Here [1] is not part of Sentence two. It is reference for 
Sentence one.
+   this.inReference = true;
+   }
// Start of tag
this.print( '' + tag.name );
 
@@ -200,6 +208,10 @@
} else {
this.print( '/' + tag + '' );
}
+
+   if ( tag === 'span'  this.inReference ) {
+   this.print( this.endSentence() );
+   }
 };
 
 module.exports = CXParser;
diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index b150841..774039a 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -36,6 +36,11 @@
desc: References can appear after period. Example: 
Hydrogen is a gas. [1] It is ...,
source: pSentence one. span 
class=\reference\a href=\#\reference/a/span Starts with 
reference/p,
result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\Sentence one. /spanspan class=\cx-segment\ 
data-segmentid=\2\span class=\reference\a class=\cx-link\ 
data-linkid=\3\ href=\#\reference/a/span Starts with 
reference/span/p
+   },
+   {
+   desc: References can appear after period without 
space. Example: Hydrogen is a gas.[1] It is ...,
+   source: pSentence one.span class=\reference\a 
href=\#\reference/a/span Starts with reference/p,
+   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\Sentence one.span class=\reference\a 
class=\cx-link\ data-linkid=\2\ href=\#\reference/a/span/spanspan 
class=\cx-segment\ data-segmentid=\3\ Starts with reference/span/p
}
],
hi: [

-- 
To view, visit https://gerrit.wikimedia.org/r/123522
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id0a16d7ab77d9860e5690090f15f8f07679ca5c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Segmentation: Handle the case of repeated references - change (mediawiki...cxserver)

2014-04-03 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123596

Change subject: Segmentation: Handle the case of repeated references
..

Segmentation: Handle the case of repeated references

Example: This is a sentence.[1][2][3][4]
Added tests and simplified the text handler

Change-Id: I992d9e02157e0649ff8bcb02992206c8a793548d
---
M segmentation/languages/CXParser.js
M segmentation/languages/hi/CXParserHi.js
M tests/segmentation/SegmentationTests.json
3 files changed, 35 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/96/123596/1

diff --git a/segmentation/languages/CXParser.js 
b/segmentation/languages/CXParser.js
index 5713b2d..70c071c 100644
--- a/segmentation/languages/CXParser.js
+++ b/segmentation/languages/CXParser.js
@@ -90,6 +90,14 @@
 };
 
 /**
+ * Undo end a sentence
+ */
+CXParser.prototype.undoEndSentence = function () {
+   this.inSentence = true;
+   this.segmentedContent = this.segmentedContent.substr( 0, 
this.segmentedContent.length - 7 );
+};
+
+/**
  * Text handler
  * @param {string} text
  */
@@ -107,7 +115,6 @@
var replacement, nextLetter;
 
replacement = prevWord + sentenceSeparator;
-   //console.log([match, prevWord, sentenceSeparator, offset]);
nextLetter = sentence[ offset + match.length ];
if ( prevWord  prevWord.length  3  prevWord[ 0 
].toUpperCase() === prevWord[ 0 ] ||
nextLetter  nextLetter.toLowerCase() === nextLetter ) 
{
@@ -120,11 +127,6 @@
}
 
text = text.replace( /(\w*)([.!?][\s])/g, textSplit );
-   // content terminating with [.|!|?]
-   text = text.replace( /([.!?])$/, function ( match, p1 ) {
-   parser.seenSentenceEnd = true;
-   return p1; // + parser.endSentence();
-   } );
this.print( text );
 };
 
@@ -155,18 +157,35 @@
this.print( this.endSentence() );
}
}
+
if ( tag.name === 'a'  !this.inSentence ) {
// sentences starting with a link
this.print( this.startSentence() );
}
 
-   if ( tag.name === 'span'  this.seenSentenceEnd 
-   tag.attributes.class === 'reference'  this.inSentence ) {
+   if ( tag.name === 'span' 
+   tag.attributes.class === 'reference'  ( this.inSentence || 
this.inReference ) ) {
// Sentences staring with reference links.
// Example: Sentence one.[1] Sentence two
// Here [1] is not part of Sentence two. It is reference for 
Sentence one.
+   // It is also possible to have this references repeated n times
+   // Example: Sentence one.[1][2][3][4] Sentence two
+   if ( this.inReference ) {
+   // This is already in Reference state. That means, this 
is a
+   // case of multiple references. We need to remove the 
last sentence close
+   this.inSentence = true;
+   this.undoEndSentence();
+   }
this.inReference = true;
}
+
+   // Check if we need to reset inReference state. References contains an 
'a' tag
+   // inside 'span' tag
+   if ( this.inReference  !( tag.name === 'a' || tag.name === 'span' ) ) 
{
+   // Reset inReference
+   this.inReference = false;
+   }
+
// Start of tag
this.print( '' + tag.name );
 
@@ -208,7 +227,8 @@
} else {
this.print( '/' + tag + '' );
}
-
+   // See if we have to print the left over /span
+   // from reference handling
if ( tag === 'span'  this.inReference ) {
this.print( this.endSentence() );
}
diff --git a/segmentation/languages/hi/CXParserHi.js 
b/segmentation/languages/hi/CXParserHi.js
index 06aa299..8615f80 100644
--- a/segmentation/languages/hi/CXParserHi.js
+++ b/segmentation/languages/hi/CXParserHi.js
@@ -32,10 +32,6 @@
return replacement;
}
text = text.replace( /([a-zA-Zअ-ह]*)([।!?][\s])/g, textSplit );
-   // content terminating with [.|!|?]
-   text = text.replace( /([।!?])$/, function ( match, p1 ) {
-   return p1 + parser.endSentence();
-   } );
this.print( text );
 };
 
diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index 774039a..7fc0194 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -35,12 +35,17 @@
{
desc: References can appear after period. Example: 
Hydrogen is a gas. [1] It is ...,
source: pSentence one. span 
class=\reference\a href=\#\reference/a/span Starts with 

[MediaWiki-commits] [Gerrit] Misc code formatting cleanup - change (mediawiki...Popups)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123190

Change subject: Misc code formatting cleanup
..

Misc code formatting cleanup

* Consistant whitespace after keywords
* Misc whitespace cleanup as per JS coding guidelines
  https://www.mediawiki.org/wiki/Manual:Coding_conventions/JavaScript
* pass mw to IIFE and use the function arguments close to function body
  ( function ( $, mw ) {
  ...
  }( jQuery, mediaWiki ) )
* Moved prefined moment to .jshintrc. Move browser:true too

Change-Id: If488974e8e5987916bc4043e4e70bb6c60472b30
---
M .jshintrc
M resources/ext.popups.core.js
2 files changed, 62 insertions(+), 56 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/90/123190/1

diff --git a/.jshintrc b/.jshintrc
index b6d8dda..caa6075 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -17,10 +17,11 @@
unused: true,
// Legacy
onevar: true,
-
+   browser: true,
/* Local */
predef: [
mediaWiki,
-   jQuery
+   jQuery,
+   moment
]
 }
\ No newline at end of file
diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index ffa3e44..bf644f9 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -2,11 +2,8 @@
  * https://en.wikipedia.org/wiki/User:Yair_rand/NavPopupsRestyled.js
  */
 
-/*global mw: false, moment: false */
-/*jshint browser: true */
-
-(function ( $ ) {
-   $( document ).ready( function() {
+( function ( $, mw ) {
+   $( document ).ready( function () {
 
var closeTimer, // The timer use to delay `closeBox`
openTimer, // The timer used to delay sending the API 
request/opening the popup form cache
@@ -40,7 +37,7 @@
 * @param {String} title
 * @param {Object} $el
 */
-   function sendRequest ( href, title, $el ) {
+   function sendRequest( href, title, $el ) {
 
curRequest = api.get( {
action: 'query',
@@ -61,8 +58,10 @@
curRequest = undefined;
 
var $a,
-   page = 
re.query.pages[re.query.pageids[0]],
-   $contentbox = $( 'div' ).addClass( 
'mwe-popups-extract' ).text( page.extract ),
+   page = re.query.pages[ 
re.query.pageids[ 0 ] ],
+   $contentbox = $( 'div' )
+   .addClass( 'mwe-popups-extract' 
)
+   .text( page.extract ),
thumbnail = page.thumbnail,
tall = thumbnail  thumbnail.height  
thumbnail.width,
$thumbnail = createThumbnail( 
thumbnail, tall ),
@@ -75,17 +74,22 @@
$timestamp = $( 'div' )
.addClass( timestampclass )
.append(
-   $( 'span' ).text( 
mw.message( 'popups-last-edited', moment( timestamp ).fromNow() ).text() )
-   );
+   $( 'span' ).text( 
mw.message( 'popups-last-edited',
+   moment( 
timestamp ).fromNow() ).text() )
+   );
 
$a = $( 'a' )
-   .append( $thumbnail, $contentbox, 
$timestamp)
+   .append( $thumbnail, $contentbox, 
$timestamp )
.attr( 'href', href )
.on( 'click', logClick );
 
-   cache[ href ] = { box: $a, thumbnail: 
thumbnail, tall: tall };
+   cache[ href ] = {
+   box: $a,
+   thumbnail: thumbnail,
+   tall: tall
+   };
createBox( href, $el );
-   });
+   } );
 
return true;
}
@@ -106,7 +110,7 @@
 * @param {boolean} tall
 * @return {Object} jQuery DOM element of the thumbnail
 */
-   function createThumbnail ( thumbnail, tall ) {
+   function createThumbnail( thumbnail, tall ) {
if ( !thumbnail ) {
return 

[MediaWiki-commits] [Gerrit] Move the segmentation tests to a new folder - change (mediawiki...cxserver)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123193

Change subject: Move the segmentation tests to a new folder
..

Move the segmentation tests to a new folder

Change-Id: I3298890cb715377cbe04eb4a6e22dd41ac9c3bae
---
M tests/index.js
R tests/segmentation/CXSegmenter.test.js
R tests/segmentation/SegmentationTests.json
3 files changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/93/123193/1

diff --git a/tests/index.js b/tests/index.js
index bdea691..8535a55 100644
--- a/tests/index.js
+++ b/tests/index.js
@@ -14,7 +14,7 @@
namespace: 'CX'
},
tests: [
-   './tests/CXSegmenter.test.js',
+   './tests/segmentation/CXSegmenter.test.js',
'./tests/mt/Rot13/Rot13.test.js',
]
 }, function ( err, report ) {
diff --git a/tests/CXSegmenter.test.js b/tests/segmentation/CXSegmenter.test.js
similarity index 100%
rename from tests/CXSegmenter.test.js
rename to tests/segmentation/CXSegmenter.test.js
diff --git a/tests/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
similarity index 100%
rename from tests/SegmentationTests.json
rename to tests/segmentation/SegmentationTests.json

-- 
To view, visit https://gerrit.wikimedia.org/r/123193
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3298890cb715377cbe04eb4a6e22dd41ac9c3bae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Use an optional description for segmentation tests - change (mediawiki...cxserver)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123198

Change subject: Use an optional description for segmentation tests
..

Use an optional description for segmentation tests

Change-Id: If00455867e04fe1d6988ea2c5373c5693f61d6c0
---
M tests/segmentation/CXSegmenter.test.js
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/98/123198/1

diff --git a/tests/segmentation/CXSegmenter.test.js 
b/tests/segmentation/CXSegmenter.test.js
index 87de0b0..2b3ae2b 100644
--- a/tests/segmentation/CXSegmenter.test.js
+++ b/tests/segmentation/CXSegmenter.test.js
@@ -17,7 +17,7 @@
segmenter.segment();
result = segmenter.getSegmentedContent();
result = result.replace( /(\r\n|\n|\t|\r)/gm, '' );
-   assert.strictEqual( result, test.result );
+   assert.strictEqual( result, test.result, test.desc || 
'' );
}
}
 } );

-- 
To view, visit https://gerrit.wikimedia.org/r/123198
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If00455867e04fe1d6988ea2c5373c5693f61d6c0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Fix the arguments for assertEqual - change (mediawiki...cxserver)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123197

Change subject: Fix the arguments for assertEqual
..

Fix the arguments for assertEqual

Order of arguments should be: actual, expected

Change-Id: Icc866ac7c05cf19f996ac94b27057788eb03a3ac
---
M tests/segmentation/CXSegmenter.test.js
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/97/123197/1

diff --git a/tests/segmentation/CXSegmenter.test.js 
b/tests/segmentation/CXSegmenter.test.js
index ad957e5..87de0b0 100644
--- a/tests/segmentation/CXSegmenter.test.js
+++ b/tests/segmentation/CXSegmenter.test.js
@@ -6,18 +6,18 @@
allTests = require( './SegmentationTests.json' );
 
for ( lang in allTests ) {
-   count += allTests[lang].length;
+   count += allTests[ lang ].length;
}
QUnit.expect( count );
for ( lang in allTests ) {
-   tests = allTests[lang];
-   for ( i = 0, len = allTests[lang].length; i  len; i++ ) {
-   test = tests[i];
+   tests = allTests[ lang ];
+   for ( i = 0, len = allTests[ lang ].length; i  len; i++ ) {
+   test = tests[ i ];
segmenter = new CX.Segmenter( test.source, lang );
segmenter.segment();
result = segmenter.getSegmentedContent();
result = result.replace( /(\r\n|\n|\t|\r)/gm, '' );
-   assert.strictEqual( test.result, result );
+   assert.strictEqual( result, test.result );
}
}
 } );

-- 
To view, visit https://gerrit.wikimedia.org/r/123197
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc866ac7c05cf19f996ac94b27057788eb03a3ac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add tests for sentences ending with reference - change (mediawiki...cxserver)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123200

Change subject: Add tests for sentences ending with reference
..

Add tests for sentences ending with reference

Change-Id: I5ec0fe5b971de5f56aa3b8dc818add87f4c3c1f3
---
M tests/mt/Rot13/Rot13.test.json
M tests/segmentation/SegmentationTests.json
2 files changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/00/123200/1

diff --git a/tests/mt/Rot13/Rot13.test.json b/tests/mt/Rot13/Rot13.test.json
index ba9c470..c7c7c89 100644
--- a/tests/mt/Rot13/Rot13.test.json
+++ b/tests/mt/Rot13/Rot13.test.json
@@ -8,11 +8,15 @@
},
3: {
source: iThis is in Italics/i Some other text
+   },
+   4: {
+   source: Sentence one. a href=\#\reference/a 
Starts with reference
}
},
result: {
1: Qrovna,
2: PUryyb jbeyq/P,
-   3: IGuvf vf va Vgnyvpf/I Fbzr bgure grkg
+   3: IGuvf vf va Vgnyvpf/I Fbzr bgure grkg,
+   4: Fragrapr bar. A HREF=\#\ersrerapr/A Fgnegf jvgu 
ersrerapr
}
 }
diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index ec91024..4de98c8 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -31,6 +31,11 @@
{
source: figurea href=\#\img 
src=\img.png\/afigcaptionFigure caption/figcaption/figure,
result: figure id=\0\span class=\cx-segment\ 
data-segmentid=\1\a class=\cx-link\ data-linkid=\2\ href=\#\img 
src=\img.png\/img/a/spanfigcaption id=\3\span 
class=\cx-segment\ data-segmentid=\4\Figure 
caption/span/figcaption/figure
+   },
+   {
+   desc: References can appear after period. Example: 
Hydrogen is a gas. [1] It is ...,
+   source: pSentence one. a href=\#\reference/a 
Starts with reference/p,
+   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\Sentence one. /spanspan class=\cx-segment\ 
data-segmentid=\2\a class=\cx-link\ data-linkid=\3\ 
href=\#\reference/a Starts with reference/span/p
}
],
hi: [

-- 
To view, visit https://gerrit.wikimedia.org/r/123200
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5ec0fe5b971de5f56aa3b8dc818add87f4c3c1f3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Correct the order of arguments for strictEqual - change (mediawiki...cxserver)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123199

Change subject: Correct the order of arguments for strictEqual
..

Correct the order of arguments for strictEqual

Order of arguments should be: actual, expected

Change-Id: Iad3821f446353c2430dfd5965fd7ccdc2a720deb
---
M tests/mt/Rot13/Rot13.test.js
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/99/123199/1

diff --git a/tests/mt/Rot13/Rot13.test.js b/tests/mt/Rot13/Rot13.test.js
index 5252df7..55b1f25 100644
--- a/tests/mt/Rot13/Rot13.test.js
+++ b/tests/mt/Rot13/Rot13.test.js
@@ -8,8 +8,9 @@
QUnit.stop();
rot13.translate( tests.source ).then( function ( result ) {
var segmentId;
+
for ( segmentId in tests.source ) {
-   assert.strictEqual( tests.result[segmentId], 
result[segmentId] );
+   assert.strictEqual( result[ segmentId ], tests.result[ 
segmentId ] );
}
QUnit.start();
} );

-- 
To view, visit https://gerrit.wikimedia.org/r/123199
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iad3821f446353c2430dfd5965fd7ccdc2a720deb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Make it possible to run individual tests - change (mediawiki...cxserver)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123207

Change subject: Make it possible to run individual tests
..

Make it possible to run individual tests

Change-Id: I190a72113f0938046d2f41496d968b6327b7e682
---
M README.md
M tests/index.js
2 files changed, 15 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/07/123207/1

diff --git a/README.md b/README.md
index c6e49ef..a2bf3fc 100644
--- a/README.md
+++ b/README.md
@@ -51,3 +51,7 @@
 To run the tests:
 
 ```$ npm test```
+
+To run individual test:
+
+```$ node tests tests/segmentation/CXSegmenter.test.js```
diff --git a/tests/index.js b/tests/index.js
index 8535a55..48c2460 100644
--- a/tests/index.js
+++ b/tests/index.js
@@ -1,22 +1,23 @@
 /*jshint node:true */
-var qunit = require( 'qunit' );
+var qunit = require( 'qunit' ),
+   tests = [
+   './tests/segmentation/CXSegmenter.test.js',
+   './tests/mt/Rot13/Rot13.test.js',
+   ];
 
 qunit.setup( {
-   log: {
+   log: process.argv[ 2 ] ? qunit.options.log : {
summary: true,
errors: true
+   },
+   code: {
+   path: './index.js',
+   namespace: 'CX'
}
 } );
 
 qunit.run( {
-   code: {
-   path: './index.js',
-   namespace: 'CX'
-   },
-   tests: [
-   './tests/segmentation/CXSegmenter.test.js',
-   './tests/mt/Rot13/Rot13.test.js',
-   ]
+   tests: process.argv[ 2 ] || tests
 }, function ( err, report ) {
if ( err || report.failed ) {
process.exit( 1 );

-- 
To view, visit https://gerrit.wikimedia.org/r/123207
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I190a72113f0938046d2f41496d968b6327b7e682
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Segmentation: Fix the wrong usage of section types - change (mediawiki...cxserver)

2014-04-02 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/123519

Change subject: Segmentation: Fix the wrong usage of section types
..

Segmentation: Fix the wrong usage of section types

Eventhough the sectionTypes array was introduced, openTag handler was
not using it by mistake

Change-Id: I1a5c49102b545a369d48ca74319826e393dd5a9a
---
M segmentation/languages/CXParser.js
M tests/segmentation/SegmentationTests.json
2 files changed, 5 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/19/123519/1

diff --git a/segmentation/languages/CXParser.js 
b/segmentation/languages/CXParser.js
index d3499d5..a57502f 100644
--- a/segmentation/languages/CXParser.js
+++ b/segmentation/languages/CXParser.js
@@ -146,8 +146,7 @@
  * @param {Object} tag
  */
 CXParser.prototype.onopentag = function ( tag ) {
-   var attrName,
-   section = /[ph1-6]|figure|figcaption|ul|div/;
+   var attrName;
 
if ( this.sectionTypes.indexOf( tag.name ) = 0 ) {
if ( this.inSentence ) {
@@ -172,7 +171,7 @@
}
 
// Sections
-   if ( tag.name.match( section ) ) {
+   if ( this.sectionTypes.indexOf( tag.name ) = 0 ) {
if ( !tag.attributes.id ) {
this.print( ' id=' + ( this.segmentCount++ ) + '' );
}
@@ -182,7 +181,7 @@
this.print( '' );
 
// Start the first segment of the section
-   if ( tag.name.match( section ) ) {
+   if ( this.sectionTypes.indexOf( tag.name ) = 0 ) {
this.print( this.startSentence() );
}
 };
diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index 4de98c8..b150841 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -34,8 +34,8 @@
},
{
desc: References can appear after period. Example: 
Hydrogen is a gas. [1] It is ...,
-   source: pSentence one. a href=\#\reference/a 
Starts with reference/p,
-   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\Sentence one. /spanspan class=\cx-segment\ 
data-segmentid=\2\a class=\cx-link\ data-linkid=\3\ 
href=\#\reference/a Starts with reference/span/p
+   source: pSentence one. span 
class=\reference\a href=\#\reference/a/span Starts with 
reference/p,
+   result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\Sentence one. /spanspan class=\cx-segment\ 
data-segmentid=\2\span class=\reference\a class=\cx-link\ 
data-linkid=\3\ href=\#\reference/a/span Starts with 
reference/span/p
}
],
hi: [

-- 
To view, visit https://gerrit.wikimedia.org/r/123519
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a5c49102b545a369d48ca74319826e393dd5a9a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Restore grunt-contrib-watch dependency - change (mediawiki...cxserver)

2014-04-01 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122642

Change subject: Restore grunt-contrib-watch dependency
..

Restore grunt-contrib-watch dependency

Follow up: I2308eedc87d31413a88194e1c5cca23c6f4c2bec

Change-Id: Idabd020937fafaa6975466ad78fc8dc39da70747
---
M package.json
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/42/122642/1

diff --git a/package.json b/package.json
index eef66f4..3f4380a 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
devDependencies: {
qunit: 0.5.17,
grunt: 0.4.2,
+   grunt-contrib-watch: 0.6.1,
grunt-contrib-jshint: 0.9.2,
grunt-jscs-checker: 0.3.2
}

-- 
To view, visit https://gerrit.wikimedia.org/r/122642
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idabd020937fafaa6975466ad78fc8dc39da70747
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Use {name}-npm instead of {name}-npmtest for cxserver - change (integration/zuul-config)

2014-04-01 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122716

Change subject: Use {name}-npm instead of {name}-npmtest for cxserver
..

Use {name}-npm instead of {name}-npmtest for cxserver

Change-Id: I1d4e3bf2653aff2a51b525c36426f3248c49d282
---
M layout.yaml
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/integration/zuul-config 
refs/changes/16/122716/1

diff --git a/layout.yaml b/layout.yaml
index 5130758..573890f 100644
--- a/layout.yaml
+++ b/layout.yaml
@@ -2232,10 +2232,10 @@
   - name: mediawiki/services/cxserver
 check-voter:
   - cxserver-jslint
-  - cxserver-npmtest
+  - cxserver-npm
 gate-and-submit:
   - cxserver-jslint
-  - cxserver-npmtest
+  - cxserver-npm
 
   - name: mediawiki/services/mathoid
 test:

-- 
To view, visit https://gerrit.wikimedia.org/r/122716
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1d4e3bf2653aff2a51b525c36426f3248c49d282
Gerrit-PatchSet: 1
Gerrit-Project: integration/zuul-config
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add cxserver-npm job for mediawiki/services/cxserver - change (integration/jenkins-job-builder-config)

2014-04-01 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122715

Change subject: Add cxserver-npm job for mediawiki/services/cxserver
..

Add cxserver-npm job for mediawiki/services/cxserver

Change-Id: I3427f38f861942a0b37cf024ed3acf8b9b0892cc
---
M mediawiki-services.yaml
1 file changed, 1 insertion(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/integration/jenkins-job-builder-config 
refs/changes/15/122715/1

diff --git a/mediawiki-services.yaml b/mediawiki-services.yaml
index 98a90d6..8b9921b 100644
--- a/mediawiki-services.yaml
+++ b/mediawiki-services.yaml
@@ -3,5 +3,4 @@
 name: 'cxserver'
 jobs:
  - '{name}-jslint'
- - '{name}-npmtest':
-node-modules: mediawiki/services/cxserver/node_modules
+- '{name}-npm'

-- 
To view, visit https://gerrit.wikimedia.org/r/122715
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3427f38f861942a0b37cf024ed3acf8b9b0892cc
Gerrit-PatchSet: 1
Gerrit-Project: integration/jenkins-job-builder-config
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Use a configurable logger - change (mediawiki...cxserver)

2014-03-31 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122339

Change subject: Use a configurable logger
..

Use a configurable logger

* Uses winston module for configurable logging
* Configured file and console logging

Change-Id: I90728f2258a86b4c7e1583416398113021616088
---
M ContentTranslationService.js
M models/DataModelManager.js
M package.json
A utils/Logger.js
4 files changed, 47 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/39/122339/1

diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index 76a8cc1..eef2c35 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -14,16 +14,23 @@
 
 'use strict';
 
-var instanceName, context, port, app, server, io, redis, express, RedisStore, 
args;
+var instanceName, context, port, app, server, io, redis, express, RedisStore, 
logger, args;
 
+logger = require( __dirname + '/utils/Logger.js' );
 express = require( 'express' );
 args = require( 'minimist' )( process.argv.slice( 2 ) );
 port = args.port || 8000;
 app = express();
 server = require( 'http' ).createServer( app );
-io = require( 'socket.io' ).listen( server );
+io = require( 'socket.io' ).listen( server, {
+   logger: {
+   debug: logger.debug,
+   info: logger.info,
+   error: logger.error,
+   warn: logger.warn
+   }
+} );
 redis = require( 'redis' );
-
 // Use Redis as the store for socket.io
 RedisStore = require( 'socket.io/lib/stores/redis' );
 io.set( 'store',
@@ -33,7 +40,6 @@
redisClient: redis.createClient()
} )
 );
-
 instanceName = 'worker(' + process.pid + ')';
 // socket.io connection establishment
 io.sockets.on( 'connection', function ( socket ) {
@@ -41,11 +47,11 @@
CXDataModelManager,
redisSub = redis.createClient();
 
-   console.log( '[CX] Client connected to ' + instanceName + '). Socket: ' 
+ socket.id );
+   logger.debug( 'Client connected to ' + instanceName + '). Socket: ' + 
socket.id );
redisSub.subscribe( 'cx' );
redisSub.on( 'message', function ( channel, message ) {
socket.emit( 'cx.data.update', JSON.parse( message ) );
-   console.log( '[CX] Received from channel #' + channel + ':' + 
message );
+   logger.debug( 'Received from channel #' + channel + ':' + 
message );
} );
 
socket.on( 'cx.init', function ( data ) {
@@ -64,7 +70,7 @@
} );
 
socket.on( 'disconnect', function () {
-   console.warn( '[CX] Disconnecting from redis' );
+   logger.debug( 'Disconnecting from redis' );
redisSub.quit();
} );
 
@@ -72,7 +78,7 @@
 
 // Everything else goes through this.
 app.use( express.static( __dirname + '/public' ) );
-console.log( '[CX] ' + instanceName + ' ready. Listening on port: ' + port );
+logger.info( instanceName + ' ready. Listening on port: ' + port );
 server.listen( port );
 
 module.exports = app;
diff --git a/models/DataModelManager.js b/models/DataModelManager.js
index 7e0fb14..23a65c4 100644
--- a/models/DataModelManager.js
+++ b/models/DataModelManager.js
@@ -10,7 +10,8 @@
 'use strict';
 
 var CXSegmenter = require( __dirname + '/../segmentation/CXSegmenter.js' 
).CXSegmenter,
-   CXMTInterface = require( __dirname + '/../mt/CXMTInterface.js' 
).CXMTInterface;
+   CXMTInterface = require( __dirname + '/../mt/CXMTInterface.js' 
).CXMTInterface,
+   logger = require( __dirname + '/../utils/Logger.js' );
 /**
  * CXDataModelManager
  * @class
@@ -40,7 +41,7 @@
PageLoader = require( __dirname + 
'/../pageloader/PageLoader.js' ).PageLoader;
pageloader = new PageLoader( 
dataModelManager.context.sourcePage );
pageloader.load().then( function ( data ) {
-   console.log( '[CX] Page fetched' );
+   console.log( 'Page fetched' );
dataModelManager.context.sourceText = data;
segmenter = new CXSegmenter( 
dataModelManager.context.sourceText );
segmenter.segment();
@@ -62,7 +63,7 @@
dataModelManager.publish();
} );
}, function () {
-   console.error( '[CX] Error in retrieving the 
page ' +
+   logger.error( 'Error in retrieving the page ' +
dataModelManager.context.sourcePage );
} );
 
@@ -83,7 +84,7 @@
this.context.store.set( this.dataModel.sourcePage, data, function () {
dataModelManager.context.pub.publish( 'cx', data );
} );
- 

[MediaWiki-commits] [Gerrit] Add npmtest job for cxserver - change (integration/jenkins-job-builder-config)

2014-03-31 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122640

Change subject: Add npmtest job for cxserver
..

Add npmtest job for cxserver

Change-Id: I5091e04d28935851544932af579a286f420c245a
---
M mediawiki-services.yaml
1 file changed, 2 insertions(+), 1 deletion(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/integration/jenkins-job-builder-config 
refs/changes/40/122640/1

diff --git a/mediawiki-services.yaml b/mediawiki-services.yaml
index 5895a59..4408589 100644
--- a/mediawiki-services.yaml
+++ b/mediawiki-services.yaml
@@ -2,4 +2,5 @@
 # mediawiki/services/cxserver.git
 name: 'cxserver'
 jobs:
- - '{name}-jslint'
\ No newline at end of file
+ - '{name}-jslint'
+ - '{name}-npmtest'

-- 
To view, visit https://gerrit.wikimedia.org/r/122640
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5091e04d28935851544932af579a286f420c245a
Gerrit-PatchSet: 1
Gerrit-Project: integration/jenkins-job-builder-config
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Make npmtest as a voting job for cxserver - change (integration/zuul-config)

2014-03-31 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122641

Change subject: Make npmtest as a voting job for cxserver
..

Make npmtest as a voting job for cxserver

Change-Id: I4778ee951cab024957204a7949a64e5a66799fe4
---
M layout.yaml
1 file changed, 2 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/integration/zuul-config 
refs/changes/41/122641/1

diff --git a/layout.yaml b/layout.yaml
index 4ffac2d..5130758 100644
--- a/layout.yaml
+++ b/layout.yaml
@@ -2232,8 +2232,10 @@
   - name: mediawiki/services/cxserver
 check-voter:
   - cxserver-jslint
+  - cxserver-npmtest
 gate-and-submit:
   - cxserver-jslint
+  - cxserver-npmtest
 
   - name: mediawiki/services/mathoid
 test:

-- 
To view, visit https://gerrit.wikimedia.org/r/122641
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4778ee951cab024957204a7949a64e5a66799fe4
Gerrit-PatchSet: 1
Gerrit-Project: integration/zuul-config
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Whitespace, code formatting cleanup - change (mediawiki...cxserver)

2014-03-30 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/122276

Change subject: Whitespace, code formatting cleanup
..

Whitespace, code formatting cleanup

Change-Id: Id785b16bd0734fe5a136abb586fb057de18d0d21
---
M ContentTranslationService.js
M public/js/main.js
2 files changed, 12 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/76/122276/1

diff --git a/ContentTranslationService.js b/ContentTranslationService.js
index 44e21c3..76a8cc1 100644
--- a/ContentTranslationService.js
+++ b/ContentTranslationService.js
@@ -14,19 +14,18 @@
 
 'use strict';
 
-var instanceName, context,
-   express = require( 'express' ),
-   args = require( 'minimist' )( process.argv.slice( 2 ) );
+var instanceName, context, port, app, server, io, redis, express, RedisStore, 
args;
 
-var port = args.port || 8000;
-
-var app = express();
-var server = require( 'http' ).createServer( app );
-var io = require( 'socket.io' ).listen( server );
-var redis = require( 'redis' );
+express = require( 'express' );
+args = require( 'minimist' )( process.argv.slice( 2 ) );
+port = args.port || 8000;
+app = express();
+server = require( 'http' ).createServer( app );
+io = require( 'socket.io' ).listen( server );
+redis = require( 'redis' );
 
 // Use Redis as the store for socket.io
-var RedisStore = require( 'socket.io/lib/stores/redis' );
+RedisStore = require( 'socket.io/lib/stores/redis' );
 io.set( 'store',
new RedisStore( {
redisPub: redis.createClient(),
diff --git a/public/js/main.js b/public/js/main.js
index 5a5fc66..d7df575 100644
--- a/public/js/main.js
+++ b/public/js/main.js
@@ -3,12 +3,12 @@
 
var cxdata;
$( '.article' ).on( 'click', '.cx-segment', function () {
-   var segment = cxdata.segments[$( this ).data( 'segmentid' )];
+   var segment = cxdata.segments[ $( this ).data( 'segmentid' ) ];
console.log( segment );
} );
 
$( '.article' ).on( 'click', '.cx-link', function () {
-   var linkid = cxdata.links[$( this ).data( 'linkid' )];
+   var linkid = cxdata.links[ $( this ).data( 'linkid' ) ];
console.log( linkid );
} );
 
@@ -19,7 +19,7 @@
socket.on( 'cx.data.update', function ( data ) {
cxdata = data;
$( 'progress' ).hide();
-   $( '.status' ).text( 'Received version '+ 
cxdata.version + '. Click on the content segments to inspect.');
+   $( '.status' ).text( 'Received version ' + 
cxdata.version + '. Click on the content segments to inspect.' );
$( '.article' ).html( cxdata.segmentedContent );
console.log( cxdata );
} );

-- 
To view, visit https://gerrit.wikimedia.org/r/122276
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id785b16bd0734fe5a136abb586fb057de18d0d21
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Minor whitespace fixes - change (mediawiki...cxserver)

2014-03-28 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121913

Change subject: Minor whitespace fixes
..

Minor whitespace fixes

Change-Id: If7989342817ab926cd4d0e8bf1d4e4674b07ffce
---
M Server.js
1 file changed, 5 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/13/121913/1

diff --git a/Server.js b/Server.js
index c6e8804..9ae7411 100644
--- a/Server.js
+++ b/Server.js
@@ -18,7 +18,7 @@
cluster.fork();
}
 
-   cluster.on( 'exit', function( worker /*, code, signal */ ) {
+   cluster.on( 'exit', function ( worker /*, code, signal */ ) {
if ( !worker.suicide ) {
var exitCode = worker.process.exitCode;
console.log( 'worker', worker.process.pid,
@@ -27,19 +27,19 @@
}
} );
 
-   process.on( 'SIGTERM', function() {
+   process.on( 'SIGTERM', function () {
console.log( 'master shutting down, killing workers' );
var workers = cluster.workers;
-   Object.keys( workers ).forEach( function( id ) {
+   Object.keys( workers ).forEach( function ( id ) {
console.log( 'Killing worker ' + id );
-   workers[id].destroy();
+   workers[ id ].destroy();
} );
console.log( 'Done killing workers, bye' );
process.exit( 1 );
} );
 } else {
// Worker.
-   process.on( 'SIGTERM', function() {
+   process.on( 'SIGTERM', function () {
console.log( 'Worker shutting down' );
process.exit( 1 );
} );

-- 
To view, visit https://gerrit.wikimedia.org/r/121913
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7989342817ab926cd4d0e8bf1d4e4674b07ffce
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Escape the selector ids while constructing - change (mediawiki...ContentTranslation)

2014-03-28 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121583

Change subject: Escape the selector ids while constructing
..

Escape the selector ids while constructing

Change-Id: I776a3d85478356fad8291c86bc9cb3097f883a32
---
M modules/translation/ext.cx.translation.js
1 file changed, 28 insertions(+), 11 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/83/121583/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 3a1fff5..dca569f 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -83,14 +83,16 @@
 * @param {string} sourceId source section identifier
 */
ContentTranslationEditor.prototype.update = function ( sourceId ) {
+   var $section = $( jquerySelectorForId( sourceId, 't' ) );
+
// Copy the whole section html to translation section.
-   $( '#t' + sourceId ).html( $( '#' + sourceId ).html() );
+   $section.html( $( '#' + sourceId ).html() );
// For every segment, use MT as replacement
-   $( '#t' + sourceId ).find( '.cx-segment' ).each( function () {
+   $section.find( '.cx-segment' ).each( function () {
$( this ).html( mw.cx.data.mt[ $( this ).data( 
'segmentid' ) ] );
} );
// Trigger input event so that the alignemnt is right.
-   $( '#t' + sourceId ).trigger( 'input' );
+   $section.trigger( 'input' );
 
this.calculateCompletion();
mw.hook( 'mw.cx.translation.change' ).fire();
@@ -100,7 +102,8 @@
ContentTranslationEditor.prototype.calculateCompletion = function () {
var completeness;
 
-   completeness = $( '.cx-column--translation' ).html().length / 
$( '.cx-column--source' ).html().length * 100;
+   completeness = $( '.cx-column--translation' ).html().length /
+   $( '.cx-column--source' ).html().length * 100;
completeness = completeness  100 ? 100 : completeness;
mw.hook( 'mw.cx.progress' ).fire( completeness );
};
@@ -138,22 +141,36 @@
/*jshint validthis:true */
$( this ).removeClass( 'placeholder' )
.unbind( 'hover click' );
-   $( '#' + $( this ).data( 'source' ) ).removeClass( 'highlight' 
);
+   $( jquerySelectorForId( $( this ).data( 'source' ) ) 
).removeClass( 'highlight' );
mw.hook( 'mw.cx.translation.add' ).fire( $( this ).data( 
'source' ) );
}
 
function sectionMouseEnter() {
/*jshint validthis:true */
$( this ).addClass( 'placeholder' ).html( '+ Add Translation' );
-   $( '#' + $( this ).data( 'source' ) ).addClass( 'highlight' );
+   $( jquerySelectorForId( $( this ).data( 'source' ) ) 
).addClass( 'highlight' );
}
 
function sectionMouseLeave() {
/*jshint validthis:true */
$( this ).removeClass( 'placeholder' ).empty();
-   $( '#' + $( this ).data( 'source' ) ).removeClass( 'highlight' 
);
+   $( jquerySelectorForId( $( this ).data( 'source' ) ) 
).removeClass( 'highlight' );
}
 
+   /**
+* Return a valid jquery selector for the given id after escaping
+* @param {string} id
+* @param {string} [prefix] id prefix
+*/
+   function jquerySelectorForId( id, prefix ) {
+   prefix = prefix || '';
+   if ( !id ) {
+   return '#' + prefix + ( Math.floor( Math.random() * 
100 ) + 1 );
+   }
+   // make it a string
+   id = id + '';
+   return '#' + prefix + id.replace( /(:|\/|\.|\[|\])/g, '\\$1' );
+   }
/**
 * Add placeholders for translation sections. The placeholders
 * are aligned to the source sections. Also provides mouse hover 
effects.
@@ -167,7 +184,7 @@
 
$section = $( this );
sourceSectionId = $section.attr( 'id' );
-   $sourceSection = $( '#' + sourceSectionId );
+   $sourceSection = $( jquerySelectorForId( 
sourceSectionId ) );
$section.css( 'min-height', $section.height() )
.attr( {
'id': 't' + sourceSectionId,
@@ -178,12 +195,12 @@
$section.on( 'input', keepAlignment );
// Bind events to the placeholder sections
$sourceSection.click( function () {
-   $( '#t' + $( this ).attr( 'id' ) ).click();
+  

[MediaWiki-commits] [Gerrit] Modify the subheading style of translation column to match s... - change (mediawiki...ContentTranslation)

2014-03-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121311

Change subject: Modify the subheading style of translation column to match 
source column
..

Modify the subheading style of translation column to match source column

Change-Id: I84be169088eb3660e2a2a519598a808223a1bdef
---
M modules/translation/styles/ext.cx.translation.less
1 file changed, 9 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/11/121311/1

diff --git a/modules/translation/styles/ext.cx.translation.less 
b/modules/translation/styles/ext.cx.translation.less
index 192a230..70b57dd 100644
--- a/modules/translation/styles/ext.cx.translation.less
+++ b/modules/translation/styles/ext.cx.translation.less
@@ -1,7 +1,14 @@
 @import ../../base/styles/grid/agora-grid;
 
-.cx-column--translation [contenteditable] {
-   outline: none;
+.cx-column--translation {
+   [contenteditable] {
+   outline: none;
+}
+   .cx-column__sub-heading {
+   .mw-ui-item;
+   .mw-ui-one-whole;
+   padding-bottom: 10px;
+   }
 }
 
 .placeholder {

-- 
To view, visit https://gerrit.wikimedia.org/r/121311
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I84be169088eb3660e2a2a519598a808223a1bdef
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Use pointer cursor for placeholder sections - change (mediawiki...ContentTranslation)

2014-03-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121577

Change subject: Use pointer cursor for placeholder sections
..

Use pointer cursor for placeholder sections

Change-Id: If986d5ceb442f714c1da5ba42bf9fc754295dc46
---
M modules/translation/styles/ext.cx.translation.less
1 file changed, 1 insertion(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/77/121577/1

diff --git a/modules/translation/styles/ext.cx.translation.less 
b/modules/translation/styles/ext.cx.translation.less
index 70b57dd..217db28 100644
--- a/modules/translation/styles/ext.cx.translation.less
+++ b/modules/translation/styles/ext.cx.translation.less
@@ -17,4 +17,5 @@
font-size: 20px;
font-weight: lighter;
color: #AAA;
+   cursor: pointer;
 }
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/121577
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If986d5ceb442f714c1da5ba42bf9fc754295dc46
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Refactor the render code for translation column - change (mediawiki...ContentTranslation)

2014-03-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121578

Change subject: Refactor the render code for translation column
..

Refactor the render code for translation column

Simplify jquery appends

Change-Id: I86f85fa04087515429ffcd971967a85203ce11fd
---
M modules/translation/ext.cx.translation.js
1 file changed, 11 insertions(+), 16 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/78/121578/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 9824d11..eed5bc4 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -30,7 +30,7 @@
};
 
ContentTranslationEditor.prototype.render = function () {
-   var $content;
+   var $content, $heading, $languageLabel, $subHeading;
 
if ( mw.cx.targetLanguage ) {
this.$container.prop( {
@@ -38,29 +38,24 @@
dir: $.uls.data.getDir( mw.cx.targetLanguage )
} );
}
-
-   this.$container.append(
-   $( 'h2' )
+   $heading = $( 'h2' )
.attr( 'contenteditable', true )
.addClass( 'cx-column__title' )
-   .text( $( '.cx-column--source .cx-column__title' 
).text() )
-   );
+   .text( $( '.cx-column--source .cx-column__title' 
).text() );
+   this.$container.append( $heading );
 
if ( mw.cx.targetLanguage ) {
this.$container.prop( {
lang: mw.cx.targetLanguage,
dir: $.uls.data.getDir( mw.cx.targetLanguage )
} );
-
-   this.$container.append(
-   $( 'div' )
-   .addClass( 'cx-column__sub-heading' )
-   .append(
-   $( 'span' )
-   .addClass( 
'cx-column__language-label' )
-   .text( 
$.uls.data.getAutonym( mw.cx.targetLanguage ) )
-   )
-   );
+   $languageLabel = $( 'span' )
+   .addClass( 'cx-column__language-label' )
+   .text( $.uls.data.getAutonym( 
mw.cx.targetLanguage ) );
+   $subHeading = $( 'div' )
+   .addClass( 'cx-column__sub-heading' )
+   .append( $languageLabel );
+   this.$container.append( $subHeading );
}
 
$content = $( 'div' )

-- 
To view, visit https://gerrit.wikimedia.org/r/121578
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I86f85fa04087515429ffcd971967a85203ce11fd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Highlight the source section on hover of placeholders in tra... - change (mediawiki...ContentTranslation)

2014-03-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121579

Change subject: Highlight the source section on hover of placeholders in 
translation column
..

Highlight the source section on hover of placeholders in translation column

Change-Id: I014bcb7db9cac3c5494826e0d4df0d5bb6f62ef5
---
M modules/source/styles/ext.cx.source.less
M modules/translation/ext.cx.translation.js
2 files changed, 6 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/79/121579/1

diff --git a/modules/source/styles/ext.cx.source.less 
b/modules/source/styles/ext.cx.source.less
index d175493..cfa7238 100644
--- a/modules/source/styles/ext.cx.source.less
+++ b/modules/source/styles/ext.cx.source.less
@@ -16,4 +16,7 @@
.mw-ui-item;
.mw-ui-one-third;
}
+   .highlight {
+   background-color: #FFFEEC;
+   }
 }
diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index eed5bc4..1b82c9b 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -157,13 +157,16 @@
} );
$section.on( 'mouseenter', function () {
$( this ).addClass( 'placeholder' ).html( '+ 
Add Translation' );
+   $( '#' + $( this ).data( 'source' ) ).addClass( 
'highlight' );
} );
$section.on( 'mouseleave', function () {
$( this ).removeClass( 'placeholder' ).empty();
+   $( '#' + $( this ).data( 'source' ) 
).removeClass( 'highlight' );
} );
$section.on( 'click', function () {
$( this ).removeClass( 'placeholder' )
.unbind( 'mouseenter mouseleave click' 
);
+   $( '#' + $( this ).data( 'source' ) 
).removeClass( 'highlight' );
mw.hook( 'mw.cx.translation.add' ).fire( $( 
this ).data( 'source' ) );
} );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/121579
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I014bcb7db9cac3c5494826e0d4df0d5bb6f62ef5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Refactor the render method of source content column - change (mediawiki...ContentTranslation)

2014-03-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121580

Change subject: Refactor the render method of source content column
..

Refactor the render method of source content column

Simplify the jquery appends

Change-Id: I7b3a48c52052fa93919449047c874537f4375a55
---
M modules/source/ext.cx.source.js
1 file changed, 25 insertions(+), 27 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/80/121580/1

diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index db4b0b0..f2e4602 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -32,7 +32,12 @@
this.listen();
};
 
+   /**
+* Render the source content column
+*/
ContentTranslationSource.prototype.render = function () {
+   var $heading, $languageLabel, $articleLink, $subHeading, 
$loader;
+
mw.cx.sourceLanguage = mw.config.get( 'wgContentLanguage' );
 
this.$container.prop( {
@@ -40,35 +45,28 @@
dir: $.uls.data.getDir( mw.cx.sourceLanguage )
} );
 
-   this.$container.append(
-   $( 'h2' )
-   .addClass( 'cx-column__title' )
-   .text( mw.cx.sourceTitle )
+   $heading = $( 'h2' )
+   .addClass( 'cx-column__title' )
+   .text( mw.cx.sourceTitle );
+   $languageLabel = $( 'span' )
+   .addClass( 'cx-column__language-label' )
+   .text( $.uls.data.getAutonym( mw.cx.sourceLanguage ) );
+   $articleLink = $( 'span' )
+   .addClass( 'cx-column__sub-heading__view-page' )
+   .html(
+   mw.message(
+   'cx-source-view-page',
+   mw.util.getUrl( mw.cx.sourceTitle )
+   ).parse()
);
+   $subHeading = $( 'div' )
+   .addClass( 'cx-column__sub-heading' )
+   .append( $languageLabel, $articleLink );
+   $loader = $( 'div' )
+   .addClass( 'cx-column__content' )
+   .text( mw.msg( 'cx-source-loading', mw.cx.sourceTitle ) 
);
+   this.$container.append( $heading, $subHeading, $loader );
 
-   this.$container.append(
-   $( 'div' )
-   .addClass( 'cx-column__sub-heading' )
-   .append(
-   $( 'span' )
-   .addClass( 
'cx-column__language-label' )
-   .text( $.uls.data.getAutonym( 
mw.cx.sourceLanguage ) ),
-   $( 'span' )
-   .addClass( 
'cx-column__sub-heading__view-page' )
-   .html(
-   mw.message(
-   
'cx-source-view-page',
-   mw.util.getUrl( 
mw.cx.sourceTitle )
-   ).parse()
-   )
-   )
-   );
-
-   this.$container.append(
-   $( 'div' )
-   .addClass( 'cx-column__content' )
-   .text( mw.msg( 'cx-source-loading', 
mw.cx.sourceTitle ) )
-   );
this.$title = this.$container.find( '.cx-column__title' );
this.$content = this.$container.find( '.cx-column__content' );
};

-- 
To view, visit https://gerrit.wikimedia.org/r/121580
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b3a48c52052fa93919449047c874537f4375a55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Highlight the source sections also on hover - change (mediawiki...ContentTranslation)

2014-03-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121581

Change subject: Highlight the source sections also on hover
..

Highlight the source sections also on hover

Refactored the addPlaceholder method to avoid code duplication

Change-Id: I0977b4f6dcdaa20be5b5797de55e1c5ffc2768be
---
M modules/translation/ext.cx.translation.js
1 file changed, 41 insertions(+), 24 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/81/121581/1

diff --git a/modules/translation/ext.cx.translation.js 
b/modules/translation/ext.cx.translation.js
index 1b82c9b..3a1fff5 100644
--- a/modules/translation/ext.cx.translation.js
+++ b/modules/translation/ext.cx.translation.js
@@ -134,42 +134,59 @@
return sectionSelector;
};
 
+   function sectionClick() {
+   /*jshint validthis:true */
+   $( this ).removeClass( 'placeholder' )
+   .unbind( 'hover click' );
+   $( '#' + $( this ).data( 'source' ) ).removeClass( 'highlight' 
);
+   mw.hook( 'mw.cx.translation.add' ).fire( $( this ).data( 
'source' ) );
+   }
+
+   function sectionMouseEnter() {
+   /*jshint validthis:true */
+   $( this ).addClass( 'placeholder' ).html( '+ Add Translation' );
+   $( '#' + $( this ).data( 'source' ) ).addClass( 'highlight' );
+   }
+
+   function sectionMouseLeave() {
+   /*jshint validthis:true */
+   $( this ).removeClass( 'placeholder' ).empty();
+   $( '#' + $( this ).data( 'source' ) ).removeClass( 'highlight' 
);
+   }
+
+   /**
+* Add placeholders for translation sections. The placeholders
+* are aligned to the source sections. Also provides mouse hover 
effects.
+*/
ContentTranslationEditor.prototype.addPlaceholders = function () {
var cxSectionSelector = this.getSectionSelector();
 
this.$content.html( mw.cx.data.segmentedContent );
this.$content.find( cxSectionSelector ).each( function () {
-   var $section = $( this ),
-   sourceSectionId = $section.attr( 'id' ),
-   $sourceSection = $( '#' + sourceSectionId );
-   $section.css( 'min-height', $section.height() );
-   $section.attr( {
-   'id': 't' + sourceSectionId,
-   'data-source': sourceSectionId,
-   'contenteditable': true
-   } );
+   var $section, sourceSectionId, $sourceSection;
+
+   $section = $( this );
+   sourceSectionId = $section.attr( 'id' );
+   $sourceSection = $( '#' + sourceSectionId );
+   $section.css( 'min-height', $section.height() )
+   .attr( {
+   'id': 't' + sourceSectionId,
+   'data-source': sourceSectionId,
+   'contenteditable': true
+   } );
$section.empty();
$section.on( 'input', keepAlignment );
-
// Bind events to the placeholder sections
$sourceSection.click( function () {
$( '#t' + $( this ).attr( 'id' ) ).click();
} );
-   $section.on( 'mouseenter', function () {
-   $( this ).addClass( 'placeholder' ).html( '+ 
Add Translation' );
-   $( '#' + $( this ).data( 'source' ) ).addClass( 
'highlight' );
+   $sourceSection.hover( function () {
+   $( '#t' + $( this ).attr( 'id' ) ).mouseenter();
+   }, function () {
+   $( '#t' + $( this ).attr( 'id' ) ).mouseleave();
} );
-   $section.on( 'mouseleave', function () {
-   $( this ).removeClass( 'placeholder' ).empty();
-   $( '#' + $( this ).data( 'source' ) 
).removeClass( 'highlight' );
-   } );
-   $section.on( 'click', function () {
-   $( this ).removeClass( 'placeholder' )
-   .unbind( 'mouseenter mouseleave click' 
);
-   $( '#' + $( this ).data( 'source' ) 
).removeClass( 'highlight' );
-   mw.hook( 'mw.cx.translation.add' ).fire( $( 
this ).data( 'source' ) );
-   } );
-
+   

[MediaWiki-commits] [Gerrit] Disable all links in the source column - change (mediawiki...ContentTranslation)

2014-03-27 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/121582

Change subject: Disable all links in the source column
..

Disable all links in the source column

Change-Id: Ic57e545f553eeceb2d6e98197ab5ade8f149acc6
---
M modules/source/ext.cx.source.js
1 file changed, 11 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/82/121582/1

diff --git a/modules/source/ext.cx.source.js b/modules/source/ext.cx.source.js
index f2e4602..fad2c0b 100644
--- a/modules/source/ext.cx.source.js
+++ b/modules/source/ext.cx.source.js
@@ -73,9 +73,20 @@
 
ContentTranslationSource.prototype.load = function () {
this.$content.html( mw.cx.data.segmentedContent );
+   // Disable all links
+   this.disableLinks();
mw.hook( 'mw.cx.source.loaded' ).fire();
};
 
+   /**
+* Disable all links in the content area.
+*/
+   ContentTranslationSource.prototype.disableLinks = function () {
+   this.$content.find( 'a' ).bind( 'click', function () {
+   return false;
+   } );
+   };
+
ContentTranslationSource.prototype.listen = function () {
mw.hook( 'mw.cx.source.ready' ).add( $.proxy( this.load, this ) 
);
};

-- 
To view, visit https://gerrit.wikimedia.org/r/121582
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic57e545f553eeceb2d6e98197ab5ade8f149acc6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Correct the entity escaping and restore parsoid data attribute - change (mediawiki...cxserver)

2014-03-25 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/120773

Change subject: Correct the entity escaping and restore parsoid data attribute
..

Correct the entity escaping and restore parsoid data attribute

Change-Id: I98acc13222de73832d6607c057fe67f82160a3bd
---
D mt/providers/ROT13.js
M mt/providers/Rot13.js
M segmentation/languages/CXParser.js
3 files changed, 6 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/73/120773/1

diff --git a/mt/providers/ROT13.js b/mt/providers/ROT13.js
deleted file mode 100644
index 4bba13c..000
--- a/mt/providers/ROT13.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Content Translation Machine Translation Interface.
- *
- */
-
-'use strict';
-
-/**
- * @class ROT13Service
- */
-function ROT13Service(config) {
-   this.config = config;
-}
-
-ROT13Service.prototype.translate = function ( sourceLang, targetLang, 
sourceText /*, onSuccess, onError */ ) {
-   return sourceText.replace(/[a-zA-Z]/g, function (c) {
-   return String.fromCharCode( (c = 'Z' ? 90 : 122) = (c = 
c.charCodeAt(0) + 13)
-   ? c
-   : c - 26);
-   } );
-};
-
-module.exports = {
-   'ROT13Service': ROT13Service
-};
\ No newline at end of file
diff --git a/mt/providers/Rot13.js b/mt/providers/Rot13.js
index e84998e..376daaa 100644
--- a/mt/providers/Rot13.js
+++ b/mt/providers/Rot13.js
@@ -54,7 +54,9 @@
 * Entity handler
 */
function entity( str ) {
-   return str.replace( '', 'quot;' );
+   return str.replace( /[']/g, function ( ch ) {
+   return '#' + ch.charCodeAt( 0 ) + ';'
+   } );
}
 
parser.onopentag = function ( tag ) {
diff --git a/segmentation/languages/CXParser.js 
b/segmentation/languages/CXParser.js
index a4b445a..ce19cde 100644
--- a/segmentation/languages/CXParser.js
+++ b/segmentation/languages/CXParser.js
@@ -68,7 +68,9 @@
  * Entity handler
  */
 function entity( str ) {
-   return str.replace( '', 'quot;' );
+   return str.replace( /[']/g, function ( ch ) {
+   return '#' + ch.charCodeAt( 0 ) + ';'
+   } );
 }
 
 /**
@@ -166,12 +168,6 @@
}
 
for ( attrName in tag.attributes ) {
-   if ( attrName === 'data-parsoid' || attrName === 'data-mw' ) {
-   // Parsoid gives the html with these attributes and has
-   // values as big escaped htmls. The parser has trouble 
in
-   // not leaking it to the text. So ignore these 
attributes.
-   continue;
-   }
this.print( ' ' + attrName + '=' + entity( tag.attributes[ 
attrName ] ) + '' );
}
 

-- 
To view, visit https://gerrit.wikimedia.org/r/120773
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98acc13222de73832d6607c057fe67f82160a3bd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Reorganzie the compact links code, make it a jquery plugin - change (mediawiki...UniversalLanguageSelector)

2014-03-24 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/120488

Change subject: Reorganzie the compact links code, make it a jquery plugin
..

Reorganzie the compact links code, make it a jquery plugin

No change in functionality. Refactored the code a lot and made it as
a jquery plugin, similar to the other components of ULS

Change-Id: I69199ba37b13ec7fd4a9b7b8eba5b3aa28f0edb5
---
M resources/js/ext.uls.compactlinks.js
M resources/js/ext.uls.init.js
2 files changed, 241 insertions(+), 234 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/UniversalLanguageSelector 
refs/changes/88/120488/1

diff --git a/resources/js/ext.uls.compactlinks.js 
b/resources/js/ext.uls.compactlinks.js
index 59c7879..05f1baa 100644
--- a/resources/js/ext.uls.compactlinks.js
+++ b/resources/js/ext.uls.compactlinks.js
@@ -21,232 +21,257 @@
'use strict';
 
/**
-* Add a language to the interlanguage list
-* @param {string} name Name of language in Autonym font
-* @param {string} url Link of the article in the respective language 
wiki
+* For the given array, remove duplicates
+* @param {Array} originalArray
+* @return de-duplicated array
 */
-   function addLanguage( name, url ) {
-   var $linkNode,
-   $listNode,
-   $interlanguageList;
+   function unique( originalArray ) {
+   var uniqueArray = [];
 
-   $linkNode = $( 'a' )
-   .addClass( 'active' )
-   .attr( 'href', url )
-   .text( name );
-
-   $listNode = $( 'li' )
-   .append( $linkNode );
-
-   $interlanguageList = $( '#p-lang  div  ul' );
-   $interlanguageList.append( $listNode );
-   }
-
-   /**
-* Find out the existing languages supported
-* by article and fetch their href
-* @return {Object} List of exiting language codes and their hrefs
-*/
-   function getInterlanguageList() {
-   var interlangList = {},
-   selectedElement;
-   $( '#p-lang  div  ul  li  a' ).each( function() {
-   selectedElement = $( this );
-   interlangList[ selectedElement.attr( 'lang' ) ] = 
selectedElement.attr( 'href' );
+   $.each( originalArray, function ( i, v ) {
+   if ( $.inArray( v, uniqueArray ) === -1 ) {
+   uniqueArray.push( v );
+   }
} );
-   return interlangList;
+   return uniqueArray;
}
 
/**
-* Fetch list of language names(in Autonym) which are supported by the 
article
-* @return {Object} List of Language names in Autonym supported by 
article
+* @class
 */
-   function getCurrentLanguages() {
-   var acceptedLanglist = {},
-   interlangList = getInterlanguageList(), i;
-   for ( i in interlangList ) {
-   if( interlangList.hasOwnProperty( i ) ) {
-   acceptedLanglist[ i ] = 
$.uls.data.getAutonym(i);
+   function CompactInterlanguageList( interlanguageList, options ) {
+   this.$interlanguageList = $( interlanguageList );
+   this.options = $.extend( {}, 
$.fn.compactInterlanguageList.defaults, options );
+   this.interlanguageList = {};
+   this.compactList = {};
+   this.$trigger = null;
+   this.compactSize = 0;
+   this.listSize = 0;
+   this.init();
+   }
+
+   CompactInterlanguageList.prototype = {
+   /**
+* Initialize the plugin
+*/
+   init: function () {
+   this.interlanguageList = this.getInterlanguageList();
+   this.listSize = this.getListSize();
+
+   if ( this.listSize = this.options.max ) {
+   return;
}
-   }
-   return acceptedLanglist;
-   }
 
-   /**
-* Frequently spoken languages which are supported by the article for
-* the Common Languages section of the ULS
-* @return {Array} List of those language codes which are supported by 
article and appears
-* in the Common Languages section of ULS
-*/
-   function getCommonLanguages() {
-   // From ext.uls.init.js
-   var frequentLang = mw.uls.getFrequentLanguageList(),
-   $acceptedLang = $.map( getCurrentLanguages(), function 
( element, index ) {
+   // if the interlanguage list is of moderate size, the 
compact size is 

[MediaWiki-commits] [Gerrit] Add mediawiki/services/cxserver project - change (integration/jenkins-job-builder-config)

2014-03-24 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/120510

Change subject: Add mediawiki/services/cxserver project
..

Add mediawiki/services/cxserver project

Change-Id: I0a685960be1aca7e7c01293b3e0bc1dcb448ef3b
---
A mediawiki-services.yaml
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/integration/jenkins-job-builder-config 
refs/changes/10/120510/1

diff --git a/mediawiki-services.yaml b/mediawiki-services.yaml
new file mode 100644
index 000..5895a59
--- /dev/null
+++ b/mediawiki-services.yaml
@@ -0,0 +1,5 @@
+- project:
+# mediawiki/services/cxserver.git
+name: 'cxserver'
+jobs:
+ - '{name}-jslint'
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/120510
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a685960be1aca7e7c01293b3e0bc1dcb448ef3b
Gerrit-PatchSet: 1
Gerrit-Project: integration/jenkins-job-builder-config
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add jobs for mediawiki/services/cxserver - change (integration/zuul-config)

2014-03-24 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/120511

Change subject: Add jobs for mediawiki/services/cxserver
..

Add jobs for mediawiki/services/cxserver

Change-Id: Iaa5460ceae88d51e2151f9f68849d7715ee6c172
---
M layout.yaml
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/integration/zuul-config 
refs/changes/11/120511/1

diff --git a/layout.yaml b/layout.yaml
index b42fe3b..3cfa54b 100644
--- a/layout.yaml
+++ b/layout.yaml
@@ -2229,6 +2229,10 @@
   - name: extension-checks
 extname: ParserHooks
 
+  - name: mediawiki/services/cxserver
+test:
+  - cxserver-jslint
+
   - name: mediawiki/services/mathoid
 test:
   - mathoidsvc-debian-glue

-- 
To view, visit https://gerrit.wikimedia.org/r/120511
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa5460ceae88d51e2151f9f68849d7715ee6c172
Gerrit-PatchSet: 1
Gerrit-Project: integration/zuul-config
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Segmentation: Add test for figure tags - change (mediawiki...cxserver)

2014-03-21 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/119931

Change subject: Segmentation: Add test for figure tags
..

Segmentation: Add test for figure tags

Change-Id: I109c13613d8927bdd7b9346e5d20110e51220816
---
M tests/segmentation/SegmentationTests.json
1 file changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/31/119931/1

diff --git a/tests/segmentation/SegmentationTests.json 
b/tests/segmentation/SegmentationTests.json
index 23cc2df..a65b30a 100644
--- a/tests/segmentation/SegmentationTests.json
+++ b/tests/segmentation/SegmentationTests.json
@@ -27,6 +27,10 @@
{
source: pa href=\#\Hydrogen/a is a a 
href=\#\gas/a/p,
result: p id=\0\span class=\cx-segment\ 
data-segmentid=\1\a class=\cx-link\ data-linkid=\2\ 
href=\#\Hydrogen/a is a a class=\cx-link\ data-linkid=\3\ 
href=\#\gas/a/span/p
+   },
+   {
+   source: figurea href=\#\img 
src=\img.png\/afigcaptionFigure caption/figcaption/figure,
+   result: figure id=\0\a class=\cx-link\ 
data-linkid=\1\ href=\#\img src=\img.png\/img/afigcaption 
id=\2\span class=\cx-segment\ data-segmentid=\3\Figure 
caption/span/figcaption/figure
}
],
hi: [

-- 
To view, visit https://gerrit.wikimedia.org/r/119931
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I109c13613d8927bdd7b9346e5d20110e51220816
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add .jshintrc and .jshintignore - change (mediawiki...cxserver)

2014-03-21 Thread Santhosh (Code Review)
Santhosh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/119934

Change subject: Add .jshintrc and .jshintignore
..

Add .jshintrc and .jshintignore

Change-Id: I9cdaccdd8fbc8835fb972a0ff9b83b97655fcbdf
---
A .jshintignore
A .jshintrc
2 files changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/cxserver 
refs/changes/34/119934/1

diff --git a/.jshintignore b/.jshintignore
new file mode 100644
index 000..dbf0821
--- /dev/null
+++ b/.jshintignore
@@ -0,0 +1 @@
+node_modules/*
\ No newline at end of file
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 000..2fa0d18
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,28 @@
+{
+   camelcase: true,
+   curly: true,
+   eqeqeq: true,
+   immed: true,
+   latedef: true,
+   newcap: true,
+   noarg: true,
+   noempty: true,
+   nonew: true,
+   quotmark: single,
+   trailing: true,
+   undef: true,
+   unused: true,
+   onevar: true,
+   bitwise: true,
+   forin: false,
+   regexp: false,
+   strict: true,
+   laxbreak: true,
+   smarttabs: true,
+   multistr: true,
+   browser: true,
+   node: true,
+   predef: [
+   jQuery
+   ]
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/119934
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9cdaccdd8fbc8835fb972a0ff9b83b97655fcbdf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/cxserver
Gerrit-Branch: master
Gerrit-Owner: Santhosh santhosh.thottin...@gmail.com

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


<    6   7   8   9   10   11   12   13   14   15   >