jenkins-bot has submitted this change and it was merged.

Change subject: HACK: Update template dialog for Parsoid's url -> href change
......................................................................


HACK: Update template dialog for Parsoid's url -> href change

Also need to strip ./ and ../

This is a dirty hack, Timo to clean this up

Change-Id: I7f377d916b90f5cdecfcd77a6d5276747a543761
---
M modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
1 file changed, 8 insertions(+), 5 deletions(-)

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



diff --git a/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js 
b/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
index eff6f6d..2fe0ad0 100644
--- a/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
+++ b/modules/ve/ui/dialogs/ve.ui.MWTemplateDialog.js
@@ -95,11 +95,12 @@
        for ( i = 0; i < len; i++ ) {
                template = dialog.content.parts[i].template;
                if ( template ) {
-                       // Method #getTemplateSpecs will use the part id 
instead of `target.url`
+                       // Method #getTemplateSpecs will use the part id 
instead of `target.href`
                        // if the target has no url property (which Parsoid 
omits if the target is
                        // dynamically generated from wikitext). In that case 
we want each template
                        // invocation to have its own inferred template spec.
-                       template.specId = template.target.url || ( '#!/part/' + 
i );
+                       // FIXME centralize regex
+                       template.specId = ( template.target.href && 
template.target.href.replace( /^(\.\.?\/)*/, '' ) ) || ( '#!/part/' + i );
                        dialog.getTemplateSpecs( template, 
makeStoreTemplateSpec( template ) );
                } else {
                        // This is a raw wikitext part (between two associated 
template invocations),
@@ -302,8 +303,9 @@
 
        // Collect all titles
        for ( i = 0, len = templates.length; i < len; i++ ) {
-               if ( templates[i].target.url ) {
-                       titles.push( templates[i].target.url );
+               if ( templates[i].target.href ) {
+                       // FIXME centralize regex
+                       titles.push( templates[i].target.href.replace( 
/^(\.\.?\/)*/, '' ) );
                }
        }
 
@@ -381,7 +383,8 @@
  */
 ve.ui.MWTemplateDialog.prototype.addTemplatePage = function ( page, template ) 
{
        var fieldset,
-               label = template.target.url || template.target.wt;
+               // FIXME centralize regex
+               label = ( template.target.href && template.target.href.replace( 
/^(\.\.?\/)*/, '' ) ) || template.target.wt;
 
        fieldset = new ve.ui.FieldsetLayout( {
                '$$': this.frame.$$,

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7f377d916b90f5cdecfcd77a6d5276747a543761
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to