Ebe123 has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/400202 )
Change subject: Add DOM Structure to Scores ...................................................................... Add DOM Structure to Scores This change encapsulates the two components of the `<score` tag rendering (sheet music & audio player) into a `<div` tag with a `mwe-score-block` class. The components themselves also have classes associated with them, such as for the sheet music. This allows for better structure and possible styling. The variable names have been updated to better represent their use, and the `override_ogg` attribute has been placed as an "elseif" after the generated audio. This also serves as a start for T114757. Change-Id: I03b29657d1ef20abd29be25173afb67bed4bbc21 --- M i18n/en.json M i18n/qqq.json M includes/Score.php 3 files changed, 28 insertions(+), 17 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Score refs/changes/02/400202/1 diff --git a/i18n/en.json b/i18n/en.json index f454639..e8caf32 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -14,6 +14,7 @@ "score-getcwderr": "Unable to obtain current working directory", "score-invalidlang": "Invalid score language lang=\"<nowiki>$1</nowiki>\". Currently recognized languages are lang=\"lilypond\" (the default) and lang=\"ABC\".", "score-invalidoggoverride": "The file \"<nowiki>$1</nowiki>\" you specified with override_ogg is invalid. Please specify the file name only, omit <nowiki>[[…]]</nowiki> and the \"{{ns:file}}:\" prefix.", + "score-mididownload": "MIDI File", "score-midioverridenotfound": "The file \"<nowiki>$1</nowiki>\" you specified with override_midi could not be found. Please specify the file name only, omit <nowiki>[[…]]</nowiki> and the \"{{ns:file}}:\" prefix.", "score-noabcinput": "ABC source file $1 could not be created.", "score-noimages": "No score images were generated. Please check your score code.", diff --git a/i18n/qqq.json b/i18n/qqq.json index c87c392..4129be1 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -20,6 +20,7 @@ "score-getcwderr": "Displayed if the extension cannot obtain the current working directory.", "score-invalidlang": "Displayed if the lang=\"…\" attribute contains an unrecognized score language. $1 is the unrecognized language.", "score-invalidoggoverride": "Displayed if the file specified with the override_ogg=\"…\" attribute is invalid. $1 is the value of the override_ogg attribute.", + "score-mididownload": "Link text to download generated MIDI file", "score-midioverridenotfound": "Displayed if the file specified with the override_midi=\"…\" attribute could not be found. $1 is the value of the override_midi attribute.", "score-noabcinput": "Displayed if an ABC source file could not be created for lang=\"ABC\". $1 is the path to the file that could not be created.", "score-noimages": "Displayed if no score images were rendered.", diff --git a/includes/Score.php b/includes/Score.php index e6df438..58f64cd 100644 --- a/includes/Score.php +++ b/includes/Score.php @@ -422,17 +422,31 @@ } } - /* return output link(s) */ + /* Create output */ + $midiLink = ''; + if ( $options['link_midi'] ) { + if ( $options['override_midi'] ) { + $url = $options['midi_file']->getUrl(); + } else { + $url = "{$options['dest_url']}/{$options['file_name_prefix']}.midi"; + } + $midiLink .= Html::OpenElement( 'a', + [ 'href' => $url, 'class' => 'mwe-score-mididownload' ] ); + } + + $output = Html::OpenElement( 'div', ['class' => 'mwe-score-block'] ) + . Html::OpenElement( 'div', ['class' => 'mwe-score-images'] ) + . $midiLink; + if ( isset( $existingFiles[$imageFileName] ) ) { list( $width, $height ) = $metaData[$imageFileName]['size']; - $link = Html::rawElement( 'img', [ + $output .= Html::rawElement( 'img', [ 'src' => "{$options['dest_url']}/$imageFileName", 'width' => $width, 'height' => $height, 'alt' => $code, ] ); } elseif ( isset( $existingFiles[$multi1FileName] ) ) { - $link = ''; for ( $i = 1; ; ++$i ) { $fileName = "{$options['file_name_prefix']}-page$i.png"; if ( !isset( $existingFiles[$fileName] ) ) { @@ -443,7 +457,7 @@ ->numParams( $i ) ->plain(); list( $width, $height ) = $metaData[$fileName]['size']; - $link .= Html::rawElement( 'img', [ + $output .= Html::rawElement( 'img', [ 'src' => "{$options['dest_url']}/$fileName", 'width' => $width, 'height' => $height, @@ -455,14 +469,9 @@ /* No images; this may happen in raw mode or when the user omits the score code */ throw new ScoreException( wfMessage( 'score-noimages' ) ); } - if ( $options['link_midi'] ) { - if ( $options['override_midi'] ) { - $url = $options['midi_file']->getUrl(); - } else { - $url = "{$options['dest_url']}/{$options['file_name_prefix']}.midi"; - } - $link = Html::rawElement( 'a', [ 'href' => $url ], $link ); - } + $closeMIDI = empty( $midiLink ) ? '' : Html::CloseElement( 'a' ); + $output .= $closeMIDI . Html::CloseElement( 'div' ); + if ( $options['generate_ogg'] ) { $length = $metaData[basename( $oggPath )]['length']; $player = new TimedMediaTransformOutput( [ @@ -476,11 +485,11 @@ 'disablecontrols' => 'options,timedText', 'width' => self::DEFAULT_PLAYER_WIDTH ] ); - $link .= $player->toHtml(); + $output .= $player->toHtml(); + } elseif ( $options['override_ogg'] !== false ) { + $output .= $parser->recursiveTagParse( "[[File:{$options['ogg_name']}]]" ); } - if ( $options['override_ogg'] !== false ) { - $link .= $parser->recursiveTagParse( "[[File:{$options['ogg_name']}]]" ); - } + $output .= Html::CloseElement( 'div' ); } catch ( Exception $e ) { self::eraseFactory( $options['factory_directory'] ); throw $e; @@ -488,7 +497,7 @@ self::eraseFactory( $options['factory_directory'] ); - return $link; + return $output; } /** -- To view, visit https://gerrit.wikimedia.org/r/400202 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I03b29657d1ef20abd29be25173afb67bed4bbc21 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Score Gerrit-Branch: master Gerrit-Owner: Ebe123 <beauleetien...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits