Page MenuHomePhabricator

Mobile server resolves {{SERVER}} and {{SERVERNAME}} incorrectly
Closed, ResolvedPublic

Description

Author: snottywong.wiki

Description:
When viewing a wikipedia article from the http://en.m.wikipedia.org/ server, the magic words {{SERVER}} and {{SERVERNAME}} both resolve to "http://en.wikipedia.org". The impact is that we have no way of testing whether the user is on the mobile site, and therefore no way of hiding/showing elements which don't display correctly on mobile phones, or which aren't appropriate for mobile users. We also have no way of creating elements which display differently on the mobile site than they do on the regular site.

Expected behavior: {{SERVER}} and {{SERVERNAME}} should resolve to "http://en.m.wikipedia.org/" when a page is being viewed via the mobile server.


Version: .5
Severity: normal

Details

Reference
bz26807

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:15 PM
bzimport set Reference to bz26807.

I'm don't know enough to say for sure, so:

Hampton is this fixed in the mobile code or should it be in MW itself?

hcatlin wrote:

I am not really familiar with what those mean at all.....

I'm not sure what the bug is..

The mobile interface is a proxy application which lets MediaWiki render basic page text, then modifies it to optimize for small screens and puts it in a mobile-specific user interface. Wiki pages have no way of "knowing" inherently that they're being viewed in another way; modifying the styles (and sometimes markup) is the mobile proxy's job.

{{SERVER}} and {{SERVERNAME}} are keywords in wiki syntax which return the wiki's hostname (in the former case including the protocol prefix). They are sometimes used by templates to generate arbitrary links to something on the site, which isn't always a super safe practice but can be handy.

If constructing an arbitrary link in a wiki page, doing it with the canonical URLs is probably the right thing to do -- you don't know that the mobile proxy will have such a link at its domain.

What I'd recommend is that there be documented ways to mark sections of a page as to be hidden for mobile or marking that something can be optimized in a particular way. CSS classes are probably good for this.

hcatlin wrote:

Anything marked with

.noprint
div.messagebox
.hiddenStructure

is automatically stripped out.

would it make sense to add ".nomobile" to the list?

hcatlin wrote:

.nomobile has been added to the list of things automatically removed.