User:Zexi.gong721/Final Report

Project Overview
The objective of this project was to establish an efficient workflow that enables users to retrieve media relevant to a currently viewed topic in Wikidocumentaries from a designated media repository and upload it to Wikimedia Commons while incorporating structured data statements. The project aimed to address various challenges in authentication, media upload, and structured data generation.

Mentors: Susanna Ånäs, Tuukka Hastrup

Authentication
The authentication component was a pivotal aspect of the project, as it allowed users to securely interact with Wikimedia Commons. Until now, the OAuth 2.0 authentication mechanism was successfully integrated into the project. The authentication aspect of the project was addressed by introducing a visual indicator in the toolbar that reflects the user's status. The authentication aspect of the project was addressed by introducing a visual indicator in the toolbar that reflects the user's status.

Clicking on this icon triggers a dropdown menu that provides options for logging in or logging out, along with displaying the username if the user is logged in.

Upon clicking the login option, users are redirected to the Wikimedia Commons authentication page. After successful login, users are automatically redirected back to the previous page in Wikidocumentaries, creating a cohesive and uninterrupted experience.

Upload
The upload functionality was essential for allowing users to directly contribute media to Wikimedia Commons through Wikidocumentaries. This component aimed to implement the upload process and associate relevant metadata with the uploaded media.

The upload component encountered challenges due to outdated and oversimplified examples in the upload API documentation. The discrepancy between the documentation and the actual process complicated the implementation, and we had to invest significant effort into structuring the API requests correctly. Additionally, the error messages received during the upload process lacked specificity, causing us to struggle with pinpointing and resolving issues. For example, the permission denial error appeared frequently without clear indications of which permissions were lacking. Until now,

The upload component of the project focused on optimizing the process of contributing media to Wikimedia Commons. A significant enhancement was the introduction of an interactive popup that displays essential image information, including title, description, license, category, author, and date. This popup is triggered when users click the action menu for an image in the image grid, and then click the upload.

//picture

This information is invaluable for users to validate and verify before proceeding with the upload process. To complete the upload, users can click the designated "Upload" button within the popup. Behind the scenes, the image information is parsed into Wiki text format, ensuring compatibility with Wikimedia Commons' requirements. The parsed information is then combined with the uploaded image and submitted to Wikimedia Commons through the API.

//picture

If the license information from the source of this image indicates that this image is not eligible for upload, the upload button will be disabled and show a message that tells the user about the license constrains.

//picture

The integration of this popup interface, along with the seamless conversion of image metadata into Wikitext, was achieved through a combination of user interface design and backend logic. This enhancement simplifies and accelerates the media contribution process while maintaining compliance with Wikimedia Commons standards.

Structured Data on Commons (SDC)
The structured data aspect of the project focused on generating meaningful structured data statements for media files uploaded to Wikimedia Commons. These statements would enhance the contextual information available to users exploring the media. After the successful upload of an image, an important enhancement was implemented to automatically add the image's category (depict) as a structured data statement for that image.

After the successful upload of an image, an important enhancement was implemented to automatically add the image's category (depict) as a structured data statement for that image.

//picture

The integration of this functionality involved collaboration between the uploaded image's metadata, the selected category, and the Wikimedia Commons' structured data system. This feature enhances the overall quality and accessibility of media files on Wikimedia Commons, aligning with the platform's mission to provide accurate and informative content.

Links of code
https://github.com/Wikidocumentaries/wikidocumentaries-ui/pull/108

https://github.com/Wikidocumentaries/wikidocumentaries-api/pull/31

Summary
In summary, the project successfully streamlined the media contribution workflow for Wikidocumentaries by addressing challenges in authentication, media upload, and structured data generation. The integration of OAuth 2.0 authentication facilitated secure interactions, while the upload functionality simplified media contribution. The generation of structured data statements enhanced the value of media files on Wikimedia Commons.

@startuml

actor       User as Foo1

Foo1 -> Frontend : click upload button

Frontend -> Backend: Oauth2 token

Backend-> CommonsAPI: get csrf token request with Oauth2 token

CommonsAPI-> Backend: csrf token

Backend-> Frontend : csrf token

Frontend -> Backend: finna Id

Backend-> FinnaAPI: download image with finna Id

FinnaAPI -> Backend: image data

Backend-> Frontend : download success

Frontend -> Backend: tokens, finna Id and image text

Backend-> FinnaAPI: check image info

FinnaAPI -> Backend: image data

Backend-> CommonsAPI: upload image

CommonsAPI-> Backend: upload response

Backend-> Frontend : upload response

Frontend -> Foo1 : upload response

@enduml

[//www.plantuml.com/plantuml/png/XPB1JeGm48RlVOfv03teaODPDTbaJthn0SOoB0JQmSuqw-FR1RRKs4GkGF__dtu_z22AGQER35hb0Elr8HG01OxC3yQOwmtkd-0Os2lv5Xgmqs17YFF4sC9dL6LlJDQJzmNjc1uRUCEe_ICefrUphIRzbPrZBy_lfmREf60bTAi90dr54eNBeFtl-1ugTyZHVNx9Mkfrn6xm7k7Kbl7hqWBNyiKlBGU7PrgXSk1cAyTjnXOLwpnveaHhIQHEjHBBNTuCqDyWbBwr2cjxikDc6dp7_mBMVqYSzyRLZvujWMHE8jMQ_ZMLHPV3LVCSaXxTz0C0 //www.plantuml.com/plantuml/png/XPB1JeGm48RlVOfv03teaODPDTbaJthn0SOoB0JQmSuqw-FR1RRKs4GkGF__dtu_z22AGQER35hb0Elr8HG01OxC3yQOwmtkd-0Os2lv5Xgmqs17YFF4sC9dL6LlJDQJzmNjc1uRUCEe_ICefrUphIRzbPrZBy_lfmREf60bTAi90dr54eNBeFtl-1ugTyZHVNx9Mkfrn6xm7k7Kbl7hqWBNyiKlBGU7PrgXSk1cAyTjnXOLwpnveaHhIQHEjHBBNTuCqDyWbBwr2cjxikDc6dp7_mBMVqYSzyRLZvujWMHE8jMQ_ZMLHPV3LVCSaXxTz0C0]