Receive Wikimedia commons media filePath from file name - mediawiki

I trying to build an analytics web ui for the media request data, from the wikimedia REST API
To get media request data, I need to pass filePath in wikimedia commons. For example:
For this sphinx image I need to pass the following filePath: /wikipedia/commons/9/96/Sphinx_Metropolitan.jpg
Currently I need to do it manually (in the image page, I need to copy the image URL from the embed dialog), is there a way to get the filePath programmatically?

I found this api, that provides the wanted information:
https://magnus-toolserver.toolforge.org/commonsapi.php

Related

Is it possible to create an HTML link to a specific API within a JSON Swagger file?

I have swagger files with URLs like https://gitlab.com//blah/blah/Orders_Swagger.json. I'm building some documentation that links to these files; that works fine. Gitlab renders the page with nice formatting. But some swagger files have dozens of APIs and sometimes I want to reference a specific, critical API, not just send the user to the top of the page.
Swagger UI supports a "deepLinking=true" configuration parameter. It is set to false by support. Gitlab embeds Swagger UI, but does not provide a way to set this parameter, so it is off at the server level.
However, you can enable it by passing a parameter in the URL: &deepLinking=1
Thus, a full, API-specific URL will look like this:
https://gitlab.com/company/blah/blah/Swagger.json?deepLinking=1#/section/targetApiName

How to retrieve data directly from .json file present on GitHub?

I am developing a Dialogflow chatbot and I found an useful Q/A '.json' file on GitHub. Is it possible to retrieve data directly from GitHub to Dialogflow? if yes, how can I it ?
Maybe, you could try to make a GET request and trying to get a jsonp file.
But chances are, that GitHub doesn't allow CORS (Cross Origin Ressource Sharing).
You can only try it out yourself.
Fetch that file as a raw Github file which will have a similar link like this. https://raw.githubusercontent.com/google-research/bert/master/sample_text.txt

Can I upload a zip file with htmls or a zip file with json files using the Web Interface of Watson Retrieve and Rank service?

Can I upload a zip file with htmls or a zip file with json files using the Web Interface of Watson Retrieve and Rank service ?
No, the web interface doesn't support that. It will let you upload multiple doc/PDF files in parallel though, without needing to zip them (up to 50 at a time)
But if you've already got your content in the right JSON format, you can post it directly to the R&R collection (e.g. Using curl or your scripting language of choice) without the web interface anyway.
The content will show up in the web UI when you come back.

Add API documentation to website using Swagger document

I have a basic webpage built, and a Swagger document JSON file of my API. I am unsure of how to actually add the data from the document to the website so that it can be browsed.
I want to build hosted documentation for the API.
This is the example given by Swagger: http://petstore.swagger.wordnik.com/#!/pet/addPet
Do I just download Swagger UI and use it in conjunction with the JSON file.
But I am unsure on to achieve this. Any advice on how to go about creating something like this would be very helpful.
Swagger-ui is basically a set of static files you can host on your server to display your API.
Unless you may any major changes, you just need to copy the contents of the /dist folder to your server and host it as part of your application (or static website, doesn't matter).
The SwaggerUi object can be customized to your needs, including the URL of the spec you're hosting.
Keep in mind that if you don't host the ui and spec on the same server, (that is, same host and same port), you need to enable CORS.

Google Maps Markers which image files are within a jar file

My web application is based on Google Maps API and I have problems trying to access an image which is within a jar file.
I want to be able to do two things:
Show a marker in the javascript map.
Show a marker in a static map.
In both cases I need to provide the path to the image file. This image is inside a jar file which is located in the /WEB-INF/lib folder once the web application is deployed in the server.
I thought that the following line would work:
iconMarker.image = "WEB-INF/lib/cimCore.jar!/META-INF/resources/img/" + ilMarker.icon;
But it shows the following error in the client browser:
"NetworkError: 404 No Found- http://ip/cimWeb/WEB-INF/lib/cimCore.jar!/META-INF/resources/img/gsearch.png"
The path is OK so I guess that accessing by means of '!' character is not the proper way.
Any idea?
You'll have to use a servlet which will load the image bytes from the classloader, and stream these bytes to the response :
Use MyServlet.class.getResourceAsStream("/META-INF/resources/img/gsearch.png") to get an input stream on the image
call response.setContentType("image/png")
get the response output stream
read all the bytes from the input stream and write them to the output stream
Note that most of the MVC frameworks have support for mapping a pattern of URLs to classpath resources, or to at least implement one part of the algorithm above for you.
Or you can just extract these images out of the jar file, and put them in the webapp's tree of externally accessible resources.
Side note: WEB-INF is, by design, not accessible from the outside. If what you wanted to do was possible, anybody could steal the jar files and configuration of any Java-based webapp.