Skip to content
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

Modify Logo skin object to handle SVGs #3898

Merged
merged 1 commit into from
Jul 23, 2020

Conversation

X3Technology
Copy link
Contributor

Resolves #3893

DNN Platform/Website/admin/Skins/Logo.ascx.cs Outdated Show resolved Hide resolved
DNN Platform/Website/admin/Skins/Logo.ascx.cs Outdated Show resolved Hide resolved
@valadas
Copy link
Contributor

valadas commented Jul 6, 2020

For the sanitization part I believe a simple try catch, if there is not svg node found we just log the info and don't show any logo.

As for third party, I think using the File manager class is the way to go? @mitchelsellers

@mitchelsellers
Copy link
Contributor

@mathisjay @valadas Yes, I think the FileManager class is the way we will have to go for the download of the file for parsing as PhysicalPath is not always going to be there and not always locally.

I'm going to throw a few more notes in on a review form a performance perspective.

Lastly, in this situation if the provided SVG file is not valid, an empty string is going to be rendered, is this proper? I think we need to give something better for a fallback?

Copy link
Contributor

@mitchelsellers mitchelsellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mathisjay FIrst of all, I don't want to be critical here at all, so please do call/email me directly with any concerns that you may have about this. This is just a mission-critical element that impacts every page-load of a site so I want to be sure that we have it right. See the attached.

One additional note/question for @dnnsoftware/approvers, this will also create a bit of a Regression in out of the box functionality with regards to ADA Compliance it seems as most likely we would need to take the existing Alt text and put it into the <title> of the SVG from what I've found. (https://css-tricks.com/accessible-svgs/) I don't typically do this with SVG's so I cannot confirm with actual compliance testing

DNN Platform/Website/admin/Skins/Logo.ascx.cs Outdated Show resolved Hide resolved
DNN Platform/Website/admin/Skins/Logo.ascx.cs Outdated Show resolved Hide resolved
DNN Platform/Website/admin/Skins/Logo.ascx.cs Outdated Show resolved Hide resolved
svg = cacheSvg;
}

Literal litSvg = new Literal();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need some sort of fallback at this point if the file couldn't be obtained.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you suggest here? Inject the Portal Name as string literal?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure on this, but there needs to be something somewhere I think

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this still needs a try/catch around it

@X3Technology
Copy link
Contributor Author

I'll look into the FileNamager class, not used that before.
If the .svg is not valid, nothing will be injected into the hyperlink. I guess we could inject the Site Name just so it is not empty. but we aren't doing anything special if they select an invalid .jpg for the logo, it will just show a broken image. I'd say, just keep it simple...

@X3Technology
Copy link
Contributor Author

Made the requested changes. I just rewrote the whole process since the previous code was only expecting an image and not efficient when allowing other types.

The previous code was already using the FileManager class to load the Logo file, so I think we are good there. Please verify.

@X3Technology
Copy link
Contributor Author

I made a few more optimizations.

I tested the current code with the following use cases;

  1. No Logo file is specific -> empty hyperlink (current behavior)
  2. Image type (jpg, png, gif) specified, but not found -> broken image shown (current behaviour) - this could only happen if the file were deleted after being selected
  3. SVG file selected as logo but theme skin object DOES NOT request InjectSVG -> Displays SVG using an tag (current behaviour)
  4. SVG file selected and theme skin object DOES request InjectSVG -> Display SVG using an SVG tag and uses cache for SVG code
  5. Skin object requests InjectSVG but Logo file is not an SVG file type -> hyperlink text shows the PortalName instead.
  6. Skin object request InjctSVG and the file type is .svg but the file contains no tag -> hyperlink text shows the PortalName instead.

I believe this maintains all the current functionality and only enables the new behaviour if the skin object requests InjectSVG.

@valadas
Copy link
Contributor

valadas commented Jul 7, 2020

@mathisjay as discussed earlier, i was working on this PR probably at the same time as you and just read your last comment after pushing to your branch... Let me know if you like my changes or if I messed up yours...

@mitchelsellers would you re-review, this should:

  • Not change the existing behaviours (needs the InjectSvg opt-in)
  • Will do some validation for an existing svg xml node
  • Will add the recommended ADA compliance information.

I also fixed the Stylecop warnings on this file.

@X3Technology
Copy link
Contributor Author

Thanks @valadas
I added a new opt-in property LinkCssClass that will put the Css class on the hyperlink instead of the <img> or <svg>

@bdukes bdukes added this to the 9.7.0 milestone Jul 7, 2020
@valadas
Copy link
Contributor

valadas commented Jul 7, 2020

Ok, what do you think now @mitchelsellers ?

@bdukes
Copy link
Contributor

bdukes commented Jul 10, 2020

I was having a hard time reviewing the changes because of how much of the original logic was adjusted or moved around. I've re-created what y'all did, but arranged it a little differently in my fork 8428629.

Let me know if y'all see any issues in that. When taken altogether, I think it results in a diff that's a lot cleaner.

The only issue I saw in my testing was that since we're caching SVG document, changing the CssClass property doesn't have an immediate effect until you do something to change the cache. Is that just a trade-off we need to make for performance (@mitchelsellers)?

@bdukes
Copy link
Contributor

bdukes commented Jul 10, 2020

I've pushed a squashed version to ab2a618, which should be easier to review.

@bdukes
Copy link
Contributor

bdukes commented Jul 10, 2020

Just wanted to make a reference in the PR to @mathisjay's comment on the commit ab2a618#commitcomment-40515132 /cc @valadas

@valadas
Copy link
Contributor

valadas commented Jul 11, 2020

It is a bit hard to follow up on commits in a fork for a PR :)

But yeah, IMO the only issue with the changes on your fork is that if the svg has no classes to begin with but we give the skinObject a CssClass, then it would include a space with your changes as in " myclass" (hence why I put it in a list, added the class and then joined them). I don't believe this List is a huge performance hit, this would just be called on first load or cache clear it would not get hammered much...

Resolves dnnsoftware#3893

Co-authored-by: Daniel Valadas <info@danielvaladas.com>
Co-authored-by: Brian Dukes <bdukes@engagesoftware.com>
@bdukes
Copy link
Contributor

bdukes commented Jul 13, 2020

@valadas thanks for the feedback, I've adjusted how we're generated the value of the class attribute:
svgXmlNode.SetAttributeValue("class", string.IsNullOrEmpty(classes) ? this.CssClass : $"{classes} {this.CssClass}");

@valadas
Copy link
Contributor

valadas commented Jul 13, 2020

@valadas thanks for the feedback, I've adjusted how we're generated the value of the class attribute:
svgXmlNode.SetAttributeValue("class", string.IsNullOrEmpty(classes) ? this.CssClass : $"{classes} {this.CssClass}");

Oh, yeah, love it.

@bdukes
Copy link
Contributor

bdukes commented Jul 20, 2020

@valadas @mitchelsellers can we get another 👍 and get this merged?

@mitchelsellers
Copy link
Contributor

Second review is there but having issues merging if someone else can

@bdukes
Copy link
Contributor

bdukes commented Jul 20, 2020

@valadas we need you to clear your "request changes" review before we can merge

@valadas
Copy link
Contributor

valadas commented Jul 23, 2020

Sorry guys, done and done

@valadas valadas merged commit 0d3b931 into dnnsoftware:develop Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Modify Logo skin control to handle .svg files
4 participants