Commit graph

17 commits

Author SHA1 Message Date
Sam Smith 040314c504 Configure footer and sidebar placements
Changes:
* Rename $wgRelatedArticlesShowReadMore to $wgRelatedArticlesShowInFooter
* Add $wgRelatedArticlesShowInSidebar, which is truthy by default, and
  short circuit the SkinBuildSidebar and SkinTemplateToolboxEnd hook
  handlers if it is falsy

Bug: T119926
Change-Id: Idf04bf3221ba44d7b898160764fbd6ba83561abb
2015-12-02 11:17:54 +00:00
Sam Smith 9157e303d2 [Hygiene] Reorganise hooks to reflect placements
There are two positions where the list of related articles is rendered:
the sidebar, and the the footer. Move the hook handlers related to
rendering the former to RelatedArticles\SidebarHooks and those related
to rendering the latter to RelatedArticles\FooterHooks.

Change-Id: Idde57905d828e63309bfdc360a3a09e64e291304
2015-12-02 11:10:04 +00:00
Baha 18990e6631 Correctly show related articles on desktop
When $wgRelatedArticlesShowReadMore was false, while deciding
whether to show related articles on the sidebar,
we used to incorrectly consider whether BetaFeatures was
enabled for the user. BetaFeatures should only be used
for enabling ReadMore and not for showing related articles
on the sidebar.

We also used to show the beta features option for ReadMore
even when the ReadMore feature was disabled. Now we only
show that option if ReadMore is enabled.

Also rename isAbleToShowRelatedPages to isInSidebar to make
the function less confusing.

Bug: T119926
Change-Id: Ia5e44d94bb20660af711772cab7e3a59f98c931f
2015-12-02 06:08:19 +05:00
Baha 95ea0b0ef7 Make RelatedArticles available as a beta feature
Hide the related articles from the sidebar if ReadMore is enabled.
Otherwise leave as is because it's used in WikiVoyage.

Bug: T117444
Change-Id: I3879ae1e53de301b0d3f5f2c066f8e8de7c1c223
2015-11-25 20:43:51 +05:00
Baha 8cf9b60ab5 Make RelatedArticles soft-depend on Cards
RelatedArticles tries to load the 'ext.cards' module and if
it succeeds it continues with showing the related articles
on the page.

Dependency: I6661527175eb889cec4193b18fa18207f332b4fc
Bug: T117108
Change-Id: I33936a3e9cd5d1f0296e48fd1c2bba77fff4e466
2015-11-18 22:22:10 +05:00
jhobs d08962d12d [Hygiene] Rename internal uses of "article" to "page"
Leave all public-facing uses of "article" (including classes) because
the extension is remaining named RelatedArticles. Replace all other
instances with "page" for consistency with other extensions.

Bug: T117908
Change-Id: Ib0f258f26b0d11cfe8a598dbd90ff37afbbe36ac
2015-11-13 19:03:39 -05:00
jenkins-bot b83e1bdc58 Merge "Optionally disable Read More using extension data" into dev 2015-11-12 15:55:01 +00:00
Sam Smith 0fed50e266 Optionally disable Read More using extension data
By default, the Read More feature tries to use editor-curated articles
before using the CirrusSearch morelike: feature. Add a configuration
variable that disables the former behaviour but leave the default in
place.

Changes:

* Add the wgReadMoreOnlyUseCirrusSearch configuration variable, which
  defaults to false, and pass it in to
  mw.relatedArticles.RelatedPagesGateway at construction time
* Add the onlyUseCirrusSearch parameter to
  mw.relatedArticles.RelatedPagesGateway, which controls whether to
  ignore the editorCuratedArticles parameter

Bug: T117443
Change-Id: I0dfa67f4a68e8dc17302fef7ebf8d23c0c1d892c
2015-11-12 12:43:29 +00:00
Sam Smith 239705928d Remove CustomData extension dependency
The related pages stored via CustomData  will have been migrated to the
cached ParserOutput class over the last 30 days, per I30bd17f, so all
interactions with/references to CustomData can be removed.

Bug: T115019
Change-Id: I36919d2443f0ee02ac6baf9a4d2228b028b2e6ed
2015-11-10 17:03:06 +00:00
Baha 3995b7a8ef Add event logging to read more
* Schema is located at https://meta.wikimedia.org/wiki/Schema:RelatedArticles.
* Track 'ready', 'seen', and 'clicked' events.
* The sampling rate can be set using the RelatedArticlesLoggingSamplingRate variable.
  If the variable is not set, sampling will be disabled. The default sampling rate
  is 0.01.
* Events are tracked using a unique user session token.

Dependency: Iea00d534371353c3ae5c06c74a08aa10cb60047b
Bug: T114303
Change-Id: I649d0817cbd10ad734989da548d20ad33e7f7360
2015-11-10 15:23:12 +05:00
Sam Smith 5b5a0b288f Put Read More behind a feature flag
Changes:
* Add the RelatedArticlesShowReadMore feature flag, which is disabled by
  default
* Only consider adding the Read More bootstrap module to the output when
  the feature is enabled

Change-Id: I60fc38115257c9a5dbf04b51dbec7f091574d8f6
2015-11-06 20:12:27 +00:00
jdlrobson e86fc3b159 Fall back to CirrusSearch's morelike: feature
When no related articles have been specified by an editor we instead
hit request pages similar to the current page using the CirrusSearch
extension's "morelike:" feature [0].

Changes:
* Config variable introduced RelatedArticlesUseCirrusSearch which allows
you to turn on use of the CirrusSearch API.
* Introduce a RelatedPagesGateway for dealing with making the API call
  and returning consistent results
* Move the "simple" API call for hydrating related pages fetched from
  the wgRelatedArticles configuration variable into RelatedPagesGateway
* Reduce the bootstrap module to just a bootstrap module!

Bug: T116707
Change-Id: Ia0ced1d7ae57c0939d1f5af275aa9d393f1420b1
2015-11-06 10:23:39 -08:00
Sam Smith 7c23636954 Add Related Articles section to Minerva
If the page has related articles, is in mainspace, isn't the main page,
and the output is being rendered with the MinervaBeta skin then a
"Related Articles" section is added to the page just before the footer.

Separate loading the information necessary to render the pages, choosing
the renderer, and rendering the data so that multiple skins - currently
Minerva and Vector per the mocks - not just multiple resolutions can all
be handled the same way:

* The bootstrap script (ext.relatedArticles.readMore.bootstrap/index.js)
  for fetches the page image and Wikidata description; loading the
  renderer module; and, finally, notifying the renderer module that it
  should render the data, which it does by emitting
  "ext.relatedArticles.readMore.init" event using mw#track
* The Minerva renderer subscribes to the event and, when it's fired,
  renders the data by passing it to the WatchstarPageList view

Bug: T113635
Change-Id: I651342bdf9796938fa7051828dd13bc6fe774783
2015-10-26 17:13:46 -07:00
Sam Smith aa30f477bd Clear extension data in ParserClearState handler
While the related parser function sets the accumulated related pages as
extension data on the parser output
(see RelatedArticles\Hooks::onFuncRelated). The ParserClearState
handler, however, sets the empty list as a property, which is then
stored in the DB.

Changes:

* Make RelatedArticles\Hooks::onParserClearState use
  ParserOutput#setExtensionData, mirroring ::onFuncRelated
* Add a unit test for the the handler

Bug: T115698
Change-Id: I3deaf1e8ee78944250c3f26315ee2450b444a035
2015-10-16 20:33:52 +01:00
Sam Smith 45787910d3 Hygiene: Fix PHPCS errors
Also, add more detail to the
RelatedArticles\Hooks::onOutputPageParserOutput DocBlock.

Change-Id: I484ebfe255bc07a11d84f518014c8cc4f73f62db
2015-10-14 11:31:50 +01:00
jdlrobson 8782824cfc Remove CustomData dependency
Since CustomData was written ParserOutput now supports the setting
and getting of properties. This patch switches RelatedArticles to use
that. I'm not sure if any other extensions depend on CustomData but
it seems to have served its purpose.

Bug: T114915
Change-Id: I30bd17fd8c43422fe7ab6f58a74565674e15ba1d
2015-10-08 15:57:44 -07:00
Sam Smith 7995ce4a42 Use extension registration
Add extension.json and populate it with information from both
RelatedArticles.php and the RelatedArticles extension wiki page [0].

Migrate the hook handlers to static functions operating on static data
rather than having a single, global instance of RelatedArticles so that
the hook handler definitions can be added to extension.json easily.

N.B. During testing the handlers for both the SkinBuildSidebar and
SkinTemplateToolboxEnd appeared to have the same effect so the TODO was
removed but not the handler for the former.

Additional changes include:

* RelatedArticles.class.php -> includes/RelatedArticles.php
* RelatedArticles -> RelatedArticles\Hooks
* Documenting all of the methods of RelatedArticles\Hooks

[0] https://www.mediawiki.org/wiki/Extension:RelatedArticles

Bug: T87965
Change-Id: I9944b9186746386ee18ca28657bb547c00ae2b8c
2015-10-07 15:54:07 +01:00