Skip to content

Commit

Permalink
Credit jquery.i18n in footer
Browse files Browse the repository at this point in the history
Track which Massviews sources are used the most
  • Loading branch information
MusikAnimal committed Mar 7, 2017
1 parent debb4d3 commit c70fcd7
Show file tree
Hide file tree
Showing 14 changed files with 29,026 additions and 138 deletions.
2 changes: 1 addition & 1 deletion javascripts/massviews/massviews.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class MassViews extends mix(Pv).with(ChartHelpers, ListHelpers) {
* @param {Object} node - HTML element of the selected source
*/
updateSourceInput(node) {
const source = node.dataset.value;
const source = this.source = node.dataset.value;

$('#source_button').data('value', source).html(`${node.textContent} <span class='caret'></span>`);

Expand Down
14 changes: 10 additions & 4 deletions javascripts/shared/pv.js
Original file line number Diff line number Diff line change
Expand Up @@ -1158,12 +1158,18 @@ class Pv extends PvConfig {

if (langApps.includes(this.project)) project = i18nLang;

let data = {
app: this.app + (location.pathname.includes('-test') ? '-test' : ''),
project
};

if (this.app === 'massviews') {
data.source = this.source;
}

$.ajax({
url: '/pageviews/meta/api.php',
data: {
app: this.app + (location.pathname.includes('-test') ? '-test' : ''),
project
},
data,
method: 'POST'
});
}
Expand Down
2 changes: 1 addition & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
"total-pageviews": "Pages by total number of pageviews",
"totals": "Totals",
"transclusions": "Transclusions",
"translation-credits": "Translations powered by $1 and $2.",
"translation-credits": "Translations powered by $1, $2 and $3.",
"tu": "Tu",
"unique-devices": "Unique devices",
"unique-editors": "Unique editors",
Expand Down
7 changes: 4 additions & 3 deletions public_html/_footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@
<?php $MusikAnimal = "<a href='https://en.wikipedia.org/wiki/User:MusikAnimal'>MusikAnimal</a>"; ?>
<?php $Kaldari = "<a href='https://en.wikipedia.org/wiki/User:Kaldari'>Kaldari</a>"; ?>
<?php $MarcelRuizForns = "<a href='https://en.wikipedia.org/wiki/User:Mforns_(WMF)'>Marcel Ruiz Forns</a>"; ?>
<?php echo $I18N->msg( 'credits', array( 'variables' => array( $MusikAnimal, $Kaldari, $MarcelRuizForns ), 'parsemag' => true ) );; ?>
<?php echo $I18N->msg( 'credits', [ 'variables' => [ $MusikAnimal, $Kaldari, $MarcelRuizForns ], 'parsemag' => true ] );; ?>
</span>
<div>
<span class="nowrap">
<?php $heart = "<span class='heart'>&hearts;</span>"; ?>
<?php $host = "<a href='https://wikitech.wikimedia.org/wiki/Portal:Tool_Labs'>" . $I18N->msg( 'tool-labs' ) . "</a>"; ?>
<?php echo $I18N->msg( 'hosted', array( 'variables' => array( $heart, $host ), 'parsemag' => true ) );; ?>
<?php echo $I18N->msg( 'hosted', [ 'variables' => [ $heart, $host ], 'parsemag' => true ] );; ?>
</span>
<span class="nowrap">
<?php $translateWiki = "<a href='https://translatewiki.net/'>translatewiki.net</a>"; ?>
<?php $jqueryI18n = "<a href='https://github.com/wikimedia/jquery.i18n'>jQuery.i18n</a>"; ?>
<?php $intuition = "<a href='https://tools.wmflabs.org/intuition/#tab-about'>Intuition</a>"; ?>
<?php echo $I18N->msg( 'translation-credits', array( 'variables' => array( $translateWiki, $intuition ), 'parsemag' => true ) ); ?>
<?php echo $I18N->msg( 'translation-credits', [ 'variables' => [ $translateWiki, $jqueryI18n, $intuition ], 'parsemag' => true ] ); ?>
</span>
</div>
<div>
Expand Down
3,588 changes: 3,570 additions & 18 deletions public_html/application.js

Large diffs are not rendered by default.

4,103 changes: 4,088 additions & 15 deletions public_html/langviews/application.js

Large diffs are not rendered by default.

4,103 changes: 4,088 additions & 15 deletions public_html/massviews/application.js

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions public_html/meta/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
$exists_sql = "SELECT * FROM " . $app . "_projects WHERE project = '$project'";
$res = (bool) $client->query( $exists_sql )->fetch_assoc();

// record exists, so increment counter
if ( $res ) {
// record exists, so increment counter
$update_sql = "UPDATE " . $app . "_projects SET count = count + 1 WHERE project = '$project'";
$client->query( $update_sql );
} else {
Expand All @@ -64,14 +64,34 @@
$client->query( $create_sql );
}

// track massviews sources
if ( $app === 'massviews' ) {
// first check if there is already a record for this project/page/platform/date
$source = $_POST['source'];
$exists_sql = "SELECT * FROM massviews_sources WHERE source = '$source'";
$res = (bool) $client->query( $exists_sql )->fetch_assoc();

if ( $res ) {
// record exists, so increment counter
$update_sql = "UPDATE massviews_sources SET count = count + 1 WHERE source = '$source'";
$client->query( $update_sql );
} else {
// create new record
$create_sql = "INSERT INTO massviews_sources VALUES(NULL, ?, 0)";
$stmt = $client->prepare( $create_sql );
$stmt->bind_param( 's', $source );
$stmt->execute();
}
}

// do the same for the timeline table
$date = (new DateTime())->format('Y-m-d');

$exists_sql = "SELECT * FROM " . $app . "_timeline WHERE date = '$date'";
$res = (bool) $client->query( $exists_sql )->fetch_assoc();

// record exists, so increment counter
if ( $res ) {
// record exists, so increment counter
$update_sql = "UPDATE " . $app . "_timeline SET count = count + 1 WHERE date = '$date'";
$client->query( $update_sql );
} else {
Expand Down
3,575 changes: 3,559 additions & 16 deletions public_html/meta/application.js

Large diffs are not rendered by default.

4,103 changes: 4,088 additions & 15 deletions public_html/redirectviews/application.js

Large diffs are not rendered by default.

3,588 changes: 3,570 additions & 18 deletions public_html/siteviews/application.js

Large diffs are not rendered by default.

1,945 changes: 1,933 additions & 12 deletions public_html/topviews/application.js

Large diffs are not rendered by default.

4,103 changes: 4,088 additions & 15 deletions public_html/userviews/application.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions views/_footer.haml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@
- $MusikAnimal = "<a href='https://en.wikipedia.org/wiki/User:MusikAnimal'>MusikAnimal</a>";
- $Kaldari = "<a href='https://en.wikipedia.org/wiki/User:Kaldari'>Kaldari</a>";
- $MarcelRuizForns = "<a href='https://en.wikipedia.org/wiki/User:Mforns_(WMF)'>Marcel Ruiz Forns</a>";
= $I18N->msg( 'credits', array( 'variables' => array( $MusikAnimal, $Kaldari, $MarcelRuizForns ), 'parsemag' => true ) );
= $I18N->msg( 'credits', [ 'variables' => [ $MusikAnimal, $Kaldari, $MarcelRuizForns ], 'parsemag' => true ] );

%div
%span.nowrap
- $heart = "<span class='heart'>&hearts;</span>";
- $host = "<a href='https://wikitech.wikimedia.org/wiki/Portal:Tool_Labs'>" . $I18N->msg( 'tool-labs' ) . "</a>";
= $I18N->msg( 'hosted', array( 'variables' => array( $heart, $host ), 'parsemag' => true ) );
= $I18N->msg( 'hosted', [ 'variables' => [ $heart, $host ], 'parsemag' => true ] );
%span.nowrap
- $translateWiki = "<a href='https://translatewiki.net/'>translatewiki.net</a>"
- $jqueryI18n = "<a href='https://github.com/wikimedia/jquery.i18n'>jQuery.i18n</a>"
- $intuition = "<a href='https://tools.wmflabs.org/intuition/#tab-about'>Intuition</a>"
= $I18N->msg( 'translation-credits', array( 'variables' => array( $translateWiki, $intuition ), 'parsemag' => true ) )
= $I18N->msg( 'translation-credits', [ 'variables' => [ $translateWiki, $jqueryI18n, $intuition ], 'parsemag' => true ] )

%div
- if ( $currentApp !== 'metaviews' )
Expand Down

0 comments on commit c70fcd7

Please sign in to comment.