Page MenuHomePhabricator

Change word "Link" to domain name in Page Exchange URL display
Closed, ResolvedPublic

Assigned To
Authored By
Yaron_Koren
Feb 28 2024, 5:41 PM
Referenced Files
F42295230: image.png
Mar 1 2024, 2:54 PM
F42283164: image.png
Mar 1 2024, 8:26 AM
F42283095: image.png
Mar 1 2024, 8:26 AM
F42262603: image.png
Feb 29 2024, 8:25 PM
F42261901: image.png
Feb 29 2024, 7:59 PM

Description

Right now, in the page Special:Packages defined by the Page Exchange extension, the URL for the website of any package shows up as a link, with the link text being just the English word "Link". This is doubly bad: the text is hardcoded in one language, and the word "Link" itself is not too helpful, regardless of the language. Instead, I think it would be better for the link text to be the domain name of the URL. That is, if the URL of a package is https://example.com/ABCDE.json, the link text for it should be example.com.

Note that this should only apply when it's a short link: when the user views a single package, the full URL of the package is displayed - which is good.

Event Timeline

hi @Yaron_Koren I am unable to find the page where the bug persists.
could you please help me?

@Jatinder190124 - I just assigned this bug to you. Do you have the Page Exchange extension installed?

@Rockingpenny4 - sorry, you will have to find a different microtask.

Already installed it @Yaron_Koren but not getting how to use it?

Do you understand what this extension does, and did you read the full installation instructions?

after installing from where i can found the special packages page .

image.png (1×1 px, 319 KB)

currently there is no special packages page

What do you see when you go to the page Special:Packages?

there is no link for Special:Packages?

is there any way to share my screen with you?

Okay - ideally, you should be logged in as an administrator on that wiki. Can you do that?

@Yaron_Koren hi ,
I have fixed the issue

image.png (431×1 px, 44 KB)

but not able to push the code .

this is the issue and other details

image.png (394×1 px, 60 KB)

anything that i am missing ?

I don't know why that "git push" call is failing for you - maybe it's due to the SSH key. It doesn't matter, though - just a patch file is good enough.

That fix looks pretty good! I think it will fail, though, if the URL value is not a valid URL - which can happen. Actually, if it's not a valid URL, I think the best solution is to just display the whole thing as a string, instead of a link.

That looks great! If you could just add a comment or two to explain what that code is doing, it would be perfect.

yes sure @Yaron_Koren

In summary, the Fix aims to display a link to a package's website. If the URL is valid, it provides the option to display either the full URL or just the host as the link text. If the URL is not valid, it displays the entire URL as a string.

Sure, I understand what the code does - I meant, add comments to the code.

can you give me the access to create branch on the gerrit repository @Yaron_Koren ?

I don't know how to do that, actually. But it shouldn't be necessary...

can you help in doing that because I am trying from hours but unable to do that

Also I am sharing a google meet link https://meet.google.com/zjh-aoqw-sqn
Please join if possible for you

You just have to put the whole text that you put in the file PXPackage.php, into the file includes/PXPackage.php.

is this fine @Yaron_Koren

/**

  • Display the website information. *
  • @param bool $showURL Whether to display the full URL or just the host.
  • @return string The HTML representation of the website information. */

public function displayWebsite( $showURL = false ) {

// Check if the URL is null, and return an empty string if true.
if ( $this->mURL == null ) {
    return '';
}

// Validate the URL using FILTER_VALIDATE_URL.
if (!filter_var($this->mURL, FILTER_VALIDATE_URL)) {
    // If the URL is not valid, display it as an attribute.
    return $this->displayAttribute('pageexchange-package-website', $this->mURL);
}

// Determine the link text based on whether to show the full URL or just the host.
$linkText = $showURL ? $this->mURL : parse_url($this->mURL)['host'];

// Create the HTML link element.
$link = Html::element( 'a', [ 'href' => $this->mURL ], $linkText );

// Display the website information as an attribute.
return $this->displayAttribute( 'pageexchange-package-website', $link );

}

I just meant to comment the parts that this patch adds - like, to explain things to people who don't know what filter_var() is. But the text you have in there seems alright - maybe a little ambiguous. For one option, you have "display [URL] as an attribute", and for the other you have "display website information as an attribute". It's not clear what the difference is between those two things.

check this one
public function displayWebsite( $showURL = false ) {

		if ( $this->mURL == null ) {
			return '';
		}
		// Validate the URL using FILTER_VALIDATE_URL.
		if (!filter_var($this->mURL, FILTER_VALIDATE_URL)) {
			// If the URL is not a valid URL, display it as a text string
			return $this->displayAttribute('pageexchange-package-website', $this->mURL);
		}
		// Determine the link text based on whether to show the full URL or just the host.
		$linkText = $showURL ? $this->mURL : parse_url($this->mURL)['host']; 
		$link = Html::element( 'a', [ 'href' => $this->mURL ], $linkText );
		return $this->displayAttribute( 'pageexchange-package-website', $link );

}

@Yaron_Koren

I hope this will solve everything

Change 1007677 had a related patch set uploaded (by Jatinder1901; author: Jatinder1901):

[mediawiki/extensions/PageExchange@master] Replace hardcoded link text to the domain name of the url

https://gerrit.wikimedia.org/r/1007677

Hi @Yaron_Koren which task or bug should I start next ?

This task is enough - no need to do another one. (It's not finished yet, by the way - my guess is that the current code will fail validation.)

@Yaron_Koren are you sure only one task for Gsoc proposal for wikimedia will be enough ?

Well, the choice of student is entirely up to me and Brian, so I would say yes. :)

OK @Yaron_Koren Thankyou very much for your help till now
I am really thankful to you for the time and patience you gave to me .

I must say you are a very humble and helpful person that I met .

I guess I should first run and verify the tests locally
Which command i should run

Or else you can check the new changes if they are fine or not
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/PageExchange/+/1007677/4..5

Sorry for the delay. Yes, you can run the tests locally - but I can also just re-test. I just re-approved the patch - let's see how it goes.

sorry but it again failed i have fixed it again

Change 1007677 merged by jenkins-bot:

[mediawiki/extensions/PageExchange@master] Replace hardcoded link text to the domain name of the url

https://gerrit.wikimedia.org/r/1007677

Hi @Yaron_Koren
Greetings of the day

As per my knowledge and the bug fixed yesterday should I start creating my proposal for the GSOC24 ?

and Am I the right person according to you whom you want to work with for the GSOC.. If not then I am to raise the bar of my efforts
?

Thank you for the fix! Yes, feel free to create your proposal already.

Brian and I have not yet decided (or even discussed, actually) who we would prefer for this project.