-
Notifications
You must be signed in to change notification settings - Fork 1.3k
page does not exist removed from username #3620
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests to make sure this change works as expected?
This seems a bit hacky, if we could address the root problem I would be happier. Is this somehow related to custom author names? |
The string gets appended client side i think. I have checked and couldn't find anything that generates the string in code. Also i found same approach in DeleteHelper |
I am sorry, you might have to spell this out for me a bit more. The API is returning this bad text, do we know why this text was created? Have you tried an upload with a bad custom author name? The solution may be client side formatting but I would massively prefer if it wasn't |
No idea about it and it's not always created. |
In the settings screen we can put in a custom author name. #3415 #3205 #3536 there are some issues around it. I don't have enough in depth knowledge about it to confirm what is happening but if you could investigate if your uploads are tainted with a custom author name set then that may give us more insight into this problem |
Is the custom name in anyway related is what I wanted to get at.
Is I want a complete diagnosis of the problem |
I found the cause it happens only for users who don't have a user page on commons or user not registered. So for each custom author name that user chooses he has to create a separate page i otherwise link is red. |
do we intend to direct user to new user page with custom author name? |
For this issue, just forget about the Custom author name. It's not specific to that. AFAIK, you'll get that "(page does not exist)" text only when there is no user page associated with the author field. See If we just need the name of the user who uploaded the image (as opposed to the author of the image) I believe adding the (See the 'user' parameter within |
But in that case wouldn't be author of image on web browser be same as username? |
I couldn't understand what you mean by this. Can you clarify? |
FYI: I was suggesting that the I say this based on the above screenshot which says "Uploaded by" and haven't yet looked at the code. If we use actually show the name of the author as "Uploaded by" that would mean the phrase "Uploaded by" is actually misleading as the uploader and author could be totally different for an image. Apologies, for the vagueness of my comments. I'm just sharing what I know in case they're helpful in some way. I'll try to look at the code and comment better. |
Uploader is the username, right? |
Author here is the custom name that i chose and that's what we want in Uploaded by i guess |
Okay i think i get it now. Few more things to clear before writing the code.
|
If I were to just go by the phrase "Uploaded by" I would say it's best to show the uploader (the username of the person who uploaded it). To back up my conclusion let me quote a recent comment by @nicolas-raoul about the use case for the "Uploaded via Mobile" tab.
The experienced users would expect the name of the uploader to be shown there as it would be helpful for them for their work. So, I think showing the uploader would be the appropriate thing to do.
I don't get this. What do you mean by this and how does this relate to the issue?
I couldn't get this too. I took a look at the code and it looks like we really are just showing the author name as "Uploaded by". This is misleading, IMO. As an aside, it looks like the code that parses the author name would just return an empty string for some valid cases. For example: File:Troy Hunt.jpg. These are also the images for which you see no "Uploaded By:" line in the Explore, Uploaded via Mobile screens! To conclude, I think we can fix this issue by properly showing uploader name[1] for "Uploaded by: ". This shouldn't be a big deal as we'll be showing the author name in the media detail view. Anyways, you can ask in the corresponding issue to see what the consensus is. [1]: obtained from |
For new users who haven't created a user page. Like i uploaded via app without creating a page for a while and in Uploaded via mobile it displayed "page does not exist" next to my username. |
@318anushka this is my own ignorance showing here: We have to create a user page? Is a user page not created when you create an account? Surely you can't upload without an account? |
yes, you have to create user page. Even if a user registers, page is not created on it own. |
@sivaraam No changes in media detail view? It'd still show the author name. I suggest creating a separate issue for this as it is related to custom author name. |
Actually no, you don't need to have a userpage to be able to upload. If you are a registered user and you didn't created your userpage as https://commons.wikimedia.org/wiki/User:USERNAMEHERE this user is still exist, just the page describe themselves is not there. (I have read the long conversation very fast, please ignore me if I am saying something you already knew) |
Done.
I think we should fix that too. The following modified version of the private static String getArtist(ExtMetadata metadata) {
try {
final String anchorStartTagTerminalChars = "\">";
final String anchorCloseTag = "</a>";
String artistHtml = metadata.artist();
return artistHtml
.substring(
artistHtml.indexOf(anchorStartTagTerminalChars),
artistHtml.indexOf(anchorCloseTag)
)
.substring(anchorStartTagTerminalChars.length());
} catch (Exception ex) {
return "";
}
} I hope this doesn't break anything, though.
As I've said before this isn't related to custom author name at all. The custom author name is just one of the ways that you could easily use to make the issue surface. It happens in general whenever a author of an image is a commons user who hasn't created a user page. Example: File:Sticker Domitilla Tete Pierre.jpg - Wikimedia Commons. This image was not uploaded using the app at all. But if you view this image using the app (by searching in Explore) or check the corresponding API call you should see the |
Codecov Report
@@ Coverage Diff @@
## master #3620 +/- ##
===========================================
+ Coverage 6.95% 6.97% +0.02%
- Complexity 291 292 +1
===========================================
Files 256 256
Lines 11730 11749 +19
Branches 959 960 +1
===========================================
+ Hits 816 820 +4
- Misses 10843 10858 +15
Partials 71 71
Continue to review full report at Codecov.
|
@@ -117,7 +120,7 @@ public static Media from(MwQueryPage page) { | |||
ExtMetadata metadata = imageInfo.getMetadata(); | |||
if (metadata == null) { | |||
Media media = new Media(null, imageInfo.getOriginalUrl(), | |||
page.title(), "", 0, null, null, null); | |||
page.title(), "", 0, null, null, null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ImageInfo doesn't have a user if metaData is null?
@@ -98,9 +98,9 @@ public View getView(int position, View convertView, ViewGroup parent) { | |||
* @param author | |||
*/ | |||
private void setAuthorView(Media item, TextView author) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still even an author? Uploader is probably more accurate?
@@ -107,7 +107,7 @@ public void fetchContributions() { | |||
.filter(mwQueryLogEvent -> !mwQueryLogEvent.isDeleted()).doOnNext(mwQueryLogEvent -> Timber.d("Image %s passed filters", mwQueryLogEvent.title())) | |||
.map(image -> { | |||
Contribution contribution = new Contribution(null, null, image.title(), | |||
"", -1, image.date(), image.date(), user, | |||
"", -1, image.date(), image.date(), user, user, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems wrong in light of the other constructor where you set creator/user to different values
null, null, sessionManager.getAuthorName(), sessionManager.getUserName(),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for fetching current user's contributions and user value is username only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay so when we are fetching current users contributions
creator == sessionManager.getUserName()
user == sessionManager.getUserName()
but when we are creating them to upload
creator == sessionManager.getAuthorName()
user == sessionManager.getUserName()
That is correct behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, didn't notice that. we are not displaying author in media detail. don't know why it is set to username.
@sivaraam shouldn't creator be getAuthorName() in first one too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sivaraam any insight?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if creator is a field we ever need right now at this point.
To add to what @318anushka said, creator is also useful as some images might literally have no relation between the Author and the person who uploaded it. Here's an example: File: Troy Hunt. The Author is Troy Hunt while the user who uploaded it is IagoQnsi.
This most likely comes into picture only in Explore, though. It should actually be a concern in Contributions too but let's give ourselves some break and not get into that for now ;)
When we create a Contribution for upload we set the creator to sessionManager.getAuthorName() aka just the user name
The author name information should come from the media rather than from the session manager but I believe we can't do it right now as we are using the logevents
API. #2904 would change this, I believe.
We then upload the creator twice??
Just to clear the confusion, that's just the code for constructing the following wiki text:
[[User:USER_NAME | USER_NAME]]
The redundant USER_NAME is just to hide the User:
prefix from the rendered wiki text.
It probably should be, I am now quite interested in what this artist metadata returns when we actually put the right data into this
pageContents
...
I really couldn't get this. I think this PR is in a right shape now. If there's something that's still not clear let me know. I'll see if I could help with clarifying that.
Also while uploading
.append("|author=[[User:").append(contribution.getCreator()).append("|") .append(contribution.getCreator()).append("]]\n");
shouldn't first one of these field be username and then creator. I don't know about this just inferring from here
I have zero knowledge of the rationale behind custom author name. But I'm suspecting it's to enable users to have a custom name in author field (as opposed to allowing them to attribute images created by others) in which case you're right. The first one should be username. Anyways, that should probably be fixed separately.
This author/creator/artist/user stew is thoroughly annoying
Yeah. This is the mess you get when the data model of the app and that returned by the server don't align well. 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not particularly happy with this PR. Why did we bother extracting the contents of the anchor tag, removing the page does not exist
suffix only to add and use a new different field?
Why is DeleteHelper still trying to remove page does not exist
?
This new field gets assigned like sessionManager.getAuthorName(), sessionManager.getUserName(),
and having these 2 identical damned methods beside each other adds more to confusion making them seem like separate things.
I think adding user
is a mistake and perhaps the only changes in this PR should be getArtist
and get rid of the suffix removal in DeleteHelper.
Viewed in browser the author field is, I believe, whatever we sent in author=[[User:myUserName|userName again?]]
And we should not differ from the website
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I guess uploadedBy
is information that isn't explicitly mentioned anywhere on the website? I'll seek confirmation on the ticket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not particularly happy with this PR. Why did we bother extracting the contents of the anchor tag, removing the
page does not exist
suffix only to add and use a new different field?
Because if we don't then the (page does not exist)
would still show up in the detail view of the images you view via 'Explore'. The new field is to just show the username near the "Uploaded by:". We still show the "Author" in the media detail view.
Why is DeleteHelper still trying to remove
page does not exist
?
Thanks for bringing that up! We can remove that code now. cc @318anushka.
It really should've been caught during the PR that added that code. Looks like it slipped through.
Also, that's another place where the user
would be the appropriate thing to use instead of the author/creator. Something to be done in a separate PR :)
This new field gets assigned like
sessionManager.getAuthorName(), sessionManager.getUserName(),
and having these 2 identical damned methods beside each other adds more to confusion making them seem like separate things.
Yeah. I think we can just go with user, user
for that part instead of sessionManager.getAuthorName(), user
. There's not much difference as of now like you point out.
I think adding
user
is a mistake and perhaps the only changes in this PR should begetArtist
and get rid of the suffix removal in DeleteHelper.
I would say it's a "boon" for the reasons I mention above. You'll likely get more info about this in the issue thread where you've asked Nicolas for clarification. Let me know if you're still find some mistakes with introducing user
. I'll see if I could clarify :)
Viewed in browser the author field is, I believe, whatever we sent in
author=[[User:myUserName|userName again?]]
And we should not differ from the website
Do you mean we shouldn't be doing any kind of extraction from anchor tag for the Author? If yes, then I agree. It's best if show it similar to how the website shows the Author. But it would be a more involved change and is out of scope of this PR.
The HTML fiddling has it's limitations such as the "Author" field not being shown in the detail view for some images. I believe this fiddling with the HTML came into picture as we needed a username that we could use as a simple string for use in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one reason it's getting quite confusing is because we are having different names for same field. How about we keep only 2 user and author for now, replacing creator with author. All of this including changes you mentioned above could be done in separate pr after this.
Also i was just waiting for nicolas's input, thought to make changes after clarifying.
app/src/main/java/fr/free/nrw/commons/explore/images/SearchImagesRenderer.java
Outdated
Show resolved
Hide resolved
Yeah okay!!
…On Thu, Apr 9, 2020, 3:09 PM Seán Mac Gillicuddy ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/src/main/java/fr/free/nrw/commons/Media.java
<#3620 (comment)>
:
> String artistHtml = metadata.artist();
- return artistHtml.substring(artistHtml.indexOf("title=\""), artistHtml.indexOf("\">"))
- .replace("title=\"User:", "");
+ return artistHtml
+ .substring(
+ artistHtml.indexOf(anchorStartTagTerminalChars),
+ artistHtml.indexOf(anchorCloseTag)
+ )
+ .substring(anchorStartTagTerminalChars.length());
Yeah keep it in java, I was just idly musing.
Maybe add the length on to the index call I think that flows better
This however I would like to see
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3620 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK4T7LFERF6OT37ZNTM5Z5LRLWJWTANCNFSM4L4IJKTQ>
.
|
This discussion is too long here, but I am sure @sivaraam and @macgills are pointing the correct issues. Despite so much effort of everyone we can't let this PR go to sleep:D @318anushka can you fix conflicts, are there anything else needs to be done? |
Yeah, actually there is an ongoing discussion on what field to reflect in uploadedBy. @sivaraam @macgills should i proceed with solving conflicts? I guess there are some more changes that needs to be done. could you please tell me what to do further. |
It might be easier to start over than resolve the conflicts, there has been quite a large change with the merging of structured data |
Sounds better!! okay so current changes are fine, i'll fix the rest. |
Description (required)
In Explore, some pictures have (page does not exist) string appended to the username.
Fixes #3341 "Page does not exist" near some usernames in Explore
What changes did you make and why?
formatted the string in Media getArtist() when author name is fetched through metadata.
Tests performed (required)
Tested ProdDebug on OnePlus 5 with API level 28.