 The next session is from Luca Mauri and about Wikibase starting from scratch. Hello, good afternoon. Thank you for having me. So, welcome to this presentation. As you can see from the title, we are now discussing about setting up a Wikibase instance from scratch. Just a few words to me. I work as an IT manager for companies unrelated to Wikimedia and a lot, but I am administrator of a couple of MediaWiki sites for personal projects. So, at a certain point on my journey to use MediaWiki, I discovered that for my personal project I needed to use the data from a Wikibase instance, or originally I thought about using the data from Wikidata. So, when I started looking in MediaWiki data on how to access the data from my own MediaWiki instance, from Wikidata to my instance, I discovered what you can read in the right part of the slide that actually the access to Wikidata is restricted to the Wikimedia project. So, from that, I understood that there was no way for me to get data from there. In the last sentence, as you can see, the text invites the user to set up a own Wikibase instance. So, the purpose of this presentation is actually to guide you and... Oh, sorry. You can't see the slides. You should see the first title slide. Okay, very good. So, well, you didn't lost anything. Very important, it was just a basic presentation on the text on the Wikidata that actually suggested the user to go on setting up a personal Wikibase instance to get access to the data. So, the goal of this presentation is to actually tell you what I did to help possibly other users to set up a Wikibase instance as I originally did. So, first of all, a little introduction to Wikibase. If people here are not aware of, actually Wikibase is the extension or the set of extensions that make Wikidata runs. So, Wikidata, for the people that don't know it, not knowing this, is a media Wikibase instance with the Wikibase extension installed on it. So, while Wikidata is, of course, the most important, the most known Wikibase instance to the public, everyone can set up his or her own Wikibase. As Wikibase is not very, very well understand and very well known outside the small community, I think that sharing the experience I had with it and setting it up is something that might benefit other users and also see that the difficulties I found might help other people not to encounter the same one. So, what we are going to do is starting from scratch, meaning we will start from two existing media week installations that I take for granted. You will know how to set up and we will adapt the two of them in the same way basically as Wikidata and the Wikipedia are set up. So, we will set up one media Wiki instance with the two extension Wikibase repository and Wikibase client enabled. And we will call this for the sake of privacy for the rest of the presentation as a server, while the second Wiki will only be enabled with the client part. So, we will simply call it client in brief for the rest of the presentation. So, at the end we will end up with two media Wiki instances similar to Wikidata and Wikipedia and a lot. So, the very first thing to understand is that Wikibase is as usual packaged in an extension package that you can download from the site as every other extension. It doesn't work on very old Wikimedia version, for instance the 1.29 that I was using in the past was not compatible, but in the past couple of years, sorry, I tested it on several versions like the 31, 34 and 35 that is the current one I am running on and they are all working quite well. So, as usual nothing difficult here, the extension needs to be uncompressed in the folder, but from now on the interesting part starts. So, next step are first of all to use Composer and second to do the basic configuration of the Wikibase. What is Composer? For the people not knowing it, for instance me when I started to work with Wikibase, Composer is a so-called application level package manager. So, it's a PHP package manager that takes care of managing all the libraries within the media Wiki installation. Also, it is of paramount importance of course to continue with the Wikibase installation and it can only be along the way. I discovered that it is also very useful for other tasks, for instance for the automatic extension installation in other cases. The key to operate Composer for extensions is to use or to edit a file that is called composer.local.json. There is an extensive documentation that I link here, of course, during over the course of the presentation we can only briefly discuss it, but for reference you can find the link to the full documentation there. So, here on the right you can see a basic example of the Composer.local.json. Please note that this file is separate from the Composer.json that manages the media Wiki installation itself. This one is for locally-installed components. So, you see that the most important part is the two strings that I highlighted in blue. The first one is the Installing Composer to automatically install a package that is called monologue that is used as a prerequisite for Wikibase. While the second one, you can see there is a merge plugin that includes a JSON configuration file that is in the extension folder of the Wikibase extension to take the data from there and also install all the libraries that are included in that JSON file. So, Composer automatically cascades down along the files and downloads the one needed. Just for an example, but this is not strictly related to Wikibase, I show you how you can, for instance, automatically install another extension. This is an extension I wrote myself that when I need to install on my media Wiki setup, I find very easy to simply put into the Composer.local.json. You don't need to manually install, download or put anything in any folder. A line like this in the Composer.local.json will work automatically by downloading the packages and install them. Remember that normally the source of the packages is the packages.org repository. After you edited the Composer.local.json, it is necessary to start the Composer executable that takes care of installing all the packages and the libraries needed. After this is done, it is necessary to do the configuration of the Wikibase like any other extension. Of course, it needs to be enabled. As I mentioned before, there are two main parts of the extension. One is the repository, the server, and the other one is the client. On the media Wiki instances that we are calling server, I enabled both of them, as you can see on the right. While on the Wikibase, the media Wiki instance that should work as a client, it is only necessary, of course, the one that is named client. The two required ones statement ask the local settings to import the basic settings that you can see in the Wikibase and the example settings.php. Those are the very basic settings. Some of them we are going to overwrite later in the course of the presentation. But you might want to have a look at them because you can see the full extent of the number of the options available and how they are set as a default. After that, you can immediately work on the server instance. It will work immediately. If you go on special pages, you will find a whole new sections with the Wikibase thing. You can start creating items and properties exactly like you do on Wikidata, for instance. The client instance will not work immediately because it needs some configuration that we are going to see in a second. Please take note and remember that the settings are named client settings and repo settings. You can immediately understand when you are setting up if you are acting on settings that affect the server or the client. Let's start with the client. This is a very basic configuration. Of course, there are a lot of options to configure. For your reference, I wrote here the link to the list of all the settings, but we will go through the easiest one. This one needs to be added, of course, as usual to the local settings.php after you loaded the extension as the previous slide. The first few parameters are the configuration telling the client where to go on the Internet to take the endpoint of the server one. This is basically the location of the server's media-week instance. If you did the installation, you should know already all the data, but you can reference all of these data from the special version page of the server. The data you take from the server you put here, as you can see, this is a client setting, but the options are called repo. You are telling the client what the data regards the repository. This is, I think, pretty straightforward. This is the configuration of the database of the, again, of the repository. So you are telling the client what is the repository database. Normally, it's simply the name of the short name of the Wikibase installation. And as usual, it's configured on the local settings on the server part. After that, there are two very important settings here. These settings define the name of the client wiki and the group of the client wiki. Please take mental note of these two data because they are very, very important. We will get to them in the server configuration to see the full extent of their importance. So this will, again, will identify this client wiki and the group this client wiki is part of. So now that we configured the things you saw in the previous slide, basically you can use the client instance and getting data from the server one using what is called the arbitrary access. The arbitrary access means that you, as you do normally with the wiki data, you need to use the statement, a magic word. You can query for a property, but you only need to tell from where item, from what item you need to take. You see that in the first example here, I have a from field telling the client what item I need to read from. This is okay. This is versatile, but normally the way you are used to get data from wiki data in wikipedia site, for instance, is using the direct access, meaning a page on the wiki is linked to an item on the wiki base installation and you simply need to ask for the property to get them. The system already knows what item is linked to what page and you only need to ask for the property. So how is this achieved? You might be surprised by the fact that till the spring of 2019, this was not clearly explained in the public documentation of wiki base, how to achieve this. I linked here a few discussions that we had, me and of course many other users had, and what we discussed on how to improve the documentation to clearly explain this. Bottom line, the point is that and be very careful. This is the most important topic of the configuration of the wiki base is the configuration of the site links. The site links, you might know, I put just a very simple example on the right from wiki data, that are a list of links from wiki data to the linked pages on other wikis. From a user perspective, this might seems to be the only use, meaning a list of links of this item in other wikis. But in fact, this is the underlying way that the server can link an item to a page in a wiki. You absolutely need to set the site link up in order for the direct access to work. So now we are going to understand how to set this up. First of all, we need to set up the table that is named sites. The sites table is the table that media wiki use to knows other sites that the media wiki instance need to relate to. Of course, it serves a lot of purpose, but for the reason of this presentation, we are only looking at it as a way to use site links. So first of all, you need to populate the sites table with the sites you need to link and the sites you need to create site links for. There's a script that is called populate sites table that of course automatically populates the sites table with the sites that are known to the wiki media foundation. But for your personal wiki base setup, of course you need to import a custom list of sites. How to do this? There are several ways to do this. The easiest way that I found is to use an XML file. An XML file that you see an example on the right and you can see the full documentation on the sites table of the media wiki manual. This XML file that you can easily also create by hand or export from other sources can be imported in the sites table to automatically generate the proper rows. As you can see here, there is an import site script that takes the XML file incidentally. Of course, it also exists an export site script doing the same thing, doing the exporting of course, while the import sites takes the XML file and creates the rows in the database with the proper information. Here on the bottom part of the slide, you can see an example on how the data from the XML file shown here are actually imported in the sites table. So this is how to populate sites table. So this is the way for the media wiki to know the sites we are going to connect to. Now, let's proceed with the server configuration. By the way, partner is left and we have one question as far as I can see, so you can arrange your time. Okay, okay, I will cut short and then we will go to the questions. So the server configuration. Again, there are a lot of options you can see that are referenced here, but the most important thing as before is how to set up the group that needs to be included in the site links column. You remember before I told you about the name of the wiki and the group the wiki is part of. So the group that the wiki is part of needs to be written here in these repositories. This one is for the group that are shown directly and these one are the groups that are shown together in the special links group. They are just shown in a different way, but they mean the same thing. So the group is configured, you remember, on the client. It is written in the sites table here. The name of the site is written on the client configuration as we saw before. And when you tell the server side to list a special group, the server takes all the site from the group in the sites table and reads the name that is configured in the client. So this way we are telling the server what sites needs to be included in the site link on the right part of the screen and then you see the links directly. But this is the way for the server to know how to create the direct link and the direct access to the client. So everything runs with the name of the site, the group to which the site belong and the configuration of the sites table as you see here. This is again the most important setting in the configuration of a wiki based instance server and client because it is the configuration that allows the exchange of data with the direct access. Just for your information, if you want to go deeper with the configuration of all now to configure site links and inter wiki that in my tests. I discovered it is worth treating as a single reason reason, a single concept, you can go reading a blog post I wrote on dev that I referencing here, I will not spend too much time here because we have just a few minutes left. But if you're interested, you can simply go to and read that this is another very interesting configuration server configuration is the formatted URL. The format URL is a parameter that identifies a property that can be used as a template to construct URL. It's easier to see an example. This is an example from wiki data data again for easier understanding. You know that the wiki data has for instance a Netflix ID property that has a string containing in it. This Netflix property contains the format URL that is defined in the server configuration file and that format URL contains the string with the placeholder. The combination of the format URL and the data here creates the you URL to go directly when you click here you don't see the full URL but it is constructed behind the scenes. Another interesting topic to discuss is where to point when you use the slash entity slash name of the entity or name of the entity.json or dot XML or whatever. What is the page that actually the server needs to go and get to return the data you asked. So here there's a mapping of the entity to of course the special entity data page. Again if you are interested in looking deeper into this topic I have a blog post that is one minute left. Let me just see if we have any other quickly topic. This is how to set up the sections. There is something you might have seen in the media wiki. This is just Michelinus thoughts but basically the presentation is done like this. Sorry for the wild ride. It was a lot of things in a little bit of time. It was an amazing session. Thanks. And there is a huge request that for you to share this slide. Yes. The slides will be loaded on commons. I will load them on commons. Amazing. So maybe we can answer questions in the chat so we can finish the session here because we are out of time. Out of time. Okay. So thank you very much for having me and have a nice afternoon. Thank you. Bye bye. Bye bye.