Albert221 (Code Review)
2017-12-30 20:06:16 UTC
Albert221 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/401093 )
Change subject: Add source DL link to popup
......................................................................
Add source DL link to popup
Add storing .ly source file and add ability
to download by creating a DL link in score's popup.
Bug: T183736
Change-Id: Ie80bda1f30d1b7046669ffa6353fc7f5328e7be0
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/Score.php
M modules/ext.score.popup.css
M modules/ext.score.popup.js
6 files changed, 29 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score refs/changes/93/401093/1
diff --git a/extension.json b/extension.json
index 29b7755..a64d03f 100644
--- a/extension.json
+++ b/extension.json
@@ -64,7 +64,8 @@
"mediawiki.api"
],
"messages": [
- "score-download-midi-file"
+ "score-download-midi-file",
+ "score-download-source-file"
]
}
},
diff --git a/i18n/en.json b/i18n/en.json
index 0129a0b..2e41273 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -10,6 +10,7 @@
"score-backend-error": "Unable to copy the generated files to their final location:\n$1",
"score-desc": "Adds a tag for rendering musical scores with LilyPond",
"score-download-midi-file": "Download MIDI file",
+ "score-download-source-file": "Download source file",
"score-error-category": "Pages with score rendering errors",
"score-error-category-desc": "There was an error while rendering the score.",
"score-getcwderr": "Unable to obtain current working directory",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b2fb0bc..52941cc 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -16,6 +16,7 @@
"score-backend-error": "Parameters:\n* $1 - result message which was returned",
"score-desc": "{{desc|name=Score|url=https://www.mediawiki.org/wiki/Extension:Score}}",
"score-download-midi-file": "Content of link to download MIDI file of score shown in score popup",
+ "score-download-source-file": "Content of link to download source .ly file of score shown in score popup",
"score-error-category": "Name of [[mw:Help:Tracking categories|tracking category]] to list pages where there was an error rendering the <code><nowiki><score></nowiki></code> tag.",
"score-error-category-desc": "Description on [[Special:TrackingCategories]] for the {{msg-mw|score-error-category}} tracking category.",
"score-getcwderr": "Displayed if the extension cannot obtain the current working directory.",
diff --git a/includes/Score.php b/includes/Score.php
index 854deb1..ece621e 100644
--- a/includes/Score.php
+++ b/includes/Score.php
@@ -477,14 +477,15 @@
'class' => 'mw-ext-score',
'data-midi' => $options['override_midi'] ?
$options['midi_file']->getUrl()
- : "{$options['dest_url']}/{$options['file_name_prefix']}.midi"
+ : "{$options['dest_url']}/{$options['file_name_prefix']}.midi",
+ 'data-source' => "{$options['dest_url']}/{$options['file_name_prefix']}.ly"
], $link );
return $link;
}
/**
- * Generates score PNG file(s) and a MIDI file.
+ * Generates score PNG file(s), LY source and a MIDI file.
*
* @param string $code Score code.
* @param array $options Rendering options. They are the same as for
@@ -604,6 +605,14 @@
// Backend operation batch
$ops = [];
+ // Add LY source to its file
+ $ops[] = [
+ 'op' => 'store',
+ 'src' => $factoryLy,
+ 'dst' => "{$options['dest_storage_path']}/{$options['file_name_prefix']}.ly"
+ ];
+ $newFiles["{$options['file_name_prefix']}.ly"] = true;
+
if ( $needMidi ) {
// Add the MIDI file to the batch
$ops[] = [
diff --git a/modules/ext.score.popup.css b/modules/ext.score.popup.css
index 61802b7..9d8bd1d 100644
--- a/modules/ext.score.popup.css
+++ b/modules/ext.score.popup.css
@@ -42,3 +42,9 @@
background: #fff;
transform: rotate( 45deg );
}
+
+.mw-ext-score-popup a:last-child:before {
+ content: "•";
+ display: inline-block;
+ margin: 0 0.5em;
+}
diff --git a/modules/ext.score.popup.js b/modules/ext.score.popup.js
index ab81595..d3c32ab 100644
--- a/modules/ext.score.popup.js
+++ b/modules/ext.score.popup.js
@@ -2,14 +2,17 @@
var popupShown = false;
function showPopup( $score ) {
- var $popup, midi = $score.data( 'midi' );
+ var $popup, midi = $score.data( 'midi' ), source = $score.data( 'source' );
$popup = $( '<div>' )
.addClass( 'mw-ext-score-popup' )
.attr( 'id', 'mw-ext-score-popup' )
- .html(
- $( '<a>' )
- .attr( 'href', midi )
- .text( mw.msg( 'score-download-midi-file' ) )
+ .append( $( '<a>' )
+ .attr( 'href', midi )
+ .text( mw.msg( 'score-download-midi-file' ) )
+ )
+ .append( $( '<a>' )
+ .attr( 'href', source )
+ .text( mw.msg( 'score-download-source-file' ) )
)
.css( 'opacity', 0 );
--
To view, visit https://gerrit.wikimedia.org/r/401093
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie80bda1f30d1b7046669ffa6353fc7f5328e7be0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Score
Gerrit-Branch: master
Gerrit-Owner: Albert221 <***@gmail.com>
Change subject: Add source DL link to popup
......................................................................
Add source DL link to popup
Add storing .ly source file and add ability
to download by creating a DL link in score's popup.
Bug: T183736
Change-Id: Ie80bda1f30d1b7046669ffa6353fc7f5328e7be0
---
M extension.json
M i18n/en.json
M i18n/qqq.json
M includes/Score.php
M modules/ext.score.popup.css
M modules/ext.score.popup.js
6 files changed, 29 insertions(+), 8 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score refs/changes/93/401093/1
diff --git a/extension.json b/extension.json
index 29b7755..a64d03f 100644
--- a/extension.json
+++ b/extension.json
@@ -64,7 +64,8 @@
"mediawiki.api"
],
"messages": [
- "score-download-midi-file"
+ "score-download-midi-file",
+ "score-download-source-file"
]
}
},
diff --git a/i18n/en.json b/i18n/en.json
index 0129a0b..2e41273 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -10,6 +10,7 @@
"score-backend-error": "Unable to copy the generated files to their final location:\n$1",
"score-desc": "Adds a tag for rendering musical scores with LilyPond",
"score-download-midi-file": "Download MIDI file",
+ "score-download-source-file": "Download source file",
"score-error-category": "Pages with score rendering errors",
"score-error-category-desc": "There was an error while rendering the score.",
"score-getcwderr": "Unable to obtain current working directory",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index b2fb0bc..52941cc 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -16,6 +16,7 @@
"score-backend-error": "Parameters:\n* $1 - result message which was returned",
"score-desc": "{{desc|name=Score|url=https://www.mediawiki.org/wiki/Extension:Score}}",
"score-download-midi-file": "Content of link to download MIDI file of score shown in score popup",
+ "score-download-source-file": "Content of link to download source .ly file of score shown in score popup",
"score-error-category": "Name of [[mw:Help:Tracking categories|tracking category]] to list pages where there was an error rendering the <code><nowiki><score></nowiki></code> tag.",
"score-error-category-desc": "Description on [[Special:TrackingCategories]] for the {{msg-mw|score-error-category}} tracking category.",
"score-getcwderr": "Displayed if the extension cannot obtain the current working directory.",
diff --git a/includes/Score.php b/includes/Score.php
index 854deb1..ece621e 100644
--- a/includes/Score.php
+++ b/includes/Score.php
@@ -477,14 +477,15 @@
'class' => 'mw-ext-score',
'data-midi' => $options['override_midi'] ?
$options['midi_file']->getUrl()
- : "{$options['dest_url']}/{$options['file_name_prefix']}.midi"
+ : "{$options['dest_url']}/{$options['file_name_prefix']}.midi",
+ 'data-source' => "{$options['dest_url']}/{$options['file_name_prefix']}.ly"
], $link );
return $link;
}
/**
- * Generates score PNG file(s) and a MIDI file.
+ * Generates score PNG file(s), LY source and a MIDI file.
*
* @param string $code Score code.
* @param array $options Rendering options. They are the same as for
@@ -604,6 +605,14 @@
// Backend operation batch
$ops = [];
+ // Add LY source to its file
+ $ops[] = [
+ 'op' => 'store',
+ 'src' => $factoryLy,
+ 'dst' => "{$options['dest_storage_path']}/{$options['file_name_prefix']}.ly"
+ ];
+ $newFiles["{$options['file_name_prefix']}.ly"] = true;
+
if ( $needMidi ) {
// Add the MIDI file to the batch
$ops[] = [
diff --git a/modules/ext.score.popup.css b/modules/ext.score.popup.css
index 61802b7..9d8bd1d 100644
--- a/modules/ext.score.popup.css
+++ b/modules/ext.score.popup.css
@@ -42,3 +42,9 @@
background: #fff;
transform: rotate( 45deg );
}
+
+.mw-ext-score-popup a:last-child:before {
+ content: "•";
+ display: inline-block;
+ margin: 0 0.5em;
+}
diff --git a/modules/ext.score.popup.js b/modules/ext.score.popup.js
index ab81595..d3c32ab 100644
--- a/modules/ext.score.popup.js
+++ b/modules/ext.score.popup.js
@@ -2,14 +2,17 @@
var popupShown = false;
function showPopup( $score ) {
- var $popup, midi = $score.data( 'midi' );
+ var $popup, midi = $score.data( 'midi' ), source = $score.data( 'source' );
$popup = $( '<div>' )
.addClass( 'mw-ext-score-popup' )
.attr( 'id', 'mw-ext-score-popup' )
- .html(
- $( '<a>' )
- .attr( 'href', midi )
- .text( mw.msg( 'score-download-midi-file' ) )
+ .append( $( '<a>' )
+ .attr( 'href', midi )
+ .text( mw.msg( 'score-download-midi-file' ) )
+ )
+ .append( $( '<a>' )
+ .attr( 'href', source )
+ .text( mw.msg( 'score-download-source-file' ) )
)
.css( 'opacity', 0 );
--
To view, visit https://gerrit.wikimedia.org/r/401093
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie80bda1f30d1b7046669ffa6353fc7f5328e7be0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Score
Gerrit-Branch: master
Gerrit-Owner: Albert221 <***@gmail.com>