Bmansurov has uploaded a new change for review.
https://gerrit.wikimedia.org/r/249957
Change subject: WIP: Add watchstar
......................................................................
WIP: Add watchstar
Change-Id: I443110a0d13669a9069f0c542ef2d37332f04248
---
M extension.json
M resources/CardsGateway.js
M resources/view/Card.js
M resources/view/card.hogan
M resources/view/styles.less
A resources/view/watch.svg
A resources/view/watched.svg
7 files changed, 72 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Cards
refs/changes/57/249957/1
diff --git a/extension.json b/extension.json
index 07f3c88..1caf20b 100644
--- a/extension.json
+++ b/extension.json
@@ -32,6 +32,18 @@
"resources/init.js"
]
},
+ "ext.cards.view.images": {
+ "targets": [
+ "mobile"
+ ],
+ "class": "ResourceLoaderImageModule",
+ "prefix": "mw-ui",
+ "selector": ".mw-ui-icon-{name}:before",
+ "images": {
+ "ext-cards-watch": "resources/view/watch.svg",
+ "ext-cards-watched":
"resources/view/watched.svg"
+ }
+ },
"ext.cards.view": {
"targets": [
"mobile"
@@ -41,7 +53,8 @@
"oojs",
"mediawiki.Title",
"mediawiki.template.hogan",
- "ext.cards.init"
+ "ext.cards.init",
+ "ext.cards.view.images"
],
"scripts": [
"resources/view/Card.js",
diff --git a/resources/CardsGateway.js b/resources/CardsGateway.js
index 44c6963..370371a 100644
--- a/resources/CardsGateway.js
+++ b/resources/CardsGateway.js
@@ -41,21 +41,24 @@
this.api.get( {
action: 'query',
- prop: 'extracts|pageimages',
+ prop: 'extracts|pageimages|info',
explaintext: true,
exlimit: articleTitles.length,
exintro: true,
exsentences: 1,
pithumbsize: thumbWidth || THUMB_WIDTH,
titles: articleTitles.join( '|' ),
+ inprop: 'watched',
continue: ''
} ).done( function ( data ) {
+ console.log(data);
if ( data.query && data.query.pages ) {
cards = $.map( data.query.pages, function (
page ) {
article = {
title: page.title,
url: ( new mw.Title( page.title
) ).getUrl(),
- hasThumbnail: false
+ hasThumbnail: false,
+ hasWatchstar: !mw.user.isAnon()
};
if ( page.thumbnail ) {
@@ -68,6 +71,11 @@
article.extract = page.extract;
}
+ if ( page.hasOwnProperty( 'watched' ) )
{
+ article.hasWatchstar = true;
+ article.isWatched = true;
+ }
+
return new Card( article );
} );
}
diff --git a/resources/view/Card.js b/resources/view/Card.js
index 3407b82..f6bae7c 100644
--- a/resources/view/Card.js
+++ b/resources/view/Card.js
@@ -16,11 +16,29 @@
mw.cards.Card.prototype.template = mw.template.get( 'ext.cards.view',
'card.hogan' );
/**
+ * Cached html
+ * @type {string}
+ * @private
+ */
+ mw.cards.Card._html = '';
+
+ /**
* Render the template and return HTML
*
* @return {String}
*/
mw.cards.Card.prototype.getHtml = function () {
- return this.template.render( this.article );
+ var html = mw.cards.Card._html;
+ if ( !html ) {
+ html = this.template.render( this.article );
+ html.find( '.watchstar' ).on( 'click', function () {
+ var $this = $( this );
+
+ $this.
+ // TODO
+ } );
+
+ }
+ return mw.cards.Card._html;
};
} )();
diff --git a/resources/view/card.hogan b/resources/view/card.hogan
index c46f96c..dbca4d4 100644
--- a/resources/view/card.hogan
+++ b/resources/view/card.hogan
@@ -7,4 +7,13 @@
<div class="extract">{{ extract }}</div>
{{/ extract }}
</a>
+ {{# hasWatchstar }}
+ <div class="watchstar-holder">
+ <span class="mw-ui-icon mw-ui-icon-element watchstar {{# isWatched
}}mw-ui-icon-ext-cards-unwatch{{/ isWatched }}{{^ isWatched
}}mw-ui-icon-ext-cards-watch{{/ isWatched }}"
+ role="button"
+ aria-label="{{# isWatched }}Stop watching{{/ isWatched }}{{^
isWatched }}Watch this page{{/ isWatched }}"
+ title="{{# isWatched }}Stop watching{{/ isWatched }}{{^
isWatched }}Watch this page{{/ isWatched }}">
+ </span>
+ </div>
+ {{/ hasWatchstar }}
</li>
diff --git a/resources/view/styles.less b/resources/view/styles.less
index cdc5a13..dce5b91 100644
--- a/resources/view/styles.less
+++ b/resources/view/styles.less
@@ -14,15 +14,20 @@
display: table;
margin: 0;
height: @thumbWidth;
- padding: 5px 10px 5px ( @thumbWidth + 10px );
+ padding: 5px 0 5px ( @thumbWidth + 10px );
position: relative;
width: 100%;
- a {
+ a,
+ .watchstar-holder {
display: table-cell;
- text-decoration: none;
vertical-align: middle;
}
+
+ a {
+ text-decoration: none;
+ width: 100%;
+ }
}
h3 {
diff --git a/resources/view/watch.svg b/resources/view/watch.svg
new file mode 100644
index 0000000..67e5a72
--- /dev/null
+++ b/resources/view/watch.svg
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24.000001 22.909092"
enable-background="new 0 0 24 24">
+ <g id="g3">
+ <path d="M13.91 10.09L12 6.274l-1.91 3.818-4.226.683 3 3L8.182 18 12
15.955 15.818 18l-.682-4.227 3-3-4.227-.682zM8.317 7.5L12 0l3.682 7.5L24
8.727l-6 5.864 1.364 8.32L12 18.954l-7.364 3.818L6 14.455 0 8.59 8.318 7.5z"
id="path5" fill="#777"/>
+ </g>
+</svg>
diff --git a/resources/view/watched.svg b/resources/view/watched.svg
new file mode 100644
index 0000000..c2fa585
--- /dev/null
+++ b/resources/view/watched.svg
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 22.915254"
enable-background="new 0 0 24 24">
+ <g id="g3">
+ <path d="M8.407 7.593L12.067 0l3.662 7.593L24 8.813l-5.966 5.83 1.49
8.272-7.456-3.932L4.61 22.78l1.356-8.272L0 8.678l8.407-1.085z" id="path5"
fill="#00af89"/>
+ </g>
+</svg>
--
To view, visit https://gerrit.wikimedia.org/r/249957
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I443110a0d13669a9069f0c542ef2d37332f04248
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Cards
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits