Commit Graph

134 Commits

Author SHA1 Message Date
DannyS712 6ac9079202 VectorTemplate: SkinTemplateToolboxEnd hook isn't deprecated
Bug: T252906
Change-Id: I6eedc41d02b9f64cefb9c8d749226489ada6aae2
2020-05-15 20:56:24 +00:00
jdlrobson 4086d850e5 Show empty language portal if HTML has been added after portal
Bug: T252800
Change-Id: Iefe0ed2728b6fd08da8f3e58edbfaae7d27d1a2d
2020-05-14 15:25:38 -07:00
jdlrobson 0846c8463d Allow plain text labels in side bar
Follow up to I2549af3e24e5d51c09e9a88ca50a0d9b2e154c3f

Bug: T252727
Change-Id: I91e6e535e2da672b41d31cee709084beb87af47a
2020-05-14 08:23:49 -07:00
jdlrobson e048c2a729 Refactor: Simplify and standardize menu definitions
* Standardise the menu markup. This means all menus in Vector will now
be wrapped in a div and will have a heading.
* All menus now have the vector-menu class. Styles specific to personal tools
are moved to layout since these are concerned with placement.
* The ul class will always have menu class.
* emptyPortal class is generalised into vector-menu-empty for consistency
with other classes and moved from common.less into Menu.less
* Standardise hooks - BaseTemplateAfterPortlet can now be run on any
menu.

Changes to HTML:
* lang and dir attributes are moved from the h3 up to the div element
.vectorTabs, .portal(s) and #p-personal now has hidden span element inside h3
* for non portals ul.menu" is now wrapped in a div.vector-menu-content

This change does impact the following CSS selectors which will need to be updated:

I see no matches for these selectors in code search.

```
 #p-variants > ul
 #p-namespaces > ul
 #p-personal > ul
 #p-views > ul
 #p-cactions > ul

```
Using global-search.toolforge.org I see one match
for p-variants, 26 for p-namespaces, 30 for p-personal,
36 for p-views and 7 for p-cactions. I see this as acceptable
breakage provided a user notice is sent out which it has been
(T252447)

Bug: T249372
Change-Id: Id59234aa6b822a24848386bdc04d8d7ed37ca145
2020-05-12 15:17:38 -07:00
jdlrobson 4679efc000 [build] Disable phan rule (for now)
This unblocks reverting HTML5 elements.
A longer term fix is brewing in
If6b10b0ddcbd4b21dd13a2813e60b604c3a23415

Change-Id: I85659d22dc2f2a803c2a7b1e57033b18900353df
2020-05-11 23:09:24 +00:00
jdlrobson 01dbda42ca Don't "break" the variants by breaking early
Hope you enjoyed the pun, as this is an unfortunate bug to have
slipped into production.

While previously we breaked after finding the selected items
prior to I098e6921e8f7ef65dacacf09b9c25f70c945e58e we shouldn't do
that any more as we're using the same loop to iterate through and
generate our items!

Bug: T251521
Change-Id: I92c28e8fba684d7977dfd207ff939ac07a7a07af
2020-05-08 07:21:59 -07:00
jdlrobson 9f2ca0d072 Refactor: Portal is also a Menu
To complete the refactor, the Portal is also refactored
as a Menu using the getMenu function.

An old code path supporting portals outputted by hooks with
strings is marked as deprecated to simplify this code in future.

array-portals-first -> data-portals-first (the value is not
an array)

Changes:
* $this->getLanguages and  $this->getToolbox() always returns an array (see BaseTemplate)
but we previously supported portals made using raw HTML. Let's move away from that
behaviour and deprecate it.
* Hooks are moved into buildSidebarProps and marked as deprecated where possible
(SkinTemplateToolboxEnd). SidebarBeforeOutput can be used instead.

Bug: T249372
Change-Id: I2549af3e24e5d51c09e9a88ca50a0d9b2e154c3f
2020-05-07 16:56:59 -07:00
jdlrobson 4dfe4a97c9 Class names with hyphens preferred over camel case
The classes were recently changed so provided this is merged before
next branch cut no need to worry about cached HTML.

Bug: T249073
Change-Id: Ib20c7a359bda858df89ebb245e682d321dd5acd0
2020-05-07 14:43:13 -07:00
jdlrobson 9cd47c5339 Refactor: VectorMenu merged in to Menu
Bug: T249372
Change-Id: Ifaf78b507c12aa251228213c89751cbb4d111d9a
2020-05-06 16:09:22 -07:00
jdlrobson a43e79c1d3 Refactor: Merge VectorTabs into Menu
Bug: T249372
Change-Id: Ib6ae191b31564dc23a3b1d6aedf48cbaaad006af
2020-05-06 10:23:58 -07:00
jdlrobson a3bb097cf8 Refactor: Generalise personal menu
the PersonalMenu should be generalised. In future we will use it as
the template for all menus

Bug: T249372
Change-Id: Id1c43d2e9eefef1d7aec45f0137e27f10ad935df
2020-05-05 17:34:44 -07:00
jenkins-bot 4086a4c824 Merge "Refactor: Remove indirection (where alternatives exist)" 2020-05-05 20:34:03 +00:00
jdlrobson 7efe7c3468 Refactor: Remove indirection (where alternatives exist)
The get method while well intended, adds an unnecessary level of
indirection to our code and can't be easily typechecked. Using
the methods directly (which if you review core code, these all
directly map to those methods) makes the code much more of a pleasure
to read.

Bug: T251212
Change-Id: Ibb2a69801d3b004a0a174308d3ac04d1d228807c
2020-05-05 13:07:14 -07:00
Nicholas Ray 91c25bc253 Add title attribute to opt-out link
The opt-out link was missing a tooltip which is important for
accessibility and to help people gain more context as to what it does.

Bug: T250093
Change-Id: Ie6cbaf5c941615d1662700415b8f1823987a563d
2020-05-05 09:52:20 -06:00
jdlrobson 97121a228f [Minor] Favor msg and getConfig over getMsg and ->config
Change-Id: I69ff5b8fc51292f745e0aa496b8129053c9d2f23
2020-05-01 19:11:58 +00:00
jenkins-bot 48b680744d Merge "Use consistent function names to SkinVector" 2020-04-30 22:16:06 +00:00
jdlrobson 6a9ee465bc [modern] A new version of Vector with a new logo
Changes to support feature:
* ResourceLoaderSkinModule logo features are dropped
* New layout provided given the fork in layout between legacy and new.
* Legacy sidebar styles now pulled out
* breakpoint styles are not carried over from legacy Vector
The new Vector layout for now has one breakpoint.

Changes to storybook:
* The storybook script now pulls down image assets so that the logos can
be shown in storybook. The script is adjusted to make use of a static folder to
serve these images.

Note:
* The legacy mode is not touched as part of this patchset.
* The personal menu is unaffected by this patch and is out of scope.
* The alignment issue is noted, but will be solved at a later date.
* Changes to portal are out of scope.
* Adding storybook for modern descoped, given its not possible to load
both legacy layout and modern layout inside a storybook at current time.

Sample config:

$wgLogos = [
        'icon' => 'https://di-logo-sandbox.firebaseapp.com/img/globe.png',
        'tagline' => [
                'src' => 'https://di-logo-sandbox.firebaseapp.com/img/tagline/en-tagline-117-13.svg',
                'width' => 117,
                'height' => 13,
        ],
        '1x' => 'https://en.wikipedia.org/static/images/project-logos/enwiki.png',
        'wordmark' => [
                'src' => 'https://en.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-en.svg',
                'width' => 116,
                'height' => 18,
        ],
];

Coauthor: Aron Manning

Bug: T246170
Change-Id: Ibc4b055150761388a6b78f9127da342c451ce0e7
2020-04-30 14:11:54 -07:00
jdlrobson d9f4a2b041 Use consistent function names to SkinVector
In future we'll convert VectorTemplate to SkinVector. In preparation
for this we create wrapper functions getMsg and getConfig so that
the interface for VectorTemplate is more similar to SkinVector.

Bug: T251212
Change-Id: I1f839d3147499d67e1c7cf71cf934bb7d20beedb
2020-04-28 15:32:06 -07:00
jenkins-bot db29a88ee0 Merge "Add buildSidebar method" 2020-04-28 20:49:31 +00:00
jdlrobson df681e031d Add buildSidebar method
Move all the sidebar generation logic into a new VectorTemplate
function.

The name mirrors the function name in SkinVector. In future,
( I7a14f74728703c50874935e9d77b35ad9434b436)
we will move this code into SkinVector where it will be able
to call parent::buildSidebar()

Bug: T251212
Change-Id: I0a4838120f6ffd3d3d798f876e3463a3f16af95b
2020-04-28 10:44:39 -07:00
AronDemian 487eda02f4 [cleanup] Drop empty `class` attribute from `#footer > ul` elements
Change-Id: Ice0241b054cbc296e9f0adf1d2920023316c8ca0
2020-04-28 02:05:30 +00:00
jdlrobson b42493a476 Refactor: DRY up menu creation!
Bug: T249372
Change-Id: I098e6921e8f7ef65dacacf09b9c25f70c945e58e
2020-04-27 13:36:39 -07:00
jdlrobson 0b8693ccec Refactor: Make VectorTabs template data conform with MenuDefinition
menu-id -> id
menu-label-id -> label-id
msg-label -> label
empty-portlet -> class

Bug: T249372
Change-Id: I15fd88269b3d111ff47e64f3669575afaeea9f97
2020-04-22 05:18:44 +00:00
jdlrobson 286b07b20a Refactor: Make VectorMenu template data conform with MenuDefinition
menu-id -> id
menu-label-id -> label-id
msg-label -> label
empty-portlet -> class

Bug: T249372
Change-Id: I50bf2424f9077ac987e03a1e552577bf7c48b3bb
2020-04-22 05:18:29 +00:00
Stephen Niedzielski 3b906fdd66 [dev] Fix indent in VectorTemplate data
Jon spotted this in Ic9d54de7e19ef8d5dfd703d95a45b78c0aaf791a.

Bug: T246419
Change-Id: Ie760610898c1754ac0640e8077faa6ec79da66c1
2020-04-17 14:23:56 -06:00
Volker E c3f9194144 Fix Special:Preferences sub section link
Now links to nested sub sections are possible with
I33318b3fb73a27ce8013 in.

Bug: T248644
Change-Id: I92d0910191dcab0a7fe43ba6976c6773384688a7
2020-04-17 00:08:42 +00:00
jdlrobson 703903daac [legacy] Split sidebar code and mark layout as legacy in preparation for new layout
Going into the new version of Vector, we'll want to rewrite the layout
rules entirely and decouple the sidebar from the logo.

To prepare for this we will move the layout file into a legacy folder.
We also separate Sidebar styles needed for the legacy mode from the old mode.

This will allow us to make changes to the header in new Vector without having to touch
or test the legacy codebase via a new file layout.less and using the existing sidebar
code.

Bug: T246170
Change-Id: Ieb4f8f2b2f0e4f48d76a210ab30acd08e3e83bcb
2020-04-16 11:29:03 -07:00
jdlrobson 4d91d52dfc Add a special class to identify the first portal
In new Vector, the logo will no longer be present, so we need a more
future proof way of determining what the first portal is.

A new class `portal-first` is added (no decision about adopting BEM
has been made yet).
Cached pages will continue to use the old selector for now.

Change-Id: I6ac4493bb1f63686b48ff0c22b18d50d9fffb51d
2020-04-15 23:39:33 +00:00
jdlrobson 63ee9450b7 Refactor: Standardize menu data (DRY!)
VectorTemplate has various functions that repeat themselves, only
differing in their choice of names.

This refactor begins by focusing on the personal menu and introducing
a generic getMenuData function. Hardcoded `p-personal` is replaced with
an `id` template key and `msg-label` is renamed `label`.

Future patches will simplify VectorTemplate by using this new
function.

You'll note the resulting PersonalMenu.mustache file is identical
to VectorTabs. These will be merged in I098e6921e8f7ef65dacacf09b9c25f70c945e58e

Bug: T249372
Change-Id: I5ae44a1008b065381eeff93f9fa625be5c5a9de9
2020-04-13 16:11:40 -07:00
VolkerE 087808ece6 Revert "Move indicators underneath `#firstHeading` in DOM"
This reverts commit f400fc57c3.

Bug: T248761
Change-Id: I3a4f1202d5e1cca9f82d1735cc498049fa25613c
2020-04-08 13:43:10 +00:00
Volker E f400fc57c3 Move indicators underneath `#firstHeading` in DOM
Adding `margin-top` property only with sibling selector for now
until cache is cleared.
Also removing already inherited from
`.mw-body-content` properties `position`,
`font-size` and `line-height` of same value.

Bug: T248761
Change-Id: I1ea5e08927a96ac69c1b65f248ae0420968b4d00
2020-04-06 17:06:31 -07:00
AronDemian f2fad08fb7 Define the legacy and modern root template names in the same location (improve locality)
Follow-up to I580fe55ca6aeb35dae8afee41e87172a5a729c7b

Change-Id: Iea8be07c7a86c5ca258ffdfa07fa52713cb1d6d5
2020-04-02 01:55:55 +02:00
jdlrobson c8001f91b1 Split legacy and modern experience on template level
The new template 'index.mustache' drops the Navigation
template partial (component) - instead embedding it in
the master template given its lack of usability.

Note to reviewer: Please ensure index.mustache and
legacy.mustache are identical.

Change-Id: I580fe55ca6aeb35dae8afee41e87172a5a729c7b
2020-03-31 14:35:00 -07:00
jdlrobson 872519ab94 Drop the Navigation component
It is not the most useful of components and adds an additional layer
of complexity similar to multiple inheritance chains that we find in
Object oriented programming.

I suggest we use index.mustache going forward for laying out the different
components and use components/template partials for reusable components.

Change-Id: I6fd5fe1c3d3826d737ccd8ed5a38890305664876
2020-03-30 15:26:34 -07:00
Nicholas Ray ec382a8c86 Add opt-out link to Sidebar for Vector/Logged-in Users Without Abstractions
This commit is singularly focused on adding a link to the sidebar for
Vector, logged-in users. It does the bare minimum to fulfill the
requirements of T243281.

Additionally, it will help to answer the question "Do we need to use
abstractions (other than maybe different templates) to separate Legacy
Vector from Vector" by intentionally leaving out any abstractions in
order to make it easier to compare with a follow-up patch
(Ib2ef15180df73360cc1de25b893e49d415d23e1a) which does use abstractions.

It is a good thing to question whether or not we need addtional
abstractions in VectorTemplate and if they will help us as unnecessary
abstractions can have the opposite effect and just lead to further
frustrations down the road.

Therefore, I urge you, the reviewer, to let me know your thoughts! If
abstractions are viewed as not making our lives any easier, the
follow-up patches may be completely discarded and that's totally okay
with me. :) I think it's a good think to talk about now though.

Important changes:

* The VectorTemplate constructor was changed to allow injecting the
config, templateParser, and isLegacy boolean (only the config was
allowed before this commit). According to MediaWiki's Stable Interface
Policy, "Constructor signatures are generally considered unstable unless
explicitly declared stable for calling" [3]. Given that VecorTemplate's
constructor is not marked as stable, it is justified to do this without
warning according to the policy.

* Due to the above, the 'setTemplate' method is no longer needed and was
marked as deprecated.

* VectorTemplateTest was made to adapt to the new VectorTemplate
constructor. Additionally, it now extends from
MediaWikiIntegrationTestCase which my intelliphense server can pick up.
I *think* MediaWikiTestCase is just an alias to
MediaWikiIntegrationTestCase [1] and MediaWikiTestCase file was renamed
to MediaWikiIntegrationTestCase in [2], but I'm willing to change it
back if there is pushback to this.

Open questions:

* What are VectorTemplate's responsibilities? To me, it acts right now
as a controller (because it echos the full HTML string from the
template), a model (because SkinTemplate::prepareQuickTemplate sets data
on it which it later retrieves through `$this->get()`), a presenter
(because it adds data tailored for a web-centric view), and a view
(because it renders HTML strings instead of letting the view/template be
solely responsible for that). Arguably, some business logic might be
mixed in there as well (because it checks to see if a User is logged
in/has necessary permissions to show x which my changes here add to).
This might not be a problem if we keep VectorTemplate relatively small,
but will it remain this way as we progress further in Desktop
Improvements?

* How do we write tests for VectorTemplate without exposing unnecessary
public methods? For example, if I want to test the `getSkinData()`
method to see what state will be sent to the template, how should I do
this? One option might be to use `TestingAccessWrapper` to expose these
private methods which is what
`VectorTemplateTest::testbuildViewsProps()` does. Another option is to
accept this method as public. Is there a better way? Keep in mind that
even with access to this method, there might be many things to mock.

[1] 0030cb525b/tests/common/TestsAutoLoader.php (L64)
[2] Ie717b0ecf4fcfd089d46248f14853c80b7ef4a76
[3] https://www.mediawiki.org/wiki/Stable_interface_policy

Bug: T243281
Change-Id: I0571b041bcd7f19bec9f103fa7bccdd093f6394d
2020-03-26 17:39:47 -06:00
jdlrobson 59747a58c8 Separate first portal in sidebar from rest
This allows us to insert HTML underneath the first portal or wrap
the portal in a containing element in future if we want to target
additional CSS to it

Change-Id: Ied28d95407b8d59fc819bb07a2cce3242bd93088
2020-03-11 23:34:11 +00:00
Timo Tijhof 406012f863 docs: Improve VectorTemplate Mustache param docs
Separate value type from value groups, to clarify that e.g.
something coming from a hook does not mean it should not have "html-".

Change-Id: I52fdd6995241e1d64f23fd8154997de813f674f4
2020-03-06 22:53:04 +00:00
jdlrobson cdd5ebd74d Use template partials rather than HTML strings
CHANGES to  index.mustache:
Changes can be understood by looking at the diff of
the file stories/skin.stories.js

The additional changes in stories folder export the data passed to
those templates. A new file is used as exporting any variable in a
file suffixed stories.js will be assumed to be a story entry.

The changes to index.mustache are as follows:
* html-footer is replaced with data-footer and Footer
component is rendered via template partial
* html-navigation is replaced with data-navigation and
Navigation component is rendered via template partial

CHANGES to Navigation.mustache:
Changes are best explained by looking at the diff to
stories/navigation.stories.js
and navigation.stories.data.js
* html-personal-menu is replaced with data-personal-menu

Bug: T245456
Change-Id: Ie96e92447a932b8a7f3844df277a1d31a2af423c
2020-03-03 09:28:52 -08:00
polishdeveloper 48988c8ab0 Instead of accessing $data property use set/get/html methods
For better encapsulation and future possibility to create Skin API
we have to stop accesing properties and start using getters/setters
instead. Once we start doing that we should be able to provide a
clear interface for our templating system.

Bug: T246161
Change-Id: Ib3539b1e3bc12341c79913af3c95acad8619cff4
2020-02-28 22:06:00 +01:00
jdlrobson 698752e38a [Dev] processTemplate used in one place
Moving all the templateParser calls to one function
so its easier to see how the template is composed.

The diff of changes to the stories folder highlight
the internal changes which are:

* html-portals replaced with html-sidebar in main template
* new Sidebar template added which outputs to html-sidebar
* Mention of "MainMenu" replaced with better understood "Sidebar"

This is precursory work to adopt templatePartials

Change-Id: I6b2196e39087f818e774d04b2d1b9ab8cb8816a1
2020-02-26 12:28:40 -08:00
jdlrobson 2d914d04ea Remove renderNavigation function for readability
The renderNavigation function provides an unnecessary level of
abstraction which I'd argue hurts readability of these functions.
Let's remove it.

Change-Id: Iad1c4db606404fecf4d5ae98981df9f05d3f661e
2020-02-17 22:20:18 +00:00
polishdeveloper 09671d768f Introduce PHPUnit tests in Vector
To make it happen, we also need to provide a way to
inject different TemplateParser.

Change-Id: I14d8474a2b52f040b688245cbd5bd6f12dddf846
2020-01-31 16:48:43 +01:00
jdlrobson 12e2287894 Simplify logo generation
Use a template variable only for html attributes of the logo
Move static HTML into Navigation.mustache

Change-Id: If37015b9ce4f37e264b6f25956e4d0ca35e8cdff
2020-01-30 02:11:05 +00:00
jdlrobson 0cdf0c238a Dev: Complete initial porting of Vector to Mustache
Bug: T240062
Change-Id: I18cb1fda6850646a38314a7d2dd356103f04ec28
2020-01-29 13:21:34 +00:00
polishdeveloper efe0ec6356 Deprecation: Deprecate Vector specific hooks
Vector provides two vector specific hooks:
 - VectorAfterToolbox
 - VectorBeforeToolbox

Instead of supporting Vector specific stuff we should aim
for a nice global skin api and allow other 3rd party to
extend MediaWiki functionality no matter which skin is currently
on.

Bug: T240062
Change-Id: I245f1316e79f814ba04f4e0a0223d4f0596cf39e
2020-01-24 16:20:50 +00:00
jdlrobson 80b5ccc634 Dev: Break Footer out into template
Add a new Footer template for modelling the footer of
Vector.

Bug: T240062
Change-Id: I60a243abeb5650542ca6f6fac8401a622faaabac
2020-01-17 13:10:37 -08:00
jdlrobson 9f82f58ea9 Dev: Include closed body and html tags in getTrail
This will allow us to render in Storybook without having issues
with unclosed tags. it also mirrors how html-headelement works
(obscuring the opening of the body and html tags)

Bug: T240062
Bug: T242674
Change-Id: I216a920c68bf3da9de55a75fc53451c68c9cc753
2020-01-17 19:16:32 +00:00
jenkins-bot 4ce1e8c1f2 Merge "SkinTemplateToolboxEnd hook output not displaying in Vector" 2020-01-14 22:58:53 +00:00
jdlrobson f416e21bc5 SkinTemplateToolboxEnd hook output not displaying in Vector
Broken in I882db161e5462cf88aa48c9cfd91448eb97a4a77

Bug: T240062
Change-Id: I94bbf79c6c2743a5769935287593aa48780bfb71
2020-01-14 14:37:12 -08:00
jenkins-bot f1aaa1ec91 Merge "Replaces $user->isWatching call with WatchedItemStore isWatching service call" 2020-01-14 22:30:09 +00:00
Jan Drewniak 361e0d6f71 Extract Portal mustache component from VectorTemplate.php
A Portal (or portlet) in the Vector context is a section of the
sidebar menu (e.g. Tools, Languges etc.).

The hook that places content between the portals (or portlets?)
such as `SkinTemplateToolboxEnd` and `otherlanguages` has been
enclosed inside of an output buffer so that any content it
produces can be passed to a template.

Bug: T239248, T240062
Change-Id: I882db161e5462cf88aa48c9cfd91448eb97a4a77
2020-01-14 22:44:58 +01:00
Jan Drewniak 093cc20ee0 Extract VectorMenu.mustache component from VectorTemplate
Extracts a new VectorMenu mustache component from VectorTemplate.
VectorMenu is the "more" menu that appears at small widths instead of the
Read/Edit/View History menu near the top of the Vector skin.

Bug: T239248, T240062
Change-Id: I41b1ec949d81303abddadb981741445572c939e3
2020-01-14 10:38:46 -08:00
jenkins-bot 68af887faf Merge "Convert $templateParser in VectorTemplate.php into an instance variable" 2020-01-13 19:37:56 +00:00
Jan Drewniak a706618a9d Convert $templateParser in VectorTemplate.php into an instance variable
Change-Id: Iaebfaefdd0722d1e63cb73585e0148f54fcdd77e
2020-01-13 15:40:57 +01:00
libraryupgrader b1978d572f build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Change-Id: I336d23b2d322d1ae1a4c3101e69088c11eb9f43c
2020-01-13 06:06:46 +00:00
Jan Drewniak d29adb5dcc Fix uerlangattributes echoing output from PersonalMenu component
Followup to 4f471bfa5e

Bug: T240062
Change-Id: I13c099befc98b42f28e58a669df495b9324190f4
2020-01-10 13:15:17 +01:00
Vedmaka 2fce68778c Replaces $user->isWatching call with WatchedItemStore isWatching service call
Bug: T208766
Change-Id: I178b1a1aa0106d82f1b336f2bda5c6371468d741
2020-01-09 21:50:40 +00:00
Jan Drewniak 4f471bfa5e Extract PersonalMenu,mustache component from VectorTemplate
PersonalMenu is the login/logout notifications etc. menu at the very
top of the Vector skin.

Bug: T239248, T240062
Change-Id: Iae224cbd838e44669a9f27e6dd303c6c3b402d41
2020-01-09 16:01:46 +01:00
libraryupgrader cfe2ff0864 build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Additional changes:
* Added .eslintcache to .gitignore.

Add check for unset 'class' attribute.

Change-Id: Ib5b8993e89f4cb8f2f5325cbbc1e02401dd19d81
2019-12-22 20:11:34 +01:00
Stephen Niedzielski 9d427dcb30 [Hygiene] [Mustache] rename SearchComponent to SearchBox
For consistency with VectorTabs, rename SearchComponent to only imply
component. At least two word names seems like a good target (instead of
just "Search") for grepability and standard component style conventions.

Bug: T239248
Change-Id: I1e4f7270ba29c2f35f08e92f8a28cd8a2ec8fe87
2019-12-06 17:00:42 -07:00
Stephen Niedzielski 60148a1a92 [Hygiene] [Mustache] improve template parameters and docs
Add typing expectations to search box template parameters. Add context
expectations to search box and tabs templates.

Bug: T239248
Change-Id: I4ff1920f5489b68ef73a219ceeceb1f5511fc9e8
2019-12-06 17:00:42 -07:00
Stephen Niedzielski e0b29624d1 Fix: tab attributes
The tab attributes were mistakenly being echoed instead of passed by
value. E.g., http://localhost:8181/wiki/A?uselang=he.

Bug: T239248
Change-Id: Ia0af96df717948743a2d66f8432b47e6f8a9c8f1
2019-12-06 17:00:39 -07:00
Jan Drewniak c12c5f06db Move namespace & view tabs into a VectorTabs.mustache component
Creates a new VectorTabs.mustache component and uses it to render
the namespace & view tabs.

Bug: T239248
Change-Id: I859e4e95a2a12470f66564db547679c9f0a16727
2019-12-04 15:51:02 +01:00
Stephen Niedzielski d6f4aaa88e Hygiene: extract VectorTemplate inline HTML to SearchComponent Mustache file
Extract SearchComponent.mustache from VectorTemplate. The "search"
message is now escaped by the template parser. As is, htmlspecialchars()
for "wgScript".

A later patch will change each component renderer function as well as
renderNavigation() to return a string.

Change-Id: I3084b7e0ef73d320c85ee780c9eff13ecea92906
2019-11-20 16:41:05 -05:00
Stephen Niedzielski c9f15a4206 Hygiene: move VectorTemplate inlined PHP to variables
Move template logic outside of the template and into variables. This
will allow a future refactor to move the template to a separate
template-only file.

Change-Id: I91c2df11106cf09428a890a2d96ecbddb18ef0fe
2019-11-20 16:35:04 -05:00
Stephen Niedzielski 625ec18f81 Hygiene: divide VectorTemplate.renderNavigation()
Cut up renderNavigation() into several discrete methods. Smaller methods
are easier to read and reason about.

Change-Id: I4e55d858ab1745fb2baddef02f7046ec842eb149
2019-11-18 15:26:20 -05:00
Timo Tijhof a5fe72696b Remove extra <span> from Vector tabs
No longer needed as of I8237976e0587.

Bug: T236410
Change-Id: I5a59c136de4572e5f11b52cc11bc93251c972369
2019-10-25 15:22:57 +00:00
Simon Legner 6b99f35cbe Cleaning a[redundant] is done in BaseTemplate
Relates to I630410aea2852f7a72fea67bbf256b3561ea0f3f.

Change-Id: I0e0ccad14236dfbfc82f38e8e4316a431dd38d7a
2019-08-21 18:03:47 +00:00
Timo Tijhof d56792addb Fix <h1> to be present even if title is "0"
Regression from 74b9803d9a, caused by a bug in LightNCandy which
caused {{foo}} to render "0", and {{#foo}} to pass as true with "0", but then
in {{#foo}}<b>{{foo}}</b>{{/foo} render as empty string producing "<b></b>".
In other words, the conditional is passing and the inner block is executed,
but the placeholder is mistakenly converting "0" => null => "" (empty string),
causing the <h1> to render but without any text in it.

Work around this bug by simply removing the conditional. Several other skins
already don't have this conditional and it's unclear why or in what
situation MediaWiki would send OutputPage to SkinTemplate without a title.

I think it would make sense in such rare case to still have a consistent
layout for extensions and gadgets to interact with and not omit the H1
element, but render it with the value that OutputPage gave it, even if it
is the empty string.

Bug: T219864
Change-Id: I6e04b512d2fe2e949ff5385cb38ceebe392fb255
2019-04-02 19:47:38 +01:00
Jdlrobson 74b9803d9a Start extracting rendering from PHP into Mustache
This reverts commit 8d0377d926
now a conversation has happened.

Bug: T217172
Change-Id: Id51bbd4358bdcc1131c11e13d5548e9c0474e711
2019-03-05 13:22:24 +00:00
Isarra 8d0377d926 Revert "Start extracting rendering from PHP into Mustache"
This reverts commit a3ca2c3e16.

Reason for revert: This requires wider discussion before moving
forward, and a more complete implementation even once we do have
consensus.

No associated task exists on which to view or continue this
discussion: linked task briefly mentions Mustache in general as an
option as part of a much wider topic, but doesn't concern this
specifically.

Issues that should be discussed include:
* What the intent even is here: is this for one skin only? Is this
  the intended path forward for all of them? Depending on which, we
  have other issues: for the former case, that it is quite
  unhelpful in terms of maintenance and further development having
  more random code diversity out there, especially in this
  half-completed state; or if it is indeed intended for all of them,
  that an RfC is needed before anything is merged, as that is a very
  significant change.
* That using Mustache in MediaWiki does add (usually minor)
  performance overhead; we need to clearly establish in the task that
  this is indeed worth it here.

Change-Id: I0bafa55b554aa8a38553e20c75859ec5eec2c062
2019-01-28 16:49:48 +00:00
Timo Tijhof d306e07824 template: Avoid raw HTML parameter for jump link labels
Change-Id: I6c638118988b6fbea95697817edf8c59c0ef6a6b
2019-01-22 21:13:05 -08:00
Timo Tijhof 9cc0ca983c template: Remove is_callable check for getIndicators()
The VectorTemplate class extends BaseTemplate, which has defined
this method since MW 1.25. The Vector skin master branch supports
MW 1.29+ only.

Change-Id: I83c6add9e8c02df028ca5905934e7d367dbe2209
2019-01-22 21:13:05 -08:00
Timo Tijhof a3ca2c3e16 Start extracting rendering from PHP into Mustache
Bug: T140664
Change-Id: I249fead8e1c7bc5dc295457bd46b05e7ed389414
2019-01-22 21:13:05 -08:00
Fomafix c68a21e78a Remove space before Xml::expandAttributes()
Xml::expandAttributes() outputs a space at the beginning before it
outputs the attributs.
This change avoids a double space between the attributes.

Before this change the HTML contains:

  <a class="mw-wiki-logo" href="..."  title="...">

After this change the HTML contains:

  <a class="mw-wiki-logo" href="..." title="...">

Change-Id: I486d26bd56a4410766f40b78466c2f3559f3a1ff
2019-01-14 06:46:33 +01:00
Fomafix 82cbdb8111 Avoid empty class="" without value
Before this change the HTML contains:

<div id="p-personal" role="navigation" class="" ...>
or
<div id="p-personal" role="navigation" class=" emptyPortlet" ...>

After this change the HTML contains:

<div id="p-personal" role="navigation" ...>
or
<div id="p-personal" role="navigation" class="emptyPortlet" ...>

Change-Id: Ic686b958940afc958693d0031ac31e5f783960a9
2019-01-13 20:02:01 +01:00
Volker E da6d4eb280 Remove unnecessary div wrapper on overflow menu
Unordered lists can be absolute positioned down to IE 7.
Outdated selector `.vectorMenu ul` remains for a release cycle
until HTML cache is renewed.

Bug: T209558
Change-Id: Id18ca9a8d705572b1f7e17920ef52b80e9aec373
2018-11-14 20:41:08 -08:00
jenkins-bot 7fd98697f1 Merge "Let Html::element do the output encoding" 2018-06-12 19:52:25 +00:00
Fomafix eccd074386 Let Html::element do the output encoding
Change-Id: I07913d3cd1851df06de912a0257b01a5fae7c125
2018-06-12 16:56:24 +02:00
Fomafix 44fd986540 Use $this->getMsg instead of wfMessage
Change-Id: Ief31c2d9037b5786657507e28ae75b6e467cccb4
2018-06-12 16:39:57 +02:00
Timo Tijhof b843094a2d Re-implement and improve mw-jump links with pure CSS
* Improve their accessibility by giving both links
  a full label "Jump to x" and "Jump to y" instead
  of "Jump to: ", "x", "y".

  This also makes things much better for localisation, for which
  we generally discourage use of concatenation.

* Use pure CSS for the toggling of the visibility on focus,
  instead of relying on JavaScript. Especially given the
  JS comes form core's 'jquery.mw-jump' module, which is
  considered technical debt per T195256. Alternatively,
  that could be copied to vector.js, but pure CSS
  is possible, so why not.

* Use plain <a> links in the HTML instead of wrapped in a <div>.
  This solves the long-standing problem whereby the margin
  between #contentSub and #mw-content-text had to be awkwardly
  negated and overridden in core and on various to make sure that
  the wrapper itself would become visible as needed, in a way that
  has margin around this. This whole problem doesn't apply when
  simply using inline links that aren't part of the regular flow
  with .mixin-screen-reader-text. On focus, the individually
  focussed link appears in regular flow, without the need for
  any custom styles.

* This uses :not(:focus) to naturally make it render in the default
  way on focus, and visibibly hidden/clipped otherwise.
  This is supported in IE9+ and Android 2+.
  There is a way to make it work with CSS2 for IE7-8, by applying
  the mixin to '.mw-jump-link' only and then undoing all of
  'position', 'width', 'height', 'clip', and 'margin' on :focus.
  But I'm not sure that's worth it here. The fallback in IE7-8
  for not supporting ":not(:focus)" is that the accessibility
  link is simply visible always, which seems like a good fallback
  for accessibility, and doesn't hurt anything.

Bug: T195256
Change-Id: Icaadb290f692b3617688d32cbb66dfb007f1c82c
2018-05-24 00:08:02 +00:00
Max Semenik eb145c8ce4 Don't use deprecated Sanitizer::escapeId()
Change-Id: I96354291594f1fcb8a263318e93fd1c059aa006d
2018-04-13 16:30:27 -07:00
Isarra b473ce1ff6 Remove unnecessary $portals['SEARCH'] = true;
Search is skipped in the sidebar 20 lines down regardless. This does
nothing.

Change-Id: If6d3dd21280211fa3511ce010a3f3fda6185a7ef
2018-03-17 18:50:55 +00:00
Timo Tijhof 2fa3b7f69a Move class files to includes/
Cleans up the top-level directory a bit.

Change-Id: I29d3b8b7098def77e643232a386d8ba834d35704
2018-03-12 16:52:48 -07:00