Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required extension and settings #15

Open
Citronhat opened this issue Jan 7, 2020 · 3 comments
Open

Required extension and settings #15

Citronhat opened this issue Jan 7, 2020 · 3 comments

Comments

@Citronhat
Copy link

I'm trying to get your extension to work with my wiki at the Miraheze wiki farm. It works perfectly well with wikipedia.org, so I suspect the issue isn't with the Wikipedia Peek extension, but with rather with the localSettings.php at Miraheze or perhaps with the extensions I have enabled in my wiki.

If you could please help me understand what settings and extensions Wikipedia Peek rely on, it would be very much appreciated. Wikipedia Peek is - as far as know - the only way to get large previews that can handle <math>, which is a feature I find very useful.

I'm pretty sure that TextExtracts is needed and that extension I do have. I use the Firefox browser.

@NiklasGollenstede
Copy link
Owner

Cool, happy you want to us it!

In terms of support, the Wikipedia/Mediawiki loader builds a single query to your API endpoint. That needs to be supported, but I don't know which components are required on your server for that to be the case. Here is the query: https://github.com/NiklasGollenstede/wikipedia-peek/blob/master/background/loaders/wikipedia.js#L65-L71

As for settings of the extension, have a look at Content Loader Modules > Wikipedia and Mediawiki > Advanced > getApiPath. That may need to be adjusted. Its pretty stupid that different installations have the API endpoint at different paths. Maybe instead of that function (which isn't user friendly at all), it should try multiple locations first and then cache it per origin.

@Citronhat
Copy link
Author

Your extension could definitely be useful to me - hence why I have spent more time than I care to admit learning some basic javascript. Unfortunately, it seems my skills are still inadequate. I can't seem to console.log() neither the API path nor the query.

I'm trying to use the Firefox Debugger, but with no luck. I think it's more difficult because the UUID changes with each built, so when I try to look at stack trace, Firefox looks for file like this
moz-extension://fa0d5722-a3f7-4127-a7ee-a828c46bd18e/content/panel.js, which it cant find during debugging.

So if you please help in the right direction, by specifying how find the query, that WP sends, it would be a big help.

@NiklasGollenstede
Copy link
Owner

Ok, so first thing I forgot to mention is that this is only available in the -dev version, but you seem to have found that.

And then it is to note that, for security/sandboxing reasons, the (user provided) code of that function gets executed in an isolated context, which seems to swallow all debugging output (i.e. console.log and the likes won't work).

the UUID changes with each built

For any given installation/profile, that UUID should remain constant. Not quite sure how you are loading the extension. Just installing the -dev build from the releases should work.

Make sure to have https://citronhat.miraheze.org/* in Content Loader Modules > Wikipedia and Mediawiki > Include Targets and also in the top level Included Sites (which is actually pretty redundant).

If you then set Content Loader Modules > Wikipedia and Mediawiki > Advanced > getApiPath to

url = new URL(url);
if ((/(?:^|\.)(?:wiki[^.]*?|mediawiki)\.org$|^citronhat[.]miraheze[.]org$/).test(url.hostname)) {
	return 'https://'+ url.host +'/w/api.php'; // always use https
}
return 'https://'+ url.host +'/api.php'; // always use https

it loads from the correct API path.

I could only find a single page on your Wiki. Loading for that results in the query: https://citronhat.miraheze.org/w/api.php?action=query&format=json&formatversion=2&redirects=&prop=extracts|pageimages&exintro=&piprop=thumbnail|original&pithumbsize=250&titles=Analyse_2_(2)
With current response:

{
  "batchcomplete": true,
  "warnings": {
    "main": {
      "warnings": "Unrecognized parameters: piprop, pithumbsize."
    },
    "extracts": {
      "warnings": "HTML may be malformed and/or unbalanced and may omit inline images. Use at your own risk. Known problems are listed at https://www.mediawiki.org/wiki/Extension:TextExtracts#Caveats."
    },
    "query": {
      "warnings": "Unrecognized value for parameter \"prop\": pageimages."
    }
  },
  "query": {
    "normalized": [
      {
        "fromencoded": false,
        "from": "Analyse_2_(2)",
        "to": "Analyse 2 (2)"
      }
    ],
    "pages": [
      {
        "pageid": 148,
        "ns": 0,
        "title": "Analyse 2 (2)",
        "extract": ""
      }
    ]
  }
}

So it seems your Wiki doesn't support thumbnail extraction, which isn't critical, but also the extract for at least this page is empty, resulting in the preview to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants