Topic on Project:Support desk

Jump to navigation Jump to search
Evolution and evolvability (talkcontribs)


What would be the necessary steps to enable this code to embed in a page:

<span class="__dimensions_badge_embed__" data-id="pub.1067741279" data-hide-zero-citations="true" data-style="small_circle"></span><script async src="" charset="utf-8"></script>

See for info

It would be highly useful to be able to get them working on WikiJournal articles.

Jonathan3 (talkcontribs)
Evolution and evolvability (talkcontribs)

Thanks - I've also copied a message over at that talkpage for its watchers.

Bawolff (talkcontribs)

Using extension:Widgets is one approach.

Another approach is to put the first part:

<span class="__dimensions_badge_embed__" data-id="pub.1067741279" data-hide-zero-citations="true" data-style="small_circle"></span>

on the page, and add

mw.loader.load( '' );

to the page named MediaWiki:Common.js on your wiki instead of the script tag (This is a special page name in your wiki that contains extra js to load)

Evolution and evolvability (talkcontribs)

Magical Thank you. You can see the results on a test wiki here:

I'm now trying to get the AltMetric badges working via a similar process. Its documentation says to inlcude:

<script type='text/javascript' src=''></script>

So I assume the relevant MediaWiki:Common.js addition is:

mw.loader.load( '' );

Does that look correct?

Bawolff (talkcontribs)

should be. Thag script tag doesnt have the async flag so there is a small possibility it wont like being loaded asynchronously, but it will probably be fine.

Also remember, including external js allows that website to potentially track your users. For many sites this is fine, just wanted to make sure you are aware

Evolution and evolvability (talkcontribs)

Thank you - I'll check up on the details on whether those badges also track.

Altmetric badges seem to work fine.

Implementing crossmark seems to be more complex. My understanding is that the page would just need:

<a data-target="crossmark"><img src="" width="150" /></a>

and also

<meta name=”dc.identifier” content=”doi:10.5555/12345678” />

Seems to not implement in this case though. I suspect it's something to do with the <meta...> tag. Any ideas?

Jonathan3 (talkcontribs)

You can add meta tags using Extension:WikiSEO but that might be overkill - maybe a Widget would be best after all :-)

Bawolff (talkcontribs)

If you set $wgAllowImageTag to true in LocalSettings.php, you can sort of do the first part as

<img src="" width="150" />

However, only meta tags using itemprop are allowed, and <a> tags with data attributes are not allowed in wikitext. This would be a good case for the Widgets extension.

Evolution and evolvability (talkcontribs)

I'm not sure how to ask for a widgets extension. Is that something to do with pharbricator?

Bawolff (talkcontribs)

Oh, I didn't realize this was for Wikimedia. Widgets extension is not going to be installed on wikiversity. You could ask on phabricator for a custom extension for this. It might also be possible to do something more complex for this in MediaWiki:Common.js

Please note: Much of what I suggested above regarding adding mw.loader.load() to MediaWiki:Common.js is not allowed under the Wikimedia privacy policy, and is not allowed to be used on Wikimedia Websites.

Evolution and evolvability (talkcontribs)

Ah, I see. Thank you for the clarification! Is the reason for not using mw.loader.load() on any wikimedia platform a fundamental limitation, or something where the privacy issues can be fixed via some extension/gadget/software solution? (sorry for being vague, I'm not very well versed in the technicalities).

Bawolff (talkcontribs)

basically mw.loader.load loads javascript. If its loading something from wikimedia thats fine. If its loading from somewhere else, the other site could use that to track users or do other malicious things

Often you can just copy the external script locally and then its ok if the external site is taken out of the mix

Evolution and evolvability (talkcontribs)

That makes sense. Who would be sensible to contact about helping out with attempting to do that (and do you have any feel for whether it is likely to be 1 hour or one month of work)?

Thanks again for all the help on this!

Bawolff (talkcontribs)

For best success, I'd say come up with a comprehensive list of everything you need (along with explanation of why you need those things & what you are trying to accomplish). Once you have that, I'm not sure who best to reach out to, but first people to try might be m:community tech or a community liason.

Evolution and evolvability (talkcontribs)

Thanks! I'll put together a more comprehensive description to explain the background, aims and expected outcome.

Reply to "Embedding Dimensions badges"