User signature time wrapped in a span

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

User signature time wrapped in a span

Misdre
I recently tried to create a small javascript to parse user signature times
on talk pages [1]. With it the readers would have been able to see the
signature's timestamp in their preferred timezone (and as a side effect it
would be consistent with the revision history) without breaking caching.

The main problem I had was that MediaWiki didn't provide a class attribute
wrapping the date nor the whole signature. There is a bug report on that
topic: https://bugzilla.wikimedia.org/show_bug.cgi?id=25141

After some time spent looking for a system message it seems the only
solution is to edit includes/parser/Parser.php. I added a span with a class
at this line:
https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob;f=includes/parser/Parser.php;h=5b14ad21b951e81980ed6841876f259eb057dd87;hb=HEAD#l4532

It works fine (at least in my own - limited - case).

Some questions related to what I've done:
- Would it be possible to wrap dates, or at least signatures in a class, as
suggested in bug #25141? it may be useful for others too
-- or perhaps to have a system message for dates (I'm not sure it's a good
idea)
- Is Parser.php the good place for that?
- Would a similar solution see its way into MediaWiki some day? or are
there problems I'm not seeing? (I'm not suggesting my script would be it,
it's a quick and dirty hack created with very limited knowledge.)


[1] using Moment.js <http://momentjs.com/>
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: User signature time wrapped in a span

Brion Vibber
Well, the *proper* fix is a sane discussion system where messages are
first-class objects and timestamps are clean metadata that can be displayed
appropriately. :)

As a hack for existing talk pages though, what you're proposing should work.

Parsing the timestamps in the text is a bit tough as it may be different in
different languages.... my recommendation is to include a 'data-timestamp'
attribute on that span and put in a language-independent machine-readable
timestamp format.

See also older discussion on bug 5347 <
https://bugzilla.wikimedia.org/show_bug.cgi?id=5347> and 19992 <
https://bugzilla.wikimedia.org/show_bug.cgi?id=19992> about possible
implementations of this sort of thing.

-- brion


On Wed, Apr 3, 2013 at 3:28 PM, Cyril <[hidden email]> wrote:

> I recently tried to create a small javascript to parse user signature times
> on talk pages [1]. With it the readers would have been able to see the
> signature's timestamp in their preferred timezone (and as a side effect it
> would be consistent with the revision history) without breaking caching.
>
> The main problem I had was that MediaWiki didn't provide a class attribute
> wrapping the date nor the whole signature. There is a bug report on that
> topic: https://bugzilla.wikimedia.org/show_bug.cgi?id=25141
>
> After some time spent looking for a system message it seems the only
> solution is to edit includes/parser/Parser.php. I added a span with a class
> at this line:
>
> https://gerrit.wikimedia.org/r/gitweb?p=mediawiki/core.git;a=blob;f=includes/parser/Parser.php;h=5b14ad21b951e81980ed6841876f259eb057dd87;hb=HEAD#l4532
>
> It works fine (at least in my own - limited - case).
>
> Some questions related to what I've done:
> - Would it be possible to wrap dates, or at least signatures in a class, as
> suggested in bug #25141? it may be useful for others too
> -- or perhaps to have a system message for dates (I'm not sure it's a good
> idea)
> - Is Parser.php the good place for that?
> - Would a similar solution see its way into MediaWiki some day? or are
> there problems I'm not seeing? (I'm not suggesting my script would be it,
> it's a quick and dirty hack created with very limited knowledge.)
>
>
> [1] using Moment.js <http://momentjs.com/>
> _______________________________________________
> Wikitech-l mailing list
> [hidden email]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: User signature time wrapped in a span

Daniel Friesen-2
On Wed, 03 Apr 2013 15:34:28 -0700, Brion Vibber <[hidden email]> wrote:

> Parsing the timestamps in the text is a bit tough as it may be different  
> in
> different languages.... my recommendation is to include a  
> 'data-timestamp'
> attribute on that span and put in a language-independent machine-readable
> timestamp format.

Note that if HTML5 is enabled on a wiki we should already support the  
basic <time> element.

--
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://danielfriesen.name/]


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: User signature time wrapped in a span

Platonides
In reply to this post by Misdre
Yes, you would have to change it at Parser.php That point would be the
appropiate one. However, given the large amount of already-posted
timestamps (and that some people may not want the spans in the wiki
source), why not simply use a regex to replace the dates in the page?


_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Reply | Threaded
Open this post in threaded view
|

Re: User signature time wrapped in a span

Brion Vibber
In reply to this post by Daniel Friesen-2
On Wed, Apr 3, 2013 at 4:15 PM, Daniel Friesen
<[hidden email]>wrote:

> On Wed, 03 Apr 2013 15:34:28 -0700, Brion Vibber <[hidden email]> wrote:
>
>  Parsing the timestamps in the text is a bit tough as it may be different
>> in
>> different languages.... my recommendation is to include a 'data-timestamp'
>> attribute on that span and put in a language-independent machine-readable
>> timestamp format.
>>
>
> Note that if HTML5 is enabled on a wiki we should already support the
> basic <time> element.
>

http://www.w3.org/TR/html5/text-level-semantics.html#the-time-element

Niiice. That's better than a custom attribute, yes.

-- brion
_______________________________________________
Wikitech-l mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l